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 13 matching lines...) Expand all Loading... |
24 | 24 |
25 namespace { | 25 namespace { |
26 typedef thunk::EnterResource<PPB_MessageLoop_API> EnterMessageLoop; | 26 typedef thunk::EnterResource<PPB_MessageLoop_API> EnterMessageLoop; |
27 } | 27 } |
28 | 28 |
29 MessageLoopResource::MessageLoopResource(PP_Instance instance) | 29 MessageLoopResource::MessageLoopResource(PP_Instance instance) |
30 : MessageLoopShared(instance), | 30 : MessageLoopShared(instance), |
31 nested_invocations_(0), | 31 nested_invocations_(0), |
32 destroyed_(false), | 32 destroyed_(false), |
33 should_destroy_(false), | 33 should_destroy_(false), |
34 is_main_thread_loop_(false) { | 34 is_main_thread_loop_(false), |
| 35 currently_handling_blocking_message_(false) { |
35 } | 36 } |
36 | 37 |
37 MessageLoopResource::MessageLoopResource(ForMainThread for_main_thread) | 38 MessageLoopResource::MessageLoopResource(ForMainThread for_main_thread) |
38 : MessageLoopShared(for_main_thread), | 39 : MessageLoopShared(for_main_thread), |
39 nested_invocations_(0), | 40 nested_invocations_(0), |
40 destroyed_(false), | 41 destroyed_(false), |
41 should_destroy_(false), | 42 should_destroy_(false), |
42 is_main_thread_loop_(true) { | 43 is_main_thread_loop_(true), |
| 44 currently_handling_blocking_message_(false) { |
43 // We attach the main thread immediately. We can't use AttachToCurrentThread, | 45 // We attach the main thread immediately. We can't use AttachToCurrentThread, |
44 // because the MessageLoop already exists. | 46 // because the MessageLoop already exists. |
45 | 47 |
46 // This must be called only once, so the slot must be empty. | 48 // This must be called only once, so the slot must be empty. |
47 CHECK(!PluginGlobals::Get()->msg_loop_slot()); | 49 CHECK(!PluginGlobals::Get()->msg_loop_slot()); |
48 // We don't add a reference for TLS here, so we don't release it. Instead, | 50 // We don't add a reference for TLS here, so we don't release it. Instead, |
49 // this loop is owned by PluginGlobals. Contrast with AttachToCurrentThread | 51 // this loop is owned by PluginGlobals. Contrast with AttachToCurrentThread |
50 // where we register ReleaseMessageLoop with TLS and call AddRef. | 52 // where we register ReleaseMessageLoop with TLS and call AddRef. |
51 base::ThreadLocalStorage::Slot* slot = new base::ThreadLocalStorage::Slot(); | 53 base::ThreadLocalStorage::Slot* slot = new base::ThreadLocalStorage::Slot(); |
52 PluginGlobals::Get()->set_msg_loop_slot(slot); | 54 PluginGlobals::Get()->set_msg_loop_slot(slot); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 info.closure = closure; | 188 info.closure = closure; |
187 info.delay_ms = delay_ms; | 189 info.delay_ms = delay_ms; |
188 pending_tasks_.push_back(info); | 190 pending_tasks_.push_back(info); |
189 } | 191 } |
190 } | 192 } |
191 | 193 |
192 base::MessageLoopProxy* MessageLoopResource::GetMessageLoopProxy() { | 194 base::MessageLoopProxy* MessageLoopResource::GetMessageLoopProxy() { |
193 return loop_proxy_.get(); | 195 return loop_proxy_.get(); |
194 } | 196 } |
195 | 197 |
| 198 bool MessageLoopResource::CurrentlyHandlingBlockingMessage() { |
| 199 return currently_handling_blocking_message_; |
| 200 } |
| 201 |
196 // static | 202 // static |
197 void MessageLoopResource::ReleaseMessageLoop(void* value) { | 203 void MessageLoopResource::ReleaseMessageLoop(void* value) { |
198 static_cast<MessageLoopResource*>(value)->DetachFromThread(); | 204 static_cast<MessageLoopResource*>(value)->DetachFromThread(); |
199 } | 205 } |
200 | 206 |
201 // ----------------------------------------------------------------------------- | 207 // ----------------------------------------------------------------------------- |
202 | 208 |
203 PP_Resource Create(PP_Instance instance) { | 209 PP_Resource Create(PP_Instance instance) { |
204 ProxyAutoLock lock; | 210 ProxyAutoLock lock; |
205 // Validate the instance. | 211 // Validate the instance. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 PPB_MessageLoop_Proxy::~PPB_MessageLoop_Proxy() { | 275 PPB_MessageLoop_Proxy::~PPB_MessageLoop_Proxy() { |
270 } | 276 } |
271 | 277 |
272 // static | 278 // static |
273 const PPB_MessageLoop_1_0* PPB_MessageLoop_Proxy::GetInterface() { | 279 const PPB_MessageLoop_1_0* PPB_MessageLoop_Proxy::GetInterface() { |
274 return &ppb_message_loop_interface; | 280 return &ppb_message_loop_interface; |
275 } | 281 } |
276 | 282 |
277 } // namespace proxy | 283 } // namespace proxy |
278 } // namespace ppapi | 284 } // namespace ppapi |
OLD | NEW |