Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 1 | // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef IPC_HANDLE_ATTACHMENT_FUCHSIA_H_ |
| 6 | #define IPC_HANDLE_ATTACHMENT_FUCHSIA_H_ |
| 7 | |
| 8 | #include <stdint.h> |
| 9 | |
Wez | 8c49ebc9 | 2017-08-10 17:11:13 | [diff] [blame] | 10 | #include "base/fuchsia/scoped_mx_handle.h" |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 11 | #include "ipc/handle_fuchsia.h" |
| 12 | #include "ipc/ipc_export.h" |
| 13 | #include "ipc/ipc_message_attachment.h" |
| 14 | |
| 15 | namespace IPC { |
| 16 | namespace internal { |
| 17 | |
| 18 | // This class represents a Fuchsia mx_handle_t attached to a Chrome IPC message. |
| 19 | class IPC_EXPORT HandleAttachmentFuchsia : public MessageAttachment { |
| 20 | public: |
| 21 | // This constructor makes a copy of |handle| and takes ownership of the |
| 22 | // result. Should only be called by the sender of a Chrome IPC message. |
Wez | 8c49ebc9 | 2017-08-10 17:11:13 | [diff] [blame] | 23 | explicit HandleAttachmentFuchsia(const mx_handle_t& handle); |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 24 | |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 25 | // This constructor takes ownership of |handle|. Should only be called by the |
| 26 | // receiver of a Chrome IPC message. |
Wez | 71a6a8e | 2017-08-28 19:38:05 | [diff] [blame] | 27 | explicit HandleAttachmentFuchsia(base::ScopedMxHandle handle); |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 28 | |
| 29 | Type GetType() const override; |
| 30 | |
Wez | 8c49ebc9 | 2017-08-10 17:11:13 | [diff] [blame] | 31 | mx_handle_t Take() { return handle_.release(); } |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 32 | |
| 33 | private: |
| 34 | ~HandleAttachmentFuchsia() override; |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 35 | |
Wez | 8c49ebc9 | 2017-08-10 17:11:13 | [diff] [blame] | 36 | base::ScopedMxHandle handle_; |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | } // namespace internal |
| 40 | } // namespace IPC |
| 41 | |
| 42 | #endif // IPC_HANDLE_ATTACHMENT_FUCHSIA_H_ |