diff options
69 files changed, 347 insertions, 460 deletions
diff --git a/chrome/renderer/chrome_ppb_pdf_impl.cc b/chrome/renderer/chrome_ppb_pdf_impl.cc index 6a2b31b..0fdcad4 100644 --- a/chrome/renderer/chrome_ppb_pdf_impl.cc +++ b/chrome/renderer/chrome_ppb_pdf_impl.cc @@ -31,7 +31,6 @@ #include "webkit/plugins/ppapi/host_globals.h" #include "webkit/plugins/ppapi/host_resource_tracker.h" #include "webkit/plugins/ppapi/plugin_delegate.h" -#include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" #include "webkit/plugins/ppapi/ppb_image_data_impl.h" @@ -142,7 +141,7 @@ PP_Var GetLocalizedString(PP_Instance instance_id, NOTREACHED(); } - return ppapi::StringVar::StringToPPVar(instance->module()->pp_module(), rv); + return ppapi::StringVar::StringToPPVar(rv); } PP_Resource GetResourceImage(PP_Instance instance_id, 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) { diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi index 571c7be..2f3a882 100644 --- a/webkit/glue/webkit_glue.gypi +++ b/webkit/glue/webkit_glue.gypi @@ -303,8 +303,8 @@ '../plugins/ppapi/ppb_url_request_info_impl.h', '../plugins/ppapi/ppb_url_response_info_impl.cc', '../plugins/ppapi/ppb_url_response_info_impl.h', - '../plugins/ppapi/ppb_var_impl.cc', - '../plugins/ppapi/ppb_var_impl.h', + '../plugins/ppapi/ppb_var_deprecated_impl.cc', + '../plugins/ppapi/ppb_var_deprecated_impl.h', '../plugins/ppapi/ppb_video_capture_impl.cc', '../plugins/ppapi/ppb_video_capture_impl.h', '../plugins/ppapi/ppb_video_decoder_impl.cc', diff --git a/webkit/plugins/ppapi/host_var_tracker.h b/webkit/plugins/ppapi/host_var_tracker.h index 73b4272..a4344df 100644 --- a/webkit/plugins/ppapi/host_var_tracker.h +++ b/webkit/plugins/ppapi/host_var_tracker.h @@ -14,7 +14,6 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/shared_impl/function_group_base.h" #include "ppapi/shared_impl/resource_tracker.h" diff --git a/webkit/plugins/ppapi/message_channel.cc b/webkit/plugins/ppapi/message_channel.cc index 33b32b7..1c3cd86 100644 --- a/webkit/plugins/ppapi/message_channel.cc +++ b/webkit/plugins/ppapi/message_channel.cc @@ -111,7 +111,7 @@ PP_Var CopyPPVar(const PP_Var& var) { StringVar* string = StringVar::FromPPVar(var); if (!string) return PP_MakeUndefined(); - return StringVar::StringToPPVar(string->pp_module(), string->value()); + return StringVar::StringToPPVar(string->value()); } else { return var; } diff --git a/webkit/plugins/ppapi/npapi_glue.cc b/webkit/plugins/ppapi/npapi_glue.cc index 7f166cd..6b94d93 100644 --- a/webkit/plugins/ppapi/npapi_glue.cc +++ b/webkit/plugins/ppapi/npapi_glue.cc @@ -96,7 +96,6 @@ PP_Var NPVariantToPPVar(PluginInstance* instance, const NPVariant* variant) { return PP_MakeDouble(NPVARIANT_TO_DOUBLE(*variant)); case NPVariantType_String: return StringVar::StringToPPVar( - instance->module()->pp_module(), NPVARIANT_TO_STRING(*variant).UTF8Characters, NPVARIANT_TO_STRING(*variant).UTF8Length); case NPVariantType_Object: @@ -121,13 +120,13 @@ NPIdentifier PPVarToNPIdentifier(PP_Var var) { } } -PP_Var NPIdentifierToPPVar(PP_Module module, NPIdentifier id) { +PP_Var NPIdentifierToPPVar(NPIdentifier id) { const NPUTF8* string_value = NULL; int32_t int_value = 0; bool is_string = false; WebBindings::extractIdentifierData(id, string_value, int_value, is_string); if (is_string) - return StringVar::StringToPPVar(module, string_value); + return StringVar::StringToPPVar(string_value); return PP_MakeInt32(int_value); } @@ -138,8 +137,7 @@ PP_Var NPObjectToPPVar(PluginInstance* instance, NPObject* object) { HostGlobals::Get()->host_var_tracker()->NPObjectVarForNPObject( instance->pp_instance(), object)); if (!object_var) { // No object for this module yet, make a new one. - object_var = new NPObjectVar(instance->module()->pp_module(), - instance->pp_instance(), object); + object_var = new NPObjectVar(instance->pp_instance(), object); } return object_var->GetPPVar(); } @@ -263,8 +261,7 @@ NPObjectAccessorWithIdentifier::NPObjectAccessorWithIdentifier( : object_(PluginObject::FromNPObject(object)), identifier_(PP_MakeUndefined()) { if (object_) { - identifier_ = NPIdentifierToPPVar( - object_->instance()->module()->pp_module(), identifier); + identifier_ = NPIdentifierToPPVar(identifier); if (identifier_.type == PP_VARTYPE_INT32 && !allow_integer_identifier) identifier_.type = PP_VARTYPE_UNDEFINED; // Mark it invalid. } @@ -276,9 +273,8 @@ NPObjectAccessorWithIdentifier::~NPObjectAccessorWithIdentifier() { // TryCatch -------------------------------------------------------------------- -TryCatch::TryCatch(PP_Module module, PP_Var* exception) - : pp_module_(module), - has_exception_(exception && exception->type != PP_VARTYPE_UNDEFINED), +TryCatch::TryCatch(PP_Var* exception) + : has_exception_(exception && exception->type != PP_VARTYPE_UNDEFINED), exception_(exception) { WebBindings::pushExceptionHandler(&TryCatch::Catch, this); } @@ -288,31 +284,14 @@ TryCatch::~TryCatch() { } void TryCatch::SetException(const char* message) { - if (!pp_module_) { - // Don't have a module to make the string. - SetInvalidObjectException(); - return; - } - if (!has_exception()) { has_exception_ = true; if (exception_) { - *exception_ = ::ppapi::StringVar::StringToPPVar(pp_module_, - message, strlen(message)); + *exception_ = ::ppapi::StringVar::StringToPPVar(message, strlen(message)); } } } -void TryCatch::SetInvalidObjectException() { - if (!has_exception()) { - has_exception_ = true; - // TODO(brettw) bug 54504: Have a global singleton string that can hold - // a generic error message. - if (exception_) - *exception_ = PP_MakeInt32(1); - } -} - // static void TryCatch::Catch(void* self, const char* message) { static_cast<TryCatch*>(self)->SetException(message); diff --git a/webkit/plugins/ppapi/npapi_glue.h b/webkit/plugins/ppapi/npapi_glue.h index c59de0a..f732402 100644 --- a/webkit/plugins/ppapi/npapi_glue.h +++ b/webkit/plugins/ppapi/npapi_glue.h @@ -47,9 +47,8 @@ WEBKIT_PLUGINS_EXPORT PP_Var NPVariantToPPVar(PluginInstance* instance, NPIdentifier PPVarToNPIdentifier(PP_Var var); // Returns a PP_Var corresponding to the given identifier. In the case of -// a string identifier, the string will be allocated associated with the -// given module. A returned string will have a reference count of 1. -PP_Var NPIdentifierToPPVar(PP_Module module, NPIdentifier id); +// a string identifier, the returned string will have a reference count of 1. +PP_Var NPIdentifierToPPVar(NPIdentifier id); // Helper function to create a PP_Var of type object that contains the given // NPObject for use byt he given module. Calling this function multiple times @@ -57,7 +56,7 @@ PP_Var NPIdentifierToPPVar(PP_Module module, NPIdentifier id); // there is still a PP_Var with a reference open to it from the previous // call. // -// The module is necessary because we can have different modules pointing to +// The instance is necessary because we can have different instances pointing to // the same NPObject, and we want to keep their refs separate. // // If no ObjectVar currently exists corresponding to the NPObject, one is @@ -231,42 +230,20 @@ class TryCatch { // The given exception may be NULL if the consumer isn't interested in // catching exceptions. If non-NULL, the given var will be updated if any // exception is thrown (so it must outlive the TryCatch object). - // - // The module associated with the exception is passed so we know which module - // to associate any exception string with. It may be NULL if you don't know - // the module at construction time, in which case you should set it later - // by calling set_module(). - // - // If an exception is thrown when the module is NULL, setting *any* exception - // will result in using the InvalidObjectException. - TryCatch(PP_Module module, PP_Var* exception); + TryCatch(PP_Var* exception); ~TryCatch(); - // Get and set the module. This may be NULL (see the constructor). - PP_Module pp_module() { return pp_module_; } - void set_pp_module(PP_Module module) { pp_module_ = module; } - // Returns true is an exception has been thrown. This can be true immediately // after construction if the var passed to the constructor is non-void. bool has_exception() const { return has_exception_; } - // Sets the given exception. If no module has been set yet, the message will - // be ignored (since we have no module to associate the string with) and the - // SetInvalidObjectException() will be used instead. - // - // If an exception has been previously set, this function will do nothing - // (normally you want only the first exception). + // Sets the given exception. If an exception has been previously set, this + // function will do nothing (normally you want only the first exception). void SetException(const char* message); - // Sets the exception to be a generic message contained in a magic string - // not associated with any module. - void SetInvalidObjectException(); - private: static void Catch(void* self, const char* message); - PP_Module pp_module_; - // True if an exception has been thrown. Since the exception itself may be // NULL if the plugin isn't interested in getting the exception, this will // always indicate if SetException has been called, regardless of whether diff --git a/webkit/plugins/ppapi/npobject_var.cc b/webkit/plugins/ppapi/npobject_var.cc index 348e6ea..5a88176 100644 --- a/webkit/plugins/ppapi/npobject_var.cc +++ b/webkit/plugins/ppapi/npobject_var.cc @@ -17,11 +17,9 @@ namespace ppapi { // NPObjectVar ----------------------------------------------------------------- -NPObjectVar::NPObjectVar(PP_Module module, - PP_Instance instance, +NPObjectVar::NPObjectVar(PP_Instance instance, NPObject* np_object) - : Var(module), - pp_instance_(instance), + : pp_instance_(instance), np_object_(np_object) { WebBindings::retainObject(np_object_); HostGlobals::Get()->host_var_tracker()->AddNPObjectVar(this); diff --git a/webkit/plugins/ppapi/npobject_var.h b/webkit/plugins/ppapi/npobject_var.h index 597799a..83430f3 100644 --- a/webkit/plugins/ppapi/npobject_var.h +++ b/webkit/plugins/ppapi/npobject_var.h @@ -9,7 +9,6 @@ #include "base/compiler_specific.h" #include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_module.h" #include "ppapi/shared_impl/var.h" #include "webkit/plugins/webkit_plugins_export.h" @@ -33,7 +32,7 @@ class NPObjectVar : public Var { // You should always use FromNPObject to create an NPObjectVar. This function // guarantees that we maintain the 1:1 mapping between NPObject and // NPObjectVar. - NPObjectVar(PP_Module module, PP_Instance instance, NPObject* np_object); + NPObjectVar(PP_Instance instance, NPObject* np_object); virtual ~NPObjectVar(); diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc index fc5b2a1..6845fb1 100644 --- a/webkit/plugins/ppapi/plugin_module.cc +++ b/webkit/plugins/ppapi/plugin_module.cc @@ -85,6 +85,7 @@ #include "ppapi/c/trusted/ppb_url_loader_trusted.h" #include "ppapi/shared_impl/ppb_input_event_shared.h" #include "ppapi/shared_impl/ppb_opengles2_shared.h" +#include "ppapi/shared_impl/ppb_var_impl.h" #include "ppapi/shared_impl/time_conversion.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/thunk.h" @@ -109,7 +110,7 @@ #include "webkit/plugins/ppapi/ppb_proxy_impl.h" #include "webkit/plugins/ppapi/ppb_scrollbar_impl.h" #include "webkit/plugins/ppapi/ppb_uma_private_impl.h" -#include "webkit/plugins/ppapi/ppb_var_impl.h" +#include "webkit/plugins/ppapi/ppb_var_deprecated_impl.h" #include "webkit/plugins/ppapi/ppb_video_capture_impl.h" #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h" #include "webkit/plugins/ppapi/ppb_video_layer_impl.h" @@ -322,9 +323,11 @@ const void* GetInterface(const char* name) { if (strcmp(name, PPB_URLLOADERTRUSTED_INTERFACE) == 0) return ::ppapi::thunk::GetPPB_URLLoaderTrusted_Thunk(); if (strcmp(name, PPB_VAR_DEPRECATED_INTERFACE) == 0) - return PPB_Var_Impl::GetVarDeprecatedInterface(); + return PPB_Var_Deprecated_Impl::GetVarDeprecatedInterface(); if (strcmp(name, PPB_VAR_INTERFACE_1_0) == 0) - return PPB_Var_Impl::GetVarInterface(); + return ::ppapi::PPB_Var_Impl::GetVarInterface1_0(); + if (strcmp(name, PPB_VAR_INTERFACE_1_1) == 0) + return ::ppapi::PPB_Var_Impl::GetVarInterface(); #ifdef ENABLE_FLAPPER_HACKS if (strcmp(name, PPB_FLASH_NETCONNECTOR_INTERFACE) == 0) diff --git a/webkit/plugins/ppapi/plugin_object.cc b/webkit/plugins/ppapi/plugin_object.cc index 5cd5396..61f155b 100644 --- a/webkit/plugins/ppapi/plugin_object.cc +++ b/webkit/plugins/ppapi/plugin_object.cc @@ -195,8 +195,8 @@ bool WrapperClass_Enumerate(NPObject* object, NPIdentifier** values, for (uint32_t i = 0; i < property_count; ++i) { if (!((*values)[i] = PPVarToNPIdentifier(properties[i]))) { // Throw an exception for the failed convertion. - *result_converter.exception() = StringVar::StringToPPVar( - obj->instance()->module()->pp_module(), kInvalidValueException); + *result_converter.exception() = + StringVar::StringToPPVar(kInvalidValueException); break; } (*count)++; diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index 92882f9..3d75d86 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -1692,7 +1692,7 @@ PP_Var PluginInstance::ExecuteScript(PP_Instance instance, // a reference to ourselves so that we can still process the result after the // WebBindings::evaluate() below. scoped_refptr<PluginInstance> ref(this); - TryCatch try_catch(module()->pp_module(), exception); + TryCatch try_catch(exception); if (try_catch.has_exception()) return PP_MakeUndefined(); @@ -1731,7 +1731,7 @@ PP_Var PluginInstance::ExecuteScript(PP_Instance instance, PP_Var PluginInstance::GetDefaultCharSet(PP_Instance instance) { std::string encoding = delegate()->GetDefaultEncoding(); - return StringVar::StringToPPVar(module()->pp_module(), encoding); + return StringVar::StringToPPVar(encoding); } void PluginInstance::Log(PP_Instance instance, @@ -1896,7 +1896,6 @@ PP_Var PluginInstance::ResolveRelativeToDocument( WebElement plugin_element = container()->element(); GURL document_url = plugin_element.document().baseURL(); return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn( - module()->pp_module(), document_url.Resolve(relative_string->value()), components); } @@ -1933,15 +1932,14 @@ PP_Bool PluginInstance::DocumentCanAccessDocument(PP_Instance instance, PP_Var PluginInstance::GetDocumentURL(PP_Instance instance, PP_URLComponents_Dev* components) { WebKit::WebDocument document = container()->element().document(); - return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn( - module()->pp_module(), document.url(), components); + return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn(document.url(), + components); } PP_Var PluginInstance::GetPluginInstanceURL( PP_Instance instance, PP_URLComponents_Dev* components) { - return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn(module()->pp_module(), - plugin_url_, + return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn(plugin_url_, components); } diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.cc b/webkit/plugins/ppapi/ppb_file_ref_impl.cc index bc0de22..8cdcd76 100644 --- a/webkit/plugins/ppapi/ppb_file_ref_impl.cc +++ b/webkit/plugins/ppapi/ppb_file_ref_impl.cc @@ -248,11 +248,7 @@ PP_Var PPB_FileRef_Impl::GetAbsolutePath() { if (GetFileSystemType() != PP_FILESYSTEMTYPE_EXTERNAL) return GetPath(); if (!external_path_var_.get()) { - PluginModule* plugin_module = ResourceHelper::GetPluginModule(this); - if (!plugin_module) - return PP_MakeNull(); external_path_var_ = new StringVar( - plugin_module->pp_module(), external_file_system_path_.AsUTF8Unsafe()); } return external_path_var_->GetPPVar(); diff --git a/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc b/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc index 432c132..3f2e083 100644 --- a/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc +++ b/webkit/plugins/ppapi/ppb_flash_clipboard_impl.cc @@ -19,7 +19,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" #include "webkit/plugins/ppapi/common.h" #include "webkit/plugins/ppapi/host_globals.h" -#include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" using ppapi::StringVar; @@ -98,7 +97,7 @@ PP_Var PPB_Flash_Clipboard_Impl::ReadPlainText( } WebKit::WebCString s = web_clipboard->readPlainText(ConvertClipboardType(clipboard_type)).utf8(); - return StringVar::StringToPPVar(instance_->module()->pp_module(), s); + return StringVar::StringToPPVar(s); } int32_t PPB_Flash_Clipboard_Impl::WritePlainText( diff --git a/webkit/plugins/ppapi/ppb_flash_impl.cc b/webkit/plugins/ppapi/ppb_flash_impl.cc index 6d75d15..b490316 100644 --- a/webkit/plugins/ppapi/ppb_flash_impl.cc +++ b/webkit/plugins/ppapi/ppb_flash_impl.cc @@ -50,7 +50,7 @@ PP_Var GetProxyForURL(PP_Instance pp_instance, const char* url) { std::string proxy_host = instance->delegate()->ResolveProxy(gurl); if (proxy_host.empty()) return PP_MakeUndefined(); // No proxy. - return StringVar::StringToPPVar(instance->module()->pp_module(), proxy_host); + return StringVar::StringToPPVar(proxy_host); } int32_t Navigate(PP_Resource request_id, @@ -110,7 +110,7 @@ PP_Var GetCommandLineArgs(PP_Module pp_module) { return PP_MakeUndefined(); std::string args = instance->delegate()->GetFlashCommandLineArgs(); - return StringVar::StringToPPVar(pp_module, args); + return StringVar::StringToPPVar(args); } const PPB_Flash ppb_flash = { diff --git a/webkit/plugins/ppapi/ppb_font_impl.cc b/webkit/plugins/ppapi/ppb_font_impl.cc index cac50b5..0c439d0 100644 --- a/webkit/plugins/ppapi/ppb_font_impl.cc +++ b/webkit/plugins/ppapi/ppb_font_impl.cc @@ -86,8 +86,7 @@ PP_Bool PPB_Font_Impl::Describe(PP_FontDescription_Dev* description, return PP_FALSE; // Convert the string. - description->face = StringVar::StringToPPVar(plugin_module->pp_module(), - face); + description->face = StringVar::StringToPPVar(face); return PP_TRUE; } diff --git a/webkit/plugins/ppapi/ppb_transport_impl.cc b/webkit/plugins/ppapi/ppb_transport_impl.cc index efed706..44593d4 100644 --- a/webkit/plugins/ppapi/ppb_transport_impl.cc +++ b/webkit/plugins/ppapi/ppb_transport_impl.cc @@ -281,8 +281,7 @@ int32_t PPB_Transport_Impl::GetNextAddress(PP_Var* address, return PP_ERROR_FAILED; if (!local_candidates_.empty()) { - *address = StringVar::StringToPPVar(plugin_module->pp_module(), - local_candidates_.front()); + *address = StringVar::StringToPPVar(local_candidates_.front()); local_candidates_.pop_front(); return PP_OK; } diff --git a/webkit/plugins/ppapi/ppb_url_response_info_impl.cc b/webkit/plugins/ppapi/ppb_url_response_info_impl.cc index c788e99..cb96f8e 100644 --- a/webkit/plugins/ppapi/ppb_url_response_info_impl.cc +++ b/webkit/plugins/ppapi/ppb_url_response_info_impl.cc @@ -12,7 +12,6 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLResponse.h" #include "webkit/plugins/ppapi/common.h" -#include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" #include "webkit/plugins/ppapi/resource_helper.h" @@ -85,27 +84,23 @@ PPB_URLResponseInfo_API* PPB_URLResponseInfo_Impl::AsPPB_URLResponseInfo_API() { } PP_Var PPB_URLResponseInfo_Impl::GetProperty(PP_URLResponseProperty property) { - PluginModule* plugin_module = ResourceHelper::GetPluginModule(this); - if (!plugin_module) - return PP_MakeUndefined(); - PP_Module pp_module = plugin_module->pp_module(); switch (property) { case PP_URLRESPONSEPROPERTY_URL: - return StringVar::StringToPPVar(pp_module, url_); + return StringVar::StringToPPVar(url_); case PP_URLRESPONSEPROPERTY_REDIRECTURL: if (IsRedirect(status_code_)) - return StringVar::StringToPPVar(pp_module, redirect_url_); + return StringVar::StringToPPVar(redirect_url_); break; case PP_URLRESPONSEPROPERTY_REDIRECTMETHOD: if (IsRedirect(status_code_)) - return StringVar::StringToPPVar(pp_module, status_text_); + return StringVar::StringToPPVar(status_text_); break; case PP_URLRESPONSEPROPERTY_STATUSCODE: return PP_MakeInt32(status_code_); case PP_URLRESPONSEPROPERTY_STATUSLINE: - return StringVar::StringToPPVar(pp_module, status_text_); + return StringVar::StringToPPVar(status_text_); case PP_URLRESPONSEPROPERTY_HEADERS: - return StringVar::StringToPPVar(pp_module, headers_); + return StringVar::StringToPPVar(headers_); } // The default is to return an undefined PP_Var. return PP_MakeUndefined(); diff --git a/webkit/plugins/ppapi/ppb_var_impl.cc b/webkit/plugins/ppapi/ppb_var_deprecated_impl.cc index d76864e..c946222 100644 --- a/webkit/plugins/ppapi/ppb_var_impl.cc +++ b/webkit/plugins/ppapi/ppb_var_deprecated_impl.cc @@ -2,13 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "webkit/plugins/ppapi/ppb_var_impl.h" +#include "webkit/plugins/ppapi/ppb_var_deprecated_impl.h" #include <limits> #include "ppapi/c/dev/ppb_var_deprecated.h" #include "ppapi/c/ppb_var.h" #include "ppapi/c/pp_var.h" +#include "ppapi/shared_impl/ppb_var_impl.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" #include "webkit/plugins/ppapi/common.h" #include "webkit/plugins/ppapi/host_globals.h" @@ -17,7 +18,6 @@ #include "webkit/plugins/ppapi/plugin_module.h" #include "webkit/plugins/ppapi/plugin_object.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" -#include "v8/include/v8.h" using ppapi::NPObjectVar; using ppapi::PpapiGlobals; @@ -109,16 +109,10 @@ bool PPVarToNPVariantNoCopy(PP_Var var, NPVariant* result) { class ObjectAccessorTryCatch : public TryCatch { public: ObjectAccessorTryCatch(PP_Var object, PP_Var* exception) - : TryCatch(0, exception), + : TryCatch(exception), object_(NPObjectVar::FromPPVar(object)) { if (!object_) { - // No object or an invalid object was given. This means we have no module - // to associated with the exception text, so use the magic invalid object - // exception. - SetInvalidObjectException(); - } else { - // When the object is valid, we have a valid module to associate - set_pp_module(object_->pp_module()); + SetException(kInvalidObjectException); } } @@ -168,32 +162,6 @@ class ObjectAccessorWithIdentifierTryCatch : public ObjectAccessorTryCatch { DISALLOW_COPY_AND_ASSIGN(ObjectAccessorWithIdentifierTryCatch); }; -// PPB_Var methods ------------------------------------------------------------- - -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 = 0; - return NULL; - } - *len = static_cast<uint32_t>(str->value().size()); - if (str->value().empty()) - return ""; // Don't return NULL on success. - return str->value().data(); -} - PP_Bool HasProperty(PP_Var var, PP_Var name, PP_Var* exception) { @@ -266,9 +234,7 @@ void EnumerateProperties(PP_Var var, *property_count = count; *properties = static_cast<PP_Var*>(malloc(sizeof(PP_Var) * count)); for (uint32_t i = 0; i < count; ++i) { - (*properties)[i] = NPIdentifierToPPVar( - accessor.GetPluginInstance()->module()->pp_module(), - identifiers[i]); + (*properties)[i] = NPIdentifierToPPVar(identifiers[i]); } free(identifiers); } @@ -426,40 +392,28 @@ PP_Var CreateObjectWithModuleDeprecated(PP_Module pp_module, ppp_class, ppp_class_data); } -const PPB_Var_Deprecated var_deprecated_interface = { - &AddRefVar, - &ReleaseVar, - &VarFromUtf8, - &VarToUtf8, - &HasPropertyDeprecated, - &HasMethodDeprecated, - &GetProperty, - &EnumerateProperties, - &SetPropertyDeprecated, - &DeletePropertyDeprecated, - &CallDeprecated, - &Construct, - &IsInstanceOfDeprecated, - &CreateObjectDeprecated, - &CreateObjectWithModuleDeprecated, -}; - -const PPB_Var var_interface = { - &AddRefVar, - &ReleaseVar, - &VarFromUtf8, - &VarToUtf8 -}; - } // namespace // static -const PPB_Var* PPB_Var_Impl::GetVarInterface() { - return &var_interface; -} +const PPB_Var_Deprecated* PPB_Var_Deprecated_Impl::GetVarDeprecatedInterface() { + 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, + &HasPropertyDeprecated, + &HasMethodDeprecated, + &GetProperty, + &EnumerateProperties, + &SetPropertyDeprecated, + &DeletePropertyDeprecated, + &CallDeprecated, + &Construct, + &IsInstanceOfDeprecated, + &CreateObjectDeprecated, + &CreateObjectWithModuleDeprecated, + }; -// static -const PPB_Var_Deprecated* PPB_Var_Impl::GetVarDeprecatedInterface() { return &var_deprecated_interface; } diff --git a/webkit/plugins/ppapi/ppb_var_impl.h b/webkit/plugins/ppapi/ppb_var_deprecated_impl.h index d2c63a1..5e12400 100644 --- a/webkit/plugins/ppapi/ppb_var_impl.h +++ b/webkit/plugins/ppapi/ppb_var_deprecated_impl.h @@ -2,22 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef WEBKIT_PLUGINS_PPAPI_PPB_VAR_IMPL_H_ -#define WEBKIT_PLUGINS_PPAPI_PPB_VAR_IMPL_H_ +#ifndef WEBKIT_PLUGINS_PPAPI_PPB_VAR_DEPRECATED_IMPL_H_ +#define WEBKIT_PLUGINS_PPAPI_PPB_VAR_DEPRECATED_IMPL_H_ -struct PPB_Var; struct PPB_Var_Deprecated; namespace webkit { namespace ppapi { -class PPB_Var_Impl { +class PPB_Var_Deprecated_Impl { public: - static const PPB_Var* GetVarInterface(); static const PPB_Var_Deprecated* GetVarDeprecatedInterface(); }; } // namespace ppapi } // namespace webkit -#endif // WEBKIT_PLUGINS_PPAPI_PPB_VAR_IMPL_H_ +#endif // WEBKIT_PLUGINS_PPAPI_PPB_VAR_DEPRECATED_IMPL_H_ diff --git a/webkit/plugins/ppapi/ppb_websocket_impl.cc b/webkit/plugins/ppapi/ppb_websocket_impl.cc index 9d4fc20..f460aea 100644 --- a/webkit/plugins/ppapi/ppb_websocket_impl.cc +++ b/webkit/plugins/ppapi/ppb_websocket_impl.cc @@ -84,8 +84,7 @@ PPB_WebSocket_Impl::PPB_WebSocket_Impl(PP_Instance instance) close_was_clean_(PP_FALSE), buffered_amount_(0), buffered_amount_after_close_(0) { - empty_string_ = new StringVar( - PpapiGlobals::Get()->GetModuleForInstance(instance), "", 0); + empty_string_ = new StringVar("", 0); } PPB_WebSocket_Impl::~PPB_WebSocket_Impl() { @@ -133,8 +132,7 @@ int32_t PPB_WebSocket_Impl::Connect(PP_Var url, if (!url_string) return PP_ERROR_BADARGUMENT; GURL gurl(url_string->value()); - url_ = new StringVar( - PpapiGlobals::Get()->GetModuleForInstance(pp_instance()), gurl.spec()); + url_ = new StringVar(gurl.spec()); if (!gurl.is_valid()) return PP_ERROR_BADARGUMENT; if (!gurl.SchemeIs("ws") && !gurl.SchemeIs("wss")) @@ -368,8 +366,7 @@ PP_Var PPB_WebSocket_Impl::GetProtocol() { return empty_string_->GetPPVar(); std::string protocol = websocket_->subprotocol().utf8(); - return StringVar::StringToPPVar( - PpapiGlobals::Get()->GetModuleForInstance(pp_instance()), protocol); + return StringVar::StringToPPVar(protocol); } PP_WebSocketReadyState_Dev PPB_WebSocket_Impl::GetReadyState() { @@ -395,8 +392,7 @@ void PPB_WebSocket_Impl::didReceiveMessage(const WebString& message) { // Append received data to queue. std::string string = message.utf8(); - PP_Var var = StringVar::StringToPPVar( - PpapiGlobals::Get()->GetModuleForInstance(pp_instance()), string); + PP_Var var = StringVar::StringToPPVar(string); received_messages_.push(var); if (!wait_for_receive_) @@ -451,8 +447,7 @@ void PPB_WebSocket_Impl::didClose(unsigned long unhandled_buffered_amount, // Store code and reason. close_code_ = code; std::string reason_string = reason.utf8(); - close_reason_ = new StringVar( - PpapiGlobals::Get()->GetModuleForInstance(pp_instance()), reason_string); + close_reason_ = new StringVar(reason_string); // Set close_was_clean_. bool was_clean = |