OLD | NEW |
---|---|
1 // Copyright (c) 2011 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/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/process.h" | 9 #include "base/process.h" |
10 #include "ipc/ipc_message.h" | 10 #include "ipc/ipc_message.h" |
11 #include "ipc/ipc_platform_file.h" | 11 #include "ipc/ipc_platform_file.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
31 class PPAPI_PROXY_EXPORT Delegate { | 31 class PPAPI_PROXY_EXPORT Delegate { |
32 public: | 32 public: |
33 virtual ~Delegate() {} | 33 virtual ~Delegate() {} |
34 | 34 |
35 // Returns the dedicated message loop for processing IPC requests. | 35 // Returns the dedicated message loop for processing IPC requests. |
36 virtual base::MessageLoopProxy* GetIPCMessageLoop() = 0; | 36 virtual base::MessageLoopProxy* GetIPCMessageLoop() = 0; |
37 | 37 |
38 // Returns the event object that becomes signalled when the main thread's | 38 // Returns the event object that becomes signalled when the main thread's |
39 // message loop exits. | 39 // message loop exits. |
40 virtual base::WaitableEvent* GetShutdownEvent() = 0; | 40 virtual base::WaitableEvent* GetShutdownEvent() = 0; |
41 | |
jschuh
2012/05/10 00:10:57
New delegate interface here.
| |
42 // Duplicates a handle to the provided object, returning one that is valid | |
43 // on the other side of the channel. This is part of the delegate interface | |
44 // because both sides of the channel may not have sufficient permission to | |
45 // duplicate handles directly. The implementation must provide the same | |
46 // guarantees as ProxyChannel::ShareHandleWithRemote below. | |
47 virtual IPC::PlatformFileForTransit ShareHandleWithRemote( | |
48 base::PlatformFile handle, | |
49 const IPC::SyncChannel& channel, | |
50 bool should_close_source) = 0; | |
41 }; | 51 }; |
42 | 52 |
43 virtual ~ProxyChannel(); | 53 virtual ~ProxyChannel(); |
44 | 54 |
45 // Alternative to InitWithChannel() for unit tests that want to send all | 55 // Alternative to InitWithChannel() for unit tests that want to send all |
46 // messages sent via this channel to the given test sink. The test sink | 56 // messages sent via this channel to the given test sink. The test sink |
47 // must outlive this class. | 57 // must outlive this class. |
48 void InitWithTestSink(IPC::TestSink* test_sink); | 58 void InitWithTestSink(IPC::TestSink* test_sink); |
49 | 59 |
50 // Shares a file handle (HANDLE / file descriptor) with the remote side. It | 60 // Shares a file handle (HANDLE / file descriptor) with the remote side. It |
(...skipping 15 matching lines...) Expand all Loading... | |
66 // Will be NULL in some unit tests and if the remote side has crashed. | 76 // Will be NULL in some unit tests and if the remote side has crashed. |
67 IPC::SyncChannel* channel() const { | 77 IPC::SyncChannel* channel() const { |
68 return channel_.get(); | 78 return channel_.get(); |
69 } | 79 } |
70 | 80 |
71 #if defined(OS_POSIX) | 81 #if defined(OS_POSIX) |
72 int TakeRendererFD(); | 82 int TakeRendererFD(); |
73 #endif | 83 #endif |
74 | 84 |
75 protected: | 85 protected: |
76 explicit ProxyChannel(base::ProcessHandle remote_process_handle); | 86 explicit ProxyChannel(); |
77 | 87 |
78 // You must call this function before anything else. Returns true on success. | 88 // You must call this function before anything else. Returns true on success. |
79 // The delegate pointer must outlive this class, ownership is not | 89 // The delegate pointer must outlive this class, ownership is not |
80 // transferred. | 90 // transferred. |
81 virtual bool InitWithChannel(Delegate* delegate, | 91 virtual bool InitWithChannel(Delegate* delegate, |
82 const IPC::ChannelHandle& channel_handle, | 92 const IPC::ChannelHandle& channel_handle, |
83 bool is_client); | 93 bool is_client); |
84 | 94 |
85 ProxyChannel::Delegate* delegate() const { | 95 ProxyChannel::Delegate* delegate() const { |
86 return delegate_; | 96 return delegate_; |
87 } | 97 } |
88 | 98 |
89 private: | 99 private: |
90 // Non-owning pointer. Guaranteed non-NULL after init is called. | 100 // Non-owning pointer. Guaranteed non-NULL after init is called. |
91 ProxyChannel::Delegate* delegate_; | 101 ProxyChannel::Delegate* delegate_; |
92 | 102 |
93 base::ProcessHandle remote_process_handle_; // See getter above. | |
94 | |
95 // When we're unit testing, this will indicate the sink for the messages to | 103 // When we're unit testing, this will indicate the sink for the messages to |
96 // be deposited so they can be inspected by the test. When non-NULL, this | 104 // be deposited so they can be inspected by the test. When non-NULL, this |
97 // indicates that the channel should not be used. | 105 // indicates that the channel should not be used. |
98 IPC::TestSink* test_sink_; | 106 IPC::TestSink* test_sink_; |
99 | 107 |
100 // Will be null for some tests when there is a test_sink_, and if the | 108 // Will be null for some tests when there is a test_sink_, and if the |
101 // remote side has crashed. | 109 // remote side has crashed. |
102 scoped_ptr<IPC::SyncChannel> channel_; | 110 scoped_ptr<IPC::SyncChannel> channel_; |
103 | 111 |
104 DISALLOW_COPY_AND_ASSIGN(ProxyChannel); | 112 DISALLOW_COPY_AND_ASSIGN(ProxyChannel); |
105 }; | 113 }; |
106 | 114 |
107 } // namespace proxy | 115 } // namespace proxy |
108 } // namespace ppapi | 116 } // namespace ppapi |
109 | 117 |
110 #endif // PPAPI_PROXY_PROXY_CHANNEL_H_ | 118 #endif // PPAPI_PROXY_PROXY_CHANNEL_H_ |
OLD | NEW |