OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_ | 5 #ifndef IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_ |
6 #define IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_ | 6 #define IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_ |
7 | 7 |
8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "ipc/ipc_export.h" | 11 #include "ipc/ipc_export.h" |
12 #include "ipc/ipc_message_attachment.h" | 12 #include "ipc/ipc_message_attachment.h" |
13 #include "mojo/public/cpp/system/handle.h" | 13 #include "mojo/public/cpp/system/handle.h" |
14 | 14 |
15 namespace IPC { | 15 namespace IPC { |
16 | 16 |
17 namespace internal { | 17 namespace internal { |
18 | 18 |
19 // A MessageAttachment that holds a MojoHandle. | 19 // A MessageAttachment that holds a MojoHandle. |
20 // This can hold any type of transferrable Mojo handle (i.e. message pipe, data | 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 | 21 // pipe, etc), but the receiver is expected to know what type of handle to |
22 // expect. | 22 // expect. |
23 class IPC_EXPORT MojoHandleAttachment : public MessageAttachment { | 23 class IPC_EXPORT MojoHandleAttachment : public MessageAttachment { |
24 public: | 24 public: |
25 explicit MojoHandleAttachment(mojo::ScopedHandle handle); | 25 explicit MojoHandleAttachment(mojo::ScopedHandle handle); |
26 | 26 |
27 Type GetType() const override; | 27 Type GetType() const override; |
28 | 28 |
29 #if defined(OS_POSIX) | |
30 // Should not be called. | |
31 base::PlatformFile TakePlatformFile() override; | |
32 #endif // OS_POSIX | |
33 | |
34 // Returns the owning handle transferring the ownership. | 29 // Returns the owning handle transferring the ownership. |
35 mojo::ScopedHandle TakeHandle(); | 30 mojo::ScopedHandle TakeHandle(); |
36 | 31 |
37 private: | 32 private: |
38 ~MojoHandleAttachment() override; | 33 ~MojoHandleAttachment() override; |
39 mojo::ScopedHandle handle_; | 34 mojo::ScopedHandle handle_; |
40 | 35 |
41 DISALLOW_COPY_AND_ASSIGN(MojoHandleAttachment); | 36 DISALLOW_COPY_AND_ASSIGN(MojoHandleAttachment); |
42 }; | 37 }; |
43 | 38 |
44 } // namespace internal | 39 } // namespace internal |
45 } // namespace IPC | 40 } // namespace IPC |
46 | 41 |
47 #endif // IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_ | 42 #endif // IPC_IPC_MOJO_HANDLE_ATTACHMENT_H_ |
OLD | NEW |