diff options
author | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-07 22:50:43 +0000 |
---|---|---|
committer | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-07 22:50:43 +0000 |
commit | 872caf56ebb67c01a01d0c8c612e171fd4332624 (patch) | |
tree | b574e7c9f2ac638f3dcd047bf58acc5365752df9 /ppapi | |
parent | f498828c37cca39771d2a578c609020b5293197c (diff) | |
download | chromium_src-872caf56ebb67c01a01d0c8c612e171fd4332624.zip chromium_src-872caf56ebb67c01a01d0c8c612e171fd4332624.tar.gz chromium_src-872caf56ebb67c01a01d0c8c612e171fd4332624.tar.bz2 |
Remove PP_Module from parameters for PPB_Var.VarFromUtf8.
This change has tendrils stretching throughout the code, but mostly this lets us delete a bunch of stuff.
This also does a slight refactor to put the PPB_Var implementations in 1 place, since they were already practically identical, and I didn't want to do the backwards-compat code in 2 places.
BUG=106596
TEST=N/A
TBR=darin,tony
darin,tony TBR for rubber-stamp of webkit/glue/webkit_glue.gypi
Review URL: http://codereview.chromium.org/8826011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113491 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
49 files changed, 272 insertions, 272 deletions
diff --git a/ppapi/api/ppb_var.idl b/ppapi/api/ppb_var.idl index d6f045f..96b684e 100644 --- a/ppapi/api/ppb_var.idl +++ b/ppapi/api/ppb_var.idl @@ -8,7 +8,8 @@ */ label Chrome { - M14 = 1.0 + M14 = 1.0, + M18 = 1.1 }; /** @@ -22,8 +23,8 @@ interface PPB_Var { * * @param[in] var A <code>PP_Var</code> that will have a reference added. */ - void AddRef( - [in] PP_Var var); + [version=1.0] + void AddRef([in] PP_Var var); /** * Release() removes a reference to given var, deleting it if the internal @@ -33,8 +34,8 @@ interface PPB_Var { * * @param[in] var A <code>PP_Var</code> that will have a reference removed. */ - void Release( - [in] PP_Var var); + [version=1.0] + void Release([in] PP_Var var); /** * VarFromUtf8() creates a string var from a string. The string must be @@ -61,10 +62,35 @@ interface PPB_Var { * @return A <code>PP_Var</code> structure containing a reference counted * string object. */ - PP_Var VarFromUtf8( - [in] PP_Module module, - [in] str_t data, - [in] uint32_t len); + [version=1.0] + PP_Var VarFromUtf8([in] PP_Module module, [in] str_t data, [in] uint32_t len); + + /** + * VarFromUtf8() creates a string var from a string. The string must be + * encoded in valid UTF-8 and is NOT NULL-terminated, the length must be + * specified in <code>len</code>. It is an error if the string is not + * valid UTF-8. + * + * If the length is 0, the <code>*data</code> pointer will not be dereferenced + * and may be <code>NULL</code>. Note, however if length is 0, the + * "NULL-ness" will not be preserved, as <code>VarToUtf8</code> will never + * return <code>NULL</code> on success, even for empty strings. + * + * The resulting object will be a refcounted string object. It will be + * AddRef'ed for the caller. When the caller is done with it, it should be + * Released. + * + * On error (basically out of memory to allocate the string, or input that + * is not valid UTF-8), this function will return a Null var. + * + * @param[in] data A string + * @param[in] len The length of the string. + * + * @return A <code>PP_Var</code> structure containing a reference counted + * string object. + */ + [version=1.1] + PP_Var VarFromUtf8([in] str_t data, [in] uint32_t len); /** * VarToUtf8() converts a string-type var to a char* encoded in UTF-8. This @@ -84,8 +110,7 @@ interface PPB_Var { * * @return A char* encoded in UTF-8. */ - str_t VarToUtf8( - [in] PP_Var var, - [out] uint32_t len); + [version=1.0] + str_t VarToUtf8([in] PP_Var var, [out] uint32_t len); }; diff --git a/ppapi/c/ppb_var.h b/ppapi/c/ppb_var.h index 5ebae16..3e6e481 100644 --- a/ppapi/c/ppb_var.h +++ b/ppapi/c/ppb_var.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From ppb_var.idl modified Wed Aug 24 20:49:04 2011. */ +/* From ppb_var.idl modified Tue Dec 6 11:26:58 2011. */ #ifndef PPAPI_C_PPB_VAR_H_ #define PPAPI_C_PPB_VAR_H_ @@ -15,7 +15,8 @@ #include "ppapi/c/pp_var.h" #define PPB_VAR_INTERFACE_1_0 "PPB_Var;1.0" -#define PPB_VAR_INTERFACE PPB_VAR_INTERFACE_1_0 +#define PPB_VAR_INTERFACE_1_1 "PPB_Var;1.1" +#define PPB_VAR_INTERFACE PPB_VAR_INTERFACE_1_1 /** * @file @@ -66,16 +67,13 @@ struct PPB_Var { * On error (basically out of memory to allocate the string, or input that * is not valid UTF-8), this function will return a Null var. * - * @param[in] module A PP_Module uniquely identifying the module or .nexe. * @param[in] data A string * @param[in] len The length of the string. * * @return A <code>PP_Var</code> structure containing a reference counted * string object. */ - struct PP_Var (*VarFromUtf8)(PP_Module module, - const char* data, - uint32_t len); + struct PP_Var (*VarFromUtf8)(const char* data, uint32_t len); /** * VarToUtf8() converts a string-type var to a char* encoded in UTF-8. This * string is NOT NULL-terminated. The length will be placed in @@ -96,6 +94,15 @@ struct PPB_Var { */ const char* (*VarToUtf8)(struct PP_Var var, uint32_t* len); }; + +struct PPB_Var_1_0 { + void (*AddRef)(struct PP_Var var); + void (*Release)(struct PP_Var var); + struct PP_Var (*VarFromUtf8)(PP_Module module, + const char* data, + uint32_t len); + const char* (*VarToUtf8)(struct PP_Var var, uint32_t* len); +}; /** * @} */ diff --git a/ppapi/cpp/var.cc b/ppapi/cpp/var.cc index d8128ed..2b52f04 100644 --- a/ppapi/cpp/var.cc +++ b/ppapi/cpp/var.cc @@ -28,6 +28,9 @@ namespace { template <> const char* interface_name<PPB_Var>() { return PPB_VAR_INTERFACE; } +template <> const char* interface_name<PPB_Var_1_0>() { + return PPB_VAR_INTERFACE_1_0; +} // Technically you can call AddRef and Release on any Var, but it may involve // cross-process calls depending on the plugin. This is an optimization so we @@ -36,6 +39,21 @@ inline bool NeedsRefcounting(const PP_Var& var) { return var.type > PP_VARTYPE_DOUBLE; } +// This helper function detects whether PPB_Var version 1.1 is available. If so, +// it uses it to create a PP_Var for the given string. Otherwise it falls back +// to PPB_Var version 1.0. +PP_Var VarFromUtf8Helper(const char* utf8_str, uint32_t len) { + if (has_interface<PPB_Var>()) { + return get_interface<PPB_Var>()->VarFromUtf8(utf8_str, len); + } else if (has_interface<PPB_Var_1_0>()) { + return get_interface<PPB_Var_1_0>()->VarFromUtf8(Module::Get()->pp_module(), + utf8_str, + len); + } else { + return PP_MakeNull(); + } +} + } // namespace Var::Var() { @@ -72,27 +90,14 @@ Var::Var(double d) { } Var::Var(const char* utf8_str) { - if (has_interface<PPB_Var>()) { - uint32_t len = utf8_str ? static_cast<uint32_t>(strlen(utf8_str)) : 0; - var_ = get_interface<PPB_Var>()->VarFromUtf8(Module::Get()->pp_module(), - utf8_str, len); - } else { - var_.type = PP_VARTYPE_NULL; - var_.padding = 0; - } + uint32_t len = utf8_str ? static_cast<uint32_t>(strlen(utf8_str)) : 0; + var_ = VarFromUtf8Helper(utf8_str, len); needs_release_ = (var_.type == PP_VARTYPE_STRING); } Var::Var(const std::string& utf8_str) { - if (has_interface<PPB_Var>()) { - var_ = get_interface<PPB_Var>()->VarFromUtf8( - Module::Get()->pp_module(), - utf8_str.c_str(), - static_cast<uint32_t>(utf8_str.size())); - } else { - var_.type = PP_VARTYPE_NULL; - var_.padding = 0; - } + var_ = VarFromUtf8Helper(utf8_str.c_str(), + static_cast<uint32_t>(utf8_str.size())); needs_release_ = (var_.type == PP_VARTYPE_STRING); } @@ -101,7 +106,7 @@ Var::Var(const Var& other) { if (NeedsRefcounting(var_)) { if (has_interface<PPB_Var>()) { needs_release_ = true; - get_interface<PPB_Var>()->AddRef(var_); + get_interface<PPB_Var_1_0>()->AddRef(var_); } else { var_.type = PP_VARTYPE_NULL; needs_release_ = false; @@ -113,7 +118,7 @@ Var::Var(const Var& other) { Var::~Var() { if (needs_release_ && has_interface<PPB_Var>()) - get_interface<PPB_Var>()->Release(var_); + get_interface<PPB_Var_1_0>()->Release(var_); } Var& Var::operator=(const Var& other) { @@ -130,12 +135,12 @@ Var& Var::operator=(const Var& other) { // Assume we already has_interface<PPB_Var> for refcounted vars or else we // couldn't have created them in the first place. needs_release_ = true; - get_interface<PPB_Var>()->AddRef(other.var_); + get_interface<PPB_Var_1_0>()->AddRef(other.var_); } else { needs_release_ = false; } if (old_needs_release) - get_interface<PPB_Var>()->Release(var_); + get_interface<PPB_Var_1_0>()->Release(var_); var_ = other.var_; return *this; @@ -201,7 +206,7 @@ std::string Var::AsString() const { if (!has_interface<PPB_Var>()) return std::string(); uint32_t len; - const char* str = get_interface<PPB_Var>()->VarToUtf8(var_, &len); + const char* str = get_interface<PPB_Var_1_0>()->VarToUtf8(var_, &len); return std::string(str, len); } diff --git a/ppapi/cpp/var.h b/ppapi/cpp/var.h index fc65d38..871fb603 100644 --- a/ppapi/cpp/var.h +++ b/ppapi/cpp/var.h @@ -8,7 +8,6 @@ #include <string> #include <vector> -#include "ppapi/c/pp_module.h" #include "ppapi/c/pp_var.h" diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_font_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_font_rpc_server.cc index 75aa7f3..d69b950 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_font_rpc_server.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_font_rpc_server.cc @@ -57,8 +57,7 @@ void PpbFontRpcServer::PPB_Font_Create( return; struct PP_FontDescription_Dev* pp_description = reinterpret_cast<struct PP_FontDescription_Dev*>(description); - if (!DeserializeTo( - rpc->channel, face, face_size, 1, &pp_description->face)) { + if (!DeserializeTo(face, face_size, 1, &pp_description->face)) { return; } *font = PPBFontInterface()->Create(instance, pp_description); @@ -137,7 +136,7 @@ void PpbFontRpcServer::PPB_Font_DrawTextAt( return; struct PP_TextRun_Dev* pp_text_run = reinterpret_cast<struct PP_TextRun_Dev*>(text_run); - if (!DeserializeTo(rpc->channel, text, text_size, 1, &pp_text_run->text)) + if (!DeserializeTo(text, text_size, 1, &pp_text_run->text)) return; struct PP_Point* pp_position = reinterpret_cast<struct PP_Point*>(position); @@ -170,7 +169,7 @@ void PpbFontRpcServer::PPB_Font_MeasureText( return; struct PP_TextRun_Dev* pp_text_run = reinterpret_cast<struct PP_TextRun_Dev*>(text_run); - if (!DeserializeTo(rpc->channel, text, text_size, 1, &pp_text_run->text)) + if (!DeserializeTo(text, text_size, 1, &pp_text_run->text)) return; *width = PPBFontInterface()->MeasureText(font, pp_text_run); @@ -193,7 +192,7 @@ void PpbFontRpcServer::PPB_Font_CharacterOffsetForPixel( return; struct PP_TextRun_Dev* pp_text_run = reinterpret_cast<struct PP_TextRun_Dev*>(text_run); - if (!DeserializeTo(rpc->channel, text, text_size, 1, &pp_text_run->text)) + if (!DeserializeTo(text, text_size, 1, &pp_text_run->text)) return; *offset = PPBFontInterface()->CharacterOffsetForPixel(font, pp_text_run, @@ -219,7 +218,7 @@ void PpbFontRpcServer::PPB_Font_PixelOffsetForCharacter( return; struct PP_TextRun_Dev* pp_text_run = reinterpret_cast<struct PP_TextRun_Dev*>(text_run); - if (!DeserializeTo(rpc->channel, text, text_size, 1, &pp_text_run->text)) + if (!DeserializeTo(text, text_size, 1, &pp_text_run->text)) return; *offset = PPBFontInterface()->PixelOffsetForCharacter(font, pp_text_run, diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_input_event_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_input_event_rpc_server.cc index a3f5064..d8b5230 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_input_event_rpc_server.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_input_event_rpc_server.cc @@ -131,8 +131,7 @@ void PpbInputEventRpcServer::PPB_InputEvent_CreateKeyboardInputEvent( return; } PP_Var character_text; - if (!DeserializeTo(rpc->channel, character_bytes, character_size, 1, - &character_text)) { + if (!DeserializeTo(character_bytes, character_size, 1, &character_text)) { return; } diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_messaging_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_messaging_rpc_server.cc index 062bb5b..08b525b 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_messaging_rpc_server.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_messaging_rpc_server.cc @@ -26,7 +26,7 @@ void PpbMessagingRpcServer::PPB_Messaging_PostMessage( rpc->result = NACL_SRPC_RESULT_APP_ERROR; PP_Var message; - if (!DeserializeTo(rpc->channel, message_bytes, message_size, 1, &message)) + if (!DeserializeTo(message_bytes, message_size, 1, &message)) return; PPBMessagingInterface()->PostMessage(instance, message); diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_pdf_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_pdf_rpc_server.cc index e36ed41..d38cf8c 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_pdf_rpc_server.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_pdf_rpc_server.cc @@ -217,7 +217,7 @@ void PpbPdfRpcServer::PPB_PDF_UserMetricsRecordAction( rpc->result = NACL_SRPC_RESULT_APP_ERROR; PP_Var pp_action = PP_MakeUndefined(); - if (!DeserializeTo(rpc->channel, action, action_size, 1, &pp_action)) + if (!DeserializeTo(action, action_size, 1, &pp_action)) return; PPBPDFInterface()->UserMetricsRecordAction(pp_action); diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_url_request_info_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_url_request_info_rpc_server.cc index 9714559b..1c5bfc4 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_url_request_info_rpc_server.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_url_request_info_rpc_server.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) 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. // // SRPC-abstraction wrappers around PPB_URLRequestInfo functions. @@ -63,7 +63,7 @@ void PpbURLRequestInfoRpcServer::PPB_URLRequestInfo_SetProperty( rpc->result = NACL_SRPC_RESULT_APP_ERROR; PP_Var value; - if (!DeserializeTo(rpc->channel, value_bytes, value_size, 1, &value)) + if (!DeserializeTo(value_bytes, value_size, 1, &value)) return; PP_Bool pp_success = PPBURLRequestInfoInterface()->SetProperty( 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 2122b9e..04016fcf 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 @@ -41,8 +41,7 @@ struct PP_Var GetSelectedText(PP_Instance instance, PP_Bool html) { PP_Var selected_text = PP_MakeUndefined(); if (srpc_result == NACL_SRPC_RESULT_OK) { - (void) DeserializeTo( - channel, text_bytes.get(), text_size, 1, &selected_text); + (void) DeserializeTo(text_bytes.get(), text_size, 1, &selected_text); } return selected_text; } 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 16323af..620058e 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/object_serialize.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/object_serialize.cc @@ -327,22 +327,19 @@ uint32_t DeserializePpVarSize(char* p, // there are enough bytes at p. // bool DeserializeString(char* p, - PP_Var* var, - NaClSrpcChannel* channel) { + PP_Var* var) { SerializedString* ss = reinterpret_cast<SerializedString*>(p); uint32_t string_length = ss->fixed.u.string_length; // VarFromUtf8 creates a buffer of size string_length using the browser-side // memory allocation function, and copies string_length bytes from // ss->string_bytes in to that buffer. The ref count of the returned var is // 1. - *var = PPBVarInterface()->VarFromUtf8(LookupModuleIdForSrpcChannel(channel), - ss->string_bytes, + *var = PPBVarInterface()->VarFromUtf8(ss->string_bytes, string_length); return true; } -bool DeserializePpVar(NaClSrpcChannel* channel, - char* bytes, +bool DeserializePpVar(char* bytes, uint32_t length, PP_Var* vars, uint32_t argc) { @@ -373,7 +370,7 @@ bool DeserializePpVar(NaClSrpcChannel* channel, break; } case PP_VARTYPE_STRING: - if (!DeserializeString(p, &vars[i], channel)) { + if (!DeserializeString(p, &vars[i])) { return false; } break; @@ -445,8 +442,7 @@ char* Serialize(const PP_Var* vars, uint32_t argc, uint32_t* length) { return bytes; } -bool DeserializeTo(NaClSrpcChannel* channel, - char* bytes, +bool DeserializeTo(char* bytes, uint32_t length, uint32_t argc, PP_Var* vars) { @@ -463,7 +459,7 @@ bool DeserializeTo(NaClSrpcChannel* channel, return false; } // Read the serialized PP_Vars into the allocated memory. - if (!DeserializePpVar(channel, bytes, length, vars, argc)) { + if (!DeserializePpVar(bytes, length, vars, argc)) { return false; } return true; 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 992e2a6..9f3340a 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/object_serialize.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/object_serialize.h @@ -1,7 +1,7 @@ /* - * 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) 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. */ #ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_OBJECT_SERIALIZE_H_ @@ -28,8 +28,7 @@ char* Serialize(const PP_Var* vars, uint32_t argc, uint32_t* length); // Deserialize a vector "bytes" of "length" bytes containing "argc" PP_Vars // into the vector of PP_Vars pointed to by "vars". Returns true if // successful, or false otherwise. -bool DeserializeTo(NaClSrpcChannel* channel, - char* bytes, +bool DeserializeTo(char* bytes, uint32_t length, uint32_t argc, PP_Var* vars); diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc index 7c50328..c0fe3c1 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc @@ -92,6 +92,7 @@ InterfaceMapElement interface_map[] = { { PPB_URLRESPONSEINFO_INTERFACE, PluginURLResponseInfo::GetInterface(), true }, { PPB_VAR_INTERFACE, PluginVar::GetInterface(), true }, + { PPB_VAR_INTERFACE_1_0, PluginVar::GetInterface1_0(), true }, { PPB_WHEEL_INPUT_EVENT_INTERFACE, PluginInputEvent::GetWheelInterface(), true }, { PPB_WIDGET_DEV_INTERFACE, PluginWidget::GetInterface(), true }, 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 0195122..e2186c7 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 @@ -99,9 +99,7 @@ PP_Var GetName(PP_Resource file_ref) { DebugPrintf("PPB_FileRef::GetName: %s\n", NaClSrpcErrorString(srpc_result)); if (srpc_result == NACL_SRPC_RESULT_OK) { - if (DeserializeTo(GetMainSrpcChannel(), name_bytes.get(), length, - 1, // argc - &name)) + if (DeserializeTo(name_bytes.get(), length, 1 /* argc */, &name)) return name; } return PP_MakeUndefined(); @@ -122,10 +120,8 @@ PP_Var GetPath(PP_Resource file_ref) { NaClSrpcErrorString(srpc_result)); if (srpc_result == NACL_SRPC_RESULT_OK && - DeserializeTo(GetMainSrpcChannel(), path_bytes.get(), length, - 1, // argc - &path)) { - return path; + DeserializeTo(path_bytes.get(), length, 1 /* argc */, &path)) { + return path; } return PP_MakeUndefined(); } 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 d0a18e5..57742b8 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 @@ -53,8 +53,7 @@ PP_Var GetFontFamilies(PP_Instance instance) { NaClSrpcErrorString(srpc_result)); if (srpc_result == NACL_SRPC_RESULT_OK) - (void) DeserializeTo( - channel, var_bytes.get(), var_size, 1, &font_families); + (void) DeserializeTo(var_bytes.get(), var_size, 1, &font_families); return font_families; } @@ -130,8 +129,7 @@ PP_Bool Describe(PP_Resource font, description->face = PP_MakeUndefined(); if (srpc_result == NACL_SRPC_RESULT_OK && success) { - (void) DeserializeTo( - channel, face_bytes.get(), face_size, 1, &description->face); + (void) DeserializeTo(face_bytes.get(), face_size, 1, &description->face); return PP_TRUE; } return PP_FALSE; diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc index ead08dd..e00e9f9 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc @@ -13,7 +13,6 @@ #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" #include "native_client/src/shared/ppapi_proxy/plugin_instance_data.h" #include "native_client/src/shared/ppapi_proxy/plugin_ppb_core.h" -#include "native_client/src/shared/ppapi_proxy/plugin_ppb_var.h" #include "native_client/src/shared/ppapi_proxy/utility.h" #include "native_client/src/shared/srpc/nacl_srpc.h" #include "ppapi/c/pp_completion_callback.h" 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 75bee3f..2b63e85 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 @@ -49,8 +49,7 @@ PP_Var GetLocalizedString( PP_Var string = PP_MakeUndefined(); if (srpc_result == NACL_SRPC_RESULT_OK) { - (void) DeserializeTo( - channel, string_bytes.get(), string_size, 1, &string); + (void) DeserializeTo(string_bytes.get(), string_size, 1, &string); } DebugPrintf("PPB_PDF::GetLocalizedString: %s\n", 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 4180a5e..cf5bb84 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,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) 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. #include "native_client/src/shared/ppapi_proxy/plugin_ppb_url_response_info.h" @@ -56,7 +56,7 @@ PP_Var GetProperty(PP_Resource response, PP_URLResponseProperty property) { NaClSrpcErrorString(srpc_result)); if (srpc_result == NACL_SRPC_RESULT_OK) - (void) DeserializeTo(channel, value_bytes.get(), value_size, 1, &value); + (void) DeserializeTo(value_bytes.get(), value_size, 1, &value); return value; } diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_var.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_var.cc index 558272e..65823c8 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_var.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_var.cc @@ -35,9 +35,8 @@ void Release(PP_Var var) { ProxyVarCache::GetInstance().ReleaseProxyVar(var); } -PP_Var VarFromUtf8(PP_Module module_id, const char* data, uint32_t len) { +PP_Var VarFromUtf8(const char* data, uint32_t len) { DebugPrintf("PPB_Var::VarFromUtf8: data='%.*s'\n", len, data); - UNREFERENCED_PARAMETER(module_id); if (!StringIsUtf8(data, len)) { DebugPrintf("PPB_Var::VarFromUtf8: not UTF8\n"); return PP_MakeNull(); @@ -53,6 +52,10 @@ PP_Var VarFromUtf8(PP_Module module_id, const char* data, uint32_t len) { return var; } +PP_Var VarFromUtf8_1_0(PP_Module /*module*/, const char* data, uint32_t len) { + return VarFromUtf8(data, len); +} + const char* VarToUtf8(PP_Var var, uint32_t* len) { DebugPrintf("PPB_Var::VarToUtf8: as_id=%"NACL_PRId64"\n", var.value.as_id); SharedStringProxyVar string_var = StringProxyVar::CastFromProxyVar( @@ -92,6 +95,16 @@ const PPB_Var* PluginVar::GetInterface() { return &var_interface; } +const PPB_Var_1_0* PluginVar::GetInterface1_0() { + static const PPB_Var_1_0 var_interface = { + AddRef, + Release, + VarFromUtf8_1_0, + VarToUtf8 + }; + return &var_interface; +} + std::string PluginVar::DebugString(const PP_Var& var) { switch (var.type) { case PP_VARTYPE_UNDEFINED: @@ -137,7 +150,7 @@ std::string PluginVar::DebugString(const PP_Var& var) { return "##ERROR##"; } -PP_Var PluginVar::StringToPPVar(PP_Module module_id, const std::string& str) { +PP_Var PluginVar::StringToPPVar(const std::string& str) { static const PPB_Var* ppb_var = NULL; if (ppb_var == NULL) { ppb_var = static_cast<const PPB_Var*>( @@ -146,8 +159,8 @@ PP_Var PluginVar::StringToPPVar(PP_Module module_id, const std::string& str) { if (ppb_var == NULL) { return PP_MakeUndefined(); } - return ppb_var->VarFromUtf8( - module_id, str.c_str(), nacl::assert_cast<uint32_t>(str.size())); + return ppb_var->VarFromUtf8(str.c_str(), + nacl::assert_cast<uint32_t>(str.size())); } std::string PluginVar::PPVarToString(const PP_Var& var) { diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_var.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_var.h index 2ed165d..3f60946 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_var.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_var.h @@ -21,9 +21,11 @@ class PluginVar { public: // Returns an interface pointer suitable to the PPAPI client. static const PPB_Var* GetInterface(); + // Returns the 1.0 interface to support backwards-compatibility. + static const PPB_Var_1_0* GetInterface1_0(); // String helpers. - static PP_Var StringToPPVar(PP_Module module_id, const std::string& str); + static PP_Var StringToPPVar(const std::string& str); static std::string PPVarToString(const PP_Var& var); // Printing and debugging. diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppp_input_event_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppp_input_event_rpc_server.cc index 0177dcc..845b998 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppp_input_event_rpc_server.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppp_input_event_rpc_server.cc @@ -12,7 +12,6 @@ #include "native_client/src/shared/ppapi_proxy/input_event_data.h" #include "native_client/src/shared/ppapi_proxy/object_serialize.h" #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" -#include "native_client/src/shared/ppapi_proxy/plugin_ppb_var.h" #include "native_client/src/shared/ppapi_proxy/plugin_ppb_input_event.h" #include "native_client/src/shared/ppapi_proxy/plugin_resource.h" #include "native_client/src/shared/ppapi_proxy/plugin_resource_tracker.h" @@ -64,7 +63,7 @@ void PppInputEventRpcServer::PPP_InputEvent_HandleInputEvent( InputEventData data; std::memcpy(&data, event_data, event_data_size); PP_Var character_text_var = PP_MakeUndefined(); - DeserializeTo(rpc->channel, character_text_bytes, character_text_size, 1, + DeserializeTo(character_text_bytes, character_text_size, 1, &character_text_var); input_event->Init(data, character_text_var); diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppp_messaging_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppp_messaging_rpc_server.cc index 174df8c..b8ef263 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppp_messaging_rpc_server.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppp_messaging_rpc_server.cc @@ -23,7 +23,7 @@ void PppMessagingRpcServer::PPP_Messaging_HandleMessage( NaClSrpcClosureRunner runner(done); PP_Var message; - if (!DeserializeTo(rpc->channel, message_bytes, message_size, 1, &message)) + if (!DeserializeTo(message_bytes, message_size, 1, &message)) return; PPPMessagingInterface()->HandleMessage(instance, message); DebugPrintf("PPP_Messaging::HandleMessage\n"); diff --git a/ppapi/native_client/src/trusted/plugin/browser_interface.cc b/ppapi/native_client/src/trusted/plugin/browser_interface.cc index 06fdc5b..e23516d 100644 --- a/ppapi/native_client/src/trusted/plugin/browser_interface.cc +++ b/ppapi/native_client/src/trusted/plugin/browser_interface.cc @@ -49,11 +49,9 @@ void BrowserInterface::AddToConsole(pp::InstancePrivate* instance, module->GetBrowserInterface(PPB_VAR_INTERFACE)); nacl::string prefix_string("NativeClient"); PP_Var prefix = - var_interface->VarFromUtf8(module->pp_module(), - prefix_string.c_str(), + var_interface->VarFromUtf8(prefix_string.c_str(), static_cast<uint32_t>(prefix_string.size())); - PP_Var str = var_interface->VarFromUtf8(module->pp_module(), - text.c_str(), + PP_Var str = var_interface->VarFromUtf8(text.c_str(), static_cast<uint32_t>(text.size())); const PPB_Console_Dev* console_interface = static_cast<const struct PPB_Console_Dev*>( diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_pdf/ppapi_ppb_pdf.cc b/ppapi/native_client/tests/ppapi_browser/ppb_pdf/ppapi_ppb_pdf.cc index fc21eaa..8bf33b7 100644 --- a/ppapi/native_client/tests/ppapi_browser/ppb_pdf/ppapi_ppb_pdf.cc +++ b/ppapi/native_client/tests/ppapi_browser/ppb_pdf/ppapi_ppb_pdf.cc @@ -199,8 +199,7 @@ void TestHistogramPDFPageCount() { void TestUserMetricsRecordAction() { const char* kString = "Action!"; - PP_Var action = PPBVar()->VarFromUtf8(pp_module(), - kString, + PP_Var action = PPBVar()->VarFromUtf8(kString, strlen(kString)); PPBPDF()->UserMetricsRecordAction(action); diff --git a/ppapi/native_client/tests/ppapi_geturl/module.cc b/ppapi/native_client/tests/ppapi_geturl/module.cc index 766c4b5..a610f08 100644 --- a/ppapi/native_client/tests/ppapi_geturl/module.cc +++ b/ppapi/native_client/tests/ppapi_geturl/module.cc @@ -221,7 +221,7 @@ PP_Var Module::StrToVar(const char* str) { return PP_MakeUndefined(); const PPB_Var* ppb_var = module->ppb_var_interface(); if (NULL != ppb_var) - return ppb_var->VarFromUtf8(module->module_id(), str, strlen(str)); + return ppb_var->VarFromUtf8(str, strlen(str)); return PP_MakeUndefined(); } diff --git a/ppapi/native_client/tests/ppapi_test_lib/test_interface.cc b/ppapi/native_client/tests/ppapi_test_lib/test_interface.cc index 55b52ff..c574bea 100644 --- a/ppapi/native_client/tests/ppapi_test_lib/test_interface.cc +++ b/ppapi/native_client/tests/ppapi_test_lib/test_interface.cc @@ -30,15 +30,14 @@ void PostTestMessage(nacl::string test_name, nacl::string message) { nacl::string test_message = test_name; test_message += ":"; test_message += message; - PP_Var post_var = PPBVar()->VarFromUtf8(pp_instance(), - test_message.c_str(), + PP_Var post_var = PPBVar()->VarFromUtf8(test_message.c_str(), test_message.size()); PPBMessaging()->PostMessage(pp_instance(), post_var); PPBVar()->Release(post_var); } PP_Var PP_MakeString(const char* s) { - return PPBVar()->VarFromUtf8(pp_module(), s, strlen(s)); + return PPBVar()->VarFromUtf8(s, strlen(s)); } nacl::string StringifyVar(const PP_Var& var) { @@ -120,8 +119,7 @@ struct CallbackInfo { }; void ReportCallbackInvocationToJS(const char* callback_name) { - PP_Var callback_var = PPBVar()->VarFromUtf8(pp_module(), - callback_name, + PP_Var callback_var = PPBVar()->VarFromUtf8(callback_name, strlen(callback_name)); // Report using postmessage for async tests. PPBMessaging()->PostMessage(pp_instance(), callback_var); diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index b43d7e3..8765d44 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -110,8 +110,6 @@ 'proxy/ppb_url_response_info_proxy.h', 'proxy/ppb_var_deprecated_proxy.cc', 'proxy/ppb_var_deprecated_proxy.h', - 'proxy/ppb_var_proxy.cc', - 'proxy/ppb_var_proxy.h', 'proxy/ppb_video_capture_proxy.cc', 'proxy/ppb_video_capture_proxy.h', 'proxy/ppb_video_decoder_proxy.cc', diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index 7b67ec1..8b29a4b 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -69,6 +69,8 @@ 'shared_impl/ppb_url_request_info_shared.h', 'shared_impl/ppb_url_util_shared.cc', 'shared_impl/ppb_url_util_shared.h', + 'shared_impl/ppb_var_impl.cc', + 'shared_impl/ppb_var_impl.h', 'shared_impl/ppb_video_decoder_shared.cc', 'shared_impl/ppb_video_decoder_shared.h', 'shared_impl/ppp_instance_combined.cc', diff --git a/ppapi/proxy/host_var_serialization_rules.cc b/ppapi/proxy/host_var_serialization_rules.cc index 84e0b4c..ae6b7f7 100644 --- a/ppapi/proxy/host_var_serialization_rules.cc +++ b/ppapi/proxy/host_var_serialization_rules.cc @@ -33,7 +33,7 @@ PP_Var HostVarSerializationRules::BeginReceiveCallerOwned( Dispatcher* /* dispatcher */) { if (var.type == PP_VARTYPE_STRING) { // Convert the string to the context of the current process. - return var_interface_->VarFromUtf8(pp_module_, str_val->c_str(), + return var_interface_->VarFromUtf8(str_val->c_str(), static_cast<uint32_t>(str_val->size())); } return var; @@ -51,7 +51,7 @@ PP_Var HostVarSerializationRules::ReceivePassRef(const PP_Var& var, Dispatcher* /* dispatcher */) { if (var.type == PP_VARTYPE_STRING) { // Convert the string to the context of the current process. - return var_interface_->VarFromUtf8(pp_module_, str_val.c_str(), + return var_interface_->VarFromUtf8(str_val.c_str(), static_cast<uint32_t>(str_val.size())); } diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index a1c100e..f03a580 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -82,7 +82,6 @@ #include "ppapi/proxy/ppb_url_loader_proxy.h" #include "ppapi/proxy/ppb_url_response_info_proxy.h" #include "ppapi/proxy/ppb_var_deprecated_proxy.h" -#include "ppapi/proxy/ppb_var_proxy.h" #include "ppapi/proxy/ppb_video_capture_proxy.h" #include "ppapi/proxy/ppb_video_decoder_proxy.h" #include "ppapi/proxy/ppp_class_proxy.h" @@ -95,6 +94,7 @@ #include "ppapi/proxy/ppp_video_decoder_proxy.h" #include "ppapi/proxy/resource_creation_proxy.h" #include "ppapi/shared_impl/ppb_opengles2_shared.h" +#include "ppapi/shared_impl/ppb_var_impl.h" #include "ppapi/thunk/thunk.h" // Helper to get the proxy name PPB_Foo_Proxy given the API name PPB_Foo. @@ -166,7 +166,9 @@ InterfaceList::InterfaceList() { AddPPB(PPB_OPENGLES2_INTERFACE, API_ID_NONE, PPB_OpenGLES2_Shared::GetInterface()); AddPPB(PPB_VAR_INTERFACE, API_ID_NONE, - GetPPB_Var_Interface()); + PPB_Var_Impl::GetVarInterface()); + AddPPB(PPB_VAR_INTERFACE_1_0, API_ID_NONE, + PPB_Var_Impl::GetVarInterface1_0()); AddFlashInterfaces(); diff --git a/ppapi/proxy/plugin_var_serialization_rules.cc b/ppapi/proxy/plugin_var_serialization_rules.cc index 3d9975a..155c844 100644 --- a/ppapi/proxy/plugin_var_serialization_rules.cc +++ b/ppapi/proxy/plugin_var_serialization_rules.cc @@ -44,7 +44,7 @@ PP_Var PluginVarSerializationRules::BeginReceiveCallerOwned( const std::string* str_val, Dispatcher* dispatcher) { if (var.type == PP_VARTYPE_STRING) - return StringVar::StringToPPVar(0, *str_val); + return StringVar::StringToPPVar(*str_val); if (var.type == PP_VARTYPE_OBJECT) { DCHECK(dispatcher->IsPlugin()); @@ -68,7 +68,7 @@ PP_Var PluginVarSerializationRules::ReceivePassRef(const PP_Var& var, const std::string& str_val, Dispatcher* dispatcher) { if (var.type == PP_VARTYPE_STRING) - return StringVar::StringToPPVar(0, str_val); + return StringVar::StringToPPVar(str_val); // Overview of sending an object with "pass ref" from the browser to the // plugin: diff --git a/ppapi/proxy/ppb_flash_proxy.cc b/ppapi/proxy/ppb_flash_proxy.cc index 6713845..2dcd68b 100644 --- a/ppapi/proxy/ppb_flash_proxy.cc +++ b/ppapi/proxy/ppb_flash_proxy.cc @@ -153,9 +153,9 @@ double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) { return result; } -PP_Var GetCommandLineArgs(PP_Module pp_module) { +PP_Var GetCommandLineArgs(PP_Module /*pp_module*/) { std::string args = ProxyModule::GetInstance()->GetFlashCommandLineArgs(); - return StringVar::StringToPPVar(pp_module, args); + return StringVar::StringToPPVar(args); } const PPB_Flash flash_interface = { diff --git a/ppapi/proxy/ppb_font_proxy.cc b/ppapi/proxy/ppb_font_proxy.cc index 111d89d..e411981 100644 --- a/ppapi/proxy/ppb_font_proxy.cc +++ b/ppapi/proxy/ppb_font_proxy.cc @@ -65,7 +65,7 @@ PP_Var PPB_Font_Proxy::GetFontFamilies(PP_Instance instance) { new PpapiHostMsg_PPBFont_GetFontFamilies(&families)); } - return StringVar::StringToPPVar(0, families); + return StringVar::StringToPPVar(families); } bool PPB_Font_Proxy::OnMessageReceived(const IPC::Message& msg) { @@ -121,7 +121,7 @@ PP_Bool Font::Describe(PP_FontDescription_Dev* description, } if (PP_ToBool(result)) - description->face = StringVar::StringToPPVar(0, face); + description->face = StringVar::StringToPPVar(face); else description->face = PP_MakeUndefined(); return result; diff --git a/ppapi/proxy/ppb_var_deprecated_proxy.cc b/ppapi/proxy/ppb_var_deprecated_proxy.cc index 2594d26..f81f319 100644 --- a/ppapi/proxy/ppb_var_deprecated_proxy.cc +++ b/ppapi/proxy/ppb_var_deprecated_proxy.cc @@ -12,6 +12,7 @@ #include "base/task.h" #include "ppapi/c/dev/ppb_var_deprecated.h" #include "ppapi/c/pp_var.h" +#include "ppapi/c/ppb_var.h" #include "ppapi/c/ppb_core.h" #include "ppapi/proxy/host_dispatcher.h" #include "ppapi/proxy/plugin_dispatcher.h" @@ -21,6 +22,7 @@ #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/ppp_class_proxy.h" #include "ppapi/proxy/serialized_var.h" +#include "ppapi/shared_impl/ppb_var_impl.h" #include "ppapi/shared_impl/var.h" namespace ppapi { @@ -52,7 +54,7 @@ PluginDispatcher* CheckExceptionAndGetDispatcher(const PP_Var& object, // The object is invalid. This means we can't figure out which dispatcher // to use, which is OK because the call will fail anyway. Set the exception. if (exception) { - *exception = StringVar::StringToPPVar(0, + *exception = StringVar::StringToPPVar( std::string("Attempting to use an invalid object")); } return NULL; @@ -60,28 +62,6 @@ PluginDispatcher* CheckExceptionAndGetDispatcher(const PP_Var& object, // PPB_Var_Deprecated plugin --------------------------------------------------- -void AddRefVar(PP_Var var) { - PpapiGlobals::Get()->GetVarTracker()->AddRefVar(var); -} - -void ReleaseVar(PP_Var var) { - PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var); -} - -PP_Var VarFromUtf8(PP_Module module, const char* data, uint32_t len) { - return StringVar::StringToPPVar(module, data, len); -} - -const char* VarToUtf8(PP_Var var, uint32_t* len) { - StringVar* str = StringVar::FromPPVar(var); - if (str) { - *len = static_cast<uint32_t>(str->value().size()); - return str->value().c_str(); - } - *len = 0; - return NULL; -} - bool HasProperty(PP_Var var, PP_Var name, PP_Var* exception) { @@ -274,23 +254,6 @@ PP_Var CreateObject(PP_Instance instance, return result.Return(dispatcher); } -const PPB_Var_Deprecated var_deprecated_interface = { - &AddRefVar, - &ReleaseVar, - &VarFromUtf8, - &VarToUtf8, - &HasProperty, - &HasMethod, - &GetProperty, - &EnumerateProperties, - &SetProperty, - &RemoveProperty, - &Call, - &Construct, - &IsInstanceOf, - &CreateObject -}; - InterfaceProxy* CreateVarDeprecatedProxy(Dispatcher* dispatcher) { return new PPB_Var_Deprecated_Proxy(dispatcher ); } @@ -313,6 +276,23 @@ PPB_Var_Deprecated_Proxy::~PPB_Var_Deprecated_Proxy() { // static const InterfaceProxy::Info* PPB_Var_Deprecated_Proxy::GetInfo() { + static const PPB_Var_Deprecated var_deprecated_interface = { + ppapi::PPB_Var_Impl::GetVarInterface1_0()->AddRef, + ppapi::PPB_Var_Impl::GetVarInterface1_0()->Release, + ppapi::PPB_Var_Impl::GetVarInterface1_0()->VarFromUtf8, + ppapi::PPB_Var_Impl::GetVarInterface1_0()->VarToUtf8, + &HasProperty, + &HasMethod, + &GetProperty, + &EnumerateProperties, + &SetProperty, + &RemoveProperty, + &Call, + &Construct, + &IsInstanceOf, + &CreateObject + }; + static const Info info = { &var_deprecated_interface, PPB_VAR_DEPRECATED_INTERFACE, diff --git a/ppapi/proxy/ppb_var_proxy.h b/ppapi/proxy/ppb_var_proxy.h deleted file mode 100644 index 465042b9..0000000 --- a/ppapi/proxy/ppb_var_proxy.h +++ /dev/null @@ -1,23 +0,0 @@ -// 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. - -#ifndef PPAPI_PPB_VAR_PROXY_H_ -#define PPAPI_PPB_VAR_PROXY_H_ - -#include "ppapi/proxy/ppapi_proxy_export.h" -#include "ppapi/proxy/interface_proxy.h" - -struct PPB_Var; - -namespace ppapi { -namespace proxy { - -// Returns a pointer to the plugin-specific implementation of PPB_Var. -// There is no proxy object since this is implemented entirely in-process. -PPAPI_PROXY_EXPORT const PPB_Var* GetPPB_Var_Interface(); - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PPB_VAR_PROXY_H_ diff --git a/ppapi/proxy/ppb_var_unittest.cc b/ppapi/proxy/ppb_var_unittest.cc index 16683d9..6a6fbae 100644 --- a/ppapi/proxy/ppb_var_unittest.cc +++ b/ppapi/proxy/ppb_var_unittest.cc @@ -10,7 +10,7 @@ #include "ppapi/c/pp_var.h" #include "ppapi/c/ppb_var.h" #include "ppapi/proxy/ppapi_proxy_test.h" -#include "ppapi/proxy/ppb_var_proxy.h" +#include "ppapi/shared_impl/ppb_var_impl.h" namespace { std::string VarToString(const PP_Var& var, const PPB_Var* ppb_var) { @@ -30,7 +30,7 @@ class PPB_VarTest : public PluginProxyTest { public: PPB_VarTest() : test_strings_(kNumStrings), vars_(kNumStrings), - ppb_var_(GetPPB_Var_Interface()) { + ppb_var_(ppapi::PPB_Var_Impl::GetVarInterface()) { // Set the value of test_strings_[i] to "i". for (size_t i = 0; i < kNumStrings; ++i) test_strings_[i] = base::IntToString(i); @@ -44,9 +44,8 @@ class PPB_VarTest : public PluginProxyTest { // Test basic String operations. TEST_F(PPB_VarTest, Strings) { for (size_t i = 0; i < kNumStrings; ++i) { - vars_[i] = ppb_var_->VarFromUtf8(pp_module(), - test_strings_[i].c_str(), - test_strings_[i].length()); + vars_[i] = ppb_var_->VarFromUtf8(test_strings_[i].c_str(), + test_strings_[i].length()); EXPECT_EQ(test_strings_[i], VarToString(vars_[i], ppb_var_)); } // At this point, they should each have a ref count of 1. Add some more. @@ -103,10 +102,9 @@ class CreateVarThreadDelegate : public base::PlatformThread::Delegate { } virtual ~CreateVarThreadDelegate() {} virtual void ThreadMain() { - const PPB_Var* ppb_var = ppapi::proxy::GetPPB_Var_Interface(); + const PPB_Var* ppb_var = ppapi::PPB_Var_Impl::GetVarInterface(); for (size_t i = 0; i < size_; ++i) { - vars_out_[i] = ppb_var->VarFromUtf8(pp_module_, - strings_in_[i].c_str(), + vars_out_[i] = ppb_var->VarFromUtf8(strings_in_[i].c_str(), strings_in_[i].length()); strings_out_[i] = VarToString(vars_out_[i], ppb_var); } @@ -127,7 +125,7 @@ class ChangeRefVarThreadDelegate : public base::PlatformThread::Delegate { } virtual ~ChangeRefVarThreadDelegate() {} virtual void ThreadMain() { - const PPB_Var* ppb_var = ppapi::proxy::GetPPB_Var_Interface(); + const PPB_Var* ppb_var = ppapi::PPB_Var_Impl::GetVarInterface(); // Increment and decrement the reference count for each var kRefsToAdd // times. Note that we always AddRef once before doing the matching Release, // to ensure that we never accidentally release the last reference. @@ -155,7 +153,7 @@ class RemoveRefVarThreadDelegate : public base::PlatformThread::Delegate { } virtual ~RemoveRefVarThreadDelegate() {} virtual void ThreadMain() { - const PPB_Var* ppb_var = ppapi::proxy::GetPPB_Var_Interface(); + const PPB_Var* ppb_var = ppapi::PPB_Var_Impl::GetVarInterface(); for (size_t i = 0; i < kNumStrings; ++i) { ppb_var->Release(vars_[i]); } diff --git a/ppapi/proxy/ppp_messaging_proxy_unittest.cc b/ppapi/proxy/ppp_messaging_proxy_unittest.cc index 25c7e55..ed12e57 100644 --- a/ppapi/proxy/ppp_messaging_proxy_unittest.cc +++ b/ppapi/proxy/ppp_messaging_proxy_unittest.cc @@ -46,7 +46,7 @@ void AddRef(PP_Var /*var*/) { } void Release(PP_Var /*var*/) { } -PP_Var VarFromUtf8(PP_Module /*module*/, const char* /*data*/, uint32_t len) { +PP_Var VarFromUtf8(const char* /*data*/, uint32_t len) { return PP_MakeUndefined(); } // No matter what id we're given, always provide kTestString and its length. diff --git a/ppapi/proxy/proxy_object_var.cc b/ppapi/proxy/proxy_object_var.cc index 4a12302..4a185e8 100644 --- a/ppapi/proxy/proxy_object_var.cc +++ b/ppapi/proxy/proxy_object_var.cc @@ -13,8 +13,7 @@ namespace ppapi { ProxyObjectVar::ProxyObjectVar(PluginDispatcher* dispatcher, int32 host_var_id) - : Var(0), - dispatcher_(dispatcher), + : dispatcher_(dispatcher), host_var_id_(host_var_id) { // Should be given valid objects or we'll crash later. DCHECK(dispatcher_); diff --git a/ppapi/shared_impl/ppb_file_ref_shared.cc b/ppapi/shared_impl/ppb_file_ref_shared.cc index 6e748e1..64268b3 100644 --- a/ppapi/shared_impl/ppb_file_ref_shared.cc +++ b/ppapi/shared_impl/ppb_file_ref_shared.cc @@ -5,7 +5,6 @@ #include "ppapi/shared_impl/ppb_file_ref_shared.h" #include "base/logging.h" -#include "ppapi/shared_impl/ppapi_globals.h" #include "ppapi/shared_impl/var.h" namespace ppapi { @@ -42,9 +41,7 @@ PP_FileSystemType PPB_FileRef_Shared::GetFileSystemType() const { PP_Var PPB_FileRef_Shared::GetName() const { if (!name_var_.get()) { - name_var_ = new StringVar( - PpapiGlobals::Get()->GetModuleForInstance(pp_instance()), - create_info_.name); + name_var_ = new StringVar(create_info_.name); } return name_var_->GetPPVar(); } @@ -53,9 +50,7 @@ PP_Var PPB_FileRef_Shared::GetPath() const { if (create_info_.file_system_type == PP_FILESYSTEMTYPE_EXTERNAL) return PP_MakeUndefined(); if (!path_var_.get()) { - path_var_ = new StringVar( - PpapiGlobals::Get()->GetModuleForInstance(pp_instance()), - create_info_.path); + path_var_ = new StringVar(create_info_.path); } return path_var_->GetPPVar(); } diff --git a/ppapi/shared_impl/ppb_input_event_shared.cc b/ppapi/shared_impl/ppb_input_event_shared.cc index 962f701..2cffa0f 100644 --- a/ppapi/shared_impl/ppb_input_event_shared.cc +++ b/ppapi/shared_impl/ppb_input_event_shared.cc @@ -4,7 +4,6 @@ #include "ppapi/shared_impl/ppb_input_event_shared.h" -#include "ppapi/shared_impl/ppapi_globals.h" #include "ppapi/shared_impl/var.h" using ppapi::thunk::PPB_InputEvent_API; @@ -100,9 +99,7 @@ uint32_t PPB_InputEvent_Shared::GetKeyCode() { } PP_Var PPB_InputEvent_Shared::GetCharacterText() { - return StringVar::StringToPPVar( - PpapiGlobals::Get()->GetModuleForInstance(pp_instance()), - data_.character_text); + return StringVar::StringToPPVar(data_.character_text); } uint32_t PPB_InputEvent_Shared::GetIMESegmentNumber() { diff --git a/ppapi/shared_impl/ppb_url_util_shared.cc b/ppapi/shared_impl/ppb_url_util_shared.cc index bdc4950..f473530 100644 --- a/ppapi/shared_impl/ppb_url_util_shared.cc +++ b/ppapi/shared_impl/ppb_url_util_shared.cc @@ -48,8 +48,7 @@ PP_Var PPB_URLUtil_Shared::Canonicalize(PP_Var url, StringVar* url_string = StringVar::FromPPVar(url); if (!url_string) return PP_MakeNull(); - return GenerateURLReturn(url_string->pp_module(), - GURL(url_string->value()), components); + return GenerateURLReturn(GURL(url_string->value()), components); } // static @@ -65,8 +64,7 @@ PP_Var PPB_URLUtil_Shared::ResolveRelativeToURL( GURL base_gurl(base_url_string->value()); if (!base_gurl.is_valid()) return PP_MakeNull(); - return GenerateURLReturn(base_url_string->pp_module(), - base_gurl.Resolve(relative_string->value()), + return GenerateURLReturn(base_gurl.Resolve(relative_string->value()), components); } @@ -87,14 +85,12 @@ PP_Bool PPB_URLUtil_Shared::IsSameSecurityOrigin(PP_Var url_a, PP_Var url_b) { // Used for returning the given GURL from a PPAPI function, with an optional // out param indicating the components. -PP_Var PPB_URLUtil_Shared::GenerateURLReturn( - PP_Module module, - const GURL& url, - PP_URLComponents_Dev* components) { +PP_Var PPB_URLUtil_Shared::GenerateURLReturn(const GURL& url, + PP_URLComponents_Dev* components) { if (!url.is_valid()) return PP_MakeNull(); ConvertComponents(url.parsed_for_possibly_invalid_spec(), components); - return StringVar::StringToPPVar(module, url.possibly_invalid_spec()); + return StringVar::StringToPPVar(url.possibly_invalid_spec()); } PP_Var PPB_URLUtil_Shared::ConvertComponentsAndReturnURL( diff --git a/ppapi/shared_impl/ppb_url_util_shared.h b/ppapi/shared_impl/ppb_url_util_shared.h index 54c7573..873da0c 100644 --- a/ppapi/shared_impl/ppb_url_util_shared.h +++ b/ppapi/shared_impl/ppb_url_util_shared.h @@ -10,7 +10,6 @@ #include "base/basictypes.h" #include "googleurl/src/url_parse.h" #include "ppapi/c/dev/ppb_url_util_dev.h" -#include "ppapi/c/pp_module.h" #include "ppapi/c/pp_var.h" #include "ppapi/shared_impl/ppapi_shared_export.h" @@ -32,8 +31,7 @@ class PPAPI_SHARED_EXPORT PPB_URLUtil_Shared { // Used for returning the given GURL from a PPAPI function, with an optional // out param indicating the components. - static PP_Var GenerateURLReturn(PP_Module pp_module, - const GURL& url, + static PP_Var GenerateURLReturn(const GURL& url, PP_URLComponents_Dev* components); // Helper function that optionally take a components structure and fills it diff --git a/ppapi/proxy/ppb_var_proxy.cc b/ppapi/shared_impl/ppb_var_impl.cc index 4301234..d279b8b4 100644 --- a/ppapi/proxy/ppb_var_proxy.cc +++ b/ppapi/shared_impl/ppb_var_impl.cc @@ -2,21 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ppapi/proxy/ppb_var_proxy.h" +#include "ppapi/shared_impl/ppb_var_impl.h" + +#include <limits> -#include "ppapi/c/pp_var.h" #include "ppapi/c/ppb_var.h" +#include "ppapi/c/pp_var.h" #include "ppapi/shared_impl/ppapi_globals.h" #include "ppapi/shared_impl/proxy_lock.h" #include "ppapi/shared_impl/var.h" #include "ppapi/shared_impl/var_tracker.h" -namespace ppapi { -namespace proxy { +using ppapi::PpapiGlobals; +using ppapi::StringVar; -namespace { - -// PPP_Var plugin -------------------------------------------------------------- +namespace ppapi { void AddRefVar(PP_Var var) { ppapi::ProxyAutoLock lock; @@ -28,9 +28,13 @@ void ReleaseVar(PP_Var var) { PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var); } -PP_Var VarFromUtf8(PP_Module module, const char* data, uint32_t len) { +PP_Var VarFromUtf8(const char* data, uint32_t len) { ppapi::ProxyAutoLock lock; - return StringVar::StringToPPVar(module, data, len); + return StringVar::StringToPPVar(data, len); +} + +PP_Var VarFromUtf8_1_0(PP_Module /*module*/, const char* data, uint32_t len) { + return VarFromUtf8(data, len); } const char* VarToUtf8(PP_Var var, uint32_t* len) { @@ -44,6 +48,7 @@ const char* VarToUtf8(PP_Var var, uint32_t* len) { return NULL; } +namespace { const PPB_Var var_interface = { &AddRefVar, &ReleaseVar, @@ -51,11 +56,23 @@ const PPB_Var var_interface = { &VarToUtf8 }; +const PPB_Var_1_0 var_interface1_0 = { + &AddRefVar, + &ReleaseVar, + &VarFromUtf8_1_0, + &VarToUtf8 +}; } // namespace -const PPB_Var* GetPPB_Var_Interface() { +// static +const PPB_Var* PPB_Var_Impl::GetVarInterface() { return &var_interface; } -} // namespace proxy +// static +const PPB_Var_1_0* PPB_Var_Impl::GetVarInterface1_0() { + return &var_interface1_0; +} + } // namespace ppapi + diff --git a/ppapi/shared_impl/ppb_var_impl.h b/ppapi/shared_impl/ppb_var_impl.h new file mode 100644 index 0000000..0ff0c6a --- /dev/null +++ b/ppapi/shared_impl/ppb_var_impl.h @@ -0,0 +1,26 @@ +// 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. + +#ifndef PPAPI_SHARED_IMPL_PPB_VAR_IMPL_H_ +#define PPAPI_SHARED_IMPL_PPB_VAR_IMPL_H_ + +#include "ppapi/c/pp_module.h" +#include "ppapi/c/pp_stdint.h" +#include "ppapi/shared_impl/ppapi_shared_export.h" + +struct PP_Var; +struct PPB_Var; +struct PPB_Var_1_0; + +namespace ppapi { + +class PPAPI_SHARED_EXPORT PPB_Var_Impl { + public: + static const PPB_Var* GetVarInterface(); + static const PPB_Var_1_0* GetVarInterface1_0(); +}; + +} // namespace ppapi + +#endif // PPAPI_SHARED_IMPL_PPB_VAR_IMPL_H_ diff --git a/ppapi/shared_impl/private/net_address_private_impl.cc b/ppapi/shared_impl/private/net_address_private_impl.cc index 1cc161f..3b9a4ae 100644 --- a/ppapi/shared_impl/private/net_address_private_impl.cc +++ b/ppapi/shared_impl/private/net_address_private_impl.cc @@ -195,7 +195,7 @@ std::string ConvertIPv6AddressToString(const sockaddr_in6* a, } #endif // OS_WIN || OS_MAC -PP_Var Describe(PP_Module module, +PP_Var Describe(PP_Module /*module*/, const struct PP_NetAddress_Private* addr, PP_Bool include_port) { if (!NetAddressPrivateImpl::ValidateNetAddress(*addr)) @@ -211,12 +211,12 @@ PP_Var Describe(PP_Module module, case AF_INET: { const sockaddr_in* a = reinterpret_cast<const sockaddr_in*>(addr->data); return StringVar::StringToPPVar( - module, ConvertIPv4AddressToString(a, !!include_port)); + ConvertIPv4AddressToString(a, !!include_port)); } case AF_INET6: { const sockaddr_in6* a = reinterpret_cast<const sockaddr_in6*>(addr->data); return StringVar::StringToPPVar( - module, ConvertIPv6AddressToString(a, !!include_port)); + ConvertIPv6AddressToString(a, !!include_port)); } default: NOTREACHED(); @@ -229,7 +229,7 @@ PP_Var Describe(PP_Module module, std::string description = include_port ? net::NetAddressToStringWithPort(a, l) : net::NetAddressToString(a, l); - return StringVar::StringToPPVar(module, description); + return StringVar::StringToPPVar(description); #endif } diff --git a/ppapi/shared_impl/var.cc b/ppapi/shared_impl/var.cc index 5013b90..3bec5ce 100644 --- a/ppapi/shared_impl/var.cc +++ b/ppapi/shared_impl/var.cc @@ -17,7 +17,7 @@ namespace ppapi { // Var ------------------------------------------------------------------------- -Var::Var(PP_Module module) : pp_module_(module), var_id_(0) { +Var::Var() : var_id_(0) { } Var::~Var() { @@ -97,14 +97,12 @@ void Var::AssignVarID(int32 id) { // StringVar ------------------------------------------------------------------- -StringVar::StringVar(PP_Module module, const std::string& str) - : Var(module), - value_(str) { +StringVar::StringVar(const std::string& str) + : value_(str) { } -StringVar::StringVar(PP_Module module, const char* str, uint32 len) - : Var(module), - value_(str, len) { +StringVar::StringVar(const char* str, uint32 len) + : value_(str, len) { } StringVar::~StringVar() { @@ -131,14 +129,13 @@ PP_VarType StringVar::GetType() const { } // static -PP_Var StringVar::StringToPPVar(PP_Module module, const std::string& var) { - return StringToPPVar(module, var.c_str(), var.size()); +PP_Var StringVar::StringToPPVar(const std::string& var) { + return StringToPPVar(var.c_str(), var.size()); } // static -PP_Var StringVar::StringToPPVar(PP_Module module, - const char* data, uint32 len) { - scoped_refptr<StringVar> str(new StringVar(module, data, len)); +PP_Var StringVar::StringToPPVar(const char* data, uint32 len) { + scoped_refptr<StringVar> str(new StringVar(data, len)); if (!str || !IsStringUTF8(str->value())) return PP_MakeNull(); return str->GetPPVar(); diff --git a/ppapi/shared_impl/var.h b/ppapi/shared_impl/var.h index ceb7271..988898a0 100644 --- a/ppapi/shared_impl/var.h +++ b/ppapi/shared_impl/var.h @@ -9,7 +9,6 @@ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" -#include "ppapi/c/pp_module.h" #include "ppapi/c/pp_var.h" #include "ppapi/shared_impl/ppapi_shared_export.h" @@ -21,9 +20,7 @@ class StringVar; // Var ------------------------------------------------------------------------- -// Represents a non-POD var. This is derived from a resource even though it -// isn't a resource from the plugin's perspective. This allows us to re-use -// the refcounting and the association with the module from the resource code. +// Represents a non-POD var. class PPAPI_SHARED_EXPORT Var : public base::RefCounted<Var> { public: virtual ~Var(); @@ -50,11 +47,8 @@ class PPAPI_SHARED_EXPORT Var : public base::RefCounted<Var> { // the plugin. int32 GetExistingVarID() const; - PP_Module pp_module() const { return pp_module_; } - protected: - // This can only be constructed as a StringVar or an ObjectVar. - explicit Var(PP_Module module); + Var(); // Returns the unique ID associated with this string or object, creating it // if necessary. The return value will be 0 if the string or object is @@ -69,8 +63,6 @@ class PPAPI_SHARED_EXPORT Var : public base::RefCounted<Var> { void AssignVarID(int32 id); private: - PP_Module pp_module_; - // This will be 0 if no ID has been assigned (this happens lazily). int32 var_id_; @@ -82,7 +74,7 @@ class PPAPI_SHARED_EXPORT Var : public base::RefCounted<Var> { // Represents a string-based Var. // // Returning a given string as a PP_Var: -// return StringVar::StringToPPVar(module, my_string); +// return StringVar::StringToPPVar(my_string); // // Converting a PP_Var to a string: // StringVar* string = StringVar::FromPPVar(var); @@ -91,8 +83,8 @@ class PPAPI_SHARED_EXPORT Var : public base::RefCounted<Var> { // DoSomethingWithTheString(string->value()); class PPAPI_SHARED_EXPORT StringVar : public Var { public: - StringVar(PP_Module module, const std::string& str); - StringVar(PP_Module module, const char* str, uint32 len); + StringVar(const std::string& str); + StringVar(const char* str, uint32 len); virtual ~StringVar(); const std::string& value() const { return value_; } @@ -107,10 +99,9 @@ class PPAPI_SHARED_EXPORT StringVar : public Var { // is not valid UTF-8, a NULL var will be returned. // // The return value will have a reference count of 1. Internally, this will - // create a StringVar, associate it with a module, and return the reference - // to it in the var. - static PP_Var StringToPPVar(PP_Module module, const std::string& str); - static PP_Var StringToPPVar(PP_Module module, const char* str, uint32 len); + // create a StringVar and return the reference to it in the var. + static PP_Var StringToPPVar(const std::string& str); + static PP_Var StringToPPVar(const char* str, uint32 len); // Helper function that converts a PP_Var to a string. This will return NULL // if the PP_Var is not of string type or the string is invalid. diff --git a/ppapi/tests/test_var.cc b/ppapi/tests/test_var.cc index ff899a0..050fdb9 100644 --- a/ppapi/tests/test_var.cc +++ b/ppapi/tests/test_var.cc @@ -46,8 +46,7 @@ std::string TestVar::TestBasicString() { { const char kStr[] = "Hello"; const uint32_t kStrLen(sizeof(kStr) - 1); - PP_Var str = var_interface_->VarFromUtf8(pp::Module::Get()->pp_module(), - kStr, kStrLen); + PP_Var str = var_interface_->VarFromUtf8(kStr, kStrLen); ASSERT_EQ(PP_VARTYPE_STRING, str.type); // Reading back the string should work. @@ -122,8 +121,7 @@ std::string TestVar::TestNullInputInUtf8Conversion() { // 0-length string should not dereference input string, and should produce // an empty string. - converted_string = var_interface_->VarFromUtf8( - pp::Module::Get()->pp_module(), NULL, 0); + converted_string = var_interface_->VarFromUtf8(NULL, 0); if (converted_string.type != PP_VARTYPE_STRING) { return "Expected 0 length to return empty string."; } diff --git a/ppapi/tests/test_websocket.cc b/ppapi/tests/test_websocket.cc index bf5c0ee..29aca17 100644 --- a/ppapi/tests/test_websocket.cc +++ b/ppapi/tests/test_websocket.cc @@ -63,8 +63,7 @@ void TestWebSocket::RunTests(const std::string& filter) { } PP_Var TestWebSocket::CreateVar(const char* string) { - return var_interface_->VarFromUtf8( - pp::Module::Get()->pp_module(), string, strlen(string)); + return var_interface_->VarFromUtf8(string, strlen(string)); } void TestWebSocket::ReleaseVar(const PP_Var& var) { |