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

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

Issue 8502030: Draft of a PPAPI interface for ArrayBuffer and typed arrays. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 9 years 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/cpp/var.h ('k') | ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_var.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 /* 1 /*
2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" 7 #include "native_client/src/shared/ppapi_proxy/object_serialize.h"
8 8
9 #include <limits> 9 #include <limits>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // Adding the length to the fixed portion would overflow. 124 // Adding the length to the fixed portion would overflow.
125 return 0; 125 return 0;
126 } 126 }
127 return static_cast<uint32_t>(NACL_OFFSETOF(SerializedString, string_bytes) 127 return static_cast<uint32_t>(NACL_OFFSETOF(SerializedString, string_bytes)
128 + string_length); 128 + string_length);
129 break; 129 break;
130 } 130 }
131 case PP_VARTYPE_OBJECT: 131 case PP_VARTYPE_OBJECT:
132 case PP_VARTYPE_ARRAY: 132 case PP_VARTYPE_ARRAY:
133 case PP_VARTYPE_DICTIONARY: 133 case PP_VARTYPE_DICTIONARY:
134 case PP_VARTYPE_ARRAY_BUFFER:
134 NACL_NOTREACHED(); 135 NACL_NOTREACHED();
135 break; 136 break;
136 } 137 }
137 // Unrecognized type. 138 // Unrecognized type.
138 return 0; 139 return 0;
139 } 140 }
140 141
141 uint32_t PpVarVectorSize(const PP_Var* vars, uint32_t argc) { 142 uint32_t PpVarVectorSize(const PP_Var* vars, uint32_t argc) {
142 size_t size = 0; 143 size_t size = 0;
143 144
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // Fill padding bytes with zeros. 209 // Fill padding bytes with zeros.
209 memset(reinterpret_cast<void*>(ss->string_bytes + string_length), 0, 210 memset(reinterpret_cast<void*>(ss->string_bytes + string_length), 0,
210 RoundedStringBytes(string_length) - string_length); 211 RoundedStringBytes(string_length) - string_length);
211 element_size = NACL_OFFSETOF(SerializedString, string_bytes) 212 element_size = NACL_OFFSETOF(SerializedString, string_bytes)
212 + RoundedStringBytes(string_length); 213 + RoundedStringBytes(string_length);
213 break; 214 break;
214 } 215 }
215 case PP_VARTYPE_OBJECT: 216 case PP_VARTYPE_OBJECT:
216 case PP_VARTYPE_ARRAY: 217 case PP_VARTYPE_ARRAY:
217 case PP_VARTYPE_DICTIONARY: 218 case PP_VARTYPE_DICTIONARY:
219 case PP_VARTYPE_ARRAY_BUFFER:
218 NACL_NOTREACHED(); 220 NACL_NOTREACHED();
219 default: 221 default:
220 return false; 222 return false;
221 } 223 }
222 offset += element_size; 224 offset += element_size;
223 } 225 }
224 return true; 226 return true;
225 } 227 }
226 228
227 229
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 if (std::numeric_limits<uint32_t>::max() == expected_element_size) { 301 if (std::numeric_limits<uint32_t>::max() == expected_element_size) {
300 return std::numeric_limits<uint32_t>::max(); 302 return std::numeric_limits<uint32_t>::max();
301 } 303 }
302 break; 304 break;
303 // NB: No default case to trigger -Wswitch-enum, so changes to 305 // NB: No default case to trigger -Wswitch-enum, so changes to
304 // PP_VarType w/o corresponding changes here will cause a 306 // PP_VarType w/o corresponding changes here will cause a
305 // compile-time error. 307 // compile-time error.
306 case PP_VARTYPE_OBJECT: 308 case PP_VARTYPE_OBJECT:
307 case PP_VARTYPE_ARRAY: 309 case PP_VARTYPE_ARRAY:
308 case PP_VARTYPE_DICTIONARY: 310 case PP_VARTYPE_DICTIONARY:
311 case PP_VARTYPE_ARRAY_BUFFER:
309 NACL_NOTREACHED(); 312 NACL_NOTREACHED();
310 break; 313 break;
311 } 314 }
312 if (length < expected_element_size) { 315 if (length < expected_element_size) {
313 return std::numeric_limits<uint32_t>::max(); 316 return std::numeric_limits<uint32_t>::max();
314 } 317 }
315 if (NULL != element_type_ptr) { 318 if (NULL != element_type_ptr) {
316 *element_type_ptr = static_cast<PP_VarType>(sfp->type); 319 *element_type_ptr = static_cast<PP_VarType>(sfp->type);
317 } 320 }
318 return expected_element_size; 321 return expected_element_size;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 break; 373 break;
371 } 374 }
372 case PP_VARTYPE_STRING: 375 case PP_VARTYPE_STRING:
373 if (!DeserializeString(p, &vars[i], channel)) { 376 if (!DeserializeString(p, &vars[i], channel)) {
374 return false; 377 return false;
375 } 378 }
376 break; 379 break;
377 case PP_VARTYPE_OBJECT: 380 case PP_VARTYPE_OBJECT:
378 case PP_VARTYPE_ARRAY: 381 case PP_VARTYPE_ARRAY:
379 case PP_VARTYPE_DICTIONARY: 382 case PP_VARTYPE_DICTIONARY:
383 case PP_VARTYPE_ARRAY_BUFFER:
380 NACL_NOTREACHED(); 384 NACL_NOTREACHED();
381 default: 385 default:
382 return false; 386 return false;
383 } 387 }
384 p += element_size; 388 p += element_size;
385 length -= element_size; 389 length -= element_size;
386 } 390 }
387 return true; 391 return true;
388 } 392 }
389 393
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 return false; 463 return false;
460 } 464 }
461 // Read the serialized PP_Vars into the allocated memory. 465 // Read the serialized PP_Vars into the allocated memory.
462 if (!DeserializePpVar(channel, bytes, length, vars, argc)) { 466 if (!DeserializePpVar(channel, bytes, length, vars, argc)) {
463 return false; 467 return false;
464 } 468 }
465 return true; 469 return true;
466 } 470 }
467 471
468 } // namespace ppapi_proxy 472 } // namespace ppapi_proxy
OLDNEW
« no previous file with comments | « ppapi/cpp/var.h ('k') | ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_var.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698