OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 PPAPI_PROXY_PROXY_CHANNEL_H_ | 5 #ifndef PPAPI_PROXY_PROXY_CHANNEL_H_ |
6 #define PPAPI_PROXY_PROXY_CHANNEL_H_ | 6 #define PPAPI_PROXY_PROXY_CHANNEL_H_ |
7 | 7 |
8 #include "base/files/scoped_file.h" | 8 #include "base/files/scoped_file.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/shared_memory.h" |
10 #include "base/process/process.h" | 11 #include "base/process/process.h" |
11 #include "ipc/ipc_listener.h" | 12 #include "ipc/ipc_listener.h" |
12 #include "ipc/ipc_platform_file.h" | 13 #include "ipc/ipc_platform_file.h" |
13 #include "ipc/ipc_sender.h" | 14 #include "ipc/ipc_sender.h" |
14 #include "ipc/ipc_sync_channel.h" | 15 #include "ipc/ipc_sync_channel.h" |
15 #include "ppapi/proxy/ppapi_proxy_export.h" | 16 #include "ppapi/proxy/ppapi_proxy_export.h" |
16 | 17 |
17 namespace base { | 18 namespace base { |
18 class SingleThreadTaskRunner; | 19 class SingleThreadTaskRunner; |
19 class WaitableEvent; | 20 class WaitableEvent; |
(...skipping 23 matching lines...) Expand all Loading... |
43 | 44 |
44 // Duplicates a handle to the provided object, returning one that is valid | 45 // Duplicates a handle to the provided object, returning one that is valid |
45 // on the other side of the channel. This is part of the delegate interface | 46 // on the other side of the channel. This is part of the delegate interface |
46 // because both sides of the channel may not have sufficient permission to | 47 // because both sides of the channel may not have sufficient permission to |
47 // duplicate handles directly. The implementation must provide the same | 48 // duplicate handles directly. The implementation must provide the same |
48 // guarantees as ProxyChannel::ShareHandleWithRemote below. | 49 // guarantees as ProxyChannel::ShareHandleWithRemote below. |
49 virtual IPC::PlatformFileForTransit ShareHandleWithRemote( | 50 virtual IPC::PlatformFileForTransit ShareHandleWithRemote( |
50 base::PlatformFile handle, | 51 base::PlatformFile handle, |
51 base::ProcessId remote_pid, | 52 base::ProcessId remote_pid, |
52 bool should_close_source) = 0; | 53 bool should_close_source) = 0; |
| 54 |
| 55 // Duplicates a shared memory handle, returning one that is valid on the |
| 56 // other side of the channel. This is part of the delegate interface |
| 57 // because both sides of the channel may not have sufficient permission to |
| 58 // duplicate handles directly. The implementation must provide the same |
| 59 // guarantees as ProxyChannel::ShareSharedMemoryHandleWithRemote below. |
| 60 virtual base::SharedMemoryHandle ShareSharedMemoryHandleWithRemote( |
| 61 const base::SharedMemoryHandle& handle, |
| 62 base::ProcessId remote_pid) = 0; |
53 }; | 63 }; |
54 | 64 |
55 ~ProxyChannel() override; | 65 ~ProxyChannel() override; |
56 | 66 |
57 // Alternative to InitWithChannel() for unit tests that want to send all | 67 // Alternative to InitWithChannel() for unit tests that want to send all |
58 // messages sent via this channel to the given test sink. The test sink | 68 // messages sent via this channel to the given test sink. The test sink |
59 // must outlive this class. In this case, the peer PID will be the current | 69 // must outlive this class. In this case, the peer PID will be the current |
60 // process ID. | 70 // process ID. |
61 void InitWithTestSink(IPC::TestSink* test_sink); | 71 void InitWithTestSink(IPC::TestSink* test_sink); |
62 | 72 |
63 // Shares a file handle (HANDLE / file descriptor) with the remote side. It | 73 // Shares a file handle (HANDLE / file descriptor) with the remote side. It |
64 // returns a handle that should be sent in exactly one IPC message. Upon | 74 // returns a handle that should be sent in exactly one IPC message. Upon |
65 // receipt, the remote side then owns that handle. Note: if sending the | 75 // receipt, the remote side then owns that handle. Note: if sending the |
66 // message fails, the returned handle is properly closed by the IPC system. If | 76 // message fails, the returned handle is properly closed by the IPC system. If |
67 // should_close_source is set to true, the original handle is closed by this | 77 // should_close_source is set to true, the original handle is closed by this |
68 // operation and should not be used again. | 78 // operation and should not be used again. |
69 IPC::PlatformFileForTransit ShareHandleWithRemote( | 79 IPC::PlatformFileForTransit ShareHandleWithRemote( |
70 base::PlatformFile handle, | 80 base::PlatformFile handle, |
71 bool should_close_source); | 81 bool should_close_source); |
72 | 82 |
| 83 // Shares a shared memory handle with the remote side. It returns a handle |
| 84 // that should be sent in exactly one IPC message. Upon receipt, the remote |
| 85 // side then owns that handle. Note: if sending the message fails, the |
| 86 // returned handle is properly closed by the IPC system. The original handle |
| 87 // is not closed by this operation. |
| 88 base::SharedMemoryHandle ShareSharedMemoryHandleWithRemote( |
| 89 const base::SharedMemoryHandle& handle); |
| 90 |
73 // IPC::Sender implementation. | 91 // IPC::Sender implementation. |
74 bool Send(IPC::Message* msg) override; | 92 bool Send(IPC::Message* msg) override; |
75 | 93 |
76 // IPC::Listener implementation. | 94 // IPC::Listener implementation. |
77 void OnChannelError() override; | 95 void OnChannelError() override; |
78 | 96 |
79 // Will be NULL in some unit tests and if the remote side has crashed. | 97 // Will be NULL in some unit tests and if the remote side has crashed. |
80 IPC::SyncChannel* channel() const { | 98 IPC::SyncChannel* channel() const { |
81 return channel_.get(); | 99 return channel_.get(); |
82 } | 100 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // remote side has crashed. | 136 // remote side has crashed. |
119 scoped_ptr<IPC::SyncChannel> channel_; | 137 scoped_ptr<IPC::SyncChannel> channel_; |
120 | 138 |
121 DISALLOW_COPY_AND_ASSIGN(ProxyChannel); | 139 DISALLOW_COPY_AND_ASSIGN(ProxyChannel); |
122 }; | 140 }; |
123 | 141 |
124 } // namespace proxy | 142 } // namespace proxy |
125 } // namespace ppapi | 143 } // namespace ppapi |
126 | 144 |
127 #endif // PPAPI_PROXY_PROXY_CHANNEL_H_ | 145 #endif // PPAPI_PROXY_PROXY_CHANNEL_H_ |
OLD | NEW |