Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(672)

Unified Diff: webkit/plugins/ppapi/plugin_module.cc

Issue 8222021: Prevent reentrant destructors in the PluginModule. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/plugins/ppapi/plugin_module.h ('k') | webkit/plugins/ppapi/ppb_proxy_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/plugin_module.cc
===================================================================
--- webkit/plugins/ppapi/plugin_module.cc (revision 104693)
+++ webkit/plugins/ppapi/plugin_module.cc (working copy)
@@ -367,6 +367,7 @@
PluginDelegate::ModuleLifetime* lifetime_delegate)
: lifetime_delegate_(lifetime_delegate),
callback_tracker_(new CallbackTracker),
+ is_in_destructor_(false),
is_crashed_(false),
broker_(NULL),
library_(NULL),
@@ -380,6 +381,11 @@
}
PluginModule::~PluginModule() {
+ // In the past there have been crashes reentering the plugin module
+ // destructor. Catch if that happens again earlier.
+ CHECK(!is_in_destructor_);
+ is_in_destructor_ = true;
+
// When the module is being deleted, there should be no more instances still
// holding a reference to us.
DCHECK(instances_.empty());
@@ -394,12 +400,18 @@
if (library_)
base::UnloadNativeLibrary(library_);
+ // Notifications that we've been deleted should be last.
ResourceTracker::Get()->ModuleDeleted(pp_module_);
+ if (!is_crashed_) {
+ // When the plugin crashes, we immediately tell the lifetime delegate that
+ // we're gone, so we don't want to tell it again.
+ lifetime_delegate_->PluginModuleDead(this);
+ }
- // When the plugin crashes, we immediately tell the lifetime delegate that
- // we're gone, so we don't want to tell it again.
- if (!is_crashed_)
- lifetime_delegate_->PluginModuleDead(this);
+ // Don't add stuff here, the two notifications that the module object has
+ // been deleted should be last. This allows, for example,
+ // PPB_Proxy.IsInModuleDestructor to map PP_Module to this class during the
+ // previous parts of the destructor.
}
bool PluginModule::InitAsInternalPlugin(const EntryPoints& entry_points) {
« no previous file with comments | « webkit/plugins/ppapi/plugin_module.h ('k') | webkit/plugins/ppapi/ppb_proxy_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698