diff options
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/plugins/ppapi/plugin_module.cc | 26 | ||||
-rw-r--r-- | webkit/plugins/ppapi/plugin_module.h | 9 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.cc | 16 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.h | 11 |
4 files changed, 37 insertions, 25 deletions
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc index 9257bc8..cdf8f69 100644 --- a/webkit/plugins/ppapi/plugin_module.cc +++ b/webkit/plugins/ppapi/plugin_module.cc @@ -419,8 +419,7 @@ PluginModule::PluginModule(const std::string& name, name_(name), path_(path), permissions_(perms), - reserve_instance_id_(NULL), - nacl_ipc_proxy_(false) { + reserve_instance_id_(NULL) { // Ensure the globals object is created. if (!host_globals) host_globals = new HostGlobals; @@ -503,27 +502,33 @@ void PluginModule::InitAsProxied( out_of_process_proxy_.reset(out_of_process_proxy); } +scoped_refptr<PluginModule> PluginModule::CreateModuleForNaClInstance() { + // Create a new module, but don't set the lifetime delegate. This isn't a + // plugin in the usual sense, so it isn't tracked by the browser. + scoped_refptr<PluginModule> nacl_module( + new PluginModule(name_, + path_, + NULL, // no lifetime_delegate + permissions_)); + return nacl_module; +} + void PluginModule::InitAsProxiedNaCl( scoped_ptr<PluginDelegate::OutOfProcessProxy> out_of_process_proxy, PP_Instance instance) { - // TODO(bbudge) We need to switch the mode of the PluginModule on a - // per-instance basis. Fix this so out_of_process_proxy and other - // state is stored in a map, indexed by instance. - nacl_ipc_proxy_ = true; InitAsProxied(out_of_process_proxy.release()); // InitAsProxied (for the trusted/out-of-process case) initializes only the // module, and one or more instances are added later. In this case, the // PluginInstance was already created as in-process, so we missed the proxy // AddInstance step and must do it now. out_of_process_proxy_->AddInstance(instance); - // In NaCl, we need to tell the instance to reset itself as proxied. This will // clear cached interface pointers and send DidCreate (etc) to the plugin // side of the proxy. PluginInstance* plugin_instance = host_globals->GetInstance(instance); if (!plugin_instance) return; - plugin_instance->ResetAsProxied(); + plugin_instance->ResetAsProxied(this); } // static @@ -577,11 +582,6 @@ void PluginModule::InstanceDeleted(PluginInstance* instance) { if (out_of_process_proxy_.get()) out_of_process_proxy_->RemoveInstance(instance->pp_instance()); instances_.erase(instance); - - if (nacl_ipc_proxy_) { - out_of_process_proxy_.reset(); - reserve_instance_id_ = NULL; - } } scoped_refptr< ::ppapi::CallbackTracker> PluginModule::GetCallbackTracker() { diff --git a/webkit/plugins/ppapi/plugin_module.h b/webkit/plugins/ppapi/plugin_module.h index 0f7a425..8c8e1d4 100644 --- a/webkit/plugins/ppapi/plugin_module.h +++ b/webkit/plugins/ppapi/plugin_module.h @@ -105,7 +105,12 @@ class WEBKIT_PLUGINS_EXPORT PluginModule : // ownership of the given pointer, even in the failure case. void InitAsProxied(PluginDelegate::OutOfProcessProxy* out_of_process_proxy); - // Initializes this module for the given NaCl proxy. This takes + // Creates a new module for a NaCl instance that will be using the IPC proxy. + // We can't use the existing module, or new instances of the plugin can't + // be created. + scoped_refptr<PluginModule> CreateModuleForNaClInstance(); + + // Initializes the NaCl module for the given out of process proxy. This takes // ownership of the given pointer, even in the failure case. void InitAsProxiedNaCl( scoped_ptr<PluginDelegate::OutOfProcessProxy> out_of_process_proxy, @@ -234,8 +239,6 @@ class WEBKIT_PLUGINS_EXPORT PluginModule : PP_Bool (*reserve_instance_id_)(PP_Module, PP_Instance); - bool nacl_ipc_proxy_; - DISALLOW_COPY_AND_ASSIGN(PluginModule); }; diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index a2cec8f..30dc9379 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -484,6 +484,9 @@ PluginInstance::~PluginInstance() { delegate_->InstanceDeleted(this); module_->InstanceDeleted(this); + // If we switched from the NaCl plugin module, notify it too. + if (original_module_.get()) + original_module_->InstanceDeleted(this); HostGlobals::Get()->InstanceDeleted(pp_instance_); } @@ -505,8 +508,8 @@ void PluginInstance::Delete() { // If this is a NaCl plugin instance, shut down the NaCl plugin by calling // its DidDestroy. Don't call DidDestroy on the untrusted plugin instance, // since there is little that it can do at this point. - if (nacl_plugin_instance_interface_.get()) - nacl_plugin_instance_interface_->DidDestroy(pp_instance()); + if (original_instance_interface_.get()) + original_instance_interface_->DidDestroy(pp_instance()); else instance_interface_->DidDestroy(pp_instance()); @@ -2543,10 +2546,15 @@ PP_Var PluginInstance::GetPluginInstanceURL( components); } -bool PluginInstance::ResetAsProxied() { +bool PluginInstance::ResetAsProxied(scoped_refptr<PluginModule> module) { + // Save the original module and switch over to the new one now that this + // plugin is using the IPC-based proxy. + original_module_ = module_; + module_ = module; + // For NaCl instances, remember the NaCl plugin instance interface, so we // can shut it down by calling its DidDestroy in our Delete() method. - nacl_plugin_instance_interface_.reset(instance_interface_.release()); + original_instance_interface_.reset(instance_interface_.release()); base::Callback<const void*(const char*)> get_plugin_interface_func = base::Bind(&PluginModule::GetPluginInterface, module_.get()); diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h index 9594331..29b9129 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.h +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h @@ -469,7 +469,7 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance : // proxy and re-sends DidCreate, DidChangeView, and HandleDocumentLoad (if // necessary). // This is for use with the NaCl proxy. - bool ResetAsProxied(); + bool ResetAsProxied(scoped_refptr<PluginModule> module); private: // Implements PPB_Gamepad_API. This is just to avoid having an excessive @@ -573,10 +573,11 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance : PluginDelegate* delegate_; scoped_refptr<PluginModule> module_; scoped_ptr< ::ppapi::PPP_Instance_Combined> instance_interface_; - // If this is the NaCl plugin, store its instance interface so we can shut - // it down properly when using the IPC-based PPAPI proxy. - // TODO(bbudge) Remove this when the proxy switch is complete. - scoped_ptr< ::ppapi::PPP_Instance_Combined> nacl_plugin_instance_interface_; + // If this is the NaCl plugin, we create a new module when we switch to the + // IPC-based PPAPI proxy. Store the original module and instance interface + // so we can shut down properly. + scoped_refptr<PluginModule> original_module_; + scoped_ptr< ::ppapi::PPP_Instance_Combined> original_instance_interface_; PP_Instance pp_instance_; |