OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_DISPATCHER_H_ | 5 #ifndef PPAPI_PROXY_DISPATCHER_H_ |
6 #define PPAPI_PROXY_DISPATCHER_H_ | 6 #define PPAPI_PROXY_DISPATCHER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 11 matching lines...) Expand all Loading... | |
22 | 22 |
23 class MessageLoop; | 23 class MessageLoop; |
24 struct PPB_Var_Deprecated; | 24 struct PPB_Var_Deprecated; |
25 | 25 |
26 namespace base { | 26 namespace base { |
27 class WaitableEvent; | 27 class WaitableEvent; |
28 } | 28 } |
29 | 29 |
30 namespace IPC { | 30 namespace IPC { |
31 class SyncChannel; | 31 class SyncChannel; |
32 class TestSink; | |
32 } | 33 } |
33 | 34 |
34 namespace pp { | 35 namespace pp { |
35 namespace proxy { | 36 namespace proxy { |
36 | 37 |
37 class InterfaceProxy; | 38 class InterfaceProxy; |
38 class VarSerializationRules; | 39 class VarSerializationRules; |
39 | 40 |
40 // An interface proxy can represent either end of a cross-process interface | 41 // An interface proxy can represent either end of a cross-process interface |
41 // call. The "source" side is where the call is invoked, and the "target" side | 42 // call. The "source" side is where the call is invoked, and the "target" side |
(...skipping 16 matching lines...) Expand all Loading... | |
58 typedef int32_t (*InitModuleFunc)(PP_Module, GetInterfaceFunc); | 59 typedef int32_t (*InitModuleFunc)(PP_Module, GetInterfaceFunc); |
59 typedef void (*ShutdownModuleFunc)(); | 60 typedef void (*ShutdownModuleFunc)(); |
60 | 61 |
61 ~Dispatcher(); | 62 ~Dispatcher(); |
62 | 63 |
63 bool InitWithChannel(MessageLoop* ipc_message_loop, | 64 bool InitWithChannel(MessageLoop* ipc_message_loop, |
64 const IPC::ChannelHandle& channel_handle, | 65 const IPC::ChannelHandle& channel_handle, |
65 bool is_client, | 66 bool is_client, |
66 base::WaitableEvent* shutdown_event); | 67 base::WaitableEvent* shutdown_event); |
67 | 68 |
69 // Alternative to Init() for unit tests that want to send all messages sent | |
viettrungluu
2011/01/27 16:52:58
Alternative to InitWithChannel()?
| |
70 // via this dispatcher to the given test sink. The test sink must outlive | |
71 // this class. | |
72 void InitWithTestSink(IPC::TestSink* test_sink); | |
73 | |
68 // Returns true if the dispatcher is on the plugin side, or false if it's the | 74 // Returns true if the dispatcher is on the plugin side, or false if it's the |
69 // browser side. | 75 // browser side. |
70 virtual bool IsPlugin() const = 0; | 76 virtual bool IsPlugin() const = 0; |
71 | 77 |
72 VarSerializationRules* serialization_rules() const { | 78 VarSerializationRules* serialization_rules() const { |
73 return serialization_rules_.get(); | 79 return serialization_rules_.get(); |
74 } | 80 } |
75 PP_Module pp_module() const { | 81 PP_Module pp_module() const { |
76 return pp_module_; | 82 return pp_module_; |
77 } | 83 } |
(...skipping 19 matching lines...) Expand all Loading... | |
97 // Called if the remote side is declaring to us which interfaces it supports | 103 // Called if the remote side is declaring to us which interfaces it supports |
98 // so we don't have to query for each one. We'll pre-create proxies for | 104 // so we don't have to query for each one. We'll pre-create proxies for |
99 // each of the given interfaces. | 105 // each of the given interfaces. |
100 | 106 |
101 // IPC::Message::Sender implementation. | 107 // IPC::Message::Sender implementation. |
102 virtual bool Send(IPC::Message* msg); | 108 virtual bool Send(IPC::Message* msg); |
103 | 109 |
104 // IPC::Channel::Listener implementation. | 110 // IPC::Channel::Listener implementation. |
105 virtual bool OnMessageReceived(const IPC::Message& msg); | 111 virtual bool OnMessageReceived(const IPC::Message& msg); |
106 | 112 |
113 // Will be NULL in some unit tests. | |
107 IPC::SyncChannel* channel() const { | 114 IPC::SyncChannel* channel() const { |
108 return channel_.get(); | 115 return channel_.get(); |
109 } | 116 } |
110 | 117 |
111 CallbackTracker& callback_tracker() { | 118 CallbackTracker& callback_tracker() { |
112 return callback_tracker_; | 119 return callback_tracker_; |
113 } | 120 } |
114 | 121 |
115 protected: | 122 protected: |
116 Dispatcher(base::ProcessHandle remote_process_handle, | 123 Dispatcher(base::ProcessHandle remote_process_handle, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 // proxyable. | 164 // proxyable. |
158 bool SetupProxyForTargetInterface(const std::string& interface); | 165 bool SetupProxyForTargetInterface(const std::string& interface); |
159 | 166 |
160 bool IsInterfaceTrusted(const std::string& interface); | 167 bool IsInterfaceTrusted(const std::string& interface); |
161 | 168 |
162 // Set by the derived classed to indicate the module ID corresponding to | 169 // Set by the derived classed to indicate the module ID corresponding to |
163 // this dispatcher. | 170 // this dispatcher. |
164 PP_Module pp_module_; | 171 PP_Module pp_module_; |
165 | 172 |
166 base::ProcessHandle remote_process_handle_; // See getter above. | 173 base::ProcessHandle remote_process_handle_; // See getter above. |
174 | |
175 // When we're unit testing, this will indicate the sink for the messages to | |
176 // be deposited so they can be inspected by the test. When non-NULL, this | |
177 // indicates that the channel should not be used. | |
178 IPC::TestSink* test_sink_; | |
179 | |
180 // Will be null for some tests when there is a test_sink_. | |
167 scoped_ptr<IPC::SyncChannel> channel_; | 181 scoped_ptr<IPC::SyncChannel> channel_; |
168 | 182 |
169 bool disallow_trusted_interfaces_; | 183 bool disallow_trusted_interfaces_; |
170 | 184 |
171 GetInterfaceFunc local_get_interface_; | 185 GetInterfaceFunc local_get_interface_; |
172 | 186 |
173 ProxyMap proxies_; | 187 ProxyMap proxies_; |
174 InterfaceProxy* id_to_proxy_[INTERFACE_ID_COUNT]; | 188 InterfaceProxy* id_to_proxy_[INTERFACE_ID_COUNT]; |
175 | 189 |
176 // True if the remote side has declared which interfaces it supports in | 190 // True if the remote side has declared which interfaces it supports in |
(...skipping 11 matching lines...) Expand all Loading... | |
188 | 202 |
189 scoped_ptr<VarSerializationRules> serialization_rules_; | 203 scoped_ptr<VarSerializationRules> serialization_rules_; |
190 | 204 |
191 DISALLOW_COPY_AND_ASSIGN(Dispatcher); | 205 DISALLOW_COPY_AND_ASSIGN(Dispatcher); |
192 }; | 206 }; |
193 | 207 |
194 } // namespace proxy | 208 } // namespace proxy |
195 } // namespace pp | 209 } // namespace pp |
196 | 210 |
197 #endif // PPAPI_PROXY_DISPATCHER_H_ | 211 #endif // PPAPI_PROXY_DISPATCHER_H_ |
OLD | NEW |