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 | |
Scott Graham | fe0e9f46 | 2017-09-18 21:25:04 | [diff] [blame] | 10 | #include "base/fuchsia/scoped_zx_handle.h" |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 11 | #include "ipc/handle_fuchsia.h" |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 12 | #include "ipc/ipc_message_attachment.h" |
Ken Rockot | fd90763 | 2017-09-14 04:23:41 | [diff] [blame] | 13 | #include "ipc/ipc_message_support_export.h" |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 14 | |
| 15 | namespace IPC { |
| 16 | namespace internal { |
| 17 | |
Scott Graham | fe0e9f46 | 2017-09-18 21:25:04 | [diff] [blame] | 18 | // This class represents a Fuchsia zx_handle_t attached to a Chrome IPC message. |
Ken Rockot | fd90763 | 2017-09-14 04:23:41 | [diff] [blame] | 19 | class IPC_MESSAGE_SUPPORT_EXPORT HandleAttachmentFuchsia |
| 20 | : public MessageAttachment { |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 21 | public: |
| 22 | // This constructor makes a copy of |handle| and takes ownership of the |
| 23 | // result. Should only be called by the sender of a Chrome IPC message. |
Scott Graham | fe0e9f46 | 2017-09-18 21:25:04 | [diff] [blame] | 24 | explicit HandleAttachmentFuchsia(const zx_handle_t& handle); |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 25 | |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 26 | // This constructor takes ownership of |handle|. Should only be called by the |
| 27 | // receiver of a Chrome IPC message. |
Scott Graham | fe0e9f46 | 2017-09-18 21:25:04 | [diff] [blame] | 28 | explicit HandleAttachmentFuchsia(base::ScopedZxHandle handle); |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 29 | |
| 30 | Type GetType() const override; |
| 31 | |
Scott Graham | fe0e9f46 | 2017-09-18 21:25:04 | [diff] [blame] | 32 | zx_handle_t Take() { return handle_.release(); } |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 33 | |
| 34 | private: |
| 35 | ~HandleAttachmentFuchsia() override; |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 36 | |
Scott Graham | fe0e9f46 | 2017-09-18 21:25:04 | [diff] [blame] | 37 | base::ScopedZxHandle handle_; |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | } // namespace internal |
| 41 | } // namespace IPC |
| 42 | |
| 43 | #endif // IPC_HANDLE_ATTACHMENT_FUCHSIA_H_ |