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

Side by Side Diff: ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_var.cc

Issue 9169052: Tweaks to PPB_VarArrayBuffer in preperation for taking out of Dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes based on reviews Created 8 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
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 "native_client/src/shared/ppapi_proxy/plugin_ppb_var.h" 5 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_var.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 PP_Var var; 92 PP_Var var;
93 var.type = PP_VARTYPE_ARRAY_BUFFER; 93 var.type = PP_VARTYPE_ARRAY_BUFFER;
94 var.value.as_id = proxy_var->id(); 94 var.value.as_id = proxy_var->id();
95 // Increment the reference count for the return to the caller. 95 // Increment the reference count for the return to the caller.
96 AddRef(var); 96 AddRef(var);
97 DebugPrintf("PPB_VarArrayBuffer::Create: as_id=%"NACL_PRId64"\n", 97 DebugPrintf("PPB_VarArrayBuffer::Create: as_id=%"NACL_PRId64"\n",
98 var.value.as_id); 98 var.value.as_id);
99 return var; 99 return var;
100 } 100 }
101 101
102 uint32_t ByteLength(PP_Var var) { 102 PP_Bool ByteLength(PP_Var var, uint32_t* byte_length) {
103 DebugPrintf("PPB_VarArrayBuffer::ByteLength: var=PPB_Var(%s)\n", 103 DebugPrintf("PPB_VarArrayBuffer::ByteLength: var=PPB_Var(%s)\n",
104 PluginVar::DebugString(var).c_str()); 104 PluginVar::DebugString(var).c_str());
105 SharedArrayBufferProxyVar buffer_var = ArrayBufferProxyVar::CastFromProxyVar( 105 SharedArrayBufferProxyVar buffer_var = ArrayBufferProxyVar::CastFromProxyVar(
106 ProxyVarCache::GetInstance().SharedProxyVarForVar(var)); 106 ProxyVarCache::GetInstance().SharedProxyVarForVar(var));
107 uint32_t len = buffer_var->buffer_length(); 107 if (buffer_var) {
108 DebugPrintf("PPB_VarArrayBuffer::ByteLength: length=%"NACL_PRIu32"\n", len); 108 *byte_length = buffer_var->buffer_length();
109 return len; 109 DebugPrintf("PPB_VarArrayBuffer::ByteLength: length=%"NACL_PRIu32"\n",
110 *byte_length);
111 return PP_TRUE;
112 }
113 return PP_FALSE;
110 } 114 }
111 115
112 void* Map(PP_Var var) { 116 void* Map(PP_Var var) {
113 DebugPrintf("PPB_VarArrayBuffer::Map: var=PPB_Var(%s)\n", 117 DebugPrintf("PPB_VarArrayBuffer::Map: var=PPB_Var(%s)\n",
114 PluginVar::DebugString(var).c_str()); 118 PluginVar::DebugString(var).c_str());
115 SharedArrayBufferProxyVar buffer_var = ArrayBufferProxyVar::CastFromProxyVar( 119 SharedArrayBufferProxyVar buffer_var = ArrayBufferProxyVar::CastFromProxyVar(
116 ProxyVarCache::GetInstance().SharedProxyVarForVar(var)); 120 ProxyVarCache::GetInstance().SharedProxyVarForVar(var));
117 void* data = buffer_var->buffer(); 121 void* data = buffer_var->buffer();
118 DebugPrintf("PPB_VarArrayBuffer::Map: buffer=%p\n", data); 122 DebugPrintf("PPB_VarArrayBuffer::Map: buffer=%p\n", data);
119 return data; 123 return data;
120 } 124 }
121 125
126 void Unmap(PP_Var var) {
127 DebugPrintf("PPB_VarArrayBuffer::Unap: var=PPB_Var(%s)\n",
128 PluginVar::DebugString(var).c_str());
129 // We don't use shared memory, so there's nothing to do.
130 }
131
122 } // namespace 132 } // namespace
123 133
124 const PPB_Var* PluginVar::GetInterface() { 134 const PPB_Var* PluginVar::GetInterface() {
125 static const PPB_Var var_interface = { 135 static const PPB_Var var_interface = {
126 AddRef, 136 AddRef,
127 Release, 137 Release,
128 VarFromUtf8, 138 VarFromUtf8,
129 VarToUtf8 139 VarToUtf8
130 }; 140 };
131 return &var_interface; 141 return &var_interface;
132 } 142 }
133 143
134 const PPB_Var_1_0* PluginVar::GetInterface1_0() { 144 const PPB_Var_1_0* PluginVar::GetInterface1_0() {
135 static const PPB_Var_1_0 var_interface = { 145 static const PPB_Var_1_0 var_interface = {
136 AddRef, 146 AddRef,
137 Release, 147 Release,
138 VarFromUtf8_1_0, 148 VarFromUtf8_1_0,
139 VarToUtf8 149 VarToUtf8
140 }; 150 };
141 return &var_interface; 151 return &var_interface;
142 } 152 }
143 153
144 const PPB_VarArrayBuffer_Dev* PluginVar::GetArrayBufferInterface() { 154 const PPB_VarArrayBuffer_Dev* PluginVar::GetArrayBufferInterface() {
145 static const PPB_VarArrayBuffer_Dev interface = { 155 static const PPB_VarArrayBuffer_Dev interface = {
146 CreateArrayBuffer, 156 CreateArrayBuffer,
147 ByteLength, 157 ByteLength,
148 Map 158 Map,
159 Unmap
149 }; 160 };
150 return &interface; 161 return &interface;
151 } 162 }
152 163
153 std::string PluginVar::DebugString(const PP_Var& var) { 164 std::string PluginVar::DebugString(const PP_Var& var) {
154 switch (var.type) { 165 switch (var.type) {
155 case PP_VARTYPE_UNDEFINED: 166 case PP_VARTYPE_UNDEFINED:
156 return "##UNDEFINED##"; 167 return "##UNDEFINED##";
157 case PP_VARTYPE_NULL: 168 case PP_VARTYPE_NULL:
158 return "##NULL##"; 169 return "##NULL##";
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 case PP_VARTYPE_STRING: 258 case PP_VARTYPE_STRING:
248 { 259 {
249 std::string str = DebugString(var); 260 std::string str = DebugString(var);
250 DebugPrintf("PP_Var(string: '%*s')", 261 DebugPrintf("PP_Var(string: '%*s')",
251 static_cast<uint32_t>(str.size()), 262 static_cast<uint32_t>(str.size()),
252 str.c_str()); 263 str.c_str());
253 } 264 }
254 case PP_VARTYPE_OBJECT: 265 case PP_VARTYPE_OBJECT:
255 DebugPrintf("PP_Var(object: %"NACL_PRIu64")", GetVarId(var)); 266 DebugPrintf("PP_Var(object: %"NACL_PRIu64")", GetVarId(var));
256 break; 267 break;
268 case PP_VARTYPE_ARRAY_BUFFER:
269 DebugPrintf("PP_Var(object: %"NACL_PRIu64")", GetVarId(var));
270 break;
257 case PP_VARTYPE_ARRAY: 271 case PP_VARTYPE_ARRAY:
258 case PP_VARTYPE_DICTIONARY: 272 case PP_VARTYPE_DICTIONARY:
259 case PP_VARTYPE_ARRAY_BUFFER:
260 NACL_NOTREACHED();
261 break; 273 break;
262 } 274 }
263 } 275 }
264 276
265 } // namespace ppapi_proxy 277 } // namespace ppapi_proxy
OLDNEW
« no previous file with comments | « ppapi/native_client/src/shared/ppapi_proxy/object_serialize.cc ('k') | ppapi/proxy/plugin_array_buffer_var.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698