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

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

Issue 600553002: PPAPI: Disallow blocking callbacks while handling a blocking message (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: try to improve comment Created 6 years, 2 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
« no previous file with comments | « ppapi/proxy/ppb_message_loop_proxy.h ('k') | ppapi/shared_impl/ppb_message_loop_shared.h » ('j') | 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 13 matching lines...) Expand all
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
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
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
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_message_loop_proxy.h ('k') | ppapi/shared_impl/ppb_message_loop_shared.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698