summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ppapi/c/ppp_instance.h4
-rw-r--r--ppapi/proxy/ppp_instance_proxy.cc5
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc24
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.h9
4 files changed, 24 insertions, 18 deletions
diff --git a/ppapi/c/ppp_instance.h b/ppapi/c/ppp_instance.h
index d5099e1..99b3cc3 100644
--- a/ppapi/c/ppp_instance.h
+++ b/ppapi/c/ppp_instance.h
@@ -74,6 +74,10 @@ struct PPP_Instance {
* even if DidCreate returned failure. The function should deallocate any data
* associated with the instance.
*
+ * The instance identifier will still be valid so the plugin can perform
+ * cleanup-related tasks. Once this function is called, the PP_Instance will
+ * be invalid.
+ *
* @param[in] instance A PP_Instance indentifying one instance of a module.
*/
void (*DidDestroy)(PP_Instance instance);
diff --git a/ppapi/proxy/ppp_instance_proxy.cc b/ppapi/proxy/ppp_instance_proxy.cc
index bb0ad79..393f031 100644
--- a/ppapi/proxy/ppp_instance_proxy.cc
+++ b/ppapi/proxy/ppp_instance_proxy.cc
@@ -186,11 +186,6 @@ void PPP_Instance_Proxy::OnMsgDidCreate(
*result = ppp_instance_target()->DidCreate(instance,
static_cast<uint32_t>(argn.size()),
&argn_array[0], &argv_array[0]);
- if (!*result) {
- // In the failure to create case, this plugin instance will be torn down
- // without further notification, so we also need to undo the routing.
- plugin_dispatcher->DidDestroyInstance(instance);
- }
}
void PPP_Instance_Proxy::OnMsgDidDestroy(PP_Instance instance) {
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 8e5f6fc..dda0165 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -418,6 +418,18 @@ const PPB_Zoom_Dev* PluginInstance::GetZoomInterface() {
// method needs to access a member of the instance after the call has returned,
// then it needs to keep its own reference on the stack.
+void PluginInstance::Delete() {
+ // Keep a reference on the stack. See NOTE above.
+ scoped_refptr<PluginInstance> ref(this);
+ instance_interface_->DidDestroy(pp_instance());
+
+ if (fullscreen_container_) {
+ fullscreen_container_->Destroy();
+ fullscreen_container_ = NULL;
+ }
+ container_ = NULL;
+}
+
void PluginInstance::Paint(WebCanvas* canvas,
const gfx::Rect& plugin_rect,
const gfx::Rect& paint_rect) {
@@ -672,18 +684,6 @@ void PluginInstance::PostMessage(PP_Var message) {
message_channel_->PostMessageToJavaScript(message);
}
-void PluginInstance::Delete() {
- // Keep a reference on the stack. See NOTE above.
- scoped_refptr<PluginInstance> ref(this);
- instance_interface_->DidDestroy(pp_instance());
-
- if (fullscreen_container_) {
- fullscreen_container_->Destroy();
- fullscreen_container_ = NULL;
- }
- container_ = NULL;
-}
-
bool PluginInstance::Initialize(WebPluginContainer* container,
const std::vector<std::string>& arg_names,
const std::vector<std::string>& arg_values,
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h
index bb19d31..837a179 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.h
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h
@@ -77,6 +77,8 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
PluginInstance(PluginDelegate* delegate,
PluginModule* module,
const PPP_Instance* instance_interface);
+
+ // Delete should be called by the WebPlugin before this destructor.
~PluginInstance();
static const PPB_Instance* GetInterface();
@@ -105,6 +107,12 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
// nonzero.
PP_Instance pp_instance() const { return pp_instance_; }
+ // Does some pre-destructor cleanup on the instance. This is necessary
+ // because some cleanup depends on the plugin instance still existing (like
+ // calling the plugin's DidDestroy function). This function is called from
+ // the WebPlugin implementation when WebKit is about to remove the plugin.
+ void Delete();
+
// Paints the current backing store to the web page.
void Paint(WebKit::WebCanvas* canvas,
const gfx::Rect& plugin_rect,
@@ -146,7 +154,6 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
PP_Var ExecuteScript(PP_Var script, PP_Var* exception);
// PPP_Instance pass-through.
- void Delete();
bool Initialize(WebKit::WebPluginContainer* container,
const std::vector<std::string>& arg_names,
const std::vector<std::string>& arg_values,