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 #include "ppapi/proxy/plugin_dispatcher.h" | 5 #include "ppapi/proxy/plugin_dispatcher.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "ipc/ipc_message.h" | 12 #include "ipc/ipc_message.h" |
13 #include "ipc/ipc_sync_channel.h" | 13 #include "ipc/ipc_sync_channel.h" |
14 #include "base/debug/trace_event.h" | 14 #include "base/debug/trace_event.h" |
15 #include "ppapi/c/pp_errors.h" | 15 #include "ppapi/c/pp_errors.h" |
16 #include "ppapi/c/ppp_instance.h" | 16 #include "ppapi/c/ppp_instance.h" |
17 #include "ppapi/proxy/interface_list.h" | 17 #include "ppapi/proxy/interface_list.h" |
18 #include "ppapi/proxy/interface_proxy.h" | 18 #include "ppapi/proxy/interface_proxy.h" |
19 #include "ppapi/proxy/plugin_message_filter.h" | 19 #include "ppapi/proxy/plugin_message_filter.h" |
20 #include "ppapi/proxy/plugin_resource_tracker.h" | 20 #include "ppapi/proxy/plugin_resource_tracker.h" |
21 #include "ppapi/proxy/plugin_var_serialization_rules.h" | 21 #include "ppapi/proxy/plugin_var_serialization_rules.h" |
22 #include "ppapi/proxy/ppapi_messages.h" | 22 #include "ppapi/proxy/ppapi_messages.h" |
23 #include "ppapi/proxy/ppb_instance_proxy.h" | 23 #include "ppapi/proxy/ppb_instance_proxy.h" |
24 #include "ppapi/proxy/ppp_class_proxy.h" | 24 #include "ppapi/proxy/ppp_class_proxy.h" |
25 #include "ppapi/proxy/resource_creation_proxy.h" | 25 #include "ppapi/proxy/resource_creation_proxy.h" |
26 #include "ppapi/proxy/resource_message_params.h" | |
27 #include "ppapi/shared_impl/ppapi_globals.h" | |
26 #include "ppapi/shared_impl/proxy_lock.h" | 28 #include "ppapi/shared_impl/proxy_lock.h" |
27 #include "ppapi/shared_impl/resource.h" | 29 #include "ppapi/shared_impl/resource.h" |
28 | 30 |
29 #if defined(OS_POSIX) && !defined(OS_NACL) | 31 #if defined(OS_POSIX) && !defined(OS_NACL) |
30 #include "base/eintr_wrapper.h" | 32 #include "base/eintr_wrapper.h" |
31 #include "ipc/ipc_channel_posix.h" | 33 #include "ipc/ipc_channel_posix.h" |
32 #endif | 34 #endif |
33 | 35 |
34 namespace ppapi { | 36 namespace ppapi { |
35 namespace proxy { | 37 namespace proxy { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 return Dispatcher::Send(msg); | 184 return Dispatcher::Send(msg); |
183 } | 185 } |
184 | 186 |
185 bool PluginDispatcher::OnMessageReceived(const IPC::Message& msg) { | 187 bool PluginDispatcher::OnMessageReceived(const IPC::Message& msg) { |
186 // We need to grab the proxy lock to ensure that we don't collide with the | 188 // We need to grab the proxy lock to ensure that we don't collide with the |
187 // plugin making pepper calls on a different thread. | 189 // plugin making pepper calls on a different thread. |
188 ProxyAutoLock lock; | 190 ProxyAutoLock lock; |
189 TRACE_EVENT2("ppapi proxy", "PluginDispatcher::OnMessageReceived", | 191 TRACE_EVENT2("ppapi proxy", "PluginDispatcher::OnMessageReceived", |
190 "Class", IPC_MESSAGE_ID_CLASS(msg.type()), | 192 "Class", IPC_MESSAGE_ID_CLASS(msg.type()), |
191 "Line", IPC_MESSAGE_ID_LINE(msg.type())); | 193 "Line", IPC_MESSAGE_ID_LINE(msg.type())); |
194 | |
195 /* | |
196 for (size_t i = 0; i < filters_.size(); i++) { | |
197 if (filters_[i]->OnMessageReceived(msg)) | |
198 return true; | |
199 } | |
200 */ | |
bbudge
2012/07/02 20:06:06
?
| |
201 | |
192 if (msg.routing_id() == MSG_ROUTING_CONTROL) { | 202 if (msg.routing_id() == MSG_ROUTING_CONTROL) { |
193 // Handle some plugin-specific control messages. | 203 // Handle some plugin-specific control messages. |
194 bool handled = true; | 204 bool handled = true; |
195 IPC_BEGIN_MESSAGE_MAP(PluginDispatcher, msg) | 205 IPC_BEGIN_MESSAGE_MAP(PluginDispatcher, msg) |
206 IPC_MESSAGE_HANDLER(PpapiPluginMsg_ResourceReply, OnMsgResourceReply) | |
196 IPC_MESSAGE_HANDLER(PpapiMsg_SupportsInterface, OnMsgSupportsInterface) | 207 IPC_MESSAGE_HANDLER(PpapiMsg_SupportsInterface, OnMsgSupportsInterface) |
197 IPC_MESSAGE_HANDLER(PpapiMsg_SetPreferences, OnMsgSetPreferences) | 208 IPC_MESSAGE_HANDLER(PpapiMsg_SetPreferences, OnMsgSetPreferences) |
198 IPC_MESSAGE_UNHANDLED(handled = false); | 209 IPC_MESSAGE_UNHANDLED(handled = false); |
199 IPC_END_MESSAGE_MAP() | 210 IPC_END_MESSAGE_MAP() |
200 if (handled) | 211 if (handled) |
201 return true; | 212 return true; |
202 } | 213 } |
203 return Dispatcher::OnMessageReceived(msg); | 214 return Dispatcher::OnMessageReceived(msg); |
204 } | 215 } |
205 | 216 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 i != temp_map.end(); ++i) { | 275 i != temp_map.end(); ++i) { |
265 if (i->second == this) { | 276 if (i->second == this) { |
266 // Synthesize an "instance destroyed" message, this will notify the | 277 // Synthesize an "instance destroyed" message, this will notify the |
267 // plugin and also remove it from our list of tracked plugins. | 278 // plugin and also remove it from our list of tracked plugins. |
268 PpapiMsg_PPPInstance_DidDestroy msg(API_ID_PPP_INSTANCE, i->first); | 279 PpapiMsg_PPPInstance_DidDestroy msg(API_ID_PPP_INSTANCE, i->first); |
269 OnMessageReceived(msg); | 280 OnMessageReceived(msg); |
270 } | 281 } |
271 } | 282 } |
272 } | 283 } |
273 | 284 |
285 void PluginDispatcher::OnMsgResourceReply( | |
286 const ppapi::proxy::ResourceMessageReplyParams& reply_params, | |
287 const IPC::Message& nested_msg) { | |
288 Resource* resource = PpapiGlobals::Get()->GetResourceTracker()->GetResource( | |
289 reply_params.pp_resource()); | |
290 if (!resource) { | |
291 NOTREACHED(); | |
292 return; | |
293 } | |
294 resource->OnReplyReceived(reply_params.sequence(), reply_params.result(), | |
295 nested_msg); | |
296 } | |
297 | |
274 void PluginDispatcher::OnMsgSupportsInterface( | 298 void PluginDispatcher::OnMsgSupportsInterface( |
275 const std::string& interface_name, | 299 const std::string& interface_name, |
276 bool* result) { | 300 bool* result) { |
277 *result = !!GetPluginInterface(interface_name); | 301 *result = !!GetPluginInterface(interface_name); |
278 | 302 |
279 // Do fallback for PPP_Instance. This is a hack here and if we have more | 303 // Do fallback for PPP_Instance. This is a hack here and if we have more |
280 // cases like this it should be generalized. The PPP_Instance proxy always | 304 // cases like this it should be generalized. The PPP_Instance proxy always |
281 // proxies the 1.1 interface, and then does fallback to 1.0 inside the | 305 // proxies the 1.1 interface, and then does fallback to 1.0 inside the |
282 // plugin process (see PPP_Instance_Proxy). So here we return true for | 306 // plugin process (see PPP_Instance_Proxy). So here we return true for |
283 // supporting the 1.1 interface if either 1.1 or 1.0 is supported. | 307 // supporting the 1.1 interface if either 1.1 or 1.0 is supported. |
(...skipping 10 matching lines...) Expand all Loading... | |
294 // once they're set. The user will have to restart to get new font prefs | 318 // once they're set. The user will have to restart to get new font prefs |
295 // propogated to plugins. | 319 // propogated to plugins. |
296 if (!received_preferences_) { | 320 if (!received_preferences_) { |
297 received_preferences_ = true; | 321 received_preferences_ = true; |
298 preferences_ = prefs; | 322 preferences_ = prefs; |
299 } | 323 } |
300 } | 324 } |
301 | 325 |
302 } // namespace proxy | 326 } // namespace proxy |
303 } // namespace ppapi | 327 } // namespace ppapi |
OLD | NEW |