OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "ppapi/proxy/ppp_class_proxy.h" | 25 #include "ppapi/proxy/ppp_class_proxy.h" |
26 #include "ppapi/proxy/resource_creation_proxy.h" | 26 #include "ppapi/proxy/resource_creation_proxy.h" |
27 #include "ppapi/shared_impl/resource.h" | 27 #include "ppapi/shared_impl/resource.h" |
28 #include "ppapi/shared_impl/tracker_base.h" | 28 #include "ppapi/shared_impl/tracker_base.h" |
29 | 29 |
30 #if defined(OS_POSIX) | 30 #if defined(OS_POSIX) |
31 #include "base/eintr_wrapper.h" | 31 #include "base/eintr_wrapper.h" |
32 #include "ipc/ipc_channel_posix.h" | 32 #include "ipc/ipc_channel_posix.h" |
33 #endif | 33 #endif |
34 | 34 |
35 using ppapi::Resource; | 35 namespace ppapi { |
36 | |
37 namespace pp { | |
38 namespace proxy { | 36 namespace proxy { |
39 | 37 |
40 namespace { | 38 namespace { |
41 | 39 |
42 typedef std::map<PP_Instance, PluginDispatcher*> InstanceToDispatcherMap; | 40 typedef std::map<PP_Instance, PluginDispatcher*> InstanceToDispatcherMap; |
43 InstanceToDispatcherMap* g_instance_to_dispatcher = NULL; | 41 InstanceToDispatcherMap* g_instance_to_dispatcher = NULL; |
44 | 42 |
45 } // namespace | 43 } // namespace |
46 | 44 |
47 PluginDispatcher::PluginDispatcher(base::ProcessHandle remote_process_handle, | 45 PluginDispatcher::PluginDispatcher(base::ProcessHandle remote_process_handle, |
48 GetInterfaceFunc get_interface) | 46 GetInterfaceFunc get_interface) |
49 : Dispatcher(remote_process_handle, get_interface), | 47 : Dispatcher(remote_process_handle, get_interface), |
50 plugin_delegate_(NULL), | 48 plugin_delegate_(NULL), |
51 received_preferences_(false), | 49 received_preferences_(false), |
52 plugin_dispatcher_id_(0) { | 50 plugin_dispatcher_id_(0) { |
53 SetSerializationRules(new PluginVarSerializationRules); | 51 SetSerializationRules(new PluginVarSerializationRules); |
54 | 52 |
55 // As a plugin, we always support the PPP_Class interface. There's no | 53 // As a plugin, we always support the PPP_Class interface. There's no |
56 // GetInterface call or name for it, so we insert it into our table now. | 54 // GetInterface call or name for it, so we insert it into our table now. |
57 target_proxies_[INTERFACE_ID_PPP_CLASS].reset(new PPP_Class_Proxy(this)); | 55 target_proxies_[INTERFACE_ID_PPP_CLASS].reset(new PPP_Class_Proxy(this)); |
58 | 56 |
59 ::ppapi::TrackerBase::Init( | 57 TrackerBase::Init(&PluginResourceTracker::GetTrackerBaseInstance); |
60 &PluginResourceTracker::GetTrackerBaseInstance); | |
61 } | 58 } |
62 | 59 |
63 PluginDispatcher::~PluginDispatcher() { | 60 PluginDispatcher::~PluginDispatcher() { |
64 if (plugin_delegate_) | 61 if (plugin_delegate_) |
65 plugin_delegate_->Unregister(plugin_dispatcher_id_); | 62 plugin_delegate_->Unregister(plugin_dispatcher_id_); |
66 } | 63 } |
67 | 64 |
68 // static | 65 // static |
69 PluginDispatcher* PluginDispatcher::GetForInstance(PP_Instance instance) { | 66 PluginDispatcher* PluginDispatcher::GetForInstance(PP_Instance instance) { |
70 if (!g_instance_to_dispatcher) | 67 if (!g_instance_to_dispatcher) |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 void PluginDispatcher::PostToWebKitThread( | 223 void PluginDispatcher::PostToWebKitThread( |
227 const tracked_objects::Location& from_here, | 224 const tracked_objects::Location& from_here, |
228 const base::Closure& task) { | 225 const base::Closure& task) { |
229 return plugin_delegate_->PostToWebKitThread(from_here, task); | 226 return plugin_delegate_->PostToWebKitThread(from_here, task); |
230 } | 227 } |
231 | 228 |
232 bool PluginDispatcher::SendToBrowser(IPC::Message* msg) { | 229 bool PluginDispatcher::SendToBrowser(IPC::Message* msg) { |
233 return plugin_delegate_->SendToBrowser(msg); | 230 return plugin_delegate_->SendToBrowser(msg); |
234 } | 231 } |
235 | 232 |
236 ppapi::WebKitForwarding* PluginDispatcher::GetWebKitForwarding() { | 233 WebKitForwarding* PluginDispatcher::GetWebKitForwarding() { |
237 return plugin_delegate_->GetWebKitForwarding(); | 234 return plugin_delegate_->GetWebKitForwarding(); |
238 } | 235 } |
239 | 236 |
240 ::ppapi::FunctionGroupBase* PluginDispatcher::GetFunctionAPI( | 237 FunctionGroupBase* PluginDispatcher::GetFunctionAPI(InterfaceID id) { |
241 pp::proxy::InterfaceID id) { | 238 scoped_ptr<FunctionGroupBase >& proxy = function_proxies_[id]; |
242 scoped_ptr< ::ppapi::FunctionGroupBase >& proxy = function_proxies_[id]; | |
243 | 239 |
244 if (proxy.get()) | 240 if (proxy.get()) |
245 return proxy.get(); | 241 return proxy.get(); |
246 | 242 |
247 if (id == INTERFACE_ID_PPB_CHAR_SET) | 243 if (id == INTERFACE_ID_PPB_CHAR_SET) |
248 proxy.reset(new PPB_CharSet_Proxy(this, NULL)); | 244 proxy.reset(new PPB_CharSet_Proxy(this, NULL)); |
249 else if(id == INTERFACE_ID_PPB_CURSORCONTROL) | 245 else if(id == INTERFACE_ID_PPB_CURSORCONTROL) |
250 proxy.reset(new PPB_CursorControl_Proxy(this, NULL)); | 246 proxy.reset(new PPB_CursorControl_Proxy(this, NULL)); |
251 else if (id == INTERFACE_ID_PPB_FONT) | 247 else if (id == INTERFACE_ID_PPB_FONT) |
252 proxy.reset(new PPB_Font_Proxy(this, NULL)); | 248 proxy.reset(new PPB_Font_Proxy(this, NULL)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 | 291 |
296 // Query the plugin & cache the result. | 292 // Query the plugin & cache the result. |
297 const void* interface_functions = GetLocalInterface(interface_name.c_str()); | 293 const void* interface_functions = GetLocalInterface(interface_name.c_str()); |
298 if (!interface_functions) | 294 if (!interface_functions) |
299 return; | 295 return; |
300 target_proxies_[info->id].reset( | 296 target_proxies_[info->id].reset( |
301 info->create_proxy(this, interface_functions)); | 297 info->create_proxy(this, interface_functions)); |
302 *result = true; | 298 *result = true; |
303 } | 299 } |
304 | 300 |
305 void PluginDispatcher::OnMsgSetPreferences(const ::ppapi::Preferences& prefs) { | 301 void PluginDispatcher::OnMsgSetPreferences(const Preferences& prefs) { |
306 // The renderer may send us preferences more than once (currently this | 302 // The renderer may send us preferences more than once (currently this |
307 // happens every time a new plugin instance is created). Since we don't have | 303 // happens every time a new plugin instance is created). Since we don't have |
308 // a way to signal to the plugin that the preferences have changed, changing | 304 // a way to signal to the plugin that the preferences have changed, changing |
309 // the default fonts and such in the middle of a running plugin could be | 305 // the default fonts and such in the middle of a running plugin could be |
310 // confusing to it. As a result, we never allow the preferences to be changed | 306 // confusing to it. As a result, we never allow the preferences to be changed |
311 // once they're set. The user will have to restart to get new font prefs | 307 // once they're set. The user will have to restart to get new font prefs |
312 // propogated to plugins. | 308 // propogated to plugins. |
313 if (!received_preferences_) { | 309 if (!received_preferences_) { |
314 received_preferences_ = true; | 310 received_preferences_ = true; |
315 preferences_ = prefs; | 311 preferences_ = prefs; |
316 } | 312 } |
317 } | 313 } |
318 | 314 |
319 } // namespace proxy | 315 } // namespace proxy |
320 } // namespace pp | 316 } // namespace ppapi |
OLD | NEW |