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

Side by Side Diff: ppapi/shared_impl/ppb_var_shared.cc

Issue 174213003: PPAPI: Use clang-format on ppapi/shared_impl (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: remove DEPS Created 6 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
« no previous file with comments | « ppapi/shared_impl/ppb_url_util_shared.h ('k') | ppapi/shared_impl/ppb_video_decoder_shared.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) 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/shared_impl/ppb_var_shared.h" 5 #include "ppapi/shared_impl/ppb_var_shared.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "ppapi/c/ppb_var.h" 9 #include "ppapi/c/ppb_var.h"
10 #include "ppapi/c/ppb_var_array_buffer.h" 10 #include "ppapi/c/ppb_var_array_buffer.h"
11 #include "ppapi/c/pp_var.h" 11 #include "ppapi/c/pp_var.h"
12 #include "ppapi/shared_impl/ppapi_globals.h" 12 #include "ppapi/shared_impl/ppapi_globals.h"
13 #include "ppapi/shared_impl/proxy_lock.h" 13 #include "ppapi/shared_impl/proxy_lock.h"
14 #include "ppapi/shared_impl/resource_tracker.h" 14 #include "ppapi/shared_impl/resource_tracker.h"
15 #include "ppapi/shared_impl/resource_var.h" 15 #include "ppapi/shared_impl/resource_var.h"
16 #include "ppapi/shared_impl/var.h" 16 #include "ppapi/shared_impl/var.h"
17 #include "ppapi/shared_impl/var_tracker.h" 17 #include "ppapi/shared_impl/var_tracker.h"
18 18
19 using ppapi::PpapiGlobals; 19 using ppapi::PpapiGlobals;
20 using ppapi::StringVar; 20 using ppapi::StringVar;
21 21
22 namespace ppapi { 22 namespace ppapi {
23 namespace { 23 namespace {
24 24
25
26 // PPB_Var methods ------------------------------------------------------------- 25 // PPB_Var methods -------------------------------------------------------------
27 26
28 void AddRefVar(PP_Var var) { 27 void AddRefVar(PP_Var var) {
29 ProxyAutoLock lock; 28 ProxyAutoLock lock;
30 PpapiGlobals::Get()->GetVarTracker()->AddRefVar(var); 29 PpapiGlobals::Get()->GetVarTracker()->AddRefVar(var);
31 } 30 }
32 31
33 void ReleaseVar(PP_Var var) { 32 void ReleaseVar(PP_Var var) {
34 ProxyAutoLock lock; 33 ProxyAutoLock lock;
35 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var); 34 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var);
(...skipping 27 matching lines...) Expand all
63 PP_Resource pp_resource = resource->GetPPResource(); 62 PP_Resource pp_resource = resource->GetPPResource();
64 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(pp_resource); 63 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(pp_resource);
65 return pp_resource; 64 return pp_resource;
66 } 65 }
67 66
68 PP_Var VarFromResource(PP_Resource resource) { 67 PP_Var VarFromResource(PP_Resource resource) {
69 ProxyAutoLock lock; 68 ProxyAutoLock lock;
70 return PpapiGlobals::Get()->GetVarTracker()->MakeResourcePPVar(resource); 69 return PpapiGlobals::Get()->GetVarTracker()->MakeResourcePPVar(resource);
71 } 70 }
72 71
73 const PPB_Var var_interface = { 72 const PPB_Var var_interface = {&AddRefVar, &ReleaseVar, &VarFromUtf8,
74 &AddRefVar, 73 &VarToUtf8, &VarToResource, &VarFromResource};
75 &ReleaseVar,
76 &VarFromUtf8,
77 &VarToUtf8,
78 &VarToResource,
79 &VarFromResource
80 };
81 74
82 const PPB_Var_1_1 var_interface1_1 = { 75 const PPB_Var_1_1 var_interface1_1 = {&AddRefVar, &ReleaseVar,
83 &AddRefVar, 76 &VarFromUtf8, &VarToUtf8};
84 &ReleaseVar,
85 &VarFromUtf8,
86 &VarToUtf8
87 };
88 77
89 const PPB_Var_1_0 var_interface1_0 = { 78 const PPB_Var_1_0 var_interface1_0 = {&AddRefVar, &ReleaseVar,
90 &AddRefVar, 79 &VarFromUtf8_1_0, &VarToUtf8};
91 &ReleaseVar,
92 &VarFromUtf8_1_0,
93 &VarToUtf8
94 };
95
96 80
97 // PPB_VarArrayBuffer methods -------------------------------------------------- 81 // PPB_VarArrayBuffer methods --------------------------------------------------
98 82
99 PP_Var CreateArrayBufferVar(uint32_t size_in_bytes) { 83 PP_Var CreateArrayBufferVar(uint32_t size_in_bytes) {
100 ProxyAutoLock lock; 84 ProxyAutoLock lock;
101 return PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( 85 return PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(
102 size_in_bytes); 86 size_in_bytes);
103 } 87 }
104 88
105 PP_Bool ByteLength(PP_Var array, uint32_t* byte_length) { 89 PP_Bool ByteLength(PP_Var array, uint32_t* byte_length) {
(...skipping 14 matching lines...) Expand all
120 } 104 }
121 105
122 void Unmap(PP_Var array) { 106 void Unmap(PP_Var array) {
123 ProxyAutoLock lock; 107 ProxyAutoLock lock;
124 ArrayBufferVar* buffer = ArrayBufferVar::FromPPVar(array); 108 ArrayBufferVar* buffer = ArrayBufferVar::FromPPVar(array);
125 if (buffer) 109 if (buffer)
126 buffer->Unmap(); 110 buffer->Unmap();
127 } 111 }
128 112
129 const PPB_VarArrayBuffer_1_0 var_arraybuffer_interface = { 113 const PPB_VarArrayBuffer_1_0 var_arraybuffer_interface = {
130 &CreateArrayBufferVar, 114 &CreateArrayBufferVar, &ByteLength, &Map, &Unmap};
131 &ByteLength,
132 &Map,
133 &Unmap
134 };
135 115
136 } // namespace 116 } // namespace
137 117
138 // static 118 // static
139 const PPB_Var_1_2* PPB_Var_Shared::GetVarInterface1_2() { 119 const PPB_Var_1_2* PPB_Var_Shared::GetVarInterface1_2() {
140 return &var_interface; 120 return &var_interface;
141 } 121 }
142 122
143 // static 123 // static
144 const PPB_Var_1_1* PPB_Var_Shared::GetVarInterface1_1() { 124 const PPB_Var_1_1* PPB_Var_Shared::GetVarInterface1_1() {
145 return &var_interface1_1; 125 return &var_interface1_1;
146 } 126 }
147 127
148 // static 128 // static
149 const PPB_Var_1_0* PPB_Var_Shared::GetVarInterface1_0() { 129 const PPB_Var_1_0* PPB_Var_Shared::GetVarInterface1_0() {
150 return &var_interface1_0; 130 return &var_interface1_0;
151 } 131 }
152 132
153 // static 133 // static
154 const PPB_VarArrayBuffer_1_0* PPB_Var_Shared::GetVarArrayBufferInterface1_0() { 134 const PPB_VarArrayBuffer_1_0* PPB_Var_Shared::GetVarArrayBufferInterface1_0() {
155 return &var_arraybuffer_interface; 135 return &var_arraybuffer_interface;
156 } 136 }
157 137
158 } // namespace ppapi 138 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/ppb_url_util_shared.h ('k') | ppapi/shared_impl/ppb_video_decoder_shared.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698