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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 return Dispatcher::Send(msg); | 188 return Dispatcher::Send(msg); |
187 } | 189 } |
188 | 190 |
189 bool PluginDispatcher::OnMessageReceived(const IPC::Message& msg) { | 191 bool PluginDispatcher::OnMessageReceived(const IPC::Message& msg) { |
190 // We need to grab the proxy lock to ensure that we don't collide with the | 192 // We need to grab the proxy lock to ensure that we don't collide with the |
191 // plugin making pepper calls on a different thread. | 193 // plugin making pepper calls on a different thread. |
192 ProxyAutoLock lock; | 194 ProxyAutoLock lock; |
193 TRACE_EVENT2("ppapi proxy", "PluginDispatcher::OnMessageReceived", | 195 TRACE_EVENT2("ppapi proxy", "PluginDispatcher::OnMessageReceived", |
194 "Class", IPC_MESSAGE_ID_CLASS(msg.type()), | 196 "Class", IPC_MESSAGE_ID_CLASS(msg.type()), |
195 "Line", IPC_MESSAGE_ID_LINE(msg.type())); | 197 "Line", IPC_MESSAGE_ID_LINE(msg.type())); |
| 198 |
| 199 /* |
| 200 for (size_t i = 0; i < filters_.size(); i++) { |
| 201 if (filters_[i]->OnMessageReceived(msg)) |
| 202 return true; |
| 203 } |
| 204 */ |
| 205 |
196 if (msg.routing_id() == MSG_ROUTING_CONTROL) { | 206 if (msg.routing_id() == MSG_ROUTING_CONTROL) { |
197 // Handle some plugin-specific control messages. | 207 // Handle some plugin-specific control messages. |
198 bool handled = true; | 208 bool handled = true; |
199 IPC_BEGIN_MESSAGE_MAP(PluginDispatcher, msg) | 209 IPC_BEGIN_MESSAGE_MAP(PluginDispatcher, msg) |
| 210 IPC_MESSAGE_HANDLER(PpapiPluginMsg_ResourceReply, OnMsgResourceReply) |
200 IPC_MESSAGE_HANDLER(PpapiMsg_SupportsInterface, OnMsgSupportsInterface) | 211 IPC_MESSAGE_HANDLER(PpapiMsg_SupportsInterface, OnMsgSupportsInterface) |
201 IPC_MESSAGE_HANDLER(PpapiMsg_SetPreferences, OnMsgSetPreferences) | 212 IPC_MESSAGE_HANDLER(PpapiMsg_SetPreferences, OnMsgSetPreferences) |
202 IPC_MESSAGE_UNHANDLED(handled = false); | 213 IPC_MESSAGE_UNHANDLED(handled = false); |
203 IPC_END_MESSAGE_MAP() | 214 IPC_END_MESSAGE_MAP() |
204 if (handled) | 215 if (handled) |
205 return true; | 216 return true; |
206 } | 217 } |
207 return Dispatcher::OnMessageReceived(msg); | 218 return Dispatcher::OnMessageReceived(msg); |
208 } | 219 } |
209 | 220 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 i != temp_map.end(); ++i) { | 279 i != temp_map.end(); ++i) { |
269 if (i->second == this) { | 280 if (i->second == this) { |
270 // Synthesize an "instance destroyed" message, this will notify the | 281 // Synthesize an "instance destroyed" message, this will notify the |
271 // plugin and also remove it from our list of tracked plugins. | 282 // plugin and also remove it from our list of tracked plugins. |
272 PpapiMsg_PPPInstance_DidDestroy msg(API_ID_PPP_INSTANCE, i->first); | 283 PpapiMsg_PPPInstance_DidDestroy msg(API_ID_PPP_INSTANCE, i->first); |
273 OnMessageReceived(msg); | 284 OnMessageReceived(msg); |
274 } | 285 } |
275 } | 286 } |
276 } | 287 } |
277 | 288 |
| 289 void PluginDispatcher::OnMsgResourceReply( |
| 290 const ppapi::proxy::ResourceMessageReplyParams& reply_params, |
| 291 const IPC::Message& nested_msg) { |
| 292 Resource* resource = PpapiGlobals::Get()->GetResourceTracker()->GetResource( |
| 293 reply_params.pp_resource()); |
| 294 if (!resource) { |
| 295 NOTREACHED(); |
| 296 return; |
| 297 } |
| 298 resource->OnReplyReceived(reply_params.sequence(), reply_params.result(), |
| 299 nested_msg); |
| 300 } |
| 301 |
278 void PluginDispatcher::OnMsgSupportsInterface( | 302 void PluginDispatcher::OnMsgSupportsInterface( |
279 const std::string& interface_name, | 303 const std::string& interface_name, |
280 bool* result) { | 304 bool* result) { |
281 *result = !!GetPluginInterface(interface_name); | 305 *result = !!GetPluginInterface(interface_name); |
282 | 306 |
283 // Do fallback for PPP_Instance. This is a hack here and if we have more | 307 // Do fallback for PPP_Instance. This is a hack here and if we have more |
284 // cases like this it should be generalized. The PPP_Instance proxy always | 308 // cases like this it should be generalized. The PPP_Instance proxy always |
285 // proxies the 1.1 interface, and then does fallback to 1.0 inside the | 309 // proxies the 1.1 interface, and then does fallback to 1.0 inside the |
286 // plugin process (see PPP_Instance_Proxy). So here we return true for | 310 // plugin process (see PPP_Instance_Proxy). So here we return true for |
287 // supporting the 1.1 interface if either 1.1 or 1.0 is supported. | 311 // supporting the 1.1 interface if either 1.1 or 1.0 is supported. |
(...skipping 10 matching lines...) Expand all Loading... |
298 // once they're set. The user will have to restart to get new font prefs | 322 // once they're set. The user will have to restart to get new font prefs |
299 // propogated to plugins. | 323 // propogated to plugins. |
300 if (!received_preferences_) { | 324 if (!received_preferences_) { |
301 received_preferences_ = true; | 325 received_preferences_ = true; |
302 preferences_ = prefs; | 326 preferences_ = prefs; |
303 } | 327 } |
304 } | 328 } |
305 | 329 |
306 } // namespace proxy | 330 } // namespace proxy |
307 } // namespace ppapi | 331 } // namespace ppapi |
OLD | NEW |