diff options
-rw-r--r-- | ppapi/proxy/plugin_globals.cc | 7 | ||||
-rw-r--r-- | ppapi/proxy/ppb_message_loop_proxy.cc | 10 |
2 files changed, 11 insertions, 6 deletions
diff --git a/ppapi/proxy/plugin_globals.cc b/ppapi/proxy/plugin_globals.cc index 1106a75..2913aa2 100644 --- a/ppapi/proxy/plugin_globals.cc +++ b/ppapi/proxy/plugin_globals.cc @@ -76,6 +76,13 @@ PluginGlobals::PluginGlobals(ForTest for_test) PluginGlobals::~PluginGlobals() { DCHECK(plugin_globals_ == this || !plugin_globals_); + // Release the main-thread message loop. We should have the last reference + // count, so this will delete the MessageLoop resource. We do this before + // we clear plugin_globals_, because the Resource destructor tries to access + // this PluginGlobals. + DCHECK(!loop_for_main_thread_ || loop_for_main_thread_->HasOneRef()); + loop_for_main_thread_ = NULL; + plugin_globals_ = NULL; } diff --git a/ppapi/proxy/ppb_message_loop_proxy.cc b/ppapi/proxy/ppb_message_loop_proxy.cc index a40fb4d..c0e9ae1 100644 --- a/ppapi/proxy/ppb_message_loop_proxy.cc +++ b/ppapi/proxy/ppb_message_loop_proxy.cc @@ -45,14 +45,12 @@ MessageLoopResource::MessageLoopResource(ForMainThread for_main_thread) // This must be called only once, so the slot must be empty. CHECK(!PluginGlobals::Get()->msg_loop_slot()); - base::ThreadLocalStorage::Slot* slot = - new base::ThreadLocalStorage::Slot(&ReleaseMessageLoop); + // We don't add a reference for TLS here, so we don't release it. Instead, + // this loop is owned by PluginGlobals. Contrast with AttachToCurrentThread + // where we register ReleaseMessageLoop with TLS and call AddRef. + base::ThreadLocalStorage::Slot* slot = new base::ThreadLocalStorage::Slot(); PluginGlobals::Get()->set_msg_loop_slot(slot); - // Take a ref to the MessageLoop on behalf of the TLS. Note that this is an - // internal ref and not a plugin ref so the plugin can't accidentally - // release it. This is released by ReleaseMessageLoop(). - AddRef(); slot->Set(this); loop_proxy_ = base::MessageLoopProxy::current(); |