diff options
Diffstat (limited to 'ppapi')
46 files changed, 255 insertions, 195 deletions
diff --git a/ppapi/c/dev/ppb_buffer_dev.h b/ppapi/c/dev/ppb_buffer_dev.h index 6788772..49252d6 100644 --- a/ppapi/c/dev/ppb_buffer_dev.h +++ b/ppapi/c/dev/ppb_buffer_dev.h @@ -6,7 +6,7 @@ #define PPAPI_C_DEV_PPB_BUFFER_DEV_H_ #include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_module.h" +#include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" @@ -16,7 +16,7 @@ struct PPB_Buffer_Dev { // Allocates a buffer of the given size in bytes. The return value will have // a non-zero ID on success, or zero on failure. Failure means the module // handle was invalid. The buffer will be initialized to contain zeroes. - PP_Resource (*Create)(PP_Module module, uint32_t size_in_bytes); + PP_Resource (*Create)(PP_Instance instance, uint32_t size_in_bytes); // Returns PP_TRUE if the given resource is a Buffer. Returns PP_FALSE if the // resource is invalid or some type other than a Buffer. diff --git a/ppapi/c/dev/ppb_char_set_dev.h b/ppapi/c/dev/ppb_char_set_dev.h index 74c1ca5..6aca03715 100644 --- a/ppapi/c/dev/ppb_char_set_dev.h +++ b/ppapi/c/dev/ppb_char_set_dev.h @@ -5,8 +5,8 @@ #ifndef PPAPI_C_DEV_PPB_CHAR_SET_DEV_H_ #define PPAPI_C_DEV_PPB_CHAR_SET_DEV_H_ +#include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" -#include "ppapi/c/pp_module.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" @@ -50,7 +50,8 @@ struct PPB_CharSet_Dev { // This function will return NULL if there was an error converting the string // and you requested PP_CHARSET_CONVERSIONERROR_FAIL, or the output character // set was unknown. - char* (*UTF16ToCharSet)(const uint16_t* utf16, uint32_t utf16_len, + char* (*UTF16ToCharSet)(PP_Instance instance, + const uint16_t* utf16, uint32_t utf16_len, const char* output_char_set, enum PP_CharSet_ConversionError on_error, uint32_t* output_length); @@ -63,7 +64,8 @@ struct PPB_CharSet_Dev { // Since UTF16 can represent every Unicode character, the only time the // replacement character will be used is if the encoding in the input string // is incorrect. - uint16_t* (*CharSetToUTF16)(const char* input, uint32_t input_len, + uint16_t* (*CharSetToUTF16)(PP_Instance instance, + const char* input, uint32_t input_len, const char* input_char_set, enum PP_CharSet_ConversionError on_error, uint32_t* output_length); @@ -74,7 +76,7 @@ struct PPB_CharSet_Dev { // WARNING: You really shouldn't be using this function unless you're dealing // with legacy data. You should be using UTF-8 or UTF-16 and you don't have // to worry about the character sets. - struct PP_Var (*GetDefaultCharSet)(PP_Module module); + struct PP_Var (*GetDefaultCharSet)(PP_Instance instance); }; #endif /* PPAPI_C_DEV_PPB_CHAR_SET_DEV_H_ */ diff --git a/ppapi/c/dev/ppb_file_io_dev.h b/ppapi/c/dev/ppb_file_io_dev.h index ee7324d..0758ca9 100644 --- a/ppapi/c/dev/ppb_file_io_dev.h +++ b/ppapi/c/dev/ppb_file_io_dev.h @@ -6,8 +6,8 @@ #define PPAPI_C_DEV_PPB_FILE_IO_DEV_H_ #include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" -#include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" @@ -44,7 +44,7 @@ PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileOpenFlags_Dev, 4); // Use this interface to operate on a regular file (PP_FileType_Regular). struct PPB_FileIO_Dev { // Creates a new FileIO object. Returns 0 if the module is invalid. - PP_Resource (*Create)(PP_Module module); + PP_Resource (*Create)(PP_Instance instance); // Returns PP_TRUE if the given resource is a FileIO. Returns PP_FALSE if the // resource is invalid or some type other than a FileIO. diff --git a/ppapi/c/dev/ppb_font_dev.h b/ppapi/c/dev/ppb_font_dev.h index 2262856..e2bba3c 100644 --- a/ppapi/c/dev/ppb_font_dev.h +++ b/ppapi/c/dev/ppb_font_dev.h @@ -6,8 +6,8 @@ #define PPAPI_C_DEV_PPB_FONT_DEV_H_ #include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" -#include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" @@ -103,7 +103,7 @@ PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_TextRun_Dev, 24); struct PPB_Font_Dev { // Returns a font which best matches the given description. The return value // will have a non-zero ID on success, or zero on failure. - PP_Resource (*Create)(PP_Module module, + PP_Resource (*Create)(PP_Instance instance, const struct PP_FontDescription_Dev* description); // Returns PP_TRUE if the given resource is a Font. Returns PP_FALSE if the diff --git a/ppapi/c/dev/ppb_transport_dev.h b/ppapi/c/dev/ppb_transport_dev.h index 1e56ff4..7dc9ad3 100644 --- a/ppapi/c/dev/ppb_transport_dev.h +++ b/ppapi/c/dev/ppb_transport_dev.h @@ -18,7 +18,7 @@ struct PPB_Transport_Dev { // Creates a new transport object with the specified name // using the specified protocol. - PP_Resource (*CreateTransport)(PP_Module module, + PP_Resource (*CreateTransport)(PP_Instance instance, const char* name, const char* proto); diff --git a/ppapi/c/ppb_url_request_info.h b/ppapi/c/ppb_url_request_info.h index de7e3da..aef42bb 100644 --- a/ppapi/c/ppb_url_request_info.h +++ b/ppapi/c/ppb_url_request_info.h @@ -6,8 +6,8 @@ #define PPAPI_C_PPB_URL_REQUEST_INFO_H_ #include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_macros.h" -#include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" @@ -35,11 +35,11 @@ typedef enum { } PP_URLRequestProperty; PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_URLRequestProperty, 4); -#define PPB_URLREQUESTINFO_INTERFACE "PPB_URLRequestInfo;0.1" +#define PPB_URLREQUESTINFO_INTERFACE "PPB_URLRequestInfo;0.2" struct PPB_URLRequestInfo { // Create a new URLRequestInfo object. Returns 0 if the module is invalid. - PP_Resource (*Create)(PP_Module module); + PP_Resource (*Create)(PP_Instance instance); // Returns PP_TRUE if the given resource is an URLRequestInfo. Returns // PP_FALSE if the resource is invalid or some type other than an diff --git a/ppapi/c/private/ppb_flash.h b/ppapi/c/private/ppb_flash.h index 49535e4..f689772 100644 --- a/ppapi/c/private/ppb_flash.h +++ b/ppapi/c/private/ppb_flash.h @@ -11,7 +11,6 @@ #include "ppapi/c/pp_errors.h" #include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_module.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_resource.h" @@ -19,7 +18,7 @@ // PPB_Flash ------------------------------------------------------------------- -#define PPB_FLASH_INTERFACE "PPB_Flash;2" +#define PPB_FLASH_INTERFACE "PPB_Flash;3" #ifdef _WIN32 typedef HANDLE PP_FileHandle; @@ -49,7 +48,8 @@ struct PPB_Flash { // this case. void (*SetInstanceAlwaysOnTop)(PP_Instance instance, bool on_top); - bool (*DrawGlyphs)(PP_Resource pp_image_data, + bool (*DrawGlyphs)(PP_Instance instance, + PP_Resource pp_image_data, const PP_FontDescription_Dev* font_desc, uint32_t color, PP_Point position, @@ -61,21 +61,21 @@ struct PPB_Flash { // Retrieves the proxy that will be used for the given URL. The result will // be a string in PAC format, or an undefined var on error. - PP_Var (*GetProxyForURL)(PP_Module module, const char* url); + PP_Var (*GetProxyForURL)(PP_Instance instance, const char* url); // Opens a module-local file, returning a file descriptor (posix) or a HANDLE // (win32) into file. Module-local file paths (here and below) are // '/'-separated UTF-8 strings, relative to a module-specific root. The return // value is the ppapi error, PP_OK if success, one of the PP_ERROR_* in case // of failure. - int32_t (*OpenModuleLocalFile)(PP_Module module, + int32_t (*OpenModuleLocalFile)(PP_Instance instance, const char* path, int32_t mode, PP_FileHandle* file); // Renames a module-local file. The return value is the ppapi error, PP_OK if // success, one of the PP_ERROR_* in case of failure. - int32_t (*RenameModuleLocalFile)(PP_Module module, + int32_t (*RenameModuleLocalFile)(PP_Instance instance, const char* path_from, const char* path_to); @@ -83,17 +83,17 @@ struct PPB_Flash { // points to a directory, deletes all the contents of the directory. The // return value is the ppapi error, PP_OK if success, one of the PP_ERROR_* in // case of failure. - int32_t (*DeleteModuleLocalFileOrDir)(PP_Module module, + int32_t (*DeleteModuleLocalFileOrDir)(PP_Instance instance, const char* path, bool recursive); // Creates a module-local directory. The return value is the ppapi error, // PP_OK if success, one of the PP_ERROR_* in case of failure. - int32_t (*CreateModuleLocalDir)(PP_Module module, const char* path); + int32_t (*CreateModuleLocalDir)(PP_Instance instance, const char* path); // Queries information about a module-local file. The return value is the // ppapi error, PP_OK if success, one of the PP_ERROR_* in case of failure. - int32_t (*QueryModuleLocalFile)(PP_Module module, + int32_t (*QueryModuleLocalFile)(PP_Instance instance, const char* path, PP_FileInfo_Dev* info); @@ -101,12 +101,12 @@ struct PPB_Flash { // value is the ppapi error, PP_OK if success, one of the PP_ERROR_* in case // of failure. If non-NULL, the returned contents should be freed with // FreeModuleLocalDirContents. - int32_t (*GetModuleLocalDirContents)(PP_Module module, + int32_t (*GetModuleLocalDirContents)(PP_Instance instance, const char* path, PP_DirContents_Dev** contents); // Frees the data allocated by GetModuleLocalDirContents. - void (*FreeModuleLocalDirContents)(PP_Module module, + void (*FreeModuleLocalDirContents)(PP_Instance instance, PP_DirContents_Dev* contents); // Navigate to URL. May open a new tab if target is not "_self". Return true diff --git a/ppapi/c/private/ppb_pdf.h b/ppapi/c/private/ppb_pdf.h index 8a03525..cdc384a 100644 --- a/ppapi/c/private/ppb_pdf.h +++ b/ppapi/c/private/ppb_pdf.h @@ -7,7 +7,6 @@ #include "ppapi/c/dev/ppb_font_dev.h" #include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_var.h" @@ -83,10 +82,11 @@ struct PP_PrivateFindResult { struct PPB_PDF { // Returns a localized string. - PP_Var (*GetLocalizedString)(PP_Module module, PP_ResourceString string_id); + PP_Var (*GetLocalizedString)(PP_Instance instance, + PP_ResourceString string_id); // Returns a resource image. - PP_Resource (*GetResourceImage)(PP_Module module, + PP_Resource (*GetResourceImage)(PP_Instance instance, PP_ResourceImage image_id); // Returns a resource identifying a font file corresponding to the given font @@ -94,7 +94,7 @@ struct PPB_PDF { // // Currently Linux-only. PP_Resource (*GetFontFileWithFallback)( - PP_Module module, + PP_Instance instance, const PP_FontDescription_Dev* description, PP_PrivateFontCharset charset); @@ -108,7 +108,7 @@ struct PPB_PDF { // Search the given string using ICU. Use PPB_Core's MemFree on results when // done. void (*SearchString)( - PP_Module module, + PP_Instance instance, const unsigned short* string, const unsigned short* term, bool case_sensitive, diff --git a/ppapi/cpp/dev/buffer_dev.cc b/ppapi/cpp/dev/buffer_dev.cc index 678211a..8a41ab4 100644 --- a/ppapi/cpp/dev/buffer_dev.cc +++ b/ppapi/cpp/dev/buffer_dev.cc @@ -28,12 +28,14 @@ Buffer_Dev::Buffer_Dev(const Buffer_Dev& other) size_(other.size_) { } -Buffer_Dev::Buffer_Dev(uint32_t size) : data_(NULL), size_(0) { +Buffer_Dev::Buffer_Dev(Instance* instance, uint32_t size) + : data_(NULL), + size_(0) { if (!has_interface<PPB_Buffer_Dev>()) return; PassRefFromConstructor(get_interface<PPB_Buffer_Dev>()->Create( - Module::Get()->pp_module(), size)); + instance->pp_instance(), size)); if (!get_interface<PPB_Buffer_Dev>()->Describe(pp_resource(), &size_) || !(data_ = get_interface<PPB_Buffer_Dev>()->Map(pp_resource()))) *this = Buffer_Dev(); diff --git a/ppapi/cpp/dev/buffer_dev.h b/ppapi/cpp/dev/buffer_dev.h index e5f7325..83c265c2 100644 --- a/ppapi/cpp/dev/buffer_dev.h +++ b/ppapi/cpp/dev/buffer_dev.h @@ -9,6 +9,8 @@ namespace pp { +class Instance; + class Buffer_Dev : public Resource { public: // Creates an is_null() Buffer object. @@ -18,7 +20,7 @@ class Buffer_Dev : public Resource { // Allocates a new Buffer in the browser with the given size. The // resulting object will be is_null() if the allocation failed. - explicit Buffer_Dev(uint32_t size); + Buffer_Dev(Instance* instance, uint32_t size); uint32_t size() const { return size_; } void* data() const { return data_; } diff --git a/ppapi/cpp/dev/file_io_dev.cc b/ppapi/cpp/dev/file_io_dev.cc index 5dae1d3..1fc273b 100644 --- a/ppapi/cpp/dev/file_io_dev.cc +++ b/ppapi/cpp/dev/file_io_dev.cc @@ -9,6 +9,7 @@ #include "ppapi/c/pp_errors.h" #include "ppapi/cpp/completion_callback.h" #include "ppapi/cpp/dev/file_ref_dev.h" +#include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" @@ -23,10 +24,13 @@ template <> const char* interface_name<PPB_FileIO_Dev>() { } // namespace FileIO_Dev::FileIO_Dev() { +} + +FileIO_Dev::FileIO_Dev(Instance* instance) { if (!has_interface<PPB_FileIO_Dev>()) return; PassRefFromConstructor(get_interface<PPB_FileIO_Dev>()->Create( - Module::Get()->pp_module())); + instance->pp_instance())); } FileIO_Dev::FileIO_Dev(const FileIO_Dev& other) diff --git a/ppapi/cpp/dev/file_io_dev.h b/ppapi/cpp/dev/file_io_dev.h index 1da3652..532f76a 100644 --- a/ppapi/cpp/dev/file_io_dev.h +++ b/ppapi/cpp/dev/file_io_dev.h @@ -14,10 +14,14 @@ namespace pp { class CompletionCallback; class FileRef_Dev; +class Instance; class FileIO_Dev : public Resource { public: + // Constructs an is_null resource. FileIO_Dev(); + + FileIO_Dev(Instance* instance); FileIO_Dev(const FileIO_Dev& other); // PPB_FileIO methods: diff --git a/ppapi/cpp/dev/font_dev.cc b/ppapi/cpp/dev/font_dev.cc index 6394b81..4ca85b0 100644 --- a/ppapi/cpp/dev/font_dev.cc +++ b/ppapi/cpp/dev/font_dev.cc @@ -8,7 +8,7 @@ #include "ppapi/cpp/common.h" #include "ppapi/cpp/image_data.h" -#include "ppapi/cpp/module.h" +#include "ppapi/cpp/instance.h" #include "ppapi/cpp/point.h" #include "ppapi/cpp/rect.h" #include "ppapi/cpp/module_impl.h" @@ -103,11 +103,11 @@ Font_Dev::Font_Dev() : Resource() { Font_Dev::Font_Dev(PP_Resource resource) : Resource(resource) { } -Font_Dev::Font_Dev(const FontDescription_Dev& description) { +Font_Dev::Font_Dev(Instance* instance, const FontDescription_Dev& description) { if (!has_interface<PPB_Font_Dev>()) return; PassRefFromConstructor(get_interface<PPB_Font_Dev>()->Create( - Module::Get()->pp_module(), &description.pp_font_description())); + instance->pp_instance(), &description.pp_font_description())); } Font_Dev::Font_Dev(const Font_Dev& other) : Resource(other) { diff --git a/ppapi/cpp/dev/font_dev.h b/ppapi/cpp/dev/font_dev.h index 137258c..fb31311 100644 --- a/ppapi/cpp/dev/font_dev.h +++ b/ppapi/cpp/dev/font_dev.h @@ -105,7 +105,7 @@ class Font_Dev : public Resource { Font_Dev(); explicit Font_Dev(PP_Resource resource); - explicit Font_Dev(const FontDescription_Dev& description); + explicit Font_Dev(Instance* instance, const FontDescription_Dev& description); Font_Dev(const Font_Dev& other); Font_Dev& operator=(const Font_Dev& other); diff --git a/ppapi/cpp/dev/transport_dev.cc b/ppapi/cpp/dev/transport_dev.cc index 0ea4a34..241c3bd 100644 --- a/ppapi/cpp/dev/transport_dev.cc +++ b/ppapi/cpp/dev/transport_dev.cc @@ -19,11 +19,12 @@ template <> const char* interface_name<PPB_Transport_Dev>() { } // namespace -Transport_Dev::Transport_Dev(const char* name, +Transport_Dev::Transport_Dev(Instance* instance, + const char* name, const char* proto) { if (has_interface<PPB_Transport_Dev>()) PassRefFromConstructor(get_interface<PPB_Transport_Dev>()->CreateTransport( - Module::Get()->pp_module(), name, proto)); + instance->pp_instance(), name, proto)); } } // namespace pp diff --git a/ppapi/cpp/dev/transport_dev.h b/ppapi/cpp/dev/transport_dev.h index a9b73c2..a03b232 100644 --- a/ppapi/cpp/dev/transport_dev.h +++ b/ppapi/cpp/dev/transport_dev.h @@ -6,15 +6,16 @@ #define PPAPI_CPP_DEV_TRANSPORT_DEV_H_ #include "ppapi/c/dev/ppb_transport_dev.h" -#include "ppapi/cpp/instance.h" #include "ppapi/cpp/resource.h" namespace pp { +class Instance; + class Transport_Dev : public Resource { public: Transport_Dev() {} - Transport_Dev(const char* name, const char* proto); + Transport_Dev(Instance* instance, const char* name, const char* proto); }; } // namespace pp diff --git a/ppapi/cpp/url_loader.cc b/ppapi/cpp/url_loader.cc index 8ef6087..81bcdfd 100644 --- a/ppapi/cpp/url_loader.cc +++ b/ppapi/cpp/url_loader.cc @@ -28,6 +28,7 @@ template <> const char* interface_name<PPB_URLLoader>() { URLLoader::URLLoader(PP_Resource resource) : Resource(resource) { } +// TODO(brettw) remove this when NaCl is updated. URLLoader::URLLoader(const Instance& instance) { if (!has_interface<PPB_URLLoader>()) return; @@ -35,6 +36,13 @@ URLLoader::URLLoader(const Instance& instance) { instance.pp_instance())); } +URLLoader::URLLoader(Instance* instance) { + if (!has_interface<PPB_URLLoader>()) + return; + PassRefFromConstructor(get_interface<PPB_URLLoader>()->Create( + instance->pp_instance())); +} + URLLoader::URLLoader(const URLLoader& other) : Resource(other) { } diff --git a/ppapi/cpp/url_loader.h b/ppapi/cpp/url_loader.h index 15f81fa..387d1dc2 100644 --- a/ppapi/cpp/url_loader.h +++ b/ppapi/cpp/url_loader.h @@ -21,7 +21,7 @@ class URLResponseInfo; // // class MyHandler { // public: -// MyHandler(const Instance& instance) +// MyHandler(Instance* instance) // : factory_(this), // loader_(instance), // did_open_(false) { @@ -80,8 +80,12 @@ class URLLoader : public Resource { // Creates an is_null() URLLoader object. URLLoader() {} - explicit URLLoader(PP_Resource resource); + // TODO(brettw) remove this when NaCl is updated to use the new version + // that takes a pointer. explicit URLLoader(const Instance& instance); + + explicit URLLoader(PP_Resource resource); + explicit URLLoader(Instance* instance); URLLoader(const URLLoader& other); // PPB_URLLoader methods: diff --git a/ppapi/cpp/url_request_info.cc b/ppapi/cpp/url_request_info.cc index 30f339b..76cf832 100644 --- a/ppapi/cpp/url_request_info.cc +++ b/ppapi/cpp/url_request_info.cc @@ -6,6 +6,7 @@ #include "ppapi/cpp/common.h" #include "ppapi/cpp/dev/file_ref_dev.h" +#include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" @@ -19,11 +20,11 @@ template <> const char* interface_name<PPB_URLRequestInfo>() { } // namespace -URLRequestInfo::URLRequestInfo() { +URLRequestInfo::URLRequestInfo(Instance* instance) { if (!has_interface<PPB_URLRequestInfo>()) return; PassRefFromConstructor( - get_interface<PPB_URLRequestInfo>()->Create(Module::Get()->pp_module())); + get_interface<PPB_URLRequestInfo>()->Create(instance->pp_instance())); } URLRequestInfo::URLRequestInfo(const URLRequestInfo& other) diff --git a/ppapi/cpp/url_request_info.h b/ppapi/cpp/url_request_info.h index 10defc1..3c7c47d 100644 --- a/ppapi/cpp/url_request_info.h +++ b/ppapi/cpp/url_request_info.h @@ -12,10 +12,14 @@ namespace pp { class FileRef_Dev; +class Instance; class URLRequestInfo : public Resource { public: - URLRequestInfo(); + // Creates an is_null resource. + URLRequestInfo() {} + + explicit URLRequestInfo(Instance* instance); URLRequestInfo(const URLRequestInfo& other); // PPB_URLRequestInfo methods: diff --git a/ppapi/proxy/plugin_var_tracker.cc b/ppapi/proxy/plugin_var_tracker.cc index f2bc5975..6ad396a 100644 --- a/ppapi/proxy/plugin_var_tracker.cc +++ b/ppapi/proxy/plugin_var_tracker.cc @@ -50,6 +50,12 @@ int64 PluginVarTracker::MakeString(const std::string& str) { return static_cast<int64>(reinterpret_cast<intptr_t>(out)); } +int64 PluginVarTracker::MakeString(const char* str, uint32_t len) { + RefCountedString* out = new RefCountedString(str, len); + out->AddRef(); + return static_cast<int64>(reinterpret_cast<intptr_t>(out)); +} + std::string PluginVarTracker::GetString(const PP_Var& var) const { return PluginStringFromID(var.value.as_id)->value(); } diff --git a/ppapi/proxy/plugin_var_tracker.h b/ppapi/proxy/plugin_var_tracker.h index 999f209..9a1b9ab 100644 --- a/ppapi/proxy/plugin_var_tracker.h +++ b/ppapi/proxy/plugin_var_tracker.h @@ -37,6 +37,7 @@ class PluginVarTracker { // Allocates a string and returns the ID of it. The refcount will be 1. int64_t MakeString(const std::string& str); + int64_t MakeString(const char* str, uint32_t len); // Returns the string associated with the given string var. The var must be // of type string and must be valid or this function will crash. diff --git a/ppapi/proxy/ppapi_messages_internal.h b/ppapi/proxy/ppapi_messages_internal.h index ca34ecf..6302bad 100644 --- a/ppapi/proxy/ppapi_messages_internal.h +++ b/ppapi/proxy/ppapi_messages_internal.h @@ -167,7 +167,7 @@ IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBAudio_StartOrStop, // PPB_AudioConfig. IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBAudioConfig_Create, - PP_Module /* module */, + PP_Instance /* instance */, int32_t /* sample_rate */, uint32_t /* sample_frame_count */, PP_Resource /* result */) @@ -179,7 +179,7 @@ IPC_SYNC_MESSAGE_ROUTED2_1( // PPB_Buffer. IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBBuffer_Create, - PP_Module /* module */, + PP_Instance /* instance */, uint32_t /* size */, PP_Resource /* result_resource */, int32_t /* result_shm_handle */) @@ -189,20 +189,22 @@ IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBCore_AddRefResource, PP_Resource) IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBCore_ReleaseResource, PP_Resource) // PPB_CharSet. -IPC_SYNC_MESSAGE_ROUTED3_2(PpapiHostMsg_PPBCharSet_UTF16ToCharSet, +IPC_SYNC_MESSAGE_ROUTED4_2(PpapiHostMsg_PPBCharSet_UTF16ToCharSet, + PP_Instance /* instance */, string16 /* utf16 */, std::string /* char_set */, int32_t /* on_error */, std::string /* output */, bool /* output_is_success */) -IPC_SYNC_MESSAGE_ROUTED3_2(PpapiHostMsg_PPBCharSet_CharSetToUTF16, +IPC_SYNC_MESSAGE_ROUTED4_2(PpapiHostMsg_PPBCharSet_CharSetToUTF16, + PP_Instance /* instance */, std::string /* input */, std::string /* char_set */, int32_t /* on_error */, string16 /* output */, bool /* output_is_success */) IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBCharSet_GetDefaultCharSet, - PP_Module /* module */, + PP_Instance /* instance */, pp::proxy::SerializedVar /* result */) // PPB_CursorControl. @@ -235,37 +237,37 @@ IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBFlash_DrawGlyphs, pp::proxy::PPBFlash_DrawGlyphs_Params /* params */, bool /* result */) IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFlash_GetProxyForURL, - PP_Module /* module */, + PP_Instance /* instance */, std::string /* url */, pp::proxy::SerializedVar /* result */) IPC_SYNC_MESSAGE_ROUTED3_2(PpapiHostMsg_PPBFlash_OpenModuleLocalFile, - PP_Module /* module */, + PP_Instance /* instance */, std::string /* path */, int32_t /* mode */, IPC::PlatformFileForTransit /* file_handle */, int32_t /* result */) IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBFlash_RenameModuleLocalFile, - PP_Module /* module */, + PP_Instance /* instance */, std::string /* path_from */, std::string /* path_to */, int32_t /* result */) IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBFlash_DeleteModuleLocalFileOrDir, - PP_Module /* module */, + PP_Instance /* instance */, std::string /* path */, bool /* recursive */, int32_t /* result */) IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFlash_CreateModuleLocalDir, - PP_Module /* module */, + PP_Instance /* instance */, std::string /* path */, int32_t /* result */) IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBFlash_QueryModuleLocalFile, - PP_Module /* module */, + PP_Instance /* instance */, std::string /* path */, PP_FileInfo_Dev /* info */, int32_t /* result */) IPC_SYNC_MESSAGE_ROUTED2_2( PpapiHostMsg_PPBFlash_GetModuleLocalDirContents, - PP_Module /* module */, + PP_Instance /* instance */, std::string /* path */, std::vector<pp::proxy::SerializedDirEntry> /* entries */, int32_t /* result */) @@ -278,7 +280,7 @@ IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBFlash_NavigateToURL, // PPB_Font. IPC_SYNC_MESSAGE_ROUTED2_3( PpapiHostMsg_PPBFont_Create, - PP_Module /* pp_module */, + PP_Instance /* instance */, pp::proxy::SerializedFontDescription /* in_description */, PP_Resource /* result */, pp::proxy::SerializedFontDescription /* out_description */, @@ -319,7 +321,7 @@ IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFullscreen_SetFullscreen, // PPB_Graphics2D. IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBGraphics2D_Create, - PP_Module /* module */, + PP_Instance /* instance */, PP_Size /* size */, PP_Bool /* is_always_opaque */, PP_Resource /* result */) @@ -349,7 +351,7 @@ IPC_SYNC_MESSAGE_ROUTED1_1( int32 /* format */, PP_Bool /* result */) IPC_SYNC_MESSAGE_ROUTED4_3(PpapiHostMsg_PPBImageData_Create, - PP_Module /* module */, + PP_Instance /* instance */, int32 /* format */, PP_Size /* size */, PP_Bool /* init_to_zero */, @@ -379,7 +381,7 @@ IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBInstance_ExecuteScript, IPC_SYNC_MESSAGE_ROUTED3_1( PpapiHostMsg_PPBPDF_GetFontFileWithFallback, - PP_Module /* module */, + PP_Instance /* instance */, pp::proxy::SerializedFontDescription /* description */, int32_t /* charset */, PP_Resource /* result */) @@ -431,7 +433,7 @@ IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBURLLoaderTrusted_GrantUniversalAccess, // PPB_URLRequestInfo. IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBURLRequestInfo_Create, - PP_Module /* module */, + PP_Instance /* instance */, PP_Resource /* result */) IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBURLRequestInfo_SetProperty, PP_Resource /* request */, @@ -527,7 +529,7 @@ IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBVar_IsInstanceOfDeprecated, int64 /* object-data */, PP_Bool /* result */) IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBVar_CreateObjectDeprecated, - PP_Module /* module */, + PP_Instance /* instance */, int64 /* object_class */, int64 /* object_data */, pp::proxy::SerializedVar /* result */) diff --git a/ppapi/proxy/ppapi_param_traits.cc b/ppapi/proxy/ppapi_param_traits.cc index dbd527d..dbbc643 100644 --- a/ppapi/proxy/ppapi_param_traits.cc +++ b/ppapi/proxy/ppapi_param_traits.cc @@ -186,6 +186,7 @@ void ParamTraits<PP_Size>::Log(const param_type& p, std::string* l) { void ParamTraits<pp::proxy::PPBFlash_DrawGlyphs_Params>::Write( Message* m, const param_type& p) { + ParamTraits<PP_Instance>::Write(m, p.instance); ParamTraits<PP_Resource>::Write(m, p.pp_image_data); ParamTraits<pp::proxy::SerializedFontDescription>::Write(m, p.font_desc); ParamTraits<uint32_t>::Write(m, p.color); @@ -210,6 +211,7 @@ bool ParamTraits<pp::proxy::PPBFlash_DrawGlyphs_Params>::Read( void** iter, param_type* r) { return + ParamTraits<PP_Instance>::Read(m, iter, &r->instance) && ParamTraits<PP_Resource>::Read(m, iter, &r->pp_image_data) && ParamTraits<pp::proxy::SerializedFontDescription>::Read(m, iter, &r->font_desc) && diff --git a/ppapi/proxy/ppb_audio_config_proxy.cc b/ppapi/proxy/ppb_audio_config_proxy.cc index 1675217..0d0e6a7 100644 --- a/ppapi/proxy/ppb_audio_config_proxy.cc +++ b/ppapi/proxy/ppb_audio_config_proxy.cc @@ -35,12 +35,12 @@ class AudioConfig : public PluginResource { namespace { -PP_Resource CreateStereo16bit(PP_Module module_id, +PP_Resource CreateStereo16bit(PP_Instance instance, PP_AudioSampleRate sample_rate, uint32_t sample_frame_count) { PP_Resource result = 0; PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBAudioConfig_Create( - INTERFACE_ID_PPB_AUDIO_CONFIG, module_id, + INTERFACE_ID_PPB_AUDIO_CONFIG, instance, static_cast<int32_t>(sample_rate), sample_frame_count, &result)); if (!result) @@ -120,12 +120,12 @@ bool PPB_AudioConfig_Proxy::OnMessageReceived(const IPC::Message& msg) { return handled; } -void PPB_AudioConfig_Proxy::OnMsgCreateStereo16Bit(PP_Module module, +void PPB_AudioConfig_Proxy::OnMsgCreateStereo16Bit(PP_Instance instance, int32_t sample_rate, uint32_t sample_frame_count, PP_Resource* result) { *result = ppb_audio_config_target()->CreateStereo16Bit( - module, static_cast<PP_AudioSampleRate>(sample_rate), + instance, static_cast<PP_AudioSampleRate>(sample_rate), sample_frame_count); } diff --git a/ppapi/proxy/ppb_audio_config_proxy.h b/ppapi/proxy/ppb_audio_config_proxy.h index 459d791..c5ef56d 100644 --- a/ppapi/proxy/ppb_audio_config_proxy.h +++ b/ppapi/proxy/ppb_audio_config_proxy.h @@ -6,7 +6,7 @@ #define PPAPI_PROXY_PPB_AUDIO_CONFIG_PROXY_H_ #include "base/basictypes.h" -#include "ppapi/c/pp_module.h" +#include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/proxy/interface_proxy.h" @@ -31,7 +31,7 @@ class PPB_AudioConfig_Proxy : public InterfaceProxy { private: // Message handlers. - void OnMsgCreateStereo16Bit(PP_Module module, + void OnMsgCreateStereo16Bit(PP_Instance instance, int32_t sample_rate, uint32_t sample_frame_count, PP_Resource* result); diff --git a/ppapi/proxy/ppb_buffer_proxy.cc b/ppapi/proxy/ppb_buffer_proxy.cc index 0015f5e..4963b7b 100644 --- a/ppapi/proxy/ppb_buffer_proxy.cc +++ b/ppapi/proxy/ppb_buffer_proxy.cc @@ -61,12 +61,12 @@ void Buffer::Unmap() { namespace { -PP_Resource Create(PP_Module module_id, uint32_t size) { +PP_Resource Create(PP_Instance instance, uint32_t size) { PP_Resource result = 0; int32_t shm_handle = -1; PluginDispatcher::Get()->Send( new PpapiHostMsg_PPBBuffer_Create( - INTERFACE_ID_PPB_BUFFER, module_id, size, + INTERFACE_ID_PPB_BUFFER, instance, size, &result, &shm_handle)); if (!result) return 0; @@ -141,11 +141,11 @@ bool PPB_Buffer_Proxy::OnMessageReceived(const IPC::Message& msg) { return handled; } -void PPB_Buffer_Proxy::OnMsgCreate(PP_Module module, +void PPB_Buffer_Proxy::OnMsgCreate(PP_Instance instance, uint32_t size, PP_Resource* result_resource, int* result_shm_handle) { - *result_resource = ppb_buffer_target()->Create(module, size); + *result_resource = ppb_buffer_target()->Create(instance, size); // TODO(brettw) set the shm handle from a trusted interface. *result_shm_handle = 0; } diff --git a/ppapi/proxy/ppb_buffer_proxy.h b/ppapi/proxy/ppb_buffer_proxy.h index ccd6721..bec74f7 100644 --- a/ppapi/proxy/ppb_buffer_proxy.h +++ b/ppapi/proxy/ppb_buffer_proxy.h @@ -5,7 +5,7 @@ #ifndef PPAPI_PPB_BUFFER_PROXY_H_ #define PPAPI_PPB_BUFFER_PROXY_H_ -#include "ppapi/c/pp_module.h" +#include "ppapi/c/pp_instance.h" #include "ppapi/proxy/interface_proxy.h" struct PPB_Buffer_Dev; @@ -29,7 +29,7 @@ class PPB_Buffer_Proxy : public InterfaceProxy { private: // Message handlers. - void OnMsgCreate(PP_Module module, + void OnMsgCreate(PP_Instance instance, uint32_t size, PP_Resource* result_resource, int* result_shm_handle); diff --git a/ppapi/proxy/ppb_char_set_proxy.cc b/ppapi/proxy/ppb_char_set_proxy.cc index ad65084..e0be4aa 100644 --- a/ppapi/proxy/ppb_char_set_proxy.cc +++ b/ppapi/proxy/ppb_char_set_proxy.cc @@ -15,14 +15,15 @@ namespace proxy { namespace { -char* UTF16ToCharSet(const uint16_t* utf16, uint32_t utf16_len, +char* UTF16ToCharSet(PP_Instance instance, + const uint16_t* utf16, uint32_t utf16_len, const char* output_char_set, PP_CharSet_ConversionError on_error, uint32_t* output_length) { bool output_is_success = false; std::string result; PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBCharSet_UTF16ToCharSet( - INTERFACE_ID_PPB_CHAR_SET, + INTERFACE_ID_PPB_CHAR_SET, instance, string16(reinterpret_cast<const char16*>(utf16), utf16_len), std::string(output_char_set), static_cast<int32_t>(on_error), &result, &output_is_success)); @@ -35,14 +36,15 @@ char* UTF16ToCharSet(const uint16_t* utf16, uint32_t utf16_len, return ret_val; } -uint16_t* CharSetToUTF16(const char* input, uint32_t input_len, +uint16_t* CharSetToUTF16(PP_Instance instance, + const char* input, uint32_t input_len, const char* input_char_set, PP_CharSet_ConversionError on_error, uint32_t* output_length) { bool output_is_success = false; string16 result; PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBCharSet_CharSetToUTF16( - INTERFACE_ID_PPB_CHAR_SET, + INTERFACE_ID_PPB_CHAR_SET, instance, std::string(input, input_len), std::string(input_char_set), static_cast<int32_t>(on_error), &result, &output_is_success)); @@ -56,10 +58,10 @@ uint16_t* CharSetToUTF16(const char* input, uint32_t input_len, return ret_val; } -PP_Var GetDefaultCharSet(PP_Module pp_module) { +PP_Var GetDefaultCharSet(PP_Instance instance) { ReceiveSerializedVarReturnValue result; PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBCharSet_GetDefaultCharSet( - INTERFACE_ID_PPB_CHAR_SET, pp_module, &result)); + INTERFACE_ID_PPB_CHAR_SET, instance, &result)); return result.Return(PluginDispatcher::Get()); } @@ -102,14 +104,15 @@ bool PPB_CharSet_Proxy::OnMessageReceived(const IPC::Message& msg) { return handled; } -void PPB_CharSet_Proxy::OnMsgUTF16ToCharSet(const string16& utf16, +void PPB_CharSet_Proxy::OnMsgUTF16ToCharSet(PP_Instance instance, + const string16& utf16, const std::string& char_set, int32_t on_error, std::string* output, bool* output_is_success) { uint32_t output_len = 0; char* result = ppb_char_set_target()->UTF16ToCharSet( - reinterpret_cast<const uint16_t*>(utf16.c_str()), + instance, reinterpret_cast<const uint16_t*>(utf16.c_str()), static_cast<uint32_t>(utf16.size()), char_set.c_str(), static_cast<PP_CharSet_ConversionError>(on_error), &output_len); @@ -122,14 +125,15 @@ void PPB_CharSet_Proxy::OnMsgUTF16ToCharSet(const string16& utf16, } } -void PPB_CharSet_Proxy::OnMsgCharSetToUTF16(const std::string& input, +void PPB_CharSet_Proxy::OnMsgCharSetToUTF16(PP_Instance instance, + const std::string& input, const std::string& char_set, int32_t on_error, string16* output, bool* output_is_success) { uint32_t output_len = 0; uint16_t* result = ppb_char_set_target()->CharSetToUTF16( - input.c_str(), static_cast<uint32_t>(input.size()), + instance, input.c_str(), static_cast<uint32_t>(input.size()), char_set.c_str(), static_cast<PP_CharSet_ConversionError>(on_error), &output_len); if (result) { @@ -142,10 +146,10 @@ void PPB_CharSet_Proxy::OnMsgCharSetToUTF16(const std::string& input, } void PPB_CharSet_Proxy::OnMsgGetDefaultCharSet( - PP_Module module, + PP_Instance instance, SerializedVarReturnValue result) { result.Return(dispatcher(), - ppb_char_set_target()->GetDefaultCharSet(module)); + ppb_char_set_target()->GetDefaultCharSet(instance)); } const PPB_Core* PPB_CharSet_Proxy::GetCoreInterface() { diff --git a/ppapi/proxy/ppb_char_set_proxy.h b/ppapi/proxy/ppb_char_set_proxy.h index d944373..7a80fcb 100644 --- a/ppapi/proxy/ppb_char_set_proxy.h +++ b/ppapi/proxy/ppb_char_set_proxy.h @@ -6,7 +6,7 @@ #define PPAPI_PROXY_PPB_CHAR_SET_PROXY_H_ #include "base/basictypes.h" -#include "ppapi/c/pp_module.h" +#include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/proxy/interface_proxy.h" @@ -34,17 +34,19 @@ class PPB_CharSet_Proxy : public InterfaceProxy { private: // Message handlers. - void OnMsgUTF16ToCharSet(const string16& utf16, + void OnMsgUTF16ToCharSet(PP_Instance instance, + const string16& utf16, const std::string& char_set, int32_t on_error, std::string* output, bool* output_is_success); - void OnMsgCharSetToUTF16(const std::string& input, + void OnMsgCharSetToUTF16(PP_Instance instance, + const std::string& input, const std::string& char_set, int32_t on_error, string16* output, bool* output_is_success); - void OnMsgGetDefaultCharSet(PP_Module module, + void OnMsgGetDefaultCharSet(PP_Instance instance, SerializedVarReturnValue result); // Returns the local PPB_Core interface for freeing strings. diff --git a/ppapi/proxy/ppb_flash_proxy.cc b/ppapi/proxy/ppb_flash_proxy.cc index 2599f94..0cffa3c 100644 --- a/ppapi/proxy/ppb_flash_proxy.cc +++ b/ppapi/proxy/ppb_flash_proxy.cc @@ -55,7 +55,8 @@ void SetInstanceAlwaysOnTop(PP_Instance pp_instance, bool on_top) { INTERFACE_ID_PPB_FLASH, pp_instance, on_top)); } -bool DrawGlyphs(PP_Resource pp_image_data, +bool DrawGlyphs(PP_Instance instance, + PP_Resource pp_image_data, const PP_FontDescription_Dev* font_desc, uint32_t color, PP_Point position, @@ -67,6 +68,7 @@ bool DrawGlyphs(PP_Resource pp_image_data, Dispatcher* dispatcher = PluginDispatcher::Get(); PPBFlash_DrawGlyphs_Params params; + params.instance = instance, params.pp_image_data = pp_image_data; params.font_desc.SetFromPPFontDescription(dispatcher, *font_desc, true); params.color = color; @@ -90,69 +92,69 @@ bool DrawGlyphs(PP_Resource pp_image_data, return result; } -PP_Var GetProxyForURL(PP_Module pp_module, const char* url) { +PP_Var GetProxyForURL(PP_Instance instance, const char* url) { ReceiveSerializedVarReturnValue result; PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL( - INTERFACE_ID_PPB_FLASH, pp_module, url, &result)); + INTERFACE_ID_PPB_FLASH, instance, url, &result)); return result.Return(PluginDispatcher::Get()); } -int32_t OpenModuleLocalFile(PP_Module module, +int32_t OpenModuleLocalFile(PP_Instance instance, const char* path, int32_t mode, PP_FileHandle* file) { int32_t result = PP_ERROR_FAILED; IPC::PlatformFileForTransit transit; PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBFlash_OpenModuleLocalFile( - INTERFACE_ID_PPB_FLASH, module, path, mode, &transit, &result)); + INTERFACE_ID_PPB_FLASH, instance, path, mode, &transit, &result)); *file = IPC::PlatformFileForTransitToPlatformFile(transit); return result; } -int32_t RenameModuleLocalFile(PP_Module module, +int32_t RenameModuleLocalFile(PP_Instance instance, const char* path_from, const char* path_to) { int32_t result = PP_ERROR_FAILED; PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBFlash_RenameModuleLocalFile( - INTERFACE_ID_PPB_FLASH, module, path_from, path_to, &result)); + INTERFACE_ID_PPB_FLASH, instance, path_from, path_to, &result)); return result; } -int32_t DeleteModuleLocalFileOrDir(PP_Module module, +int32_t DeleteModuleLocalFileOrDir(PP_Instance instance, const char* path, bool recursive) { int32_t result = PP_ERROR_FAILED; PluginDispatcher::Get()->Send( new PpapiHostMsg_PPBFlash_DeleteModuleLocalFileOrDir( - INTERFACE_ID_PPB_FLASH, module, path, recursive, &result)); + INTERFACE_ID_PPB_FLASH, instance, path, recursive, &result)); return result; } -int32_t CreateModuleLocalDir(PP_Module module, const char* path) { +int32_t CreateModuleLocalDir(PP_Instance instance, const char* path) { int32_t result = PP_ERROR_FAILED; PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBFlash_CreateModuleLocalDir( - INTERFACE_ID_PPB_FLASH, module, path, &result)); + INTERFACE_ID_PPB_FLASH, instance, path, &result)); return result; } -int32_t QueryModuleLocalFile(PP_Module module, +int32_t QueryModuleLocalFile(PP_Instance instance, const char* path, PP_FileInfo_Dev* info) { int32_t result = PP_ERROR_FAILED; PluginDispatcher::Get()->Send( new PpapiHostMsg_PPBFlash_QueryModuleLocalFile( - INTERFACE_ID_PPB_FLASH, module, path, info, &result)); + INTERFACE_ID_PPB_FLASH, instance, path, info, &result)); return result; } -int32_t GetModuleLocalDirContents(PP_Module module, +int32_t GetModuleLocalDirContents(PP_Instance instance, const char* path, PP_DirContents_Dev** contents) { int32_t result = PP_ERROR_FAILED; std::vector<SerializedDirEntry> entries; PluginDispatcher::Get()->Send( new PpapiHostMsg_PPBFlash_GetModuleLocalDirContents( - INTERFACE_ID_PPB_FLASH, module, path, &entries, &result)); + INTERFACE_ID_PPB_FLASH, instance, path, &entries, &result)); if (result != PP_OK) return result; @@ -174,7 +176,7 @@ int32_t GetModuleLocalDirContents(PP_Module module, return result; } -void FreeModuleLocalDirContents(PP_Module module, +void FreeModuleLocalDirContents(PP_Instance instance, PP_DirContents_Dev* contents) { for (int32_t i = 0; i < contents->count; ++i) delete[] contents->entries[i].name; @@ -271,7 +273,7 @@ void PPB_Flash_Proxy::OnMsgDrawGlyphs( return; *result = ppb_flash_target()->DrawGlyphs( - params.pp_image_data, &font_desc, params.color, + params.instance, params.pp_image_data, &font_desc, params.color, params.position, params.clip, const_cast<float(*)[3]>(params.transformation), static_cast<uint32_t>(params.glyph_indices.size()), @@ -279,64 +281,67 @@ void PPB_Flash_Proxy::OnMsgDrawGlyphs( const_cast<PP_Point*>(¶ms.glyph_advances[0])); } -void PPB_Flash_Proxy::OnMsgGetProxyForURL(PP_Module module, +void PPB_Flash_Proxy::OnMsgGetProxyForURL(PP_Instance instance, const std::string& url, SerializedVarReturnValue result) { result.Return(dispatcher(), ppb_flash_target()->GetProxyForURL( - module, url.c_str())); + instance, url.c_str())); } void PPB_Flash_Proxy::OnMsgOpenModuleLocalFile( - PP_Module module, + PP_Instance instance, const std::string& path, int32_t mode, IPC::PlatformFileForTransit* file_handle, int32_t* result) { base::PlatformFile file; - *result = ppb_flash_target()->OpenModuleLocalFile(module, path.c_str(), mode, - &file); + *result = ppb_flash_target()->OpenModuleLocalFile(instance, path.c_str(), + mode, &file); *file_handle = PlatformFileToPlatformFileForTransit(result, file); } void PPB_Flash_Proxy::OnMsgRenameModuleLocalFile( - PP_Module module, + PP_Instance instance, const std::string& path_from, const std::string& path_to, int32_t* result) { - *result = ppb_flash_target()->RenameModuleLocalFile(module, path_from.c_str(), + *result = ppb_flash_target()->RenameModuleLocalFile(instance, + path_from.c_str(), path_to.c_str()); } void PPB_Flash_Proxy::OnMsgDeleteModuleLocalFileOrDir( - PP_Module module, + PP_Instance instance, const std::string& path, bool recursive, int32_t* result) { - *result = ppb_flash_target()->DeleteModuleLocalFileOrDir(module, path.c_str(), + *result = ppb_flash_target()->DeleteModuleLocalFileOrDir(instance, + path.c_str(), recursive); } -void PPB_Flash_Proxy::OnMsgCreateModuleLocalDir(PP_Module module, +void PPB_Flash_Proxy::OnMsgCreateModuleLocalDir(PP_Instance instance, const std::string& path, int32_t* result) { - *result = ppb_flash_target()->CreateModuleLocalDir(module, path.c_str()); + *result = ppb_flash_target()->CreateModuleLocalDir(instance, path.c_str()); } -void PPB_Flash_Proxy::OnMsgQueryModuleLocalFile(PP_Module module, +void PPB_Flash_Proxy::OnMsgQueryModuleLocalFile(PP_Instance instance, const std::string& path, PP_FileInfo_Dev* info, int32_t* result) { - *result = ppb_flash_target()->QueryModuleLocalFile(module, path.c_str(), + *result = ppb_flash_target()->QueryModuleLocalFile(instance, path.c_str(), info); } void PPB_Flash_Proxy::OnMsgGetModuleLocalDirContents( - PP_Module module, + PP_Instance instance, const std::string& path, std::vector<pp::proxy::SerializedDirEntry>* entries, int32_t* result) { PP_DirContents_Dev* contents = NULL; - *result = ppb_flash_target()->GetModuleLocalDirContents(module, path.c_str(), + *result = ppb_flash_target()->GetModuleLocalDirContents(instance, + path.c_str(), &contents); if (*result != PP_OK) return; @@ -347,7 +352,7 @@ void PPB_Flash_Proxy::OnMsgGetModuleLocalDirContents( (*entries)[i].name.assign(contents->entries[i].name); (*entries)[i].is_dir = contents->entries[i].is_dir; } - ppb_flash_target()->FreeModuleLocalDirContents(module, contents); + ppb_flash_target()->FreeModuleLocalDirContents(instance, contents); } void PPB_Flash_Proxy::OnMsgNavigateToURL(PP_Instance instance, diff --git a/ppapi/proxy/ppb_flash_proxy.h b/ppapi/proxy/ppb_flash_proxy.h index 629761f..cbe30bd 100644 --- a/ppapi/proxy/ppb_flash_proxy.h +++ b/ppapi/proxy/ppb_flash_proxy.h @@ -43,31 +43,31 @@ class PPB_Flash_Proxy : public InterfaceProxy { bool on_top); void OnMsgDrawGlyphs(const pp::proxy::PPBFlash_DrawGlyphs_Params& params, bool* result); - void OnMsgGetProxyForURL(PP_Module module, + void OnMsgGetProxyForURL(PP_Instance instance, const std::string& url, SerializedVarReturnValue result); - void OnMsgOpenModuleLocalFile(PP_Module module, + void OnMsgOpenModuleLocalFile(PP_Instance instance, const std::string& path, int32_t mode, IPC::PlatformFileForTransit* file_handle, int32_t* result); - void OnMsgRenameModuleLocalFile(PP_Module module, + void OnMsgRenameModuleLocalFile(PP_Instance instance, const std::string& path_from, const std::string& path_to, int32_t* result); - void OnMsgDeleteModuleLocalFileOrDir(PP_Module module, + void OnMsgDeleteModuleLocalFileOrDir(PP_Instance instance, const std::string& path, bool recursive, int32_t* result); - void OnMsgCreateModuleLocalDir(PP_Module module, + void OnMsgCreateModuleLocalDir(PP_Instance instance, const std::string& path, int32_t* result); - void OnMsgQueryModuleLocalFile(PP_Module module, + void OnMsgQueryModuleLocalFile(PP_Instance instance, const std::string& path, PP_FileInfo_Dev* info, int32_t* result); void OnMsgGetModuleLocalDirContents( - PP_Module module, + PP_Instance instance, const std::string& path, std::vector<pp::proxy::SerializedDirEntry>* entries, int32_t* result); diff --git a/ppapi/proxy/ppb_font_proxy.cc b/ppapi/proxy/ppb_font_proxy.cc index 1c72622..2dc2744 100644 --- a/ppapi/proxy/ppb_font_proxy.cc +++ b/ppapi/proxy/ppb_font_proxy.cc @@ -43,7 +43,7 @@ Font::~Font() { namespace { -PP_Resource Create(PP_Module module_id, +PP_Resource Create(PP_Instance instance, const PP_FontDescription_Dev* description) { PluginDispatcher* dispatcher = PluginDispatcher::Get(); @@ -55,7 +55,7 @@ PP_Resource Create(PP_Module module_id, std::string out_metrics; PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBFont_Create( INTERFACE_ID_PPB_FONT, - module_id, in_description, &result, &out_description, &out_metrics)); + instance, in_description, &result, &out_description, &out_metrics)); if (!result) return 0; // Failure creating font. @@ -206,7 +206,7 @@ bool PPB_Font_Proxy::OnMessageReceived(const IPC::Message& msg) { } void PPB_Font_Proxy::OnMsgCreate( - PP_Module pp_module, + PP_Instance instance, const SerializedFontDescription& in_description, PP_Resource* result, SerializedFontDescription* out_description, @@ -221,7 +221,7 @@ void PPB_Font_Proxy::OnMsgCreate( memset(&out_pp_desc, 0, sizeof(PP_FontDescription_Dev)); out_pp_desc.face = PP_MakeUndefined(); - *result = ppb_font_target()->Create(pp_module, &in_pp_desc); + *result = ppb_font_target()->Create(instance, &in_pp_desc); if (*result) { // Get the metrics and resulting description to return to the browser. PP_FontMetrics_Dev metrics; diff --git a/ppapi/proxy/ppb_font_proxy.h b/ppapi/proxy/ppb_font_proxy.h index 4e68d70..322af80 100644 --- a/ppapi/proxy/ppb_font_proxy.h +++ b/ppapi/proxy/ppb_font_proxy.h @@ -6,7 +6,7 @@ #define PPAPI_PROXY_PPB_FONT_PROXY_H_ #include "base/basictypes.h" -#include "ppapi/c/pp_module.h" +#include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/proxy/interface_proxy.h" @@ -35,7 +35,7 @@ class PPB_Font_Proxy : public InterfaceProxy { private: // Message handlers. - void OnMsgCreate(PP_Module pp_module, + void OnMsgCreate(PP_Instance instance, const SerializedFontDescription& in_description, PP_Resource* result, SerializedFontDescription* out_description, diff --git a/ppapi/proxy/ppb_graphics_2d_proxy.cc b/ppapi/proxy/ppb_graphics_2d_proxy.cc index 06d5d0a..033f71c 100644 --- a/ppapi/proxy/ppb_graphics_2d_proxy.cc +++ b/ppapi/proxy/ppb_graphics_2d_proxy.cc @@ -55,13 +55,13 @@ class Graphics2D : public PluginResource { namespace { -PP_Resource Create(PP_Module module_id, +PP_Resource Create(PP_Instance instance, const PP_Size* size, PP_Bool is_always_opaque) { PluginDispatcher* dispatcher = PluginDispatcher::Get(); PP_Resource result = 0; dispatcher->Send(new PpapiHostMsg_PPBGraphics2D_Create( - INTERFACE_ID_PPB_GRAPHICS_2D, module_id, *size, is_always_opaque, + INTERFACE_ID_PPB_GRAPHICS_2D, instance, *size, is_always_opaque, &result)); if (result) { linked_ptr<Graphics2D> graphics_2d(new Graphics2D(*size, is_always_opaque)); @@ -188,12 +188,12 @@ bool PPB_Graphics2D_Proxy::OnMessageReceived(const IPC::Message& msg) { return handled; } -void PPB_Graphics2D_Proxy::OnMsgCreate(PP_Module module, +void PPB_Graphics2D_Proxy::OnMsgCreate(PP_Instance instance, const PP_Size& size, PP_Bool is_always_opaque, PP_Resource* result) { *result = ppb_graphics_2d_target()->Create( - module, &size, is_always_opaque); + instance, &size, is_always_opaque); } void PPB_Graphics2D_Proxy::OnMsgPaintImageData(PP_Resource graphics_2d, diff --git a/ppapi/proxy/ppb_image_data_proxy.cc b/ppapi/proxy/ppb_image_data_proxy.cc index 14b0479..9b8c2a2 100644 --- a/ppapi/proxy/ppb_image_data_proxy.cc +++ b/ppapi/proxy/ppb_image_data_proxy.cc @@ -40,7 +40,7 @@ PP_Bool IsImageDataFormatSupported(PP_ImageDataFormat format) { return supported; } -PP_Resource Create(PP_Module module_id, +PP_Resource Create(PP_Instance instance, PP_ImageDataFormat format, const PP_Size* size, PP_Bool init_to_zero) { @@ -49,7 +49,7 @@ PP_Resource Create(PP_Module module_id, ImageHandle image_handle = ImageData::NullHandle; PluginDispatcher::Get()->Send( new PpapiHostMsg_PPBImageData_Create( - INTERFACE_ID_PPB_IMAGE_DATA, module_id, format, *size, init_to_zero, + INTERFACE_ID_PPB_IMAGE_DATA, instance, format, *size, init_to_zero, &result, &image_data_desc, &image_handle)); if (result && image_data_desc.size() == sizeof(PP_ImageDataDesc)) { @@ -143,7 +143,7 @@ void PPB_ImageData_Proxy::OnMsgIsImageDataFormatSupported(int32 format, static_cast<PP_ImageDataFormat>(format)); } -void PPB_ImageData_Proxy::OnMsgCreate(PP_Module module, +void PPB_ImageData_Proxy::OnMsgCreate(PP_Instance instance, int32_t format, const PP_Size& size, PP_Bool init_to_zero, @@ -151,7 +151,7 @@ void PPB_ImageData_Proxy::OnMsgCreate(PP_Module module, std::string* image_data_desc, ImageHandle* result_image_handle) { *result = ppb_image_data_target()->Create( - module, static_cast<PP_ImageDataFormat>(format), &size, init_to_zero); + instance, static_cast<PP_ImageDataFormat>(format), &size, init_to_zero); *result_image_handle = ImageData::NullHandle; if (*result) { // The ImageDesc is just serialized as a string. diff --git a/ppapi/proxy/ppb_image_data_proxy.h b/ppapi/proxy/ppb_image_data_proxy.h index beec054..5a0d076 100644 --- a/ppapi/proxy/ppb_image_data_proxy.h +++ b/ppapi/proxy/ppb_image_data_proxy.h @@ -38,7 +38,7 @@ class PPB_ImageData_Proxy : public InterfaceProxy { // Message handlers. void OnMsgGetNativeImageDataFormat(int32* result); void OnMsgIsImageDataFormatSupported(int32 format, PP_Bool* result); - void OnMsgCreate(PP_Module module, + void OnMsgCreate(PP_Instance instance, int32_t format, const PP_Size& size, PP_Bool init_to_zero, diff --git a/ppapi/proxy/ppb_pdf_proxy.cc b/ppapi/proxy/ppb_pdf_proxy.cc index ddc404c..776a90a 100644 --- a/ppapi/proxy/ppb_pdf_proxy.cc +++ b/ppapi/proxy/ppb_pdf_proxy.cc @@ -57,7 +57,7 @@ std::string* PrivateFontFile::AddFontTable(uint32_t table, namespace { PP_Resource GetFontFileWithFallback( - PP_Module module_id, + PP_Instance instance, const PP_FontDescription_Dev* description, PP_PrivateFontCharset charset) { PluginDispatcher* dispatcher = PluginDispatcher::Get(); @@ -66,7 +66,7 @@ PP_Resource GetFontFileWithFallback( PP_Resource result = 0; dispatcher->Send(new PpapiHostMsg_PPBPDF_GetFontFileWithFallback( - INTERFACE_ID_PPB_PDF, module_id, desc, charset, &result)); + INTERFACE_ID_PPB_PDF, instance, desc, charset, &result)); if (!result) return 0; @@ -139,13 +139,13 @@ bool PPB_PDF_Proxy::OnMessageReceived(const IPC::Message& msg) { } void PPB_PDF_Proxy::OnMsgGetFontFileWithFallback( - PP_Module module, + PP_Instance instance, const SerializedFontDescription& in_desc, int32_t charset, PP_Resource* result) { PP_FontDescription_Dev desc; in_desc.SetToPPFontDescription(dispatcher(), &desc, false); - *result = ppb_pdf_target()->GetFontFileWithFallback(module, &desc, + *result = ppb_pdf_target()->GetFontFileWithFallback(instance, &desc, static_cast<PP_PrivateFontCharset>(charset)); } diff --git a/ppapi/proxy/ppb_url_request_info_proxy.cc b/ppapi/proxy/ppb_url_request_info_proxy.cc index 02bd3e6..fdd5e5d 100644 --- a/ppapi/proxy/ppb_url_request_info_proxy.cc +++ b/ppapi/proxy/ppb_url_request_info_proxy.cc @@ -26,10 +26,10 @@ class URLRequestInfo : public PluginResource { namespace { -PP_Resource Create(PP_Module module_id) { +PP_Resource Create(PP_Instance instance) { PP_Resource result; PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBURLRequestInfo_Create( - INTERFACE_ID_PPB_URL_REQUEST_INFO, module_id, &result)); + INTERFACE_ID_PPB_URL_REQUEST_INFO, instance, &result)); if (result) { linked_ptr<URLRequestInfo> object(new URLRequestInfo); PluginDispatcher::Get()->plugin_resource_tracker()->AddResource( @@ -128,9 +128,9 @@ bool PPB_URLRequestInfo_Proxy::OnMessageReceived(const IPC::Message& msg) { } void PPB_URLRequestInfo_Proxy::OnMsgCreate( - PP_Module module, + PP_Instance instance, PP_Resource* result) { - *result = ppb_url_request_info_target()->Create(module); + *result = ppb_url_request_info_target()->Create(instance); } void PPB_URLRequestInfo_Proxy::OnMsgSetProperty( diff --git a/ppapi/proxy/ppb_url_request_info_proxy.h b/ppapi/proxy/ppb_url_request_info_proxy.h index 47e2e27..e317615 100644 --- a/ppapi/proxy/ppb_url_request_info_proxy.h +++ b/ppapi/proxy/ppb_url_request_info_proxy.h @@ -6,7 +6,7 @@ #define PPAPI_PROXY_PPB_URL_REQUEST_INFO_PROXY_H_ #include "base/basictypes.h" -#include "ppapi/c/pp_module.h" +#include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/proxy/interface_proxy.h" @@ -34,7 +34,7 @@ class PPB_URLRequestInfo_Proxy : public InterfaceProxy { private: // Message handlers. - void OnMsgCreate(PP_Module module, PP_Resource* result); + void OnMsgCreate(PP_Instance instance, PP_Resource* result); void OnMsgSetProperty(PP_Resource request, int32_t property, SerializedVarReceiveInput value); diff --git a/ppapi/proxy/ppb_var_deprecated_proxy.cc b/ppapi/proxy/ppb_var_deprecated_proxy.cc index f37b0e3..0fcca7f 100644 --- a/ppapi/proxy/ppb_var_deprecated_proxy.cc +++ b/ppapi/proxy/ppb_var_deprecated_proxy.cc @@ -30,12 +30,11 @@ void ReleaseVar(PP_Var var) { PluginDispatcher::Get()->plugin_var_tracker()->Release(var); } -PP_Var VarFromUtf8(PP_Module module_id, const char* data, uint32_t len) { +PP_Var VarFromUtf8(PP_Module module, const char* data, uint32_t len) { PP_Var ret; ret.type = PP_VARTYPE_STRING; - // TODO(brettw) avoid this extra copy. ret.value.as_id = PluginDispatcher::Get()->plugin_var_tracker()->MakeString( - std::string(data, len)); + data, len); return ret; } @@ -45,10 +44,9 @@ const char* VarToUtf8(PP_Var var, uint32_t* len) { if (str) { *len = static_cast<uint32_t>(str->size()); return str->c_str(); - } else { - *len = 0; - return NULL; } + *len = 0; + return NULL; } bool HasProperty(PP_Var var, @@ -197,7 +195,7 @@ bool IsInstanceOf(PP_Var var, return PPBoolToBool(result); } -PP_Var CreateObject(PP_Module module_id, +PP_Var CreateObject(PP_Instance instance, const PPP_Class_Deprecated* ppp_class, void* ppp_class_data) { Dispatcher* dispatcher = PluginDispatcher::Get(); @@ -206,7 +204,7 @@ PP_Var CreateObject(PP_Module module_id, int64 data_int = static_cast<int64>(reinterpret_cast<intptr_t>(ppp_class_data)); dispatcher->Send(new PpapiHostMsg_PPBVar_CreateObjectDeprecated( - INTERFACE_ID_PPB_VAR_DEPRECATED, module_id, class_int, data_int, + INTERFACE_ID_PPB_VAR_DEPRECATED, instance, class_int, data_int, &result)); return result.Return(dispatcher); } @@ -377,12 +375,12 @@ void PPB_Var_Deprecated_Proxy::OnMsgIsInstanceOfDeprecated( } void PPB_Var_Deprecated_Proxy::OnMsgCreateObjectDeprecated( - PP_Module module_id, + PP_Instance instance, int64 ppp_class, int64 class_data, SerializedVarReturnValue result) { result.Return(dispatcher(), PPP_Class_Proxy::CreateProxiedObject( - ppb_var_target(), dispatcher(), module_id, ppp_class, class_data)); + ppb_var_target(), dispatcher(), instance, ppp_class, class_data)); } } // namespace proxy diff --git a/ppapi/proxy/ppb_var_deprecated_proxy.h b/ppapi/proxy/ppb_var_deprecated_proxy.h index c712460..193da9d 100644 --- a/ppapi/proxy/ppb_var_deprecated_proxy.h +++ b/ppapi/proxy/ppb_var_deprecated_proxy.h @@ -8,7 +8,6 @@ #include <vector> #include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_module.h" #include "ppapi/proxy/interface_proxy.h" struct PPB_Var_Deprecated; @@ -84,7 +83,7 @@ class PPB_Var_Deprecated_Proxy : public InterfaceProxy { int64 ppp_class, int64* ppp_class_data, PP_Bool* result); - void OnMsgCreateObjectDeprecated(PP_Module module_id, + void OnMsgCreateObjectDeprecated(PP_Instance instance, int64 ppp_class, int64 ppp_class_data, SerializedVarReturnValue result); diff --git a/ppapi/proxy/serialized_structs.cc b/ppapi/proxy/serialized_structs.cc index ab33bab..f744db9 100644 --- a/ppapi/proxy/serialized_structs.cc +++ b/ppapi/proxy/serialized_structs.cc @@ -63,7 +63,8 @@ void SerializedFontDescription::SetToPPFontDescription( } PPBFlash_DrawGlyphs_Params::PPBFlash_DrawGlyphs_Params() - : pp_image_data(0), + : instance(0), + pp_image_data(0), font_desc(), color(0) { } diff --git a/ppapi/proxy/serialized_structs.h b/ppapi/proxy/serialized_structs.h index 2c78dd4..496fd3a 100644 --- a/ppapi/proxy/serialized_structs.h +++ b/ppapi/proxy/serialized_structs.h @@ -11,6 +11,7 @@ #include "base/shared_memory.h" #include "build/build_config.h" #include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_resource.h" @@ -88,6 +89,7 @@ struct PPBFlash_DrawGlyphs_Params { PPBFlash_DrawGlyphs_Params(); ~PPBFlash_DrawGlyphs_Params(); + PP_Instance instance; PP_Resource pp_image_data; SerializedFontDescription font_desc; uint32_t color; diff --git a/ppapi/tests/test_buffer.cc b/ppapi/tests/test_buffer.cc index 3cb8030..fddc573 100644 --- a/ppapi/tests/test_buffer.cc +++ b/ppapi/tests/test_buffer.cc @@ -26,7 +26,7 @@ void TestBuffer::RunTest() { } std::string TestBuffer::TestInvalidSize() { - pp::Buffer_Dev zero_size(0); + pp::Buffer_Dev zero_size(instance_, 0); if (!zero_size.is_null()) return "Zero size accepted"; @@ -34,7 +34,7 @@ std::string TestBuffer::TestInvalidSize() { } std::string TestBuffer::TestInitToZero() { - pp::Buffer_Dev buffer(100); + pp::Buffer_Dev buffer(instance_, 100); if (buffer.is_null()) return "Could not create buffer"; @@ -66,7 +66,7 @@ std::string TestBuffer::TestIsBuffer() { return "Device context was reported as a buffer"; // Make a valid buffer. - pp::Buffer_Dev buffer(100); + pp::Buffer_Dev buffer(instance_, 100); if (buffer.is_null()) return "Couldn't create buffer"; if (!buffer_interface_->IsBuffer(buffer.pp_resource())) diff --git a/ppapi/tests/test_char_set.cc b/ppapi/tests/test_char_set.cc index c760a01..acc381f 100644 --- a/ppapi/tests/test_char_set.cc +++ b/ppapi/tests/test_char_set.cc @@ -32,7 +32,7 @@ std::string TestCharSet::TestUTF16ToCharSet() { utf16.push_back(0); uint32_t utf8result_len = 0; char* utf8result = char_set_interface_->UTF16ToCharSet( - &utf16[0], 0, "latin1", + instance_->pp_instance(), &utf16[0], 0, "latin1", PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &utf8result_len); ASSERT_TRUE(utf8result); ASSERT_TRUE(utf8result[0] == 0); @@ -43,8 +43,8 @@ std::string TestCharSet::TestUTF16ToCharSet() { std::string utf8source("Hello, world. \xe4\xbd\xa0\xe5\xa5\xbd"); utf16 = UTF8ToUTF16(utf8source); utf8result = char_set_interface_->UTF16ToCharSet( - &utf16[0], static_cast<uint32_t>(utf16.size()), "Utf-8", - PP_CHARSET_CONVERSIONERROR_FAIL, &utf8result_len); + instance_->pp_instance(), &utf16[0], static_cast<uint32_t>(utf16.size()), + "Utf-8", PP_CHARSET_CONVERSIONERROR_FAIL, &utf8result_len); ASSERT_TRUE(utf8source == std::string(utf8result, utf8result_len)); pp::Module::Get()->core()->MemFree(utf8result); @@ -54,15 +54,15 @@ std::string TestCharSet::TestUTF16ToCharSet() { // Fail mode. utf8result_len = 1234; // Test that this gets 0'ed on failure. utf8result = char_set_interface_->UTF16ToCharSet( - &utf16[0], static_cast<uint32_t>(utf16.size()), "latin1", - PP_CHARSET_CONVERSIONERROR_FAIL, &utf8result_len); + instance_->pp_instance(), &utf16[0], static_cast<uint32_t>(utf16.size()), + "latin1", PP_CHARSET_CONVERSIONERROR_FAIL, &utf8result_len); ASSERT_TRUE(utf8result_len == 0); ASSERT_TRUE(utf8result == NULL); // Skip mode. utf8result = char_set_interface_->UTF16ToCharSet( - &utf16[0], static_cast<uint32_t>(utf16.size()), "latin1", - PP_CHARSET_CONVERSIONERROR_SKIP, &utf8result_len); + instance_->pp_instance(), &utf16[0], static_cast<uint32_t>(utf16.size()), + "latin1", PP_CHARSET_CONVERSIONERROR_SKIP, &utf8result_len); ASSERT_TRUE(utf8result_len == 2); ASSERT_TRUE(utf8result[0] == 'h' && utf8result[1] == 'i' && utf8result[2] == 0); @@ -70,8 +70,8 @@ std::string TestCharSet::TestUTF16ToCharSet() { // Substitute mode. utf8result = char_set_interface_->UTF16ToCharSet( - &utf16[0], static_cast<uint32_t>(utf16.size()), "latin1", - PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &utf8result_len); + instance_->pp_instance(), &utf16[0], static_cast<uint32_t>(utf16.size()), + "latin1", PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &utf8result_len); ASSERT_TRUE(utf8result_len == 3); ASSERT_TRUE(utf8result[0] == 'h' && utf8result[1] == '?' && utf8result[2] == 'i' && utf8result[3] == 0); @@ -82,8 +82,8 @@ std::string TestCharSet::TestUTF16ToCharSet() { utf16.push_back(0xD800); // High surrogate. utf16.push_back('A'); // Not a low surrogate. utf8result = char_set_interface_->UTF16ToCharSet( - &utf16[0], static_cast<uint32_t>(utf16.size()), "latin1", - PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &utf8result_len); + instance_->pp_instance(), &utf16[0], static_cast<uint32_t>(utf16.size()), + "latin1", PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &utf8result_len); ASSERT_TRUE(utf8result_len == 2); ASSERT_TRUE(utf8result[0] == '?' && utf8result[1] == 'A' && utf8result[2] == 0); @@ -91,8 +91,8 @@ std::string TestCharSet::TestUTF16ToCharSet() { // Invalid encoding name. utf8result = char_set_interface_->UTF16ToCharSet( - &utf16[0], static_cast<uint32_t>(utf16.size()), "poopiepants", - PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &utf8result_len); + instance_->pp_instance(), &utf16[0], static_cast<uint32_t>(utf16.size()), + "poopiepants", PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &utf8result_len); ASSERT_TRUE(!utf8result); ASSERT_TRUE(utf8result_len == 0); @@ -103,7 +103,8 @@ std::string TestCharSet::TestCharSetToUTF16() { // Empty string. uint32_t utf16result_len; uint16_t* utf16result = char_set_interface_->CharSetToUTF16( - "", 0, "latin1", PP_CHARSET_CONVERSIONERROR_FAIL, &utf16result_len); + instance_->pp_instance(), "", 0, "latin1", + PP_CHARSET_CONVERSIONERROR_FAIL, &utf16result_len); ASSERT_TRUE(utf16result); ASSERT_TRUE(utf16result_len == 0); ASSERT_TRUE(utf16result[0] == 0); @@ -111,7 +112,8 @@ std::string TestCharSet::TestCharSetToUTF16() { // Basic Latin1. char latin1[] = "H\xef"; utf16result = char_set_interface_->CharSetToUTF16( - latin1, 2, "latin1", PP_CHARSET_CONVERSIONERROR_FAIL, &utf16result_len); + instance_->pp_instance(), latin1, 2, "latin1", + PP_CHARSET_CONVERSIONERROR_FAIL, &utf16result_len); ASSERT_TRUE(utf16result); ASSERT_TRUE(utf16result_len == 2); ASSERT_TRUE(utf16result[0] == 'H' && utf16result[1] == 0xef && @@ -120,13 +122,15 @@ std::string TestCharSet::TestCharSetToUTF16() { // Invalid input encoding with FAIL. char badutf8[] = "A\xe4Z"; utf16result = char_set_interface_->CharSetToUTF16( - badutf8, 3, "utf8", PP_CHARSET_CONVERSIONERROR_FAIL, &utf16result_len); + instance_->pp_instance(), badutf8, 3, "utf8", + PP_CHARSET_CONVERSIONERROR_FAIL, &utf16result_len); ASSERT_TRUE(!utf16result); ASSERT_TRUE(utf16result_len == 0); // Invalid input with SKIP. utf16result = char_set_interface_->CharSetToUTF16( - badutf8, 3, "utf8", PP_CHARSET_CONVERSIONERROR_SKIP, &utf16result_len); + instance_->pp_instance(), badutf8, 3, "utf8", + PP_CHARSET_CONVERSIONERROR_SKIP, &utf16result_len); ASSERT_TRUE(utf16result); ASSERT_TRUE(utf16result_len == 2); ASSERT_TRUE(utf16result[0] == 'A' && utf16result[1] == 'Z' && @@ -134,8 +138,8 @@ std::string TestCharSet::TestCharSetToUTF16() { // Invalid input with SUBSTITUTE. utf16result = char_set_interface_->CharSetToUTF16( - badutf8, 3, "utf8", PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, - &utf16result_len); + instance_->pp_instance(), badutf8, 3, "utf8", + PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &utf16result_len); ASSERT_TRUE(utf16result); ASSERT_TRUE(utf16result_len == 3); ASSERT_TRUE(utf16result[0] == 'A' && utf16result[1] == 0xFFFD && @@ -143,7 +147,7 @@ std::string TestCharSet::TestCharSetToUTF16() { // Invalid encoding name. utf16result = char_set_interface_->CharSetToUTF16( - badutf8, 3, "poopiepants", + instance_->pp_instance(), badutf8, 3, "poopiepants", PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &utf16result_len); ASSERT_TRUE(!utf16result); ASSERT_TRUE(utf16result_len == 0); @@ -154,7 +158,8 @@ std::string TestCharSet::TestCharSetToUTF16() { std::vector<uint16_t> TestCharSet::UTF8ToUTF16(const std::string& utf8) { uint32_t result_len = 0; uint16_t* result = char_set_interface_->CharSetToUTF16( - utf8.c_str(), static_cast<uint32_t>(utf8.size()), + instance_->pp_instance(), utf8.c_str(), + static_cast<uint32_t>(utf8.size()), "utf-8", PP_CHARSET_CONVERSIONERROR_FAIL, &result_len); std::vector<uint16_t> result_vector; |