summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-03 12:10:00 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-03 12:10:00 +0000
commitf137d06c2dff4ddb37955dd8852e97dfb3bc3a53 (patch)
tree008523506be111795fafe62d27351b70f6cd2c00 /ppapi
parent43f4dcdc9d2b1c2a4bb6762e4a16304ffed8d2ac (diff)
downloadchromium_src-f137d06c2dff4ddb37955dd8852e97dfb3bc3a53.zip
chromium_src-f137d06c2dff4ddb37955dd8852e97dfb3bc3a53.tar.gz
chromium_src-f137d06c2dff4ddb37955dd8852e97dfb3bc3a53.tar.bz2
PPAPI: Fix destructor ordering problem for main-thread message loop
See bug for more info. BUG=167841 Review URL: https://chromiumcodereview.appspot.com/11740016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174945 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/proxy/plugin_globals.cc7
-rw-r--r--ppapi/proxy/ppb_message_loop_proxy.cc10
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();