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

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

Issue 8016008: Make much of the proxy thread-safe with 1 great big lock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 9 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/ppb_core_proxy.cc ('k') | ppapi/proxy/ppb_var_unittest.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_var_proxy.h" 5 #include "ppapi/proxy/ppb_var_proxy.h"
6 6
7 #include "ppapi/c/pp_var.h" 7 #include "ppapi/c/pp_var.h"
8 #include "ppapi/c/ppb_var.h" 8 #include "ppapi/c/ppb_var.h"
9 #include "ppapi/proxy/plugin_resource_tracker.h" 9 #include "ppapi/proxy/plugin_resource_tracker.h"
10 #include "ppapi/proxy/plugin_var_tracker.h" 10 #include "ppapi/proxy/plugin_var_tracker.h"
11 #include "ppapi/shared_impl/proxy_lock.h"
11 #include "ppapi/shared_impl/var.h" 12 #include "ppapi/shared_impl/var.h"
12 13
13 namespace ppapi { 14 namespace ppapi {
14 namespace proxy { 15 namespace proxy {
15 16
16 namespace { 17 namespace {
17 18
18 // PPP_Var plugin -------------------------------------------------------------- 19 // PPP_Var plugin --------------------------------------------------------------
19 20
20 void AddRefVar(PP_Var var) { 21 void AddRefVar(PP_Var var) {
22 ppapi::ProxyAutoLock lock;
21 PluginResourceTracker::GetInstance()->var_tracker().AddRefVar(var); 23 PluginResourceTracker::GetInstance()->var_tracker().AddRefVar(var);
22 } 24 }
23 25
24 void ReleaseVar(PP_Var var) { 26 void ReleaseVar(PP_Var var) {
27 ppapi::ProxyAutoLock lock;
25 PluginResourceTracker::GetInstance()->var_tracker().ReleaseVar(var); 28 PluginResourceTracker::GetInstance()->var_tracker().ReleaseVar(var);
26 } 29 }
27 30
28 PP_Var VarFromUtf8(PP_Module module, const char* data, uint32_t len) { 31 PP_Var VarFromUtf8(PP_Module module, const char* data, uint32_t len) {
32 ppapi::ProxyAutoLock lock;
29 return StringVar::StringToPPVar(module, data, len); 33 return StringVar::StringToPPVar(module, data, len);
30 } 34 }
31 35
32 const char* VarToUtf8(PP_Var var, uint32_t* len) { 36 const char* VarToUtf8(PP_Var var, uint32_t* len) {
37 ppapi::ProxyAutoLock lock;
33 StringVar* str = StringVar::FromPPVar(var); 38 StringVar* str = StringVar::FromPPVar(var);
34 if (str) { 39 if (str) {
35 *len = static_cast<uint32_t>(str->value().size()); 40 *len = static_cast<uint32_t>(str->value().size());
36 return str->value().c_str(); 41 return str->value().c_str();
37 } 42 }
38 *len = 0; 43 *len = 0;
39 return NULL; 44 return NULL;
40 } 45 }
41 46
42 const PPB_Var var_interface = { 47 const PPB_Var var_interface = {
43 &AddRefVar, 48 &AddRefVar,
44 &ReleaseVar, 49 &ReleaseVar,
45 &VarFromUtf8, 50 &VarFromUtf8,
46 &VarToUtf8 51 &VarToUtf8
47 }; 52 };
48 53
49 } // namespace 54 } // namespace
50 55
51 const PPB_Var* GetPPB_Var_Interface() { 56 const PPB_Var* GetPPB_Var_Interface() {
52 return &var_interface; 57 return &var_interface;
53 } 58 }
54 59
55 } // namespace proxy 60 } // namespace proxy
56 } // namespace ppapi 61 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_core_proxy.cc ('k') | ppapi/proxy/ppb_var_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698