diff options
author | sehr@google.com <sehr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-13 16:14:58 +0000 |
---|---|---|
committer | sehr@google.com <sehr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-13 16:14:58 +0000 |
commit | 1b6875888838d83ee233e0aa3713245355bacb1a (patch) | |
tree | 114d11b11b69d8f06c93873a46eba1e07a979b8b /ppapi | |
parent | ef144818659939564d62f9c23f7df077071d66c8 (diff) | |
download | chromium_src-1b6875888838d83ee233e0aa3713245355bacb1a.zip chromium_src-1b6875888838d83ee233e0aa3713245355bacb1a.tar.gz chromium_src-1b6875888838d83ee233e0aa3713245355bacb1a.tar.bz2 |
Lift the 64K message size limit for postMessage to/from NativeClient.
BUG= http://code.google.com/p/chromium/issues/detail?id=106266
TEST=ppapi/tests/test_post_message.cc
Review URL: http://codereview.chromium.org/9187071
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117643 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
15 files changed, 51 insertions, 57 deletions
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_testing_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_testing_rpc_server.cc index 17ae5fb..8e98384 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_testing_rpc_server.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_testing_rpc_server.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -122,7 +122,7 @@ void PpbTestingRpcServer::PPB_Testing_GetDocumentURL( pp_url_components = reinterpret_cast<struct PP_URLComponents_Dev*>(components); } - if (*url_bytes != ppapi_proxy::kMaxVarSize) + if (*url_bytes != ppapi_proxy::kMaxReturnVarSize) return; struct PP_Var pp_url = PPBTestingInterface()->GetDocumentURL( diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_input_event.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_input_event.cc index 0448da2..9f2d717 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_input_event.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_input_event.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -86,7 +86,7 @@ PP_Bool HandleInputEvent(PP_Instance instance, PP_Resource input_event) { DCHECK((character_text.type == PP_VARTYPE_UNDEFINED) || (character_text.type == PP_VARTYPE_STRING)); // Serialize the character_text Var. - uint32_t text_size = kMaxVarSize; + uint32_t text_size = 0; nacl::scoped_array<char> text_bytes(Serialize(&character_text, 1, &text_size)); int32_t handled; diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_messaging.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_messaging.cc index ebd5444..75031a9 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_messaging.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_messaging.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,7 +19,7 @@ namespace { void HandleMessage(PP_Instance instance, struct PP_Var message) { DebugPrintf("PPP_Messaging::HandleMessage: instance=%"NACL_PRIu32"\n", instance); - uint32_t message_length = kMaxVarSize; + uint32_t message_length = 0; nacl::scoped_array<char> message_bytes(Serialize(&message, 1, &message_length)); NaClSrpcError srpc_result = @@ -43,4 +43,3 @@ const PPP_Messaging* BrowserMessaging::GetInterface() { } } // namespace ppapi_proxy - diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_selection.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_selection.cc index 04016fcf..367fdf2 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_selection.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppp_selection.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -26,8 +26,8 @@ struct PP_Var GetSelectedText(PP_Instance instance, PP_Bool html) { DebugPrintf("PPP_Selection_Dev::GetSelectedText: " "instance=%"NACL_PRIu32"\n", instance); NaClSrpcChannel* channel = GetMainSrpcChannel(instance); - nacl_abi_size_t text_size = kMaxVarSize; - nacl::scoped_array<char> text_bytes(new char[kMaxVarSize]); + nacl_abi_size_t text_size = kMaxReturnVarSize; + nacl::scoped_array<char> text_bytes(new char[text_size]); NaClSrpcError srpc_result = PppSelectionRpcClient::PPP_Selection_GetSelectedText( channel, @@ -56,4 +56,3 @@ const PPP_Selection_Dev* BrowserSelection::GetInterface() { } } // namespace ppapi_proxy - diff --git a/ppapi/native_client/src/shared/ppapi_proxy/object_serialize.cc b/ppapi/native_client/src/shared/ppapi_proxy/object_serialize.cc index 6edf78c..1d73cfb 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/object_serialize.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/object_serialize.cc @@ -464,7 +464,7 @@ bool SerializeTo(const PP_Var* var, char* bytes, uint32_t* length) { } char* Serialize(const PP_Var* vars, uint32_t argc, uint32_t* length) { - // Length needs to be set. + // Length needs to be returnable. if (NULL == length) { return NULL; } @@ -479,10 +479,10 @@ char* Serialize(const PP_Var* vars, uint32_t argc, uint32_t* length) { } // Compute the size of the buffer. Zero indicates error. uint32_t tmp_length = PpVarVectorSize(vars, argc); - if (0 == tmp_length || tmp_length > *length) { + if (0 == tmp_length) { return NULL; } - // Allocate the buffer, if the client didn't pass one. + // Allocate the buffer. char* bytes = new char[tmp_length]; if (NULL == bytes) { return NULL; diff --git a/ppapi/native_client/src/shared/ppapi_proxy/object_serialize.h b/ppapi/native_client/src/shared/ppapi_proxy/object_serialize.h index 9f3340a..1b57ea0 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/object_serialize.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/object_serialize.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The Chromium Authors. All rights reserved. + * Copyright (c) 2012 The Chromium Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -13,7 +13,8 @@ struct NaClSrpcChannel; namespace ppapi_proxy { -const uint32_t kMaxVarSize = 64 * 1024; +// The maximum size of a pre-allocated return parameter passed to SRPC. +const uint32_t kMaxReturnVarSize = 64 * 1024; // Serialize one PP_Var to the location given in "bytes", using no more // than "*length" bytes . If successful, "*length" reflects the number of diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_file_ref.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_file_ref.cc index e2186c7..1afa0cf 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_file_ref.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_file_ref.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -89,7 +89,7 @@ PP_Var GetName(PP_Resource file_ref) { DebugPrintf("PPB_FileRef::GetName: file_ref=%"NACL_PRIu32"\n", file_ref); PP_Var name = PP_MakeUndefined(); - nacl_abi_size_t length = kMaxVarSize; + nacl_abi_size_t length = kMaxReturnVarSize; nacl::scoped_array<char> name_bytes(new char[length]); NaClSrpcError srpc_result = PpbFileRefRpcClient::PPB_FileRef_GetName( GetMainSrpcChannel(), @@ -109,7 +109,7 @@ PP_Var GetPath(PP_Resource file_ref) { DebugPrintf("PPB_FileRef::GetPath: file_ref=%"NACL_PRIu32"\n", file_ref); PP_Var path = PP_MakeUndefined(); - nacl_abi_size_t length = kMaxVarSize; + nacl_abi_size_t length = kMaxReturnVarSize; nacl::scoped_array<char> path_bytes(new char[length]); NaClSrpcError srpc_result = PpbFileRefRpcClient::PPB_FileRef_GetPath( GetMainSrpcChannel(), diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_font.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_font.cc index 57742b8..6faaf26 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_font.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_font.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -39,8 +39,8 @@ PP_Var GetFontFamilies(PP_Instance instance) { NaClSrpcChannel* channel = GetMainSrpcChannel(); PP_Var font_families = PP_MakeUndefined(); - nacl_abi_size_t var_size = kMaxVarSize; - nacl::scoped_array<char> var_bytes(new char[kMaxVarSize]); + nacl_abi_size_t var_size = kMaxReturnVarSize; + nacl::scoped_array<char> var_bytes(new char[var_size]); NaClSrpcError srpc_result = PpbFontRpcClient::PPB_Font_GetFontFamilies( @@ -61,7 +61,7 @@ PP_Resource Create(PP_Instance instance, const struct PP_FontDescription_Dev* description) { DebugPrintf("PPB_Font::Create: instance=%"NACL_PRIu32"\n", instance); - nacl_abi_size_t face_size = kMaxVarSize; + nacl_abi_size_t face_size = 0; nacl::scoped_array<char> face_bytes( Serialize(&description->face, 1, &face_size)); @@ -110,8 +110,8 @@ PP_Bool Describe(PP_Resource font, int32_t success = 0; nacl_abi_size_t description_size = kPPFontDescriptionBytes; - nacl_abi_size_t face_size = kMaxVarSize; - nacl::scoped_array<char> face_bytes(new char[kMaxVarSize]); + nacl_abi_size_t face_size = kMaxReturnVarSize; + nacl::scoped_array<char> face_bytes(new char[face_size]); nacl_abi_size_t metrics_size = kPPFontMetricsBytes; NaClSrpcError srpc_result = PpbFontRpcClient::PPB_Font_Describe( @@ -144,7 +144,7 @@ PP_Bool DrawTextAt(PP_Resource font, PP_Bool image_data_is_opaque) { DebugPrintf("PPB_Font::DrawTextAt: font=%"NACL_PRIu32"\n", font); - nacl_abi_size_t text_size = kMaxVarSize; + nacl_abi_size_t text_size = 0; nacl::scoped_array<char> text_bytes( Serialize(&text_run->text, 1, &text_size)); @@ -177,7 +177,7 @@ int32_t MeasureText(PP_Resource font, const struct PP_TextRun_Dev* text_run) { DebugPrintf("PPB_Font::MeasureText: font=%"NACL_PRIu32"\n", font); - nacl_abi_size_t text_size = kMaxVarSize; + nacl_abi_size_t text_size = 0; nacl::scoped_array<char> text_bytes( Serialize(&text_run->text, 1, &text_size)); int32_t width = 0; @@ -201,7 +201,7 @@ uint32_t CharacterOffsetForPixel(PP_Resource font, int32_t pixel_position) { DebugPrintf("PPB_Font::CharacterOffsetForPixel: font=%"NACL_PRIu32"\n", font); - nacl_abi_size_t text_size = kMaxVarSize; + nacl_abi_size_t text_size = 0; nacl::scoped_array<char> text_bytes( Serialize(&text_run->text, 1, &text_size)); int32_t offset = kInvalidOffset; @@ -227,7 +227,7 @@ int32_t PixelOffsetForCharacter(PP_Resource font, uint32_t char_offset) { DebugPrintf("PPB_Font::PixelOffsetForCharacter: font=%"NACL_PRIu32"\n", font); - nacl_abi_size_t text_size = kMaxVarSize; + nacl_abi_size_t text_size = 0; nacl::scoped_array<char> text_bytes( Serialize(&text_run->text, 1, &text_size)); int32_t offset = kInvalidOffset; @@ -265,4 +265,3 @@ const PPB_Font_Dev* PluginFont::GetInterface() { } } // namespace ppapi_proxy - diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.cc index 4b37516..774f4d6 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.cc @@ -1,6 +1,6 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can -// be found in the LICENSE file. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. #include "native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.h" @@ -23,7 +23,6 @@ namespace { using ppapi_proxy::DebugPrintf; using ppapi_proxy::GetMainSrpcChannel; using ppapi_proxy::kInvalidResourceId; -using ppapi_proxy::kMaxVarSize; using ppapi_proxy::PluginInputEvent; using ppapi_proxy::PluginResource; using ppapi_proxy::Serialize; @@ -272,7 +271,7 @@ PP_Resource CreateKeyboardInputEvent(PP_Instance instance, "%"NACL_PRIu32", key_code=%"NACL_PRIu32"\n", instance, type, time_stamp, modifiers, key_code); // Serialize the character_text Var. - uint32_t text_size = kMaxVarSize; + uint32_t text_size = 0; nacl::scoped_array<char> text_bytes(Serialize(&character_text, 1, &text_size)); PP_Resource resource_id = kInvalidResourceId; @@ -441,4 +440,3 @@ PP_Var PluginInputEvent::GetCharacterText() const { } } // namespace ppapi_proxy - diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_messaging.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_messaging.cc index ab586fc..654daff 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_messaging.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_messaging.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -24,7 +24,7 @@ void PostMessage(PP_Instance instance, struct PP_Var message) { if (!ppapi_proxy::PPBCoreInterface()->IsMainThread()) return; // Only supported on main thread. - uint32_t message_length = kMaxVarSize; + uint32_t message_length = 0; nacl::scoped_array<char> message_bytes(Serialize(&message, 1, &message_length)); NaClSrpcError srpc_result = diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_pdf.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_pdf.cc index 2b63e85..ab1d0b2 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_pdf.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_pdf.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -38,8 +38,8 @@ PP_Var GetLocalizedString( "instance=%"NACL_PRIu32"\n", instance); NaClSrpcChannel* channel = GetMainSrpcChannel(); - nacl_abi_size_t string_size = kMaxVarSize; - nacl::scoped_array<char> string_bytes(new char[kMaxVarSize]); + nacl_abi_size_t string_size = kMaxReturnVarSize; + nacl::scoped_array<char> string_bytes(new char[string_size]); NaClSrpcError srpc_result = PpbPdfRpcClient::PPB_PDF_GetLocalizedString( channel, @@ -196,7 +196,7 @@ void HistogramPDFPageCount(int count) { void UserMetricsRecordAction(struct PP_Var action) { DebugPrintf("PPB_PDF::UserMetricsRecordAction\n"); - nacl_abi_size_t action_size = kMaxVarSize; + nacl_abi_size_t action_size = 0; nacl::scoped_array<char> action_bytes( Serialize(&action, 1, &action_size)); NaClSrpcError srpc_result = @@ -251,4 +251,3 @@ const PPB_PDF* PluginPDF::GetInterface() { } } // namespace ppapi_proxy - diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_testing.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_testing.cc index dbd01b44..19ec02a 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_testing.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_testing.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -125,8 +125,8 @@ struct PP_Var GetDocumentURL(PP_Instance instance, NaClSrpcChannel* channel = GetMainSrpcChannel(); nacl_abi_size_t components_size = (components != NULL) ? kPPURLComponentsDevBytes : 0; - nacl_abi_size_t url_size = kMaxVarSize; - nacl::scoped_array<char> url_bytes(new (std::nothrow) char[url_size]); + nacl_abi_size_t url_size = kMaxReturnVarSize; + nacl::scoped_array<char> url_bytes(new char[url_size]); if (url_bytes.get() == NULL) return PP_MakeUndefined(); diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_url_request_info.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_url_request_info.cc index 62320ed..1e0f82b 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_url_request_info.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_url_request_info.cc @@ -1,6 +1,6 @@ -// Copyright 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can -// be found in the LICENSE file. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. #include "native_client/src/shared/ppapi_proxy/plugin_ppb_url_request_info.h" @@ -58,7 +58,7 @@ PP_Bool SetProperty(PP_Resource request, DebugPrintf("PPB_URLRequestInfo::SetProperty: request=%"NACL_PRIu32"\n", request); - nacl_abi_size_t value_size = kMaxVarSize; + nacl_abi_size_t value_size = 0; nacl::scoped_array<char> value_bytes(Serialize(&value, 1, &value_size)); int32_t success; diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_url_response_info.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_url_response_info.cc index cf5bb84..0a557df 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_url_response_info.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_url_response_info.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -42,8 +42,8 @@ PP_Var GetProperty(PP_Resource response, PP_URLResponseProperty property) { NaClSrpcChannel* channel = GetMainSrpcChannel(); PP_Var value = PP_MakeUndefined(); - nacl_abi_size_t value_size = kMaxVarSize; - nacl::scoped_array<char> value_bytes(new char[kMaxVarSize]); + nacl_abi_size_t value_size = kMaxReturnVarSize; + nacl::scoped_array<char> value_bytes(new char[value_size]); NaClSrpcError srpc_result = PpbURLResponseInfoRpcClient::PPB_URLResponseInfo_GetProperty( diff --git a/ppapi/tests/test_post_message.cc b/ppapi/tests/test_post_message.cc index 5054a6a..6051e30 100644 --- a/ppapi/tests/test_post_message.cc +++ b/ppapi/tests/test_post_message.cc @@ -251,9 +251,9 @@ std::string TestPostMessage::TestSendingArrayBuffer() { WaitForMessages(); ASSERT_TRUE(ClearListeners()); - // TODO(dmichael): Add testing of longer array buffers when crbug.com/106266 - // is fixed. - uint32_t sizes[] = { 0, 100, 1000 }; + // TODO(sehr,dmichael): Add testing of longer array buffers when + // crbug.com/110086 is fixed. + uint32_t sizes[] = { 0, 100, 1000, 10000, 100000 }; for (size_t i = 0; i < sizeof(sizes)/sizeof(sizes[i]); ++i) { std::ostringstream size_stream; size_stream << sizes[i]; @@ -484,4 +484,3 @@ std::string TestPostMessage::TestNonMainThread() { PASS(); } - |