OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |