Avi Drissman | ea1be23 | 2022-09-14 23:29:06 | [diff] [blame] | 1 | // Copyright 2015 The Chromium Authors |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
amistry | d4aa70d | 2016-06-23 07:52:37 | [diff] [blame] | 5 | #ifndef IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_ |
| 6 | #define IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_ |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 7 | |
avi | 246998d8 | 2015-12-22 02:39:04 | [diff] [blame] | 8 | #include "build/build_config.h" |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 9 | #include "ipc/ipc_message_attachment.h" |
Ken Rockot | fd90763 | 2017-09-14 04:23:41 | [diff] [blame] | 10 | #include "ipc/ipc_message_support_export.h" |
rockot | 85dce086 | 2015-11-13 01:33:59 | [diff] [blame] | 11 | #include "mojo/public/cpp/system/handle.h" |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 12 | |
| 13 | namespace IPC { |
| 14 | |
| 15 | namespace internal { |
| 16 | |
| 17 | // A MessageAttachment that holds a MojoHandle. |
amistry | 980a61b | 2016-06-09 02:51:20 | [diff] [blame] | 18 | // This can hold any type of transferrable Mojo handle (i.e. message pipe, data |
| 19 | // pipe, etc), but the receiver is expected to know what type of handle to |
| 20 | // expect. |
Ken Rockot | fd90763 | 2017-09-14 04:23:41 | [diff] [blame] | 21 | class IPC_MESSAGE_SUPPORT_EXPORT MojoHandleAttachment |
| 22 | : public MessageAttachment { |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 23 | public: |
| 24 | explicit MojoHandleAttachment(mojo::ScopedHandle handle); |
| 25 | |
Peter Boström | 896f137 | 2021-11-05 01:12:30 | [diff] [blame] | 26 | MojoHandleAttachment(const MojoHandleAttachment&) = delete; |
| 27 | MojoHandleAttachment& operator=(const MojoHandleAttachment&) = delete; |
| 28 | |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 29 | Type GetType() const override; |
| 30 | |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 31 | // Returns the owning handle transferring the ownership. |
| 32 | mojo::ScopedHandle TakeHandle(); |
| 33 | |
| 34 | private: |
| 35 | ~MojoHandleAttachment() override; |
| 36 | mojo::ScopedHandle handle_; |
morrita | 81b17e0 | 2015-02-06 00:58:30 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | } // namespace internal |
| 40 | } // namespace IPC |
| 41 | |
amistry | d4aa70d | 2016-06-23 07:52:37 | [diff] [blame] | 42 | #endif // IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_ |