morrita | 1b52e4c | 2015-02-06 09:58:30 +0900 | [diff] [blame] | 1 | // Copyright (c) 2015 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 | |
amistry | 6555e69 | 2016-06-23 16:52:37 +0900 | [diff] [blame] | 5 | #ifndef IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_ |
| 6 | #define IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_ |
morrita | 1b52e4c | 2015-02-06 09:58:30 +0900 | [diff] [blame] | 7 | |
| 8 | #include "base/files/file.h" |
avi | 42ebda4 | 2015-12-22 11:39:04 +0900 | [diff] [blame] | 9 | #include "base/macros.h" |
| 10 | #include "build/build_config.h" |
morrita | 1b52e4c | 2015-02-06 09:58:30 +0900 | [diff] [blame] | 11 | #include "ipc/ipc_message_attachment.h" |
Ken Rockot | b3a77c9 | 2017-09-14 13:23:41 +0900 | [diff] [blame] | 12 | #include "ipc/ipc_message_support_export.h" |
rockot | af32acb | 2015-11-13 10:33:59 +0900 | [diff] [blame] | 13 | #include "mojo/public/cpp/system/handle.h" |
morrita | 1b52e4c | 2015-02-06 09:58:30 +0900 | [diff] [blame] | 14 | |
| 15 | namespace IPC { |
| 16 | |
| 17 | namespace internal { |
| 18 | |
| 19 | // A MessageAttachment that holds a MojoHandle. |
amistry | 15654a9 | 2016-06-09 11:51:20 +0900 | [diff] [blame] | 20 | // This can hold any type of transferrable Mojo handle (i.e. message pipe, data |
| 21 | // pipe, etc), but the receiver is expected to know what type of handle to |
| 22 | // expect. |
Ken Rockot | b3a77c9 | 2017-09-14 13:23:41 +0900 | [diff] [blame] | 23 | class IPC_MESSAGE_SUPPORT_EXPORT MojoHandleAttachment |
| 24 | : public MessageAttachment { |
morrita | 1b52e4c | 2015-02-06 09:58:30 +0900 | [diff] [blame] | 25 | public: |
| 26 | explicit MojoHandleAttachment(mojo::ScopedHandle handle); |
| 27 | |
| 28 | Type GetType() const override; |
| 29 | |
morrita | 1b52e4c | 2015-02-06 09:58:30 +0900 | [diff] [blame] | 30 | // Returns the owning handle transferring the ownership. |
| 31 | mojo::ScopedHandle TakeHandle(); |
| 32 | |
| 33 | private: |
| 34 | ~MojoHandleAttachment() override; |
| 35 | mojo::ScopedHandle handle_; |
| 36 | |
| 37 | DISALLOW_COPY_AND_ASSIGN(MojoHandleAttachment); |
| 38 | }; |
| 39 | |
| 40 | } // namespace internal |
| 41 | } // namespace IPC |
| 42 | |
amistry | 6555e69 | 2016-06-23 16:52:37 +0900 | [diff] [blame] | 43 | #endif // IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_ |