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

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

Issue 9187071: Lift the 64K message size limit for postMessage to/from NativeClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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 /* 1 /*
2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 * Copyright (c) 2012 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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 // Serialize the var. 457 // Serialize the var.
458 if (!SerializePpVar(var, 1, bytes, tmp_length)) { 458 if (!SerializePpVar(var, 1, bytes, tmp_length)) {
459 return false; 459 return false;
460 } 460 }
461 // Return success. 461 // Return success.
462 *length = tmp_length; 462 *length = tmp_length;
463 return true; 463 return true;
464 } 464 }
465 465
466 char* Serialize(const PP_Var* vars, uint32_t argc, uint32_t* length) { 466 char* Serialize(const PP_Var* vars, uint32_t argc, uint32_t* length) {
467 // Length needs to be set. 467 // Length needs to be returnable.
468 if (NULL == length) { 468 if (NULL == length) {
469 return NULL; 469 return NULL;
470 } 470 }
471 // No need to do anything if there are no vars to serialize. 471 // No need to do anything if there are no vars to serialize.
472 if (0 == argc) { 472 if (0 == argc) {
473 *length = 0; 473 *length = 0;
474 return NULL; 474 return NULL;
475 } 475 }
476 // Report an error if no vars are passed but argc > 0. 476 // Report an error if no vars are passed but argc > 0.
477 if (NULL == vars) { 477 if (NULL == vars) {
478 return NULL; 478 return NULL;
479 } 479 }
480 // Compute the size of the buffer. Zero indicates error. 480 // Compute the size of the buffer. Zero indicates error.
481 uint32_t tmp_length = PpVarVectorSize(vars, argc); 481 uint32_t tmp_length = PpVarVectorSize(vars, argc);
482 if (0 == tmp_length || tmp_length > *length) { 482 if (0 == tmp_length) {
483 return NULL; 483 return NULL;
484 } 484 }
485 // Allocate the buffer, if the client didn't pass one. 485 // Allocate the buffer.
486 char* bytes = new char[tmp_length]; 486 char* bytes = new char[tmp_length];
487 if (NULL == bytes) { 487 if (NULL == bytes) {
488 return NULL; 488 return NULL;
489 } 489 }
490 // Serialize the vars. 490 // Serialize the vars.
491 if (!SerializePpVar(vars, argc, bytes, tmp_length)) { 491 if (!SerializePpVar(vars, argc, bytes, tmp_length)) {
492 delete[] bytes; 492 delete[] bytes;
493 return NULL; 493 return NULL;
494 } 494 }
495 // Return success. 495 // Return success.
(...skipping 18 matching lines...) Expand all
514 return false; 514 return false;
515 } 515 }
516 // Read the serialized PP_Vars into the allocated memory. 516 // Read the serialized PP_Vars into the allocated memory.
517 if (!DeserializePpVar(bytes, length, vars, argc)) { 517 if (!DeserializePpVar(bytes, length, vars, argc)) {
518 return false; 518 return false;
519 } 519 }
520 return true; 520 return true;
521 } 521 }
522 522
523 } // namespace ppapi_proxy 523 } // namespace ppapi_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698