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

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

Issue 12045093: PPAPI: Add locking for PPB_MessageLoop (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Just the message loop locking Created 7 years, 10 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 | « no previous file | 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 191 }
192 192
193 // static 193 // static
194 void MessageLoopResource::ReleaseMessageLoop(void* value) { 194 void MessageLoopResource::ReleaseMessageLoop(void* value) {
195 static_cast<MessageLoopResource*>(value)->DetachFromThread(); 195 static_cast<MessageLoopResource*>(value)->DetachFromThread();
196 } 196 }
197 197
198 // ----------------------------------------------------------------------------- 198 // -----------------------------------------------------------------------------
199 199
200 PP_Resource Create(PP_Instance instance) { 200 PP_Resource Create(PP_Instance instance) {
201 ProxyAutoLock lock;
201 // Validate the instance. 202 // Validate the instance.
202 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); 203 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
203 if (!dispatcher) 204 if (!dispatcher)
204 return 0; 205 return 0;
205 return (new MessageLoopResource(instance))->GetReference(); 206 return (new MessageLoopResource(instance))->GetReference();
206 } 207 }
207 208
208 PP_Resource GetForMainThread() { 209 PP_Resource GetForMainThread() {
210 ProxyAutoLock lock;
209 return PluginGlobals::Get()->loop_for_main_thread()->GetReference(); 211 return PluginGlobals::Get()->loop_for_main_thread()->GetReference();
210 } 212 }
211 213
212 PP_Resource GetCurrent() { 214 PP_Resource GetCurrent() {
215 ProxyAutoLock lock;
213 Resource* resource = MessageLoopResource::GetCurrent(); 216 Resource* resource = MessageLoopResource::GetCurrent();
214 if (resource) 217 if (resource)
215 return resource->GetReference(); 218 return resource->GetReference();
216 return 0; 219 return 0;
217 } 220 }
218 221
219 int32_t AttachToCurrentThread(PP_Resource message_loop) { 222 int32_t AttachToCurrentThread(PP_Resource message_loop) {
220 EnterMessageLoop enter(message_loop, true); 223 EnterMessageLoop enter(message_loop, true);
221 if (enter.succeeded()) 224 if (enter.succeeded())
222 return enter.object()->AttachToCurrentThread(); 225 return enter.object()->AttachToCurrentThread();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 PPB_MessageLoop_Proxy::~PPB_MessageLoop_Proxy() { 266 PPB_MessageLoop_Proxy::~PPB_MessageLoop_Proxy() {
264 } 267 }
265 268
266 // static 269 // static
267 const PPB_MessageLoop_1_0* PPB_MessageLoop_Proxy::GetInterface() { 270 const PPB_MessageLoop_1_0* PPB_MessageLoop_Proxy::GetInterface() {
268 return &ppb_message_loop_interface; 271 return &ppb_message_loop_interface;
269 } 272 }
270 273
271 } // namespace proxy 274 } // namespace proxy
272 } // namespace ppapi 275 } // namespace ppapi
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698