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

Side by Side Diff: ppapi/proxy/ppb_message_loop_proxy.cc

Issue 11740016: PPAPI: Fix destructor ordering problem for main-thread message loop (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: oops, loop is sometimes NULL Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/plugin_globals.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/proxy/ppb_message_loop_proxy.h" 5 #include "ppapi/proxy/ppb_message_loop_proxy.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 27 matching lines...) Expand all
38 : MessageLoopShared(for_main_thread), 38 : MessageLoopShared(for_main_thread),
39 nested_invocations_(0), 39 nested_invocations_(0),
40 destroyed_(false), 40 destroyed_(false),
41 should_destroy_(false), 41 should_destroy_(false),
42 is_main_thread_loop_(true) { 42 is_main_thread_loop_(true) {
43 // We attach the main thread immediately. We can't use AttachToCurrentThread, 43 // We attach the main thread immediately. We can't use AttachToCurrentThread,
44 // because the MessageLoop already exists. 44 // because the MessageLoop already exists.
45 45
46 // This must be called only once, so the slot must be empty. 46 // This must be called only once, so the slot must be empty.
47 CHECK(!PluginGlobals::Get()->msg_loop_slot()); 47 CHECK(!PluginGlobals::Get()->msg_loop_slot());
48 base::ThreadLocalStorage::Slot* slot = 48 // We don't add a reference for TLS here, so we don't release it. Instead,
49 new base::ThreadLocalStorage::Slot(&ReleaseMessageLoop); 49 // this loop is owned by PluginGlobals. Contrast with AttachToCurrentThread
50 // where we register ReleaseMessageLoop with TLS and call AddRef.
51 base::ThreadLocalStorage::Slot* slot = new base::ThreadLocalStorage::Slot();
50 PluginGlobals::Get()->set_msg_loop_slot(slot); 52 PluginGlobals::Get()->set_msg_loop_slot(slot);
51 53
52 // Take a ref to the MessageLoop on behalf of the TLS. Note that this is an
53 // internal ref and not a plugin ref so the plugin can't accidentally
54 // release it. This is released by ReleaseMessageLoop().
55 AddRef();
56 slot->Set(this); 54 slot->Set(this);
57 55
58 loop_proxy_ = base::MessageLoopProxy::current(); 56 loop_proxy_ = base::MessageLoopProxy::current();
59 } 57 }
60 58
61 59
62 MessageLoopResource::~MessageLoopResource() { 60 MessageLoopResource::~MessageLoopResource() {
63 } 61 }
64 62
65 PPB_MessageLoop_API* MessageLoopResource::AsPPB_MessageLoop_API() { 63 PPB_MessageLoop_API* MessageLoopResource::AsPPB_MessageLoop_API() {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 PPB_MessageLoop_Proxy::~PPB_MessageLoop_Proxy() { 263 PPB_MessageLoop_Proxy::~PPB_MessageLoop_Proxy() {
266 } 264 }
267 265
268 // static 266 // static
269 const PPB_MessageLoop_1_0* PPB_MessageLoop_Proxy::GetInterface() { 267 const PPB_MessageLoop_1_0* PPB_MessageLoop_Proxy::GetInterface() {
270 return &ppb_message_loop_interface; 268 return &ppb_message_loop_interface;
271 } 269 }
272 270
273 } // namespace proxy 271 } // namespace proxy
274 } // namespace ppapi 272 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/plugin_globals.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698