summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/common/pepper_plugin_registry.cc4
-rw-r--r--chrome/renderer/pepper_plugin_delegate_impl.cc5
-rw-r--r--ppapi/c/dev/ppb_buffer_dev.h4
-rw-r--r--ppapi/c/dev/ppb_char_set_dev.h10
-rw-r--r--ppapi/c/dev/ppb_file_io_dev.h4
-rw-r--r--ppapi/c/dev/ppb_font_dev.h4
-rw-r--r--ppapi/c/dev/ppb_transport_dev.h2
-rw-r--r--ppapi/c/ppb_url_request_info.h6
-rw-r--r--ppapi/c/private/ppb_flash.h22
-rw-r--r--ppapi/c/private/ppb_pdf.h10
-rw-r--r--ppapi/cpp/dev/buffer_dev.cc6
-rw-r--r--ppapi/cpp/dev/buffer_dev.h4
-rw-r--r--ppapi/cpp/dev/file_io_dev.cc6
-rw-r--r--ppapi/cpp/dev/file_io_dev.h4
-rw-r--r--ppapi/cpp/dev/font_dev.cc6
-rw-r--r--ppapi/cpp/dev/font_dev.h2
-rw-r--r--ppapi/cpp/dev/transport_dev.cc5
-rw-r--r--ppapi/cpp/dev/transport_dev.h5
-rw-r--r--ppapi/cpp/url_loader.cc8
-rw-r--r--ppapi/cpp/url_loader.h8
-rw-r--r--ppapi/cpp/url_request_info.cc5
-rw-r--r--ppapi/cpp/url_request_info.h6
-rw-r--r--ppapi/proxy/plugin_var_tracker.cc6
-rw-r--r--ppapi/proxy/plugin_var_tracker.h1
-rw-r--r--ppapi/proxy/ppapi_messages_internal.h38
-rw-r--r--ppapi/proxy/ppapi_param_traits.cc2
-rw-r--r--ppapi/proxy/ppb_audio_config_proxy.cc8
-rw-r--r--ppapi/proxy/ppb_audio_config_proxy.h4
-rw-r--r--ppapi/proxy/ppb_buffer_proxy.cc8
-rw-r--r--ppapi/proxy/ppb_buffer_proxy.h4
-rw-r--r--ppapi/proxy/ppb_char_set_proxy.cc28
-rw-r--r--ppapi/proxy/ppb_char_set_proxy.h10
-rw-r--r--ppapi/proxy/ppb_flash_proxy.cc71
-rw-r--r--ppapi/proxy/ppb_flash_proxy.h14
-rw-r--r--ppapi/proxy/ppb_font_proxy.cc8
-rw-r--r--ppapi/proxy/ppb_font_proxy.h4
-rw-r--r--ppapi/proxy/ppb_graphics_2d_proxy.cc8
-rw-r--r--ppapi/proxy/ppb_image_data_proxy.cc8
-rw-r--r--ppapi/proxy/ppb_image_data_proxy.h2
-rw-r--r--ppapi/proxy/ppb_pdf_proxy.cc8
-rw-r--r--ppapi/proxy/ppb_url_request_info_proxy.cc8
-rw-r--r--ppapi/proxy/ppb_url_request_info_proxy.h4
-rw-r--r--ppapi/proxy/ppb_var_deprecated_proxy.cc18
-rw-r--r--ppapi/proxy/ppb_var_deprecated_proxy.h3
-rw-r--r--ppapi/proxy/serialized_structs.cc3
-rw-r--r--ppapi/proxy/serialized_structs.h2
-rw-r--r--ppapi/tests/test_buffer.cc6
-rw-r--r--ppapi/tests/test_char_set.cc47
-rw-r--r--webkit/plugins/ppapi/callbacks_unittest.cc21
-rw-r--r--webkit/plugins/ppapi/mock_resource.h2
-rw-r--r--webkit/plugins/ppapi/npapi_glue.cc13
-rw-r--r--webkit/plugins/ppapi/npapi_glue.h5
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc52
-rw-r--r--webkit/plugins/ppapi/plugin_module.h27
-rw-r--r--webkit/plugins/ppapi/plugin_object.cc27
-rw-r--r--webkit/plugins/ppapi/plugin_object.h10
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc66
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.h45
-rw-r--r--webkit/plugins/ppapi/ppapi_unittest.h1
-rw-r--r--webkit/plugins/ppapi/ppb_audio_impl.cc24
-rw-r--r--webkit/plugins/ppapi/ppb_audio_impl.h13
-rw-r--r--webkit/plugins/ppapi/ppb_buffer_impl.cc14
-rw-r--r--webkit/plugins/ppapi/ppb_buffer_impl.h2
-rw-r--r--webkit/plugins/ppapi/ppb_char_set_impl.cc19
-rw-r--r--webkit/plugins/ppapi/ppb_context_3d_impl.cc3
-rw-r--r--webkit/plugins/ppapi/ppb_directory_reader_impl.cc7
-rw-r--r--webkit/plugins/ppapi/ppb_file_chooser_impl.cc12
-rw-r--r--webkit/plugins/ppapi/ppb_file_chooser_impl.h3
-rw-r--r--webkit/plugins/ppapi/ppb_file_io_impl.cc31
-rw-r--r--webkit/plugins/ppapi/ppb_file_io_impl.h3
-rw-r--r--webkit/plugins/ppapi/ppb_file_ref_impl.cc28
-rw-r--r--webkit/plugins/ppapi/ppb_file_ref_impl.h4
-rw-r--r--webkit/plugins/ppapi/ppb_file_system_impl.cc2
-rw-r--r--webkit/plugins/ppapi/ppb_flash_impl.cc41
-rw-r--r--webkit/plugins/ppapi/ppb_flash_impl.h8
-rw-r--r--webkit/plugins/ppapi/ppb_flash_impl_linux.cc3
-rw-r--r--webkit/plugins/ppapi/ppb_font_impl.cc16
-rw-r--r--webkit/plugins/ppapi/ppb_font_impl.h2
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.cc12
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.h2
-rw-r--r--webkit/plugins/ppapi/ppb_image_data_impl.cc11
-rw-r--r--webkit/plugins/ppapi/ppb_image_data_impl.h2
-rw-r--r--webkit/plugins/ppapi/ppb_pdf_impl.cc33
-rw-r--r--webkit/plugins/ppapi/ppb_scrollbar_impl.cc4
-rw-r--r--webkit/plugins/ppapi/ppb_surface_3d_impl.cc3
-rw-r--r--webkit/plugins/ppapi/ppb_surface_3d_impl.h5
-rw-r--r--webkit/plugins/ppapi/ppb_transport_impl.cc6
-rw-r--r--webkit/plugins/ppapi/ppb_transport_impl.h2
-rw-r--r--webkit/plugins/ppapi/ppb_url_loader_impl.cc63
-rw-r--r--webkit/plugins/ppapi/ppb_url_loader_impl.h15
-rw-r--r--webkit/plugins/ppapi/ppb_url_request_info_impl.cc12
-rw-r--r--webkit/plugins/ppapi/ppb_url_request_info_impl.h2
-rw-r--r--webkit/plugins/ppapi/ppb_url_response_info_impl.cc17
-rw-r--r--webkit/plugins/ppapi/ppb_url_response_info_impl.h2
-rw-r--r--webkit/plugins/ppapi/ppb_url_util_impl.cc1
-rw-r--r--webkit/plugins/ppapi/ppb_video_decoder_impl.cc3
-rw-r--r--webkit/plugins/ppapi/ppb_video_decoder_impl.h3
-rw-r--r--webkit/plugins/ppapi/ppb_widget_impl.cc5
-rw-r--r--webkit/plugins/ppapi/resource.cc13
-rw-r--r--webkit/plugins/ppapi/resource.h38
-rw-r--r--webkit/plugins/ppapi/resource_tracker.cc92
-rw-r--r--webkit/plugins/ppapi/resource_tracker.h34
-rw-r--r--webkit/plugins/ppapi/resource_tracker_unittest.cc36
-rw-r--r--webkit/plugins/ppapi/url_request_info_unittest.cc2
-rw-r--r--webkit/plugins/ppapi/var.cc105
-rw-r--r--webkit/plugins/ppapi/var.h46
-rw-r--r--webkit/plugins/ppapi/var_object_class.cc56
-rw-r--r--webkit/plugins/ppapi/var_object_class.h4
108 files changed, 866 insertions, 726 deletions
diff --git a/chrome/common/pepper_plugin_registry.cc b/chrome/common/pepper_plugin_registry.cc
index 053d897..963f248 100644
--- a/chrome/common/pepper_plugin_registry.cc
+++ b/chrome/common/pepper_plugin_registry.cc
@@ -296,12 +296,14 @@ PepperPluginRegistry::PepperPluginRegistry() {
const FilePath& path = plugins[i].path;
scoped_refptr<webkit::ppapi::PluginModule> module(
new webkit::ppapi::PluginModule(this));
+ // Must call this before bailing out later since the PluginModule's
+ // destructor will call the corresponding Remove in the "continue" case.
+ AddLiveModule(path, module);
if (!module->InitAsLibrary(path)) {
DLOG(ERROR) << "Failed to load pepper module: " << path.value();
continue;
}
module->set_name(plugins[i].name);
preloaded_modules_[path] = module;
- AddLiveModule(path, module);
}
}
diff --git a/chrome/renderer/pepper_plugin_delegate_impl.cc b/chrome/renderer/pepper_plugin_delegate_impl.cc
index d96fe71..b61ec28 100644
--- a/chrome/renderer/pepper_plugin_delegate_impl.cc
+++ b/chrome/renderer/pepper_plugin_delegate_impl.cc
@@ -394,8 +394,10 @@ PepperPluginDelegateImpl::CreatePepperPlugin(const FilePath& path) {
}
// Create a new HostDispatcher for the proxying, and hook it to a new
- // PluginModule.
+ // PluginModule. Note that AddLiveModule must be called before any early
+ // returns since the module's destructor will remove itself.
module = new webkit::ppapi::PluginModule(PepperPluginRegistry::GetInstance());
+ PepperPluginRegistry::GetInstance()->AddLiveModule(path, module);
scoped_ptr<DispatcherWrapper> dispatcher(new DispatcherWrapper);
if (!dispatcher->Init(
plugin_process_handle, channel_handle,
@@ -403,7 +405,6 @@ PepperPluginDelegateImpl::CreatePepperPlugin(const FilePath& path) {
webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc()))
return scoped_refptr<webkit::ppapi::PluginModule>();
module->InitAsProxied(dispatcher.release());
- PepperPluginRegistry::GetInstance()->AddLiveModule(path, module);
return module;
}
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*>(&params.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;
diff --git a/webkit/plugins/ppapi/callbacks_unittest.cc b/webkit/plugins/ppapi/callbacks_unittest.cc
index 3fd92b9..9426cd3 100644
--- a/webkit/plugins/ppapi/callbacks_unittest.cc
+++ b/webkit/plugins/ppapi/callbacks_unittest.cc
@@ -11,6 +11,7 @@
#include "webkit/plugins/ppapi/callbacks.h"
#include "webkit/plugins/ppapi/mock_resource.h"
#include "webkit/plugins/ppapi/plugin_module.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/resource_tracker.h"
namespace webkit {
@@ -60,7 +61,7 @@ TEST_F(CallbackShutdownTest, AbortOnShutdown) {
EXPECT_EQ(0U, info_did_run().run_count);
scoped_refptr<TrackedCompletionCallback> callback_did_run =
new TrackedCompletionCallback(
- module()->GetCallbackTracker(),
+ instance()->module()->GetCallbackTracker(),
0,
PP_MakeCompletionCallback(&TestCallback, &info_did_run()));
EXPECT_EQ(0U, info_did_run().run_count);
@@ -72,7 +73,7 @@ TEST_F(CallbackShutdownTest, AbortOnShutdown) {
EXPECT_EQ(0U, info_did_abort().run_count);
scoped_refptr<TrackedCompletionCallback> callback_did_abort =
new TrackedCompletionCallback(
- module()->GetCallbackTracker(),
+ instance()->module()->GetCallbackTracker(),
0,
PP_MakeCompletionCallback(&TestCallback, &info_did_abort()));
EXPECT_EQ(0U, info_did_abort().run_count);
@@ -85,7 +86,7 @@ TEST_F(CallbackShutdownTest, AbortOnShutdown) {
EXPECT_EQ(0U, info_didnt_run().run_count);
scoped_refptr<TrackedCompletionCallback> callback_didnt_run =
new TrackedCompletionCallback(
- module()->GetCallbackTracker(),
+ instance()->module()->GetCallbackTracker(),
0,
PP_MakeCompletionCallback(&TestCallback, &info_didnt_run()));
EXPECT_EQ(0U, info_didnt_run().run_count);
@@ -109,7 +110,7 @@ namespace {
class CallbackMockResource : public MockResource {
public:
- CallbackMockResource(PluginModule* module) : MockResource(module) {}
+ CallbackMockResource(PluginInstance* instance) : MockResource(instance) {}
~CallbackMockResource() {}
PP_Resource SetupForTest() {
@@ -117,19 +118,19 @@ class CallbackMockResource : public MockResource {
EXPECT_NE(0, resource_id);
callback_did_run_ = new TrackedCompletionCallback(
- module()->GetCallbackTracker(),
+ instance()->module()->GetCallbackTracker(),
resource_id,
PP_MakeCompletionCallback(&TestCallback, &info_did_run_));
EXPECT_EQ(0U, info_did_run_.run_count);
callback_did_abort_ = new TrackedCompletionCallback(
- module()->GetCallbackTracker(),
+ instance()->module()->GetCallbackTracker(),
resource_id,
PP_MakeCompletionCallback(&TestCallback, &info_did_abort_));
EXPECT_EQ(0U, info_did_abort_.run_count);
callback_didnt_run_ = new TrackedCompletionCallback(
- module()->GetCallbackTracker(),
+ instance()->module()->GetCallbackTracker(),
resource_id,
PP_MakeCompletionCallback(&TestCallback, &info_didnt_run_));
EXPECT_EQ(0U, info_didnt_run_.run_count);
@@ -187,13 +188,13 @@ TEST_F(CallbackResourceTest, AbortOnNoRef) {
// Check that the uncompleted one gets aborted, and that the others don't get
// called again.
scoped_refptr<CallbackMockResource> resource_1(
- new CallbackMockResource(module()));
+ new CallbackMockResource(instance()));
PP_Resource resource_1_id = resource_1->SetupForTest();
// Also do the same for a second resource, and make sure that unref-ing the
// first resource doesn't much up the second resource.
scoped_refptr<CallbackMockResource> resource_2(
- new CallbackMockResource(module()));
+ new CallbackMockResource(instance()));
PP_Resource resource_2_id = resource_2->SetupForTest();
// Double-check that resource #1 is still okay.
@@ -222,7 +223,7 @@ TEST_F(CallbackResourceTest, Resurrection) {
ResourceTracker* resource_tracker = ResourceTracker::Get();
scoped_refptr<CallbackMockResource> resource(
- new CallbackMockResource(module()));
+ new CallbackMockResource(instance()));
PP_Resource resource_id = resource->SetupForTest();
// Unref it, spin the message loop to run posted calls, and check that things
diff --git a/webkit/plugins/ppapi/mock_resource.h b/webkit/plugins/ppapi/mock_resource.h
index 081c990..d8034c9 100644
--- a/webkit/plugins/ppapi/mock_resource.h
+++ b/webkit/plugins/ppapi/mock_resource.h
@@ -15,7 +15,7 @@ namespace ppapi {
// static_cast to get its own implementation.
class MockResource : public Resource {
public:
- MockResource(PluginModule* module) : Resource(module) {}
+ MockResource(PluginInstance* instance) : Resource(instance) {}
~MockResource() {}
virtual MockResource* AsMockResource() { return this; }
diff --git a/webkit/plugins/ppapi/npapi_glue.cc b/webkit/plugins/ppapi/npapi_glue.cc
index d22c13f..478d524 100644
--- a/webkit/plugins/ppapi/npapi_glue.cc
+++ b/webkit/plugins/ppapi/npapi_glue.cc
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "base/ref_counted.h"
#include "base/string_util.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/plugin_object.h"
#include "webkit/plugins/ppapi/var.h"
#include "third_party/npapi/bindings/npapi.h"
@@ -150,14 +151,15 @@ void PPResultAndExceptionToNPResult::ThrowException() {
// PPVarArrayFromNPVariantArray ------------------------------------------------
-PPVarArrayFromNPVariantArray::PPVarArrayFromNPVariantArray(PluginModule* module,
+PPVarArrayFromNPVariantArray::PPVarArrayFromNPVariantArray(
+ PluginInstance* instance,
size_t size,
const NPVariant* variants)
: size_(size) {
if (size_ > 0) {
array_.reset(new PP_Var[size_]);
for (size_t i = 0; i < size_; i++)
- array_[i] = Var::NPVariantToPPVar(module, &variants[i]);
+ array_[i] = Var::NPVariantToPPVar(instance, &variants[i]);
}
}
@@ -168,8 +170,8 @@ PPVarArrayFromNPVariantArray::~PPVarArrayFromNPVariantArray() {
// PPVarFromNPObject -----------------------------------------------------------
-PPVarFromNPObject::PPVarFromNPObject(PluginModule* module, NPObject* object)
- : var_(ObjectVar::NPObjectToPPVar(module, object)) {
+PPVarFromNPObject::PPVarFromNPObject(PluginInstance* instance, NPObject* object)
+ : var_(ObjectVar::NPObjectToPPVar(instance, object)) {
}
PPVarFromNPObject::~PPVarFromNPObject() {
@@ -185,7 +187,8 @@ NPObjectAccessorWithIdentifier::NPObjectAccessorWithIdentifier(
: object_(PluginObject::FromNPObject(object)),
identifier_(PP_MakeUndefined()) {
if (object_) {
- identifier_ = Var::NPIdentifierToPPVar(object_->module(), identifier);
+ identifier_ = Var::NPIdentifierToPPVar(object_->instance()->module(),
+ identifier);
if (identifier_.type == PP_VARTYPE_INT32 && !allow_integer_identifier)
identifier_.type = PP_VARTYPE_UNDEFINED; // Mark it invalid.
}
diff --git a/webkit/plugins/ppapi/npapi_glue.h b/webkit/plugins/ppapi/npapi_glue.h
index 11fd82a..4a887f1 100644
--- a/webkit/plugins/ppapi/npapi_glue.h
+++ b/webkit/plugins/ppapi/npapi_glue.h
@@ -16,6 +16,7 @@ typedef void* NPIdentifier;
namespace webkit {
namespace ppapi {
+class PluginInstance;
class PluginModule;
class PluginObject;
@@ -108,7 +109,7 @@ class PPResultAndExceptionToNPResult {
// WebKit to the plugin.
class PPVarArrayFromNPVariantArray {
public:
- PPVarArrayFromNPVariantArray(PluginModule* module,
+ PPVarArrayFromNPVariantArray(PluginInstance* instance,
size_t size,
const NPVariant* variants);
~PPVarArrayFromNPVariantArray();
@@ -128,7 +129,7 @@ class PPVarArrayFromNPVariantArray {
// is used when converting 'this' pointer from WebKit to the plugin.
class PPVarFromNPObject {
public:
- PPVarFromNPObject(PluginModule* module, NPObject* object);
+ PPVarFromNPObject(PluginInstance* instance, NPObject* object);
~PPVarFromNPObject();
PP_Var var() const { return var_; }
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index e1c5ce0..ea0188d 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -55,7 +55,6 @@
#include "ppapi/c/trusted/ppb_url_loader_trusted.h"
#include "webkit/plugins/ppapi/callbacks.h"
#include "webkit/plugins/ppapi/common.h"
-#include "webkit/plugins/ppapi/plugin_object.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_audio_impl.h"
#include "webkit/plugins/ppapi/ppb_buffer_impl.h"
@@ -367,17 +366,6 @@ PluginModule::PluginModule(PluginDelegate::ModuleLifetime* lifetime_delegate)
}
PluginModule::~PluginModule() {
- // Free all the plugin objects. This will automatically clear the back-
- // pointer from the NPObject so WebKit can't call into the plugin any more.
- //
- // Swap out the set so we can delete from it (the objects will try to
- // unregister themselves inside the delete call).
- PluginObjectSet plugin_object_copy;
- live_plugin_objects_.swap(plugin_object_copy);
- for (PluginObjectSet::iterator i = live_plugin_objects_.begin();
- i != live_plugin_objects_.end(); ++i)
- delete *i;
-
// When the module is being deleted, there should be no more instances still
// holding a reference to us.
DCHECK(instances_.empty());
@@ -474,46 +462,6 @@ void PluginModule::InstanceDeleted(PluginInstance* instance) {
instances_.erase(instance);
}
-void PluginModule::AddNPObjectVar(ObjectVar* object_var) {
- DCHECK(np_object_to_object_var_.find(object_var->np_object()) ==
- np_object_to_object_var_.end()) << "ObjectVar already in map";
- np_object_to_object_var_[object_var->np_object()] = object_var;
-}
-
-void PluginModule::RemoveNPObjectVar(ObjectVar* object_var) {
- NPObjectToObjectVarMap::iterator found =
- np_object_to_object_var_.find(object_var->np_object());
- if (found == np_object_to_object_var_.end()) {
- NOTREACHED() << "ObjectVar not registered.";
- return;
- }
- if (found->second != object_var) {
- NOTREACHED() << "ObjectVar doesn't match.";
- return;
- }
- np_object_to_object_var_.erase(found);
-}
-
-ObjectVar* PluginModule::ObjectVarForNPObject(NPObject* np_object) const {
- NPObjectToObjectVarMap::const_iterator found =
- np_object_to_object_var_.find(np_object);
- if (found == np_object_to_object_var_.end())
- return NULL;
- return found->second;
-}
-
-void PluginModule::AddPluginObject(PluginObject* plugin_object) {
- DCHECK(live_plugin_objects_.find(plugin_object) ==
- live_plugin_objects_.end());
- live_plugin_objects_.insert(plugin_object);
-}
-
-void PluginModule::RemovePluginObject(PluginObject* plugin_object) {
- // Don't actually verify that the object is in the set since during module
- // deletion we'll be in the process of freeing them.
- live_plugin_objects_.erase(plugin_object);
-}
-
scoped_refptr<CallbackTracker> PluginModule::GetCallbackTracker() {
return callback_tracker_;
}
diff --git a/webkit/plugins/ppapi/plugin_module.h b/webkit/plugins/ppapi/plugin_module.h
index 913b003..cfdfb6af 100644
--- a/webkit/plugins/ppapi/plugin_module.h
+++ b/webkit/plugins/ppapi/plugin_module.h
@@ -20,7 +20,6 @@
class FilePath;
class MessageLoop;
-typedef struct NPObject NPObject;
struct PPB_Core;
typedef void* NPIdentifier;
@@ -42,10 +41,8 @@ namespace webkit {
namespace ppapi {
class CallbackTracker;
-class ObjectVar;
class PluginDelegate;
class PluginInstance;
-class PluginObject;
// Represents one plugin library loaded into one renderer. This library may
// have multiple instances.
@@ -122,22 +119,6 @@ class PluginModule : public base::RefCounted<PluginModule>,
void InstanceCreated(PluginInstance* instance);
void InstanceDeleted(PluginInstance* instance);
- // Tracks all live ObjectVar. This is so we can map between PluginModule +
- // NPObject and get the ObjectVar corresponding to it. This Add/Remove
- // function should be called by the ObjectVar when it is created and
- // destroyed.
- void AddNPObjectVar(ObjectVar* object_var);
- void RemoveNPObjectVar(ObjectVar* object_var);
-
- // Looks up a previously registered ObjectVar for the given NPObject and
- // module. Returns NULL if there is no ObjectVar corresponding to the given
- // NPObject for the given module. See AddNPObjectVar above.
- ObjectVar* ObjectVarForNPObject(NPObject* np_object) const;
-
- // Tracks all live PluginObjects.
- void AddPluginObject(PluginObject* plugin_object);
- void RemovePluginObject(PluginObject* plugin_object);
-
scoped_refptr<CallbackTracker> GetCallbackTracker();
private:
@@ -178,14 +159,6 @@ class PluginModule : public base::RefCounted<PluginModule>,
typedef std::set<PluginInstance*> PluginInstanceSet;
PluginInstanceSet instances_;
- // Tracks all live ObjectVars used by this module so we can map NPObjects to
- // the corresponding object. These are non-owning references.
- typedef std::map<NPObject*, ObjectVar*> NPObjectToObjectVarMap;
- NPObjectToObjectVarMap np_object_to_object_var_;
-
- typedef std::set<PluginObject*> PluginObjectSet;
- PluginObjectSet live_plugin_objects_;
-
DISALLOW_COPY_AND_ASSIGN(PluginModule);
};
diff --git a/webkit/plugins/ppapi/plugin_object.cc b/webkit/plugins/ppapi/plugin_object.cc
index 516f255..e17d42a 100644
--- a/webkit/plugins/ppapi/plugin_object.cc
+++ b/webkit/plugins/ppapi/plugin_object.cc
@@ -19,6 +19,7 @@
#include "third_party/WebKit/WebKit/chromium/public/WebBindings.h"
#include "webkit/plugins/ppapi/npapi_glue.h"
#include "webkit/plugins/ppapi/plugin_module.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/resource.h"
#include "webkit/plugins/ppapi/string.h"
#include "webkit/plugins/ppapi/var.h"
@@ -73,7 +74,8 @@ bool WrapperClass_Invoke(NPObject* object, NPIdentifier method_name,
PPResultAndExceptionToNPResult result_converter(
accessor.object()->GetNPObject(), result);
- PPVarArrayFromNPVariantArray args(accessor.object()->module(), argc, argv);
+ PPVarArrayFromNPVariantArray args(accessor.object()->instance(),
+ argc, argv);
return result_converter.SetResult(accessor.object()->ppp_class()->Call(
accessor.object()->ppp_class_data(), accessor.identifier(),
@@ -86,7 +88,7 @@ bool WrapperClass_InvokeDefault(NPObject* np_object, const NPVariant* argv,
if (!obj)
return false;
- PPVarArrayFromNPVariantArray args(obj->module(), argc, argv);
+ PPVarArrayFromNPVariantArray args(obj->instance(), argc, argv);
PPResultAndExceptionToNPResult result_converter(obj->GetNPObject(), result);
result_converter.SetResult(obj->ppp_class()->Call(
@@ -130,7 +132,8 @@ bool WrapperClass_SetProperty(NPObject* object, NPIdentifier property_name,
PPResultAndExceptionToNPResult result_converter(
accessor.object()->GetNPObject(), NULL);
- PP_Var value_var = Var::NPVariantToPPVar(accessor.object()->module(), value);
+ PP_Var value_var = Var::NPVariantToPPVar(accessor.object()->instance(),
+ value);
accessor.object()->ppp_class()->SetProperty(
accessor.object()->ppp_class_data(), accessor.identifier(), value_var,
result_converter.exception());
@@ -177,7 +180,7 @@ bool WrapperClass_Enumerate(NPObject* object, NPIdentifier** values,
if (!((*values)[i] = Var::PPVarToNPIdentifier(properties[i]))) {
// Throw an exception for the failed convertion.
*result_converter.exception() = StringVar::StringToPPVar(
- obj->module(), kInvalidValueException);
+ obj->instance()->module(), kInvalidValueException);
break;
}
(*count)++;
@@ -211,7 +214,7 @@ bool WrapperClass_Construct(NPObject* object, const NPVariant* argv,
if (!obj)
return false;
- PPVarArrayFromNPVariantArray args(obj->module(), argc, argv);
+ PPVarArrayFromNPVariantArray args(obj->instance(), argc, argv);
PPResultAndExceptionToNPResult result_converter(obj->GetNPObject(), result);
return result_converter.SetResult(obj->ppp_class()->Construct(
obj->ppp_class_data(), argc, args.array(),
@@ -246,18 +249,18 @@ struct PluginObject::NPObjectWrapper : public NPObject {
PluginObject* obj;
};
-PluginObject::PluginObject(PluginModule* module,
+PluginObject::PluginObject(PluginInstance* instance,
NPObjectWrapper* object_wrapper,
const PPP_Class_Deprecated* ppp_class,
void* ppp_class_data)
- : module_(module),
+ : instance_(instance),
object_wrapper_(object_wrapper),
ppp_class_(ppp_class),
ppp_class_data_(ppp_class_data) {
// Make the object wrapper refer back to this class so our NPObject
// implementation can call back into the Pepper layer.
object_wrapper_->obj = this;
- module_->AddPluginObject(this);
+ instance_->AddPluginObject(this);
}
PluginObject::~PluginObject() {
@@ -268,10 +271,10 @@ PluginObject::~PluginObject() {
// delete the NPObject.
DCHECK(object_wrapper_->obj == this);
object_wrapper_->obj = NULL;
- module_->RemovePluginObject(this);
+ instance_->RemovePluginObject(this);
}
-PP_Var PluginObject::Create(PluginModule* module,
+PP_Var PluginObject::Create(PluginInstance* instance,
const PPP_Class_Deprecated* ppp_class,
void* ppp_class_data) {
// This will internally end up calling our AllocateObjectWrapper via the
@@ -284,12 +287,12 @@ PP_Var PluginObject::Create(PluginModule* module,
// PluginModule. The NPObject will normally handle its lifetime, and it
// will get deleted in the destroy method. It may also get deleted when the
// plugin module is deallocated.
- new PluginObject(module, wrapper, ppp_class, ppp_class_data);
+ new PluginObject(instance, wrapper, ppp_class, ppp_class_data);
// We can just use a normal ObjectVar to refer to this object from the
// plugin. It will hold a ref to the underlying NPObject which will in turn
// hold our pluginObject.
- return ObjectVar::NPObjectToPPVar(module, wrapper);
+ return ObjectVar::NPObjectToPPVar(instance, wrapper);
}
NPObject* PluginObject::GetNPObject() const {
diff --git a/webkit/plugins/ppapi/plugin_object.h b/webkit/plugins/ppapi/plugin_object.h
index 01637e5..9f4b607 100644
--- a/webkit/plugins/ppapi/plugin_object.h
+++ b/webkit/plugins/ppapi/plugin_object.h
@@ -17,7 +17,7 @@ typedef struct _NPVariant NPVariant;
namespace webkit {
namespace ppapi {
-class PluginModule;
+class PluginInstance;
class PluginObject {
public:
@@ -25,11 +25,11 @@ class PluginObject {
// Allocates a new PluginObject and returns it as a PP_Var with a
// refcount of 1.
- static PP_Var Create(PluginModule* module,
+ static PP_Var Create(PluginInstance* instance,
const PPP_Class_Deprecated* ppp_class,
void* ppp_class_data);
- PluginModule* module() const { return module_; }
+ PluginInstance* instance() const { return instance_; }
const PPP_Class_Deprecated* ppp_class() { return ppp_class_; }
void* ppp_class_data() { return ppp_class_data_; };
@@ -64,12 +64,12 @@ class PluginObject {
//
// The NPObjectWrapper (an NPObject) should already have the reference
// incremented on it, and this class will take ownership of that reference.
- PluginObject(PluginModule* module,
+ PluginObject(PluginInstance* instance,
NPObjectWrapper* object_wrapper,
const PPP_Class_Deprecated* ppp_class,
void* ppp_class_data);
- PluginModule* module_;
+ PluginInstance* instance_;
// Holds a pointer to the NPObject wrapper backing the var. This class
// derives from NPObject and we hold a reference to it, so it must be
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 7533a79..5179497 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -44,6 +44,7 @@
#include "webkit/plugins/ppapi/fullscreen_container.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
+#include "webkit/plugins/ppapi/plugin_object.h"
#include "webkit/plugins/ppapi/ppb_buffer_impl.h"
#include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
@@ -320,7 +321,16 @@ PluginInstance::PluginInstance(PluginDelegate* delegate,
}
PluginInstance::~PluginInstance() {
- FOR_EACH_OBSERVER(Observer, observers_, InstanceDestroyed(this));
+ // Free all the plugin objects. This will automatically clear the back-
+ // pointer from the NPObject so WebKit can't call into the plugin any more.
+ //
+ // Swap out the set so we can delete from it (the objects will try to
+ // unregister themselves inside the delete call).
+ PluginObjectSet plugin_object_copy;
+ live_plugin_objects_.swap(plugin_object_copy);
+ for (PluginObjectSet::iterator i = live_plugin_objects_.begin();
+ i != live_plugin_objects_.end(); ++i)
+ delete *i;
delegate_->InstanceDeleted(this);
module_->InstanceDeleted(this);
@@ -351,14 +361,6 @@ const PPB_Zoom_Dev* PluginInstance::GetZoomInterface() {
return &ppb_zoom;
}
-void PluginInstance::AddObserver(Observer* observer) {
- observers_.AddObserver(observer);
-}
-
-void PluginInstance::RemoveObserver(Observer* observer) {
- observers_.RemoveObserver(observer);
-}
-
void PluginInstance::Paint(WebCanvas* canvas,
const gfx::Rect& plugin_rect,
const gfx::Rect& paint_rect) {
@@ -418,13 +420,13 @@ PP_Var PluginInstance::GetWindowObject() {
if (!frame)
return PP_MakeUndefined();
- return ObjectVar::NPObjectToPPVar(module(), frame->windowObject());
+ return ObjectVar::NPObjectToPPVar(this, frame->windowObject());
}
PP_Var PluginInstance::GetOwnerElementObject() {
if (!container_)
return PP_MakeUndefined();
- return ObjectVar::NPObjectToPPVar(module(),
+ return ObjectVar::NPObjectToPPVar(this,
container_->scriptableObjectForElement());
}
@@ -525,7 +527,7 @@ PP_Var PluginInstance::ExecuteScript(PP_Var script, PP_Var* exception) {
return PP_MakeUndefined();
}
- PP_Var ret = Var::NPVariantToPPVar(module_, &result);
+ PP_Var ret = Var::NPVariantToPPVar(this, &result);
WebBindings::releaseVariantValue(&result);
return ret;
}
@@ -1189,5 +1191,45 @@ PPB_Surface3D_Impl* PluginInstance::bound_graphics_3d() const {
return bound_graphics_->Cast<PPB_Surface3D_Impl>();
}
+void PluginInstance::AddPluginObject(PluginObject* plugin_object) {
+ DCHECK(live_plugin_objects_.find(plugin_object) ==
+ live_plugin_objects_.end());
+ live_plugin_objects_.insert(plugin_object);
+}
+
+void PluginInstance::RemovePluginObject(PluginObject* plugin_object) {
+ // Don't actually verify that the object is in the set since during module
+ // deletion we'll be in the process of freeing them.
+ live_plugin_objects_.erase(plugin_object);
+}
+
+void PluginInstance::AddNPObjectVar(ObjectVar* object_var) {
+ DCHECK(np_object_to_object_var_.find(object_var->np_object()) ==
+ np_object_to_object_var_.end()) << "ObjectVar already in map";
+ np_object_to_object_var_[object_var->np_object()] = object_var;
+}
+
+void PluginInstance::RemoveNPObjectVar(ObjectVar* object_var) {
+ NPObjectToObjectVarMap::iterator found =
+ np_object_to_object_var_.find(object_var->np_object());
+ if (found == np_object_to_object_var_.end()) {
+ NOTREACHED() << "ObjectVar not registered.";
+ return;
+ }
+ if (found->second != object_var) {
+ NOTREACHED() << "ObjectVar doesn't match.";
+ return;
+ }
+ np_object_to_object_var_.erase(found);
+}
+
+ObjectVar* PluginInstance::ObjectVarForNPObject(NPObject* np_object) const {
+ NPObjectToObjectVarMap::const_iterator found =
+ np_object_to_object_var_.find(np_object);
+ if (found == np_object_to_object_var_.end())
+ return NULL;
+ return found->second;
+}
+
} // namespace ppapi
} // namespace webkit
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h
index a4624e6..8a220c6 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.h
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h
@@ -5,11 +5,12 @@
#ifndef WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_
#define WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_
+#include <map>
+#include <set>
#include <string>
#include <vector>
#include "base/basictypes.h"
-#include "base/observer_list.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "base/string16.h"
@@ -23,6 +24,7 @@
#include "third_party/WebKit/WebKit/chromium/public/WebCanvas.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
+typedef struct NPObject NPObject;
struct PP_Var;
struct PPB_Instance;
struct PPB_Find_Dev;
@@ -51,8 +53,10 @@ namespace webkit {
namespace ppapi {
class FullscreenContainer;
+class ObjectVar;
class PluginDelegate;
class PluginModule;
+class PluginObject;
class PPB_Graphics2D_Impl;
class PPB_ImageData_Impl;
class PPB_Surface3D_Impl;
@@ -65,14 +69,6 @@ class Resource;
// ResourceTracker.
class PluginInstance : public base::RefCounted<PluginInstance> {
public:
- class Observer {
- public:
- // Indicates that the instance is being destroyed. This will be called from
- // the instance's destructor so don't do anything in this callback that
- // uses the instance.
- virtual void InstanceDestroyed(PluginInstance* instance) = 0;
- };
-
PluginInstance(PluginDelegate* delegate,
PluginModule* module,
const PPP_Instance* instance_interface);
@@ -102,12 +98,6 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
// nonzero.
PP_Instance pp_instance() const { return pp_instance_; }
- // Other classes can register an observer for instance events. These pointers
- // are NOT owned by the Instance. If the object implementing the observer
- // goes away, it must take care to unregister itself.
- void AddObserver(Observer* observer);
- void RemoveObserver(Observer* observer);
-
// Paints the current backing store to the web page.
void Paint(WebKit::WebCanvas* canvas,
const gfx::Rect& plugin_rect,
@@ -172,6 +162,10 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
gfx::Rect* dib_bounds,
gfx::Rect* clip);
+ // Tracks all live PluginObjects.
+ void AddPluginObject(PluginObject* plugin_object);
+ void RemovePluginObject(PluginObject* plugin_object);
+
string16 GetSelectedText(bool html);
string16 GetLinkAtPosition(const gfx::Point& point);
void Zoom(double factor, bool text_only);
@@ -197,6 +191,18 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
PluginDelegate::PlatformContext3D* CreateContext3D();
+ // Tracks all live ObjectVar. This is so we can map between PluginModule +
+ // NPObject and get the ObjectVar corresponding to it. This Add/Remove
+ // function should be called by the ObjectVar when it is created and
+ // destroyed.
+ void AddNPObjectVar(ObjectVar* object_var);
+ void RemoveNPObjectVar(ObjectVar* object_var);
+
+ // Looks up a previously registered ObjectVar for the given NPObject and
+ // module. Returns NULL if there is no ObjectVar corresponding to the given
+ // NPObject for the given module. See AddNPObjectVar above.
+ ObjectVar* ObjectVarForNPObject(NPObject* np_object) const;
+
private:
bool LoadFindInterface();
bool LoadPdfInterface();
@@ -318,8 +324,13 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
// Plugin container for fullscreen mode. NULL if not in fullscreen mode.
FullscreenContainer* fullscreen_container_;
- // Non-owning pointers to all active observers.
- ObserverList<Observer, false> observers_;
+ typedef std::set<PluginObject*> PluginObjectSet;
+ PluginObjectSet live_plugin_objects_;
+
+ // Tracks all live ObjectVars used by this module so we can map NPObjects to
+ // the corresponding object. These are non-owning references.
+ typedef std::map<NPObject*, ObjectVar*> NPObjectToObjectVarMap;
+ NPObjectToObjectVarMap np_object_to_object_var_;
DISALLOW_COPY_AND_ASSIGN(PluginInstance);
};
diff --git a/webkit/plugins/ppapi/ppapi_unittest.h b/webkit/plugins/ppapi/ppapi_unittest.h
index c18af87..a48e620 100644
--- a/webkit/plugins/ppapi/ppapi_unittest.h
+++ b/webkit/plugins/ppapi/ppapi_unittest.h
@@ -27,6 +27,7 @@ class PpapiUnittest : public testing::Test,
virtual void SetUp();
virtual void TearDown();
+ MockPluginDelegate* delegate() { return delegate_.get(); }
PluginModule* module() const { return module_.get(); }
PluginInstance* instance() const { return instance_.get(); }
diff --git a/webkit/plugins/ppapi/ppb_audio_impl.cc b/webkit/plugins/ppapi/ppb_audio_impl.cc
index cd8dca7..93561f8 100644
--- a/webkit/plugins/ppapi/ppb_audio_impl.cc
+++ b/webkit/plugins/ppapi/ppb_audio_impl.cc
@@ -41,8 +41,7 @@ PP_Resource CreateStereo16bit(PP_Instance instance_id,
return 0;
scoped_refptr<PPB_AudioConfig_Impl> config(
- new PPB_AudioConfig_Impl(instance->module(), sample_rate,
- sample_frame_count));
+ new PPB_AudioConfig_Impl(instance, sample_rate, sample_frame_count));
return config->GetReference();
}
@@ -92,8 +91,7 @@ PP_Resource Create(PP_Instance instance_id, PP_Resource config_id,
return 0;
if (!user_callback)
return 0;
- scoped_refptr<PPB_Audio_Impl> audio(
- new PPB_Audio_Impl(instance->module(), instance_id));
+ scoped_refptr<PPB_Audio_Impl> audio(new PPB_Audio_Impl(instance));
if (!audio->Init(instance->delegate(), config_id,
user_callback, user_data))
return 0;
@@ -138,8 +136,7 @@ PP_Resource CreateTrusted(PP_Instance instance_id) {
PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
if (!instance)
return 0;
- scoped_refptr<PPB_Audio_Impl> audio(
- new PPB_Audio_Impl(instance->module(), instance_id));
+ scoped_refptr<PPB_Audio_Impl> audio(new PPB_Audio_Impl(instance));
return audio->GetReference();
}
@@ -152,11 +149,7 @@ int32_t Open(PP_Resource audio_id,
return PP_ERROR_BADRESOURCE;
if (!created.func)
return PP_ERROR_BADARGUMENT;
- PP_Instance instance_id = audio->pp_instance();
- PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
- if (!instance)
- return PP_ERROR_FAILED;
- return audio->Open(instance->delegate(), config_id, created);
+ return audio->Open(audio->instance()->delegate(), config_id, created);
}
int32_t GetSyncSocket(PP_Resource audio_id, int* sync_socket) {
@@ -189,10 +182,10 @@ const PPB_AudioTrusted ppb_audiotrusted = {
// PPB_AudioConfig_Impl --------------------------------------------------------
PPB_AudioConfig_Impl::PPB_AudioConfig_Impl(
- PluginModule* module,
+ PluginInstance* instance,
PP_AudioSampleRate sample_rate,
uint32_t sample_frame_count)
- : Resource(module),
+ : Resource(instance),
sample_rate_(sample_rate),
sample_frame_count_(sample_frame_count) {
}
@@ -217,9 +210,8 @@ PPB_AudioConfig_Impl* PPB_AudioConfig_Impl::AsPPB_AudioConfig_Impl() {
// PPB_Audio_Impl --------------------------------------------------------------
-PPB_Audio_Impl::PPB_Audio_Impl(PluginModule* module, PP_Instance instance_id)
- : Resource(module),
- pp_instance_(instance_id),
+PPB_Audio_Impl::PPB_Audio_Impl(PluginInstance* instance)
+ : Resource(instance),
audio_(NULL),
create_callback_pending_(false) {
create_callback_ = PP_MakeCompletionCallback(NULL, NULL);
diff --git a/webkit/plugins/ppapi/ppb_audio_impl.h b/webkit/plugins/ppapi/ppb_audio_impl.h
index 04bc04d..cc0c112 100644
--- a/webkit/plugins/ppapi/ppb_audio_impl.h
+++ b/webkit/plugins/ppapi/ppb_audio_impl.h
@@ -15,7 +15,6 @@
#include "ppapi/c/trusted/ppb_audio_trusted.h"
#include "ppapi/shared_impl/audio_impl.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/resource.h"
@@ -23,11 +22,10 @@ namespace webkit {
namespace ppapi {
class PluginInstance;
-class PluginModule;
class PPB_AudioConfig_Impl : public Resource {
public:
- PPB_AudioConfig_Impl(PluginModule* module,
+ PPB_AudioConfig_Impl(PluginInstance* instance,
PP_AudioSampleRate sample_rate,
uint32_t sample_frame_count);
size_t BufferSize();
@@ -50,16 +48,12 @@ class PPB_Audio_Impl : public Resource,
public pp::shared_impl::AudioImpl,
public PluginDelegate::PlatformAudio::Client {
public:
- explicit PPB_Audio_Impl(PluginModule* module, PP_Instance instance_id);
+ explicit PPB_Audio_Impl(PluginInstance* instance);
virtual ~PPB_Audio_Impl();
static const PPB_Audio* GetInterface();
static const PPB_AudioTrusted* GetTrustedInterface();
- PP_Instance pp_instance() {
- return pp_instance_;
- }
-
// PPB_Audio implementation.
bool Init(PluginDelegate* plugin_delegate,
PP_Resource config_id,
@@ -87,9 +81,6 @@ class PPB_Audio_Impl : public Resource,
// AudioConfig used for creating this Audio object.
scoped_refptr<PPB_AudioConfig_Impl> config_;
- // Plugin instance that owns this audio object.
- PP_Instance pp_instance_;
-
// PluginDelegate audio object that we delegate audio IPC through.
PluginDelegate::PlatformAudio* audio_;
diff --git a/webkit/plugins/ppapi/ppb_buffer_impl.cc b/webkit/plugins/ppapi/ppb_buffer_impl.cc
index 1c67ec3..7a18338 100644
--- a/webkit/plugins/ppapi/ppb_buffer_impl.cc
+++ b/webkit/plugins/ppapi/ppb_buffer_impl.cc
@@ -10,10 +10,8 @@
#include "base/scoped_ptr.h"
#include "ppapi/c/dev/ppb_buffer_dev.h"
#include "ppapi/c/pp_instance.h"
-#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "webkit/plugins/ppapi/common.h"
-#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
namespace webkit {
@@ -21,12 +19,12 @@ namespace ppapi {
namespace {
-PP_Resource Create(PP_Module module_id, uint32_t size) {
- PluginModule* module = ResourceTracker::Get()->GetModule(module_id);
- if (!module)
+PP_Resource Create(PP_Instance instance_id, uint32_t size) {
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!instance)
return 0;
- scoped_refptr<PPB_Buffer_Impl> buffer(new PPB_Buffer_Impl(module));
+ scoped_refptr<PPB_Buffer_Impl> buffer(new PPB_Buffer_Impl(instance));
if (!buffer->Init(size))
return 0;
@@ -72,8 +70,8 @@ const PPB_Buffer_Dev ppb_buffer = {
} // namespace
-PPB_Buffer_Impl::PPB_Buffer_Impl(PluginModule* module)
- : Resource(module),
+PPB_Buffer_Impl::PPB_Buffer_Impl(PluginInstance* instance)
+ : Resource(instance),
size_(0) {
}
diff --git a/webkit/plugins/ppapi/ppb_buffer_impl.h b/webkit/plugins/ppapi/ppb_buffer_impl.h
index 9642e51..d562b0b 100644
--- a/webkit/plugins/ppapi/ppb_buffer_impl.h
+++ b/webkit/plugins/ppapi/ppb_buffer_impl.h
@@ -18,7 +18,7 @@ class PluginInstance;
class PPB_Buffer_Impl : public Resource {
public:
- explicit PPB_Buffer_Impl(PluginModule* module);
+ explicit PPB_Buffer_Impl(PluginInstance* instance);
virtual ~PPB_Buffer_Impl();
uint32_t size() const { return size_; }
diff --git a/webkit/plugins/ppapi/ppb_char_set_impl.cc b/webkit/plugins/ppapi/ppb_char_set_impl.cc
index edab32e..74144ed 100644
--- a/webkit/plugins/ppapi/ppb_char_set_impl.cc
+++ b/webkit/plugins/ppapi/ppb_char_set_impl.cc
@@ -13,8 +13,8 @@
#include "unicode/ucnv_err.h"
#include "unicode/ustring.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/resource_tracker.h"
#include "webkit/plugins/ppapi/var.h"
namespace webkit {
@@ -46,7 +46,8 @@ bool PPToBaseConversionError(PP_CharSet_ConversionError on_error,
// implementation in base, so we partially duplicate the code from
// icu_string_conversions.cc with the correct error handling setup required
// by this PPAPI interface.
-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) {
@@ -114,7 +115,8 @@ char* UTF16ToCharSet(const uint16_t* utf16, uint32_t utf16_len,
return encoded;
}
-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) {
@@ -141,14 +143,13 @@ uint16_t* CharSetToUTF16(const char* input, uint32_t input_len,
return ret_buf;
}
-PP_Var GetDefaultCharSet(PP_Module pp_module) {
- PluginModule* module = ResourceTracker::Get()->GetModule(pp_module);
- if (!module)
+PP_Var GetDefaultCharSet(PP_Instance instance_id) {
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!instance)
return PP_MakeUndefined();
- std::string encoding =
- module->GetSomeInstance()->delegate()->GetDefaultEncoding();
- return StringVar::StringToPPVar(module, encoding);
+ std::string encoding = instance->delegate()->GetDefaultEncoding();
+ return StringVar::StringToPPVar(instance->module(), encoding);
}
const PPB_CharSet_Dev ppb_charset = {
diff --git a/webkit/plugins/ppapi/ppb_context_3d_impl.cc b/webkit/plugins/ppapi/ppb_context_3d_impl.cc
index 369cbc9..034b3a9 100644
--- a/webkit/plugins/ppapi/ppb_context_3d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_context_3d_impl.cc
@@ -4,6 +4,7 @@
#include "webkit/plugins/ppapi/ppb_context_3d_impl.h"
+#include "base/logging.h"
#include "gpu/command_buffer/common/command_buffer.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
@@ -88,7 +89,7 @@ const PPB_Context3D_Dev ppb_context3d = {
} // namespace
PPB_Context3D_Impl::PPB_Context3D_Impl(PluginInstance* instance)
- : Resource(instance->module()),
+ : Resource(instance),
instance_(instance),
gles2_impl_(NULL),
draw_surface_(NULL),
diff --git a/webkit/plugins/ppapi/ppb_directory_reader_impl.cc b/webkit/plugins/ppapi/ppb_directory_reader_impl.cc
index c650be5..36e43bf 100644
--- a/webkit/plugins/ppapi/ppb_directory_reader_impl.cc
+++ b/webkit/plugins/ppapi/ppb_directory_reader_impl.cc
@@ -49,7 +49,8 @@ PP_Resource Create(PP_Resource directory_ref_id) {
if (!directory_ref)
return 0;
- PPB_DirectoryReader_Impl* reader = new PPB_DirectoryReader_Impl(directory_ref);
+ PPB_DirectoryReader_Impl* reader =
+ new PPB_DirectoryReader_Impl(directory_ref);
return reader->GetReference();
}
@@ -78,7 +79,7 @@ const PPB_DirectoryReader_Dev ppb_directoryreader = {
PPB_DirectoryReader_Impl::PPB_DirectoryReader_Impl(
PPB_FileRef_Impl* directory_ref)
- : Resource(directory_ref->module()),
+ : Resource(directory_ref->instance()),
directory_ref_(directory_ref),
has_more_(true),
entry_(NULL) {
@@ -149,7 +150,7 @@ bool PPB_DirectoryReader_Impl::FillUpEntry() {
if (entry_->file_ref)
ResourceTracker::Get()->UnrefResource(entry_->file_ref);
PPB_FileRef_Impl* file_ref =
- new PPB_FileRef_Impl(module(), directory_ref_->GetFileSystem(),
+ new PPB_FileRef_Impl(instance(), directory_ref_->GetFileSystem(),
FilePathStringToUTF8String(dir_entry.name));
entry_->file_ref = file_ref->GetReference();
entry_->file_type =
diff --git a/webkit/plugins/ppapi/ppb_file_chooser_impl.cc b/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
index b8e4a79..7d65e65 100644
--- a/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
@@ -103,10 +103,10 @@ class FileChooserCompletionImpl : public WebFileChooserCompletion {
} // namespace
-PPB_FileChooser_Impl::PPB_FileChooser_Impl(PluginInstance* instance,
- const PP_FileChooserOptions_Dev* options)
- : Resource(instance->module()),
- delegate_(instance->delegate()),
+PPB_FileChooser_Impl::PPB_FileChooser_Impl(
+ PluginInstance* instance,
+ const PP_FileChooserOptions_Dev* options)
+ : Resource(instance),
mode_(options->mode),
accept_mime_types_(options->accept_mime_types),
completion_callback_() {
@@ -131,7 +131,7 @@ void PPB_FileChooser_Impl::StoreChosenFiles(
for (std::vector<std::string>::const_iterator it = files.begin();
it != end_it; it++) {
chosen_files_.push_back(make_scoped_refptr(
- new PPB_FileRef_Impl(module(), FilePath().AppendASCII(*it))));
+ new PPB_FileRef_Impl(instance(), FilePath().AppendASCII(*it))));
}
if (!completion_callback_.func)
@@ -153,7 +153,7 @@ int32_t PPB_FileChooser_Impl::Show(PP_CompletionCallback callback) {
params.acceptTypes = WebString::fromUTF8(accept_mime_types_);
params.directory = false;
- return delegate_->RunFileChooser(
+ return instance()->delegate()->RunFileChooser(
params, new FileChooserCompletionImpl(this));
}
diff --git a/webkit/plugins/ppapi/ppb_file_chooser_impl.h b/webkit/plugins/ppapi/ppb_file_chooser_impl.h
index d60b503..1d4c7de 100644
--- a/webkit/plugins/ppapi/ppb_file_chooser_impl.h
+++ b/webkit/plugins/ppapi/ppb_file_chooser_impl.h
@@ -23,7 +23,7 @@ class PPB_FileRef_Impl;
class PPB_FileChooser_Impl : public Resource {
public:
PPB_FileChooser_Impl(PluginInstance* instance,
- const PP_FileChooserOptions_Dev* options);
+ const PP_FileChooserOptions_Dev* options);
virtual ~PPB_FileChooser_Impl();
// Returns a pointer to the interface implementing PPB_FileChooser that is
@@ -41,7 +41,6 @@ class PPB_FileChooser_Impl : public Resource {
scoped_refptr<PPB_FileRef_Impl> GetNextChosenFile();
private:
- PluginDelegate* delegate_;
PP_FileChooserMode_Dev mode_;
std::string accept_mime_types_;
PP_CompletionCallback completion_callback_;
diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.cc b/webkit/plugins/ppapi/ppb_file_io_impl.cc
index 6440d16..ac8004b 100644
--- a/webkit/plugins/ppapi/ppb_file_io_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_io_impl.cc
@@ -26,12 +26,12 @@ namespace ppapi {
namespace {
-PP_Resource Create(PP_Module module_id) {
- PluginModule* module = ResourceTracker::Get()->GetModule(module_id);
- if (!module)
+PP_Resource Create(PP_Instance instance_id) {
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!instance)
return 0;
- PPB_FileIO_Impl* file_io = new PPB_FileIO_Impl(module);
+ PPB_FileIO_Impl* file_io = new PPB_FileIO_Impl(instance);
return file_io->GetReference();
}
@@ -200,9 +200,8 @@ int PlatformFileErrorToPepperError(base::PlatformFileError error_code) {
} // namespace
-PPB_FileIO_Impl::PPB_FileIO_Impl(PluginModule* module)
- : Resource(module),
- delegate_(module->GetSomeInstance()->delegate()),
+PPB_FileIO_Impl::PPB_FileIO_Impl(PluginInstance* instance)
+ : Resource(instance),
ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)),
file_(base::kInvalidPlatformFileValue),
callback_(),
@@ -255,7 +254,7 @@ int32_t PPB_FileIO_Impl::Open(PPB_FileRef_Impl* file_ref,
}
file_system_type_ = file_ref->GetFileSystemType();
- if (!delegate_->AsyncOpenFile(
+ if (!instance()->delegate()->AsyncOpenFile(
file_ref->GetSystemPath(), flags,
callback_factory_.NewCallback(
&PPB_FileIO_Impl::AsyncOpenFileCallback)))
@@ -278,7 +277,7 @@ int32_t PPB_FileIO_Impl::Query(PP_FileInfo_Dev* info,
info_ = info;
if (!base::FileUtilProxy::GetFileInfoFromPlatformFile(
- delegate_->GetFileThreadMessageLoopProxy(), file_,
+ instance()->delegate()->GetFileThreadMessageLoopProxy(), file_,
callback_factory_.NewCallback(&PPB_FileIO_Impl::QueryInfoCallback)))
return PP_ERROR_FAILED;
@@ -294,7 +293,7 @@ int32_t PPB_FileIO_Impl::Touch(PP_Time last_access_time,
return rv;
if (!base::FileUtilProxy::Touch(
- delegate_->GetFileThreadMessageLoopProxy(),
+ instance()->delegate()->GetFileThreadMessageLoopProxy(),
file_, base::Time::FromDoubleT(last_access_time),
base::Time::FromDoubleT(last_modified_time),
callback_factory_.NewCallback(&PPB_FileIO_Impl::StatusCallback)))
@@ -313,7 +312,7 @@ int32_t PPB_FileIO_Impl::Read(int64_t offset,
return rv;
if (!base::FileUtilProxy::Read(
- delegate_->GetFileThreadMessageLoopProxy(),
+ instance()->delegate()->GetFileThreadMessageLoopProxy(),
file_, offset, buffer, bytes_to_read,
callback_factory_.NewCallback(&PPB_FileIO_Impl::ReadWriteCallback)))
return PP_ERROR_FAILED;
@@ -331,7 +330,7 @@ int32_t PPB_FileIO_Impl::Write(int64_t offset,
return rv;
if (!base::FileUtilProxy::Write(
- delegate_->GetFileThreadMessageLoopProxy(),
+ instance()->delegate()->GetFileThreadMessageLoopProxy(),
file_, offset, buffer, bytes_to_write,
callback_factory_.NewCallback(&PPB_FileIO_Impl::ReadWriteCallback)))
return PP_ERROR_FAILED;
@@ -347,7 +346,7 @@ int32_t PPB_FileIO_Impl::SetLength(int64_t length,
return rv;
if (!base::FileUtilProxy::Truncate(
- delegate_->GetFileThreadMessageLoopProxy(),
+ instance()->delegate()->GetFileThreadMessageLoopProxy(),
file_, length,
callback_factory_.NewCallback(&PPB_FileIO_Impl::StatusCallback)))
return PP_ERROR_FAILED;
@@ -362,7 +361,7 @@ int32_t PPB_FileIO_Impl::Flush(PP_CompletionCallback callback) {
return rv;
if (!base::FileUtilProxy::Flush(
- delegate_->GetFileThreadMessageLoopProxy(), file_,
+ instance()->delegate()->GetFileThreadMessageLoopProxy(), file_,
callback_factory_.NewCallback(&PPB_FileIO_Impl::StatusCallback)))
return PP_ERROR_FAILED;
@@ -373,7 +372,7 @@ int32_t PPB_FileIO_Impl::Flush(PP_CompletionCallback callback) {
void PPB_FileIO_Impl::Close() {
if (file_ != base::kInvalidPlatformFileValue) {
base::FileUtilProxy::Close(
- delegate_->GetFileThreadMessageLoopProxy(), file_, NULL);
+ instance()->delegate()->GetFileThreadMessageLoopProxy(), file_, NULL);
file_ = base::kInvalidPlatformFileValue;
}
}
@@ -430,7 +429,7 @@ void PPB_FileIO_Impl::RegisterCallback(PP_CompletionCallback callback) {
PP_Resource resource_id = GetReferenceNoAddRef();
CHECK(resource_id);
callback_ = new TrackedCompletionCallback(
- module()->GetCallbackTracker(), resource_id, callback);
+ instance()->module()->GetCallbackTracker(), resource_id, callback);
}
void PPB_FileIO_Impl::RunPendingCallback(int result) {
diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.h b/webkit/plugins/ppapi/ppb_file_io_impl.h
index 0743fdb..3786540 100644
--- a/webkit/plugins/ppapi/ppb_file_io_impl.h
+++ b/webkit/plugins/ppapi/ppb_file_io_impl.h
@@ -30,7 +30,7 @@ class PPB_FileRef_Impl;
class PPB_FileIO_Impl : public Resource {
public:
- explicit PPB_FileIO_Impl(PluginModule* module);
+ explicit PPB_FileIO_Impl(PluginInstance* instance);
virtual ~PPB_FileIO_Impl();
// Returns a pointer to the interface implementing PPB_FileIO that is exposed
@@ -98,7 +98,6 @@ class PPB_FileIO_Impl : public Resource {
void ReadWriteCallback(base::PlatformFileError error_code,
int bytes_read_or_written);
- PluginDelegate* delegate_;
base::ScopedCallbackFactory<PPB_FileIO_Impl> callback_factory_;
base::PlatformFile file_;
diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.cc b/webkit/plugins/ppapi/ppb_file_ref_impl.cc
index f400ce4..0665d2f 100644
--- a/webkit/plugins/ppapi/ppb_file_ref_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_ref_impl.cc
@@ -55,7 +55,7 @@ PP_Resource Create(PP_Resource file_system_id, const char* path) {
TrimTrailingSlash(&validated_path);
PPB_FileRef_Impl* file_ref =
- new PPB_FileRef_Impl(file_system->instance()->module(),
+ new PPB_FileRef_Impl(file_system->instance(),
file_system, validated_path);
return file_ref->GetReference();
}
@@ -77,7 +77,8 @@ PP_Var GetName(PP_Resource file_ref_id) {
Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
if (!file_ref)
return PP_MakeUndefined();
- return StringVar::StringToPPVar(file_ref->module(), file_ref->GetName());
+ return StringVar::StringToPPVar(file_ref->instance()->module(),
+ file_ref->GetName());
}
PP_Var GetPath(PP_Resource file_ref_id) {
@@ -89,7 +90,8 @@ PP_Var GetPath(PP_Resource file_ref_id) {
if (file_ref->GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
return PP_MakeUndefined();
- return StringVar::StringToPPVar(file_ref->module(), file_ref->GetPath());
+ return StringVar::StringToPPVar(file_ref->instance()->module(),
+ file_ref->GetPath());
}
PP_Resource GetParent(PP_Resource file_ref_id) {
@@ -116,7 +118,8 @@ int32_t MakeDirectory(PP_Resource directory_ref_id,
if (!directory_ref)
return PP_ERROR_BADRESOURCE;
- scoped_refptr<PPB_FileSystem_Impl> file_system = directory_ref->GetFileSystem();
+ scoped_refptr<PPB_FileSystem_Impl> file_system =
+ directory_ref->GetFileSystem();
if (!file_system || !file_system->opened() ||
(file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
return PP_ERROR_NOACCESS;
@@ -253,17 +256,18 @@ PPB_FileRef_Impl::PPB_FileRef_Impl()
file_system_(NULL) {
}
-PPB_FileRef_Impl::PPB_FileRef_Impl(PluginModule* module,
- scoped_refptr<PPB_FileSystem_Impl> file_system,
- const std::string& validated_path)
- : Resource(module),
+PPB_FileRef_Impl::PPB_FileRef_Impl(
+ PluginInstance* instance,
+ scoped_refptr<PPB_FileSystem_Impl> file_system,
+ const std::string& validated_path)
+ : Resource(instance),
file_system_(file_system),
virtual_path_(validated_path) {
}
-PPB_FileRef_Impl::PPB_FileRef_Impl(PluginModule* module,
- const FilePath& external_file_path)
- : Resource(module),
+PPB_FileRef_Impl::PPB_FileRef_Impl(PluginInstance* instance,
+ const FilePath& external_file_path)
+ : Resource(instance),
file_system_(NULL),
system_path_(external_file_path) {
}
@@ -317,7 +321,7 @@ scoped_refptr<PPB_FileRef_Impl> PPB_FileRef_Impl::GetParent() {
pos++;
std::string parent_path = virtual_path_.substr(0, pos);
- PPB_FileRef_Impl* parent_ref = new PPB_FileRef_Impl(module(), file_system_,
+ PPB_FileRef_Impl* parent_ref = new PPB_FileRef_Impl(instance(), file_system_,
parent_path);
return parent_ref;
}
diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.h b/webkit/plugins/ppapi/ppb_file_ref_impl.h
index 40924e7..f006991 100644
--- a/webkit/plugins/ppapi/ppb_file_ref_impl.h
+++ b/webkit/plugins/ppapi/ppb_file_ref_impl.h
@@ -21,10 +21,10 @@ class PluginModule;
class PPB_FileRef_Impl : public Resource {
public:
PPB_FileRef_Impl();
- PPB_FileRef_Impl(PluginModule* module,
+ PPB_FileRef_Impl(PluginInstance* instance,
scoped_refptr<PPB_FileSystem_Impl> file_system,
const std::string& validated_path);
- PPB_FileRef_Impl(PluginModule* module,
+ PPB_FileRef_Impl(PluginInstance* instance,
const FilePath& external_file_path);
virtual ~PPB_FileRef_Impl();
diff --git a/webkit/plugins/ppapi/ppb_file_system_impl.cc b/webkit/plugins/ppapi/ppb_file_system_impl.cc
index cec5cec..5f61a7d 100644
--- a/webkit/plugins/ppapi/ppb_file_system_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_system_impl.cc
@@ -75,7 +75,7 @@ const PPB_FileSystem_Dev ppb_filesystem = {
PPB_FileSystem_Impl::PPB_FileSystem_Impl(PluginInstance* instance,
PP_FileSystemType_Dev type)
- : Resource(instance->module()),
+ : Resource(instance),
instance_(instance),
type_(type),
opened_(false) {
diff --git a/webkit/plugins/ppapi/ppb_flash_impl.cc b/webkit/plugins/ppapi/ppb_flash_impl.cc
index 8f20203..386b24f 100644
--- a/webkit/plugins/ppapi/ppb_flash_impl.cc
+++ b/webkit/plugins/ppapi/ppb_flash_impl.cc
@@ -28,14 +28,6 @@ namespace ppapi {
namespace {
-PluginInstance* GetSomeInstance(PP_Module pp_module) {
- PluginModule* module = ResourceTracker::Get()->GetModule(pp_module);
- if (!module)
- return NULL;
-
- return module->GetSomeInstance();
-}
-
void SetInstanceAlwaysOnTop(PP_Instance pp_instance, bool on_top) {
PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance);
if (!instance)
@@ -43,8 +35,8 @@ void SetInstanceAlwaysOnTop(PP_Instance pp_instance, bool on_top) {
instance->set_always_on_top(on_top);
}
-PP_Var GetProxyForURL(PP_Module pp_module, const char* url) {
- PluginInstance* instance = GetSomeInstance(pp_module);
+PP_Var GetProxyForURL(PP_Instance pp_instance, const char* url) {
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance);
if (!instance)
return PP_MakeUndefined();
@@ -66,11 +58,11 @@ FilePath GetFilePathFromUTF8(const char* path) {
#endif
}
-int32_t OpenModuleLocalFile(PP_Module module,
+int32_t OpenModuleLocalFile(PP_Instance pp_instance,
const char* path,
int32_t mode,
PP_FileHandle* file) {
- PluginInstance* instance = GetSomeInstance(module);
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance);
if (!instance)
return PP_ERROR_FAILED;
@@ -106,10 +98,10 @@ int32_t OpenModuleLocalFile(PP_Module module,
}
-int32_t RenameModuleLocalFile(PP_Module module,
+int32_t RenameModuleLocalFile(PP_Instance pp_instance,
const char* path_from,
const char* path_to) {
- PluginInstance* instance = GetSomeInstance(module);
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance);
if (!instance)
return PP_ERROR_FAILED;
@@ -120,10 +112,10 @@ int32_t RenameModuleLocalFile(PP_Module module,
return PlatformFileErrorToPepperError(result);
}
-int32_t DeleteModuleLocalFileOrDir(PP_Module module,
+int32_t DeleteModuleLocalFileOrDir(PP_Instance pp_instance,
const char* path,
bool recursive) {
- PluginInstance* instance = GetSomeInstance(module);
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance);
if (!instance)
return PP_ERROR_FAILED;
@@ -133,8 +125,8 @@ int32_t DeleteModuleLocalFileOrDir(PP_Module module,
return PlatformFileErrorToPepperError(result);
}
-int32_t CreateModuleLocalDir(PP_Module module, const char* path) {
- PluginInstance* instance = GetSomeInstance(module);
+int32_t CreateModuleLocalDir(PP_Instance pp_instance, const char* path) {
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance);
if (!instance)
return PP_ERROR_FAILED;
@@ -143,10 +135,10 @@ int32_t CreateModuleLocalDir(PP_Module module, const char* path) {
return PlatformFileErrorToPepperError(result);
}
-int32_t QueryModuleLocalFile(PP_Module module,
+int32_t QueryModuleLocalFile(PP_Instance pp_instance,
const char* path,
PP_FileInfo_Dev* info) {
- PluginInstance* instance = GetSomeInstance(module);
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance);
if (!instance)
return PP_ERROR_FAILED;
@@ -167,10 +159,10 @@ int32_t QueryModuleLocalFile(PP_Module module,
return PlatformFileErrorToPepperError(result);
}
-int32_t GetModuleLocalDirContents(PP_Module module,
+int32_t GetModuleLocalDirContents(PP_Instance pp_instance,
const char* path,
PP_DirContents_Dev** contents) {
- PluginInstance* instance = GetSomeInstance(module);
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance);
if (!instance)
return PP_ERROR_FAILED;
@@ -205,7 +197,7 @@ int32_t GetModuleLocalDirContents(PP_Module module,
return PP_OK;
}
-void FreeModuleLocalDirContents(PP_Module module,
+void FreeModuleLocalDirContents(PP_Instance instance,
PP_DirContents_Dev* contents) {
DCHECK(contents);
for (int32_t i = 0; i < contents->count; ++i) {
@@ -305,8 +297,7 @@ const PPB_Flash_NetConnector ppb_flash_netconnector = {
PPB_Flash_NetConnector_Impl::PPB_Flash_NetConnector_Impl(
PluginInstance* instance)
- : Resource(instance->module()),
- instance_(instance) {
+ : Resource(instance) {
}
PPB_Flash_NetConnector_Impl::~PPB_Flash_NetConnector_Impl() {
diff --git a/webkit/plugins/ppapi/ppb_flash_impl.h b/webkit/plugins/ppapi/ppb_flash_impl.h
index 25b20d0..7eb2e8b 100644
--- a/webkit/plugins/ppapi/ppb_flash_impl.h
+++ b/webkit/plugins/ppapi/ppb_flash_impl.h
@@ -23,7 +23,8 @@ class PPB_Flash_Impl {
// exposed to the plugin.
static const PPB_Flash* GetInterface();
- static bool DrawGlyphs(PP_Resource pp_image_data,
+ static bool DrawGlyphs(PP_Instance pp_instance,
+ PP_Resource pp_image_data,
const PP_FontDescription_Dev* font_desc,
uint32_t color,
PP_Point position,
@@ -52,8 +53,6 @@ class PPB_Flash_NetConnector_Impl : public Resource {
// Resource override.
virtual PPB_Flash_NetConnector_Impl* AsPPB_Flash_NetConnector_Impl();
- PluginInstance* instance() { return instance_; }
-
// PPB_Flash_NetConnector implementation.
int32_t ConnectTcp(const char* host,
uint16_t port,
@@ -73,9 +72,6 @@ class PPB_Flash_NetConnector_Impl : public Resource {
const PP_Flash_NetAddress& remote_addr);
private:
- // Plugin instance this connector with which is associated.
- PluginInstance* instance_;
-
// Any pending callback (for |ConnectTcp()| or |ConnectTcpAddress()|).
scoped_refptr<TrackedCompletionCallback> callback_;
diff --git a/webkit/plugins/ppapi/ppb_flash_impl_linux.cc b/webkit/plugins/ppapi/ppb_flash_impl_linux.cc
index 23290eb..50346b4 100644
--- a/webkit/plugins/ppapi/ppb_flash_impl_linux.cc
+++ b/webkit/plugins/ppapi/ppb_flash_impl_linux.cc
@@ -20,7 +20,8 @@
namespace webkit {
namespace ppapi {
-bool PPB_Flash_Impl::DrawGlyphs(PP_Resource pp_image_data,
+bool PPB_Flash_Impl::DrawGlyphs(PP_Instance,
+ PP_Resource pp_image_data,
const PP_FontDescription_Dev* font_desc,
uint32_t color,
PP_Point position,
diff --git a/webkit/plugins/ppapi/ppb_font_impl.cc b/webkit/plugins/ppapi/ppb_font_impl.cc
index d0faee9..c63f02ea 100644
--- a/webkit/plugins/ppapi/ppb_font_impl.cc
+++ b/webkit/plugins/ppapi/ppb_font_impl.cc
@@ -15,7 +15,7 @@
#include "third_party/WebKit/WebKit/chromium/public/WebFloatRect.h"
#include "third_party/WebKit/WebKit/chromium/public/WebTextRun.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_image_data_impl.h"
#include "webkit/plugins/ppapi/string.h"
#include "webkit/plugins/ppapi/var.h"
@@ -109,16 +109,16 @@ bool PPTextRunToWebTextRun(const PP_TextRun_Dev* run, WebTextRun* output) {
return true;
}
-PP_Resource Create(PP_Module module_id,
+PP_Resource Create(PP_Instance instance_id,
const PP_FontDescription_Dev* description) {
- PluginModule* module = ResourceTracker::Get()->GetModule(module_id);
- if (!module)
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!instance)
return 0;
if (!IsPPFontDescriptionValid(*description))
return 0;
- scoped_refptr<PPB_Font_Impl> font(new PPB_Font_Impl(module, *description));
+ scoped_refptr<PPB_Font_Impl> font(new PPB_Font_Impl(instance, *description));
return font->GetReference();
}
@@ -186,9 +186,9 @@ const PPB_Font_Dev ppb_font = {
} // namespace
-PPB_Font_Impl::PPB_Font_Impl(PluginModule* module,
+PPB_Font_Impl::PPB_Font_Impl(PluginInstance* instance,
const PP_FontDescription_Dev& desc)
- : Resource(module) {
+ : Resource(instance) {
WebFontDescription web_font_desc = PPFontDescToWebFontDesc(desc);
font_.reset(WebFont::create(web_font_desc));
}
@@ -214,7 +214,7 @@ bool PPB_Font_Impl::Describe(PP_FontDescription_Dev* description,
// While converting the other way in PPFontDescToWebFontDesc we validated
// that the enums can be casted.
- description->face = StringVar::StringToPPVar(module(),
+ description->face = StringVar::StringToPPVar(instance()->module(),
UTF16ToUTF8(web_desc.family));
description->family = static_cast<PP_FontFamily_Dev>(web_desc.genericFamily);
description->size = static_cast<uint32_t>(web_desc.size);
diff --git a/webkit/plugins/ppapi/ppb_font_impl.h b/webkit/plugins/ppapi/ppb_font_impl.h
index ff70330..7a51acf 100644
--- a/webkit/plugins/ppapi/ppb_font_impl.h
+++ b/webkit/plugins/ppapi/ppb_font_impl.h
@@ -21,7 +21,7 @@ class PluginInstance;
class PPB_Font_Impl : public Resource {
public:
- PPB_Font_Impl(PluginModule* module, const PP_FontDescription_Dev& desc);
+ PPB_Font_Impl(PluginInstance* instance, const PP_FontDescription_Dev& desc);
virtual ~PPB_Font_Impl();
// Returns a pointer to the interface implementing PPB_Font that is exposed to
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index 507a3a9..3105b61 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -14,13 +14,11 @@
#include "gfx/rect.h"
#include "skia/ext/platform_canvas.h"
#include "ppapi/c/pp_errors.h"
-#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_rect.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/ppb_graphics_2d.h"
#include "third_party/skia/include/core/SkBitmap.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_image_data_impl.h"
@@ -119,8 +117,8 @@ PP_Resource Create(PP_Instance instance_id,
if (!instance)
return 0;
- scoped_refptr<PPB_Graphics2D_Impl> context(new PPB_Graphics2D_Impl(
- instance->module()));
+ scoped_refptr<PPB_Graphics2D_Impl> context(
+ new PPB_Graphics2D_Impl(instance));
if (!context->Init(size->width, size->height, PPBoolToBool(is_always_opaque)))
return 0;
return context->GetReference();
@@ -217,8 +215,8 @@ struct PPB_Graphics2D_Impl::QueuedOperation {
scoped_refptr<PPB_ImageData_Impl> replace_image;
};
-PPB_Graphics2D_Impl::PPB_Graphics2D_Impl(PluginModule* module)
- : Resource(module),
+PPB_Graphics2D_Impl::PPB_Graphics2D_Impl(PluginInstance* instance)
+ : Resource(instance),
bound_instance_(NULL),
flushed_any_data_(false),
offscreen_flush_pending_(false),
@@ -235,7 +233,7 @@ const PPB_Graphics2D* PPB_Graphics2D_Impl::GetInterface() {
bool PPB_Graphics2D_Impl::Init(int width, int height, bool is_always_opaque) {
// The underlying PPB_ImageData_Impl will validate the dimensions.
- image_data_ = new PPB_ImageData_Impl(module());
+ image_data_ = new PPB_ImageData_Impl(instance());
if (!image_data_->Init(PPB_ImageData_Impl::GetNativeImageDataFormat(),
width, height, true) ||
!image_data_->Map()) {
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.h b/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
index 40f2e5d..f2f60b4 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
@@ -28,7 +28,7 @@ class PluginModule;
class PPB_Graphics2D_Impl : public Resource {
public:
- PPB_Graphics2D_Impl(PluginModule* module);
+ PPB_Graphics2D_Impl(PluginInstance* instance);
virtual ~PPB_Graphics2D_Impl();
// Returns a pointer to the interface implementing PPB_ImageData that is
diff --git a/webkit/plugins/ppapi/ppb_image_data_impl.cc b/webkit/plugins/ppapi/ppb_image_data_impl.cc
index b961a66..042f38b 100644
--- a/webkit/plugins/ppapi/ppb_image_data_impl.cc
+++ b/webkit/plugins/ppapi/ppb_image_data_impl.cc
@@ -11,13 +11,11 @@
#include "base/scoped_ptr.h"
#include "skia/ext/platform_canvas.h"
#include "ppapi/c/pp_instance.h"
-#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/ppb_image_data.h"
#include "ppapi/c/trusted/ppb_image_data_trusted.h"
#include "third_party/skia/include/core/SkColorPriv.h"
#include "webkit/plugins/ppapi/common.h"
-#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
namespace webkit {
@@ -41,8 +39,7 @@ PP_Resource Create(PP_Instance instance_id,
if (!instance)
return 0;
- scoped_refptr<PPB_ImageData_Impl> data(
- new PPB_ImageData_Impl(instance->module()));
+ scoped_refptr<PPB_ImageData_Impl> data(new PPB_ImageData_Impl(instance));
if (!data->Init(format,
size->width,
size->height,
@@ -112,8 +109,8 @@ const PPB_ImageDataTrusted ppb_imagedata_trusted = {
} // namespace
-PPB_ImageData_Impl::PPB_ImageData_Impl(PluginModule* module)
- : Resource(module),
+PPB_ImageData_Impl::PPB_ImageData_Impl(PluginInstance* instance)
+ : Resource(instance),
format_(PP_IMAGEDATAFORMAT_BGRA_PREMUL),
width_(0),
height_(0) {
@@ -167,7 +164,7 @@ bool PPB_ImageData_Impl::Init(PP_ImageDataFormat format,
return false; // Prevent overflow of signed 32-bit ints.
platform_image_.reset(
- module()->GetSomeInstance()->delegate()->CreateImage2D(width, height));
+ instance()->delegate()->CreateImage2D(width, height));
format_ = format;
width_ = width;
height_ = height;
diff --git a/webkit/plugins/ppapi/ppb_image_data_impl.h b/webkit/plugins/ppapi/ppb_image_data_impl.h
index e036d39..84b2bde 100644
--- a/webkit/plugins/ppapi/ppb_image_data_impl.h
+++ b/webkit/plugins/ppapi/ppb_image_data_impl.h
@@ -23,7 +23,7 @@ namespace ppapi {
class PPB_ImageData_Impl : public Resource {
public:
- explicit PPB_ImageData_Impl(PluginModule* module);
+ explicit PPB_ImageData_Impl(PluginInstance* instance);
virtual ~PPB_ImageData_Impl();
int width() const { return width_; }
diff --git a/webkit/plugins/ppapi/ppb_pdf_impl.cc b/webkit/plugins/ppapi/ppb_pdf_impl.cc
index ee58aef..364e9c3 100644
--- a/webkit/plugins/ppapi/ppb_pdf_impl.cc
+++ b/webkit/plugins/ppapi/ppb_pdf_impl.cc
@@ -28,8 +28,8 @@ namespace ppapi {
#if defined(OS_LINUX)
class PrivateFontFile : public Resource {
public:
- PrivateFontFile(PluginModule* module, int fd)
- : Resource(module),
+ PrivateFontFile(PluginInstance* instance, int fd)
+ : Resource(instance),
fd_(fd) {
}
virtual ~PrivateFontFile() {
@@ -82,9 +82,10 @@ static const ResourceImageInfo kResourceImageMap[] = {
IDR_PDF_THUMBNAIL_NUM_BACKGROUND },
};
-PP_Var GetLocalizedString(PP_Module module_id, PP_ResourceString string_id) {
- PluginModule* module = ResourceTracker::Get()->GetModule(module_id);
- if (!module)
+PP_Var GetLocalizedString(PP_Instance instance_id,
+ PP_ResourceString string_id) {
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!instance)
return PP_MakeUndefined();
std::string rv;
@@ -98,10 +99,11 @@ PP_Var GetLocalizedString(PP_Module module_id, PP_ResourceString string_id) {
NOTREACHED();
}
- return StringVar::StringToPPVar(module, rv);
+ return StringVar::StringToPPVar(instance->module(), rv);
}
-PP_Resource GetResourceImage(PP_Module module_id, PP_ResourceImage image_id) {
+PP_Resource GetResourceImage(PP_Instance instance_id,
+ PP_ResourceImage image_id) {
int res_id = 0;
for (size_t i = 0; i < arraysize(kResourceImageMap); ++i) {
if (kResourceImageMap[i].pp_id == image_id) {
@@ -115,10 +117,11 @@ PP_Resource GetResourceImage(PP_Module module_id, PP_ResourceImage image_id) {
SkBitmap* res_bitmap =
ResourceBundle::GetSharedInstance().GetBitmapNamed(res_id);
- PluginModule* module = ResourceTracker::Get()->GetModule(module_id);
- if (!module)
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!instance)
return 0;
- scoped_refptr<PPB_ImageData_Impl> image_data(new PPB_ImageData_Impl(module));
+ scoped_refptr<PPB_ImageData_Impl> image_data(
+ new PPB_ImageData_Impl(instance));
if (!image_data->Init(PPB_ImageData_Impl::GetNativeImageDataFormat(),
res_bitmap->width(), res_bitmap->height(), false)) {
return 0;
@@ -139,12 +142,12 @@ PP_Resource GetResourceImage(PP_Module module_id, PP_ResourceImage image_id) {
}
PP_Resource GetFontFileWithFallback(
- PP_Module module_id,
+ PP_Instance instance_id,
const PP_FontDescription_Dev* description,
PP_PrivateFontCharset charset) {
#if defined(OS_LINUX)
- PluginModule* module = ResourceTracker::Get()->GetModule(module_id);
- if (!module)
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!instance)
return 0;
scoped_refptr<StringVar> face_name(StringVar::FromPPVar(description->face));
@@ -159,7 +162,7 @@ PP_Resource GetFontFileWithFallback(
if (fd == -1)
return 0;
- scoped_refptr<PrivateFontFile> font(new PrivateFontFile(module, fd));
+ scoped_refptr<PrivateFontFile> font(new PrivateFontFile(instance, fd));
return font->GetReference();
#else
@@ -184,7 +187,7 @@ bool GetFontTableForPrivateFontFile(PP_Resource font_file,
#endif
}
-void SearchString(PP_Module module,
+void SearchString(PP_Instance instance,
const unsigned short* input_string,
const unsigned short* input_term,
bool case_sensitive,
diff --git a/webkit/plugins/ppapi/ppb_scrollbar_impl.cc b/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
index c436748..bb93951 100644
--- a/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
+++ b/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
@@ -203,8 +203,8 @@ void PPB_Scrollbar_Impl::SetLocationInternal(const PP_Rect* location) {
void PPB_Scrollbar_Impl::valueChanged(WebKit::WebScrollbar* scrollbar) {
const PPP_Scrollbar_Dev* ppp_scrollbar =
- static_cast<const PPP_Scrollbar_Dev*>(
- module()->GetPluginInterface(PPP_SCROLLBAR_DEV_INTERFACE));
+ static_cast<const PPP_Scrollbar_Dev*>(instance()->module()->
+ GetPluginInterface(PPP_SCROLLBAR_DEV_INTERFACE));
if (!ppp_scrollbar)
return;
ScopedResourceId resource(this);
diff --git a/webkit/plugins/ppapi/ppb_surface_3d_impl.cc b/webkit/plugins/ppapi/ppb_surface_3d_impl.cc
index 5b42cf9..ab37013 100644
--- a/webkit/plugins/ppapi/ppb_surface_3d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_surface_3d_impl.cc
@@ -65,8 +65,7 @@ const PPB_Surface3D_Dev ppb_surface3d = {
} // namespace
PPB_Surface3D_Impl::PPB_Surface3D_Impl(PluginInstance* instance)
- : Resource(instance->module()),
- instance_(instance),
+ : Resource(instance),
bound_to_instance_(false),
swap_initiated_(false),
swap_callback_(PP_BlockUntilComplete()),
diff --git a/webkit/plugins/ppapi/ppb_surface_3d_impl.h b/webkit/plugins/ppapi/ppb_surface_3d_impl.h
index 0cd0643..e3d4173 100644
--- a/webkit/plugins/ppapi/ppb_surface_3d_impl.h
+++ b/webkit/plugins/ppapi/ppb_surface_3d_impl.h
@@ -30,9 +30,6 @@ class PPB_Surface3D_Impl : public Resource {
bool Init(PP_Config3D_Dev config,
const int32_t* attrib_list);
- PluginInstance* instance() const {
- return instance_;
- }
PluginDelegate::PlatformContext3D* context() const {
return context_;
}
@@ -58,8 +55,6 @@ class PPB_Surface3D_Impl : public Resource {
// Called when SwapBuffers is complete.
void OnSwapBuffers();
- // Plugin instance this surface is associated with.
- PluginInstance* instance_;
bool bound_to_instance_;
// True when the page's SwapBuffers has been issued but not returned yet.
diff --git a/webkit/plugins/ppapi/ppb_transport_impl.cc b/webkit/plugins/ppapi/ppb_transport_impl.cc
index 568e9cb..69139e7 100644
--- a/webkit/plugins/ppapi/ppb_transport_impl.cc
+++ b/webkit/plugins/ppapi/ppb_transport_impl.cc
@@ -18,7 +18,7 @@ namespace {
// 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) {
// TODO(juberti): implement me
@@ -118,8 +118,8 @@ const PPB_Transport_Dev ppb_transport = {
} // namespace
-PPB_Transport_Impl::PPB_Transport_Impl(PluginModule* module)
- : Resource(module) {
+PPB_Transport_Impl::PPB_Transport_Impl(PluginInstance* instance)
+ : Resource(instance) {
// TODO(juberti): impl
}
diff --git a/webkit/plugins/ppapi/ppb_transport_impl.h b/webkit/plugins/ppapi/ppb_transport_impl.h
index 7a98a37..96169c7 100644
--- a/webkit/plugins/ppapi/ppb_transport_impl.h
+++ b/webkit/plugins/ppapi/ppb_transport_impl.h
@@ -18,7 +18,7 @@ namespace ppapi {
class PPB_Transport_Impl : public Resource {
public:
- explicit PPB_Transport_Impl(PluginModule* module);
+ explicit PPB_Transport_Impl(PluginInstance* instance);
virtual ~PPB_Transport_Impl();
static const PPB_Transport_Dev* GetInterface();
diff --git a/webkit/plugins/ppapi/ppb_url_loader_impl.cc b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
index 27b7af6..83c5e27 100644
--- a/webkit/plugins/ppapi/ppb_url_loader_impl.cc
+++ b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
@@ -196,8 +196,7 @@ WebKit::WebFrame* GetFrame(PluginInstance* instance) {
PPB_URLLoader_Impl::PPB_URLLoader_Impl(PluginInstance* instance,
bool main_document_loader)
- : Resource(instance->module()),
- instance_(instance),
+ : Resource(instance),
main_document_loader_(main_document_loader),
pending_callback_(),
bytes_sent_(0),
@@ -209,12 +208,9 @@ PPB_URLLoader_Impl::PPB_URLLoader_Impl(PluginInstance* instance,
done_status_(PP_ERROR_WOULDBLOCK),
has_universal_access_(false),
status_callback_(NULL) {
- instance->AddObserver(this);
}
PPB_URLLoader_Impl::~PPB_URLLoader_Impl() {
- if (instance_)
- instance_->RemoveObserver(this);
}
// static
@@ -231,6 +227,15 @@ PPB_URLLoader_Impl* PPB_URLLoader_Impl::AsPPB_URLLoader_Impl() {
return this;
}
+void PPB_URLLoader_Impl::LastPluginRefWasDeleted(bool instance_destroyed) {
+ Resource::LastPluginRefWasDeleted(instance_destroyed);
+ if (instance_destroyed) {
+ // Free the WebKit request when the instance has been destroyed to avoid
+ // using bandwidth just in case this object lives longer than the instance.
+ loader_.reset();
+ }
+}
+
int32_t PPB_URLLoader_Impl::Open(PPB_URLRequestInfo_Impl* request,
PP_CompletionCallback callback) {
int32_t rv = ValidateCallback(callback);
@@ -240,7 +245,7 @@ int32_t PPB_URLLoader_Impl::Open(PPB_URLRequestInfo_Impl* request,
if (loader_.get())
return PP_ERROR_INPROGRESS;
- WebFrame* frame = GetFrame(instance_);
+ WebFrame* frame = GetFrame(instance());
if (!frame)
return PP_ERROR_FAILED;
WebURLRequest web_request(request->ToWebURLRequest(frame));
@@ -269,7 +274,7 @@ int32_t PPB_URLLoader_Impl::FollowRedirect(PP_CompletionCallback callback) {
WebURL redirect_url = GURL(response_info_->redirect_url());
- rv = CanRequest(GetFrame(instance_), redirect_url);
+ rv = CanRequest(GetFrame(instance()), redirect_url);
if (rv != PP_OK)
return rv;
@@ -352,7 +357,7 @@ void PPB_URLLoader_Impl::Close() {
if (loader_.get()) {
loader_->cancel();
} else if (main_document_loader_) {
- WebFrame* frame = instance_->container()->element().document().frame();
+ WebFrame* frame = instance()->container()->element().document().frame();
frame->stopLoading();
}
// TODO(viettrungluu): Check what happens to the callback (probably the
@@ -377,7 +382,7 @@ void PPB_URLLoader_Impl::willSendRequest(
loader_->setDefersLoading(true);
RunCallback(PP_OK);
} else {
- int32_t rv = CanRequest(GetFrame(instance_), new_request.url());
+ int32_t rv = CanRequest(GetFrame(instance()), new_request.url());
if (rv != PP_OK) {
loader_->setDefersLoading(true);
RunCallback(rv);
@@ -438,40 +443,6 @@ void PPB_URLLoader_Impl::didFail(WebURLLoader* loader,
RunCallback(done_status_);
}
-void PPB_URLLoader_Impl::InstanceDestroyed(PluginInstance* instance) {
- // When the instance is destroyed, we force delete any associated loads.
- DCHECK(instance == instance_);
- instance_ = NULL;
-
- // Normally the only ref to this class will be from the plugin which
- // ForceDeletePluginResourceRefs will free. We don't want our object to be
- // deleted out from under us until the function completes.
- scoped_refptr<PPB_URLLoader_Impl> death_grip(this);
-
- // Force delete any plugin refs to us. If the instance is being deleted, we
- // don't want to allow the requests to continue to use bandwidth and send us
- // callbacks (for which we might have no plugin).
- ResourceTracker *tracker = ResourceTracker::Get();
- PP_Resource loader_resource = GetReferenceNoAddRef();
- if (loader_resource)
- tracker->ForceDeletePluginResourceRefs(loader_resource);
-
- // Also force free the response from the plugin, both the plugin's ref(s)
- // and ours.
- if (response_info_.get()) {
- PP_Resource response_info_resource = response_info_->GetReferenceNoAddRef();
- if (response_info_resource)
- tracker->ForceDeletePluginResourceRefs(response_info_resource);
- response_info_ = NULL;
- }
-
- // Free the WebKit request.
- loader_.reset();
-
- // Often, |this| will be deleted at the end of this function when death_grip
- // goes out of scope.
-}
-
int32_t PPB_URLLoader_Impl::ValidateCallback(PP_CompletionCallback callback) {
// We only support non-blocking calls.
if (!callback.func)
@@ -490,7 +461,7 @@ void PPB_URLLoader_Impl::RegisterCallback(PP_CompletionCallback callback) {
PP_Resource resource_id = GetReferenceNoAddRef();
CHECK(resource_id);
pending_callback_ = new TrackedCompletionCallback(
- module()->GetCallbackTracker(), resource_id, callback);
+ instance()->module()->GetCallbackTracker(), resource_id, callback);
}
void PPB_URLLoader_Impl::RunCallback(int32_t result) {
@@ -521,7 +492,7 @@ size_t PPB_URLLoader_Impl::FillUserBuffer() {
void PPB_URLLoader_Impl::SaveResponse(const WebKit::WebURLResponse& response) {
scoped_refptr<PPB_URLResponseInfo_Impl> response_info(
- new PPB_URLResponseInfo_Impl(module()));
+ new PPB_URLResponseInfo_Impl(instance()));
if (response_info->Initialize(response))
response_info_ = response_info;
}
@@ -551,7 +522,7 @@ void PPB_URLLoader_Impl::UpdateStatus() {
// getting download progress when they happen to set the upload progress
// flag.
status_callback_(
- instance_->pp_instance(), pp_resource,
+ instance()->pp_instance(), pp_resource,
RecordUploadProgress() ? bytes_sent_ : -1,
RecordUploadProgress() ? total_bytes_to_be_sent_ : -1,
RecordDownloadProgress() ? bytes_received_ : -1,
diff --git a/webkit/plugins/ppapi/ppb_url_loader_impl.h b/webkit/plugins/ppapi/ppb_url_loader_impl.h
index 4a3d72e..aa3950b 100644
--- a/webkit/plugins/ppapi/ppb_url_loader_impl.h
+++ b/webkit/plugins/ppapi/ppb_url_loader_impl.h
@@ -31,9 +31,7 @@ class PluginInstance;
class PPB_URLRequestInfo_Impl;
class PPB_URLResponseInfo_Impl;
-class PPB_URLLoader_Impl : public Resource,
- public WebKit::WebURLLoaderClient,
- public PluginInstance::Observer {
+class PPB_URLLoader_Impl : public Resource, public WebKit::WebURLLoaderClient {
public:
PPB_URLLoader_Impl(PluginInstance* instance, bool main_document_loader);
virtual ~PPB_URLLoader_Impl();
@@ -48,6 +46,7 @@ class PPB_URLLoader_Impl : public Resource,
// Resource overrides.
virtual PPB_URLLoader_Impl* AsPPB_URLLoader_Impl();
+ virtual void LastPluginRefWasDeleted(bool instance_destroyed);
// PPB_URLLoader implementation.
int32_t Open(PPB_URLRequestInfo_Impl* request,
@@ -85,9 +84,6 @@ class PPB_URLLoader_Impl : public Resource,
virtual void didFail(WebKit::WebURLLoader* loader,
const WebKit::WebURLError& error);
- // PluginInstance::Observer implementation.
- virtual void InstanceDestroyed(PluginInstance* instance);
-
PPB_URLResponseInfo_Impl* response_info() const { return response_info_; }
private:
@@ -122,13 +118,6 @@ class PPB_URLLoader_Impl : public Resource,
bool RecordDownloadProgress() const;
bool RecordUploadProgress() const;
- // This will be NULL if the instance has been deleted but this
- // PPB_URLLoader_Impl was somehow leaked. In general, you should not need to
- // check this for NULL. However, if you see a NULL pointer crash, that means
- // somebody is holding a reference to this object longer than the
- // PluginInstance's lifetime.
- PluginInstance* instance_;
-
// If true, then the plugin instance is a full-frame plugin and we're just
// wrapping the main document's loader (i.e. loader_ is null).
bool main_document_loader_;
diff --git a/webkit/plugins/ppapi/ppb_url_request_info_impl.cc b/webkit/plugins/ppapi/ppb_url_request_info_impl.cc
index cb1e545..5c59a67 100644
--- a/webkit/plugins/ppapi/ppb_url_request_info_impl.cc
+++ b/webkit/plugins/ppapi/ppb_url_request_info_impl.cc
@@ -81,12 +81,12 @@ bool AreValidHeaders(const std::string& headers) {
return true;
}
-PP_Resource Create(PP_Module module_id) {
- PluginModule* module = ResourceTracker::Get()->GetModule(module_id);
- if (!module)
+PP_Resource Create(PP_Instance instance_id) {
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!instance)
return 0;
- PPB_URLRequestInfo_Impl* request = new PPB_URLRequestInfo_Impl(module);
+ PPB_URLRequestInfo_Impl* request = new PPB_URLRequestInfo_Impl(instance);
return request->GetReference();
}
@@ -187,8 +187,8 @@ struct PPB_URLRequestInfo_Impl::BodyItem {
PP_Time expected_last_modified_time;
};
-PPB_URLRequestInfo_Impl::PPB_URLRequestInfo_Impl(PluginModule* module)
- : Resource(module),
+PPB_URLRequestInfo_Impl::PPB_URLRequestInfo_Impl(PluginInstance* instance)
+ : Resource(instance),
stream_to_file_(false),
follow_redirects_(true),
record_download_progress_(false),
diff --git a/webkit/plugins/ppapi/ppb_url_request_info_impl.h b/webkit/plugins/ppapi/ppb_url_request_info_impl.h
index a55edfe..64c27fe 100644
--- a/webkit/plugins/ppapi/ppb_url_request_info_impl.h
+++ b/webkit/plugins/ppapi/ppb_url_request_info_impl.h
@@ -24,7 +24,7 @@ class PPB_FileRef_Impl;
class PPB_URLRequestInfo_Impl : public Resource {
public:
- explicit PPB_URLRequestInfo_Impl(PluginModule* module);
+ explicit PPB_URLRequestInfo_Impl(PluginInstance* instance);
virtual ~PPB_URLRequestInfo_Impl();
// Returns a pointer to the interface implementing PPB_URLRequestInfo that is
diff --git a/webkit/plugins/ppapi/ppb_url_response_info_impl.cc b/webkit/plugins/ppapi/ppb_url_response_info_impl.cc
index 43e3d9e..5ca945a 100644
--- a/webkit/plugins/ppapi/ppb_url_response_info_impl.cc
+++ b/webkit/plugins/ppapi/ppb_url_response_info_impl.cc
@@ -11,6 +11,7 @@
#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h"
#include "webkit/plugins/ppapi/common.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
#include "webkit/plugins/ppapi/var.h"
#include "webkit/glue/webkit_glue.h"
@@ -80,8 +81,8 @@ bool IsRedirect(int32_t status) {
} // namespace
-PPB_URLResponseInfo_Impl::PPB_URLResponseInfo_Impl(PluginModule* module)
- : Resource(module),
+PPB_URLResponseInfo_Impl::PPB_URLResponseInfo_Impl(PluginInstance* instance)
+ : Resource(instance),
status_code_(-1) {
}
@@ -101,21 +102,21 @@ PPB_URLResponseInfo_Impl::AsPPB_URLResponseInfo_Impl() {
PP_Var PPB_URLResponseInfo_Impl::GetProperty(PP_URLResponseProperty property) {
switch (property) {
case PP_URLRESPONSEPROPERTY_URL:
- return StringVar::StringToPPVar(module(), url_);
+ return StringVar::StringToPPVar(instance()->module(), url_);
case PP_URLRESPONSEPROPERTY_REDIRECTURL:
if (IsRedirect(status_code_))
- return StringVar::StringToPPVar(module(), redirect_url_);
+ return StringVar::StringToPPVar(instance()->module(), redirect_url_);
break;
case PP_URLRESPONSEPROPERTY_REDIRECTMETHOD:
if (IsRedirect(status_code_))
- return StringVar::StringToPPVar(module(), status_text_);
+ return StringVar::StringToPPVar(instance()->module(), status_text_);
break;
case PP_URLRESPONSEPROPERTY_STATUSCODE:
return PP_MakeInt32(status_code_);
case PP_URLRESPONSEPROPERTY_STATUSLINE:
- return StringVar::StringToPPVar(module(), status_text_);
+ return StringVar::StringToPPVar(instance()->module(), status_text_);
case PP_URLRESPONSEPROPERTY_HEADERS:
- return StringVar::StringToPPVar(module(), headers_);
+ return StringVar::StringToPPVar(instance()->module(), headers_);
}
// The default is to return an undefined PP_Var.
return PP_MakeUndefined();
@@ -136,7 +137,7 @@ bool PPB_URLResponseInfo_Impl::Initialize(const WebURLResponse& response) {
WebString file_path = response.downloadFilePath();
if (!file_path.isEmpty())
- body_ = new PPB_FileRef_Impl(module(),
+ body_ = new PPB_FileRef_Impl(instance(),
webkit_glue::WebStringToFilePath(file_path));
return true;
}
diff --git a/webkit/plugins/ppapi/ppb_url_response_info_impl.h b/webkit/plugins/ppapi/ppb_url_response_info_impl.h
index ee12d35c..fa916d9 100644
--- a/webkit/plugins/ppapi/ppb_url_response_info_impl.h
+++ b/webkit/plugins/ppapi/ppb_url_response_info_impl.h
@@ -22,7 +22,7 @@ class PPB_FileRef_Impl;
class PPB_URLResponseInfo_Impl : public Resource {
public:
- explicit PPB_URLResponseInfo_Impl(PluginModule* module);
+ explicit PPB_URLResponseInfo_Impl(PluginInstance* instance);
virtual ~PPB_URLResponseInfo_Impl();
// Returns a pointer to the interface implementing PPB_URLResponseInfo that
diff --git a/webkit/plugins/ppapi/ppb_url_util_impl.cc b/webkit/plugins/ppapi/ppb_url_util_impl.cc
index 47980e4..1465145 100644
--- a/webkit/plugins/ppapi/ppb_url_util_impl.cc
+++ b/webkit/plugins/ppapi/ppb_url_util_impl.cc
@@ -15,6 +15,7 @@
#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
+#include "webkit/plugins/ppapi/resource_tracker.h"
#include "webkit/plugins/ppapi/string.h"
#include "webkit/plugins/ppapi/var.h"
diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
index bd7f204..9d6add6 100644
--- a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
+++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
@@ -97,8 +97,7 @@ const PPB_VideoDecoder_Dev ppb_videodecoder = {
} // namespace
PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PluginInstance* instance)
- : Resource(instance->module()),
- instance_(instance) {
+ : Resource(instance) {
}
PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() {
diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.h b/webkit/plugins/ppapi/ppb_video_decoder_impl.h
index 169ebed..cc4527e 100644
--- a/webkit/plugins/ppapi/ppb_video_decoder_impl.h
+++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.h
@@ -32,8 +32,6 @@ class PPB_VideoDecoder_Impl : public Resource {
// Resource overrides.
virtual PPB_VideoDecoder_Impl* AsPPB_VideoDecoder_Impl();
- PluginInstance* instance() { return instance_.get(); }
-
// PPB_VideoDecoder implementation.
bool Init(const PP_VideoDecoderConfig_Dev& decoder_config);
bool Decode(PP_VideoCompressedDataBuffer_Dev& input_buffer);
@@ -44,7 +42,6 @@ class PPB_VideoDecoder_Impl : public Resource {
// This is NULL before initialization, and if this PPB_VideoDecoder_Impl is
// swapped with another.
scoped_ptr<PluginDelegate::PlatformVideoDecoder> platform_video_decoder_;
- scoped_refptr<PluginInstance> instance_;
DISALLOW_COPY_AND_ASSIGN(PPB_VideoDecoder_Impl);
};
diff --git a/webkit/plugins/ppapi/ppb_widget_impl.cc b/webkit/plugins/ppapi/ppb_widget_impl.cc
index 57491b5..89a0c069 100644
--- a/webkit/plugins/ppapi/ppb_widget_impl.cc
+++ b/webkit/plugins/ppapi/ppb_widget_impl.cc
@@ -69,8 +69,7 @@ const PPB_Widget_Dev ppb_widget = {
} // namespace
PPB_Widget_Impl::PPB_Widget_Impl(PluginInstance* instance)
- : Resource(instance->module()),
- instance_(instance) {
+ : Resource(instance) {
}
PPB_Widget_Impl::~PPB_Widget_Impl() {
@@ -97,7 +96,7 @@ void PPB_Widget_Impl::SetLocation(const PP_Rect* location) {
void PPB_Widget_Impl::Invalidate(const PP_Rect* dirty) {
const PPP_Widget_Dev* widget = static_cast<const PPP_Widget_Dev*>(
- module()->GetPluginInterface(PPP_WIDGET_DEV_INTERFACE));
+ instance()->module()->GetPluginInterface(PPP_WIDGET_DEV_INTERFACE));
if (!widget)
return;
ScopedResourceId resource(this);
diff --git a/webkit/plugins/ppapi/resource.cc b/webkit/plugins/ppapi/resource.cc
index 4f77104..9619861 100644
--- a/webkit/plugins/ppapi/resource.cc
+++ b/webkit/plugins/ppapi/resource.cc
@@ -6,14 +6,15 @@
#include "base/logging.h"
#include "webkit/plugins/ppapi/callbacks.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/resource_tracker.h"
namespace webkit {
namespace ppapi {
-Resource::Resource(PluginModule* module)
- : resource_id_(0), module_(module) {
+Resource::Resource(PluginInstance* instance)
+ : resource_id_(0), instance_(instance) {
}
Resource::~Resource() {
@@ -32,10 +33,14 @@ PP_Resource Resource::GetReferenceNoAddRef() const {
return resource_id_;
}
-void Resource::StoppedTracking() {
+void Resource::LastPluginRefWasDeleted(bool instance_destroyed) {
DCHECK(resource_id_ != 0);
- module_->GetCallbackTracker()->PostAbortForResource(resource_id_);
+ instance()->module()->GetCallbackTracker()->PostAbortForResource(
+ resource_id_);
resource_id_ = 0;
+
+ if (instance_destroyed)
+ instance_ = NULL;
}
#define DEFINE_TYPE_GETTER(RESOURCE) \
diff --git a/webkit/plugins/ppapi/resource.h b/webkit/plugins/ppapi/resource.h
index d8114d0..fb4f2ef 100644
--- a/webkit/plugins/ppapi/resource.h
+++ b/webkit/plugins/ppapi/resource.h
@@ -16,7 +16,6 @@ namespace ppapi {
// If you inherit from resource, make sure you add the class name here.
#define FOR_ALL_RESOURCES(F) \
F(MockResource) \
- F(ObjectVar) \
F(PPB_AudioConfig_Impl) \
F(PPB_Audio_Impl) \
F(PPB_Buffer_Impl) \
@@ -39,10 +38,7 @@ namespace ppapi {
F(PPB_URLResponseInfo_Impl) \
F(PPB_VideoDecoder_Impl) \
F(PPB_Widget_Impl) \
- F(PrivateFontFile) \
- F(StringVar) \
- F(Var) \
- F(VarObjectClass)
+ F(PrivateFontFile)
// Forward declaration of Resource classes.
#define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE;
@@ -51,7 +47,7 @@ FOR_ALL_RESOURCES(DECLARE_RESOURCE_CLASS)
class Resource : public base::RefCountedThreadSafe<Resource> {
public:
- explicit Resource(PluginModule* module);
+ explicit Resource(PluginInstance* instance);
virtual ~Resource();
// Returns NULL if the resource is invalid or is a different type.
@@ -61,7 +57,10 @@ class Resource : public base::RefCountedThreadSafe<Resource> {
return resource ? resource->Cast<T>() : NULL;
}
- PluginModule* module() const { return module_; }
+ // Returns the instance owning this resource. This is generally to be
+ // non-NULL except if the instance is destroyed and some code internal to the
+ // PPAPI implementation is keeping a reference for some reason.
+ PluginInstance* instance() const { return instance_; }
// Cast the resource into a specified type. This will return NULL if the
// resource does not match the specified type. Specializations of this
@@ -101,6 +100,22 @@ class Resource : public base::RefCountedThreadSafe<Resource> {
const PP_Resource id;
};
+ // Called by the resource tracker when the last reference from the plugin
+ // was released. For a few types of resources, the resource could still
+ // stay alive if there are other references held by the PPAPI implementation
+ // (possibly for callbacks and things).
+ //
+ // When the plugin instance is deleted, all resources associated with that
+ // plugin will have their plugin references force-deleted and this function
+ // will be called with instance_destroyed as true. If the plugin normally
+ // Release()s a reference before the instance is destroyed,
+ // instance_destroyed will be false. It's possible in some rare cases for the
+ // plugin to get a new reference to the object in this latter case, if it's
+ // stored internal to the PPAPI implementation and returned by some function.
+ //
+ // If you override this, be sure to call the base class' implementation.
+ virtual void LastPluginRefWasDeleted(bool instance_destroyed);
+
private:
// Type-specific getters for individual resource types. These will return
// NULL if the resource does not match the specified type. Used by the Cast()
@@ -118,13 +133,8 @@ class Resource : public base::RefCountedThreadSafe<Resource> {
// refcount.
PP_Resource resource_id_;
- // Non-owning pointer to our module.
- PluginModule* module_;
-
- // Called by the resource tracker when the last plugin reference has been
- // dropped.
- friend class ResourceTracker;
- void StoppedTracking();
+ // Non-owning pointer to our instance. See getter above.
+ PluginInstance* instance_;
DISALLOW_COPY_AND_ASSIGN(Resource);
};
diff --git a/webkit/plugins/ppapi/resource_tracker.cc b/webkit/plugins/ppapi/resource_tracker.cc
index 7f66160..38d55a9 100644
--- a/webkit/plugins/ppapi/resource_tracker.cc
+++ b/webkit/plugins/ppapi/resource_tracker.cc
@@ -11,7 +11,9 @@
#include "base/logging.h"
#include "base/rand_util.h"
#include "ppapi/c/pp_resource.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/resource.h"
+#include "webkit/plugins/ppapi/var.h"
namespace webkit {
namespace ppapi {
@@ -31,7 +33,8 @@ scoped_refptr<Resource> ResourceTracker::GetResource(PP_Resource res) const {
ResourceTracker* ResourceTracker::singleton_override_ = NULL;
ResourceTracker::ResourceTracker()
- : last_id_(0) {
+ : last_resource_id_(0),
+ last_var_id_(0) {
}
ResourceTracker::~ResourceTracker() {
@@ -45,14 +48,27 @@ ResourceTracker* ResourceTracker::Get() {
}
PP_Resource ResourceTracker::AddResource(Resource* resource) {
- // If the plugin manages to create 4B resources...
- if (last_id_ == std::numeric_limits<PP_Resource>::max()) {
+ // If the plugin manages to create 4 billion resources, don't do crazy stuff.
+ if (last_resource_id_ == std::numeric_limits<PP_Resource>::max())
+ return 0;
+
+ // Add the resource with plugin use-count 1.
+ PP_Resource new_id = ++last_resource_id_;
+ live_resources_.insert(std::make_pair(new_id, std::make_pair(resource, 1)));
+ instance_to_resources_[resource->instance()->pp_instance()].insert(new_id);
+ return new_id;
+}
+
+int32 ResourceTracker::AddVar(Var* var) {
+ // If the plugin manages to create 4B strings...
+ if (last_var_id_ == std::numeric_limits<int32>::max()) {
return 0;
}
// Add the resource with plugin use-count 1.
- ++last_id_;
- live_resources_.insert(std::make_pair(last_id_, std::make_pair(resource, 1)));
- return last_id_;
+ ++last_var_id_;
+ live_vars_.insert(std::make_pair(last_var_id_,
+ std::make_pair(var, 1)));
+ return last_var_id_;
}
bool ResourceTracker::AddRefResource(PP_Resource res) {
@@ -72,7 +88,14 @@ bool ResourceTracker::UnrefResource(PP_Resource res) {
ResourceMap::iterator i = live_resources_.find(res);
if (i != live_resources_.end()) {
if (!--i->second.second) {
- i->second.first->StoppedTracking();
+ Resource* to_release = i->second.first;
+ to_release->LastPluginRefWasDeleted(false);
+
+ ResourceSet& instance_resource_set =
+ instance_to_resources_[to_release->instance()->pp_instance()];
+ DCHECK(instance_resource_set.find(res) != instance_resource_set.end());
+ instance_resource_set.erase(res);
+
live_resources_.erase(i);
}
return true;
@@ -87,7 +110,16 @@ void ResourceTracker::ForceDeletePluginResourceRefs(PP_Resource res) {
return; // Nothing to do.
i->second.second = 0;
- i->second.first->StoppedTracking();
+ Resource* resource = i->second.first;
+
+ // Must delete from the resource set first since the resource's instance
+ // pointer will get zeroed out in LastPluginRefWasDeleted.
+ ResourceSet& resource_set = instance_to_resources_[
+ resource->instance()->pp_instance()];
+ DCHECK(resource_set.find(res) != resource_set.end());
+ resource_set.erase(res);
+
+ resource->LastPluginRefWasDeleted(true);
live_resources_.erase(i);
}
@@ -105,6 +137,36 @@ uint32 ResourceTracker::GetLiveObjectsForModule(PluginModule* module) const {
return count;
}
+scoped_refptr<Var> ResourceTracker::GetVar(int32 var_id) const {
+ VarMap::const_iterator result = live_vars_.find(var_id);
+ if (result == live_vars_.end()) {
+ return scoped_refptr<Var>();
+ }
+ return result->second.first;
+}
+
+bool ResourceTracker::AddRefVar(int32 var_id) {
+ VarMap::iterator i = live_vars_.find(var_id);
+ if (i != live_vars_.end()) {
+ // We don't protect against overflow, since a plugin as malicious as to ref
+ // once per every byte in the address space could have just as well unrefed
+ // one time too many.
+ ++i->second.second;
+ return true;
+ }
+ return false;
+}
+
+bool ResourceTracker::UnrefVar(int32 var_id) {
+ VarMap::iterator i = live_vars_.find(var_id);
+ if (i != live_vars_.end()) {
+ if (!--i->second.second)
+ live_vars_.erase(i);
+ return true;
+ }
+ return false;
+}
+
PP_Instance ResourceTracker::AddInstance(PluginInstance* instance) {
#ifndef NDEBUG
// Make sure we're not adding one more than once.
@@ -130,6 +192,20 @@ PP_Instance ResourceTracker::AddInstance(PluginInstance* instance) {
}
void ResourceTracker::InstanceDeleted(PP_Instance instance) {
+ // Force release all plugin references to resources associated with the
+ // deleted instance.
+ ResourceSet& resource_set = instance_to_resources_[instance];
+ ResourceSet::iterator i = resource_set.begin();
+ while (i != resource_set.end()) {
+ // Iterators to a set are stable so we can iterate the set while the items
+ // are being deleted as long as we're careful not to delete the item we're
+ // holding an iterator to.
+ ResourceSet::iterator current = i++;
+ ForceDeletePluginResourceRefs(*current);
+ }
+ DCHECK(resource_set.empty());
+ instance_to_resources_.erase(instance);
+
InstanceMap::iterator found = instance_map_.find(instance);
if (found == instance_map_.end()) {
NOTREACHED();
diff --git a/webkit/plugins/ppapi/resource_tracker.h b/webkit/plugins/ppapi/resource_tracker.h
index 7a5e002..0b49ad8 100644
--- a/webkit/plugins/ppapi/resource_tracker.h
+++ b/webkit/plugins/ppapi/resource_tracker.h
@@ -6,6 +6,7 @@
#define WEBKIT_PLUGINS_PPAPI_RESOURCE_TRACKER_H_
#include <map>
+#include <set>
#include <utility>
#include "base/basictypes.h"
@@ -27,6 +28,7 @@ class PluginInstance;
class PluginModule;
class Resource;
class ResourceTrackerTest;
+class Var;
// This class maintains a global list of all live pepper resources. It allows
// us to check resource ID validity and to map them to a specific module.
@@ -51,9 +53,8 @@ class ResourceTracker {
bool AddRefResource(PP_Resource res);
bool UnrefResource(PP_Resource res);
- // Forces the plugin refcount of the given resource to 0. This can be used to
- // delete an object the plugin has leaked or whose lifetime is otherwise
- // exceeded.
+ // Forces the plugin refcount of the given resource to 0. This is used when
+ // the instance is destroyed and we want to free all resources.
//
// Note that this may not necessarily delete the resource object since the
// regular refcount is maintained separately from the plugin refcount and
@@ -66,6 +67,13 @@ class ResourceTracker {
// This is slow, use only for testing.
uint32 GetLiveObjectsForModule(PluginModule* module) const;
+ // PP_Vars -------------------------------------------------------------------
+
+ scoped_refptr<Var> GetVar(int32 var_id) const;
+
+ bool AddRefVar(int32 var_id);
+ bool UnrefVar(int32 var_id);
+
// PP_Modules ----------------------------------------------------------------
// Adds a new plugin module to the list of tracked module, and returns a new
@@ -98,6 +106,7 @@ class ResourceTracker {
friend struct base::DefaultLazyInstanceTraits<ResourceTracker>;
friend class Resource;
friend class ResourceTrackerTest;
+ friend class Var;
// Prohibit creation other then by the Singleton class.
ResourceTracker();
@@ -108,6 +117,9 @@ class ResourceTracker {
// Resource class.
PP_Resource AddResource(Resource* resource);
+ // The same as AddResource but for Var, and returns the new Var ID.
+ int32 AddVar(Var* var);
+
// Overrides the singleton object. This is used for tests which want to
// specify their own tracker (otherwise, you can get cross-talk between
// tests since the data will live into the subsequent tests).
@@ -117,8 +129,9 @@ class ResourceTracker {
// See SetSingletonOverride above.
static ResourceTracker* singleton_override_;
- // Last assigned resource ID.
- PP_Resource last_id_;
+ // Last assigned resource & var ID.
+ PP_Resource last_resource_id_;
+ int32 last_var_id_;
// For each PP_Resource, keep the Resource* (as refptr) and plugin use count.
// This use count is different then Resource's RefCount, and is manipulated
@@ -130,6 +143,17 @@ class ResourceTracker {
typedef base::hash_map<PP_Resource, ResourceAndRefCount> ResourceMap;
ResourceMap live_resources_;
+ // Like ResourceAndRefCount but for vars, which are associated with modules.
+ typedef std::pair<scoped_refptr<Var>, size_t> VarAndRefCount;
+ typedef base::hash_map<int32, VarAndRefCount> VarMap;
+ VarMap live_vars_;
+
+ // Tracks all resources associated with each instance. This is used to
+ // delete resources when the instance has been destroyed to avoid leaks.
+ typedef std::set<PP_Resource> ResourceSet;
+ typedef std::map<PP_Instance, ResourceSet> InstanceToResourceMap;
+ InstanceToResourceMap instance_to_resources_;
+
// Tracks all live instances. The pointers are non-owning, the PluginInstance
// destructor will notify us when the instance is deleted.
typedef std::map<PP_Instance, PluginInstance*> InstanceMap;
diff --git a/webkit/plugins/ppapi/resource_tracker_unittest.cc b/webkit/plugins/ppapi/resource_tracker_unittest.cc
index 4170460..bbcff1f 100644
--- a/webkit/plugins/ppapi/resource_tracker_unittest.cc
+++ b/webkit/plugins/ppapi/resource_tracker_unittest.cc
@@ -4,7 +4,10 @@
#include "webkit/plugins/ppapi/ppapi_unittest.h"
+#include "ppapi/c/ppp_instance.h"
+#include "webkit/plugins/ppapi/mock_plugin_delegate.h"
#include "webkit/plugins/ppapi/mock_resource.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/resource_tracker.h"
namespace webkit {
@@ -16,7 +19,7 @@ class TrackedMockResource : public MockResource {
public:
static int tracked_objects_alive;
- TrackedMockResource(PluginModule* module) : MockResource(module) {
+ TrackedMockResource(PluginInstance* instance) : MockResource(instance) {
tracked_objects_alive++;
}
~TrackedMockResource() {
@@ -53,7 +56,7 @@ TEST_F(ResourceTrackerTest, Ref) {
EXPECT_EQ(0u, tracker().GetLiveObjectsForModule(module()));
{
scoped_refptr<TrackedMockResource> new_resource(
- new TrackedMockResource(module()));
+ new TrackedMockResource(instance()));
ASSERT_EQ(1, TrackedMockResource::tracked_objects_alive);
// Since we haven't gotten a PP_Resource, it's not associated with the
@@ -66,7 +69,7 @@ TEST_F(ResourceTrackerTest, Ref) {
PP_Resource resource_id = 0;
{
scoped_refptr<TrackedMockResource> new_resource(
- new TrackedMockResource(module()));
+ new TrackedMockResource(instance()));
ASSERT_EQ(1, TrackedMockResource::tracked_objects_alive);
resource_id = new_resource->GetReference();
EXPECT_EQ(1u, tracker().GetLiveObjectsForModule(module()));
@@ -87,14 +90,20 @@ TEST_F(ResourceTrackerTest, Ref) {
ASSERT_EQ(0, TrackedMockResource::tracked_objects_alive);
}
-TEST_F(ResourceTrackerTest, ForceDelete) {
- // Make two resources.
+TEST_F(ResourceTrackerTest, ForceDeleteWithInstance) {
+ // Make a second instance (the test harness already creates & manages one).
+ scoped_refptr<PluginInstance> instance2(
+ new PluginInstance(delegate(), module(),
+ static_cast<const PPP_Instance*>(
+ GetMockInterface(PPP_INSTANCE_INTERFACE))));
+
+ // Make two resources and take refs on behalf of the "plugin" for each.
scoped_refptr<TrackedMockResource> resource1(
- new TrackedMockResource(module()));
- PP_Resource pp_resource1 = resource1->GetReference();
+ new TrackedMockResource(instance2));
+ resource1->GetReference();
scoped_refptr<TrackedMockResource> resource2(
- new TrackedMockResource(module()));
- PP_Resource pp_resource2 = resource2->GetReference();
+ new TrackedMockResource(instance2));
+ resource2->GetReference();
// Keep an "internal" ref to only the first (the PP_Resource also holds a
// ref to each resource on behalf of the plugin).
@@ -103,12 +112,13 @@ TEST_F(ResourceTrackerTest, ForceDelete) {
ASSERT_EQ(2, TrackedMockResource::tracked_objects_alive);
EXPECT_EQ(2u, tracker().GetLiveObjectsForModule(module()));
- // Force delete both refs.
- tracker().ForceDeletePluginResourceRefs(pp_resource1);
- tracker().ForceDeletePluginResourceRefs(pp_resource2);
+ // Free the instance, this should release both plugin refs.
+ instance2 = NULL;
EXPECT_EQ(0u, tracker().GetLiveObjectsForModule(module()));
- // The resource we have a scoped_refptr to should still be alive.
+ // The resource we have a scoped_refptr to should still be alive, but it
+ // should have a NULL instance.
+ ASSERT_FALSE(resource1->instance());
ASSERT_EQ(1, TrackedMockResource::tracked_objects_alive);
resource1 = NULL;
ASSERT_EQ(0, TrackedMockResource::tracked_objects_alive);
diff --git a/webkit/plugins/ppapi/url_request_info_unittest.cc b/webkit/plugins/ppapi/url_request_info_unittest.cc
index 769d760..ba66058 100644
--- a/webkit/plugins/ppapi/url_request_info_unittest.cc
+++ b/webkit/plugins/ppapi/url_request_info_unittest.cc
@@ -45,7 +45,7 @@ namespace ppapi {
class URLRequestInfoTest : public PpapiUnittest {
public:
- URLRequestInfoTest() : info_(new PPB_URLRequestInfo_Impl(module())) {
+ URLRequestInfoTest() : info_(new PPB_URLRequestInfo_Impl(instance())) {
}
static void SetUpTestCase() {
diff --git a/webkit/plugins/ppapi/var.cc b/webkit/plugins/ppapi/var.cc
index 4ed0e10..6710c8e 100644
--- a/webkit/plugins/ppapi/var.cc
+++ b/webkit/plugins/ppapi/var.cc
@@ -17,6 +17,7 @@
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/plugin_object.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
+#include "webkit/plugins/ppapi/resource_tracker.h"
#include "v8/include/v8.h"
using WebKit::WebBindings;
@@ -206,7 +207,7 @@ PP_Var RunJSFunction(PP_Var scope_var,
if (WebBindings::invokeDefault(NULL, NPVARIANT_TO_OBJECT(function_var),
args.get(), argc, &result_var)) {
- result = Var::NPVariantToPPVar(obj->module(), &result_var);
+ result = Var::NPVariantToPPVar(obj->instance(), &result_var);
} else {
DCHECK(try_catch.has_exception());
result = PP_MakeUndefined();
@@ -377,7 +378,7 @@ PP_Var GetProperty(PP_Var var,
return PP_MakeUndefined();
}
- PP_Var ret = Var::NPVariantToPPVar(accessor.object()->module(), &result);
+ PP_Var ret = Var::NPVariantToPPVar(accessor.object()->instance(), &result);
WebBindings::releaseVariantValue(&result);
return ret;
}
@@ -407,8 +408,9 @@ 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] = Var::NPIdentifierToPPVar(accessor.object()->module(),
- identifiers[i]);
+ (*properties)[i] = Var::NPIdentifierToPPVar(
+ accessor.object()->instance()->module(),
+ identifiers[i]);
}
free(identifiers);
}
@@ -493,7 +495,7 @@ struct PP_Var Call(struct PP_Var object,
return PP_MakeUndefined();
}
- PP_Var ret = Var::NPVariantToPPVar(accessor.module(), &result);
+ PP_Var ret = Var::NPVariantToPPVar(accessor.object()->instance(), &result);
WebBindings::releaseVariantValue(&result);
return ret;
}
@@ -551,7 +553,7 @@ PP_Var CallDeprecated(PP_Var var,
return PP_MakeUndefined();
}
- PP_Var ret = Var::NPVariantToPPVar(accessor.module(), &result);
+ PP_Var ret = Var::NPVariantToPPVar(accessor.object()->instance(), &result);
WebBindings::releaseVariantValue(&result);
return ret;
}
@@ -584,7 +586,7 @@ PP_Var Construct(PP_Var var,
return PP_MakeUndefined();
}
- PP_Var ret = Var::NPVariantToPPVar(accessor.module(), &result);
+ PP_Var ret = Var::NPVariantToPPVar(accessor.object()->instance(), &result);
WebBindings::releaseVariantValue(&result);
return ret;
}
@@ -608,7 +610,7 @@ PP_Var CreateObjectDeprecated(PP_Instance instance_id,
DLOG(ERROR) << "Create object passed an invalid instance.";
return PP_MakeNull();
}
- return PluginObject::Create(instance->module(), ppp_class, ppp_class_data);
+ return PluginObject::Create(instance, ppp_class, ppp_class_data);
}
PP_Var CreateObjectWithModuleDeprecated(PP_Module module_id,
@@ -617,7 +619,8 @@ PP_Var CreateObjectWithModuleDeprecated(PP_Module module_id,
PluginModule* module = ResourceTracker::Get()->GetModule(module_id);
if (!module)
return PP_MakeNull();
- return PluginObject::Create(module, ppp_class, ppp_class_data);
+ return PluginObject::Create(module->GetSomeInstance(),
+ ppp_class, ppp_class_data);
}
const PPB_Var_Deprecated var_deprecated_interface = {
@@ -659,18 +662,15 @@ const PPB_Var var_interface = {
// Var -------------------------------------------------------------------------
-Var::Var(PluginModule* module) : Resource(module) {
+Var::Var(PluginModule* module) : module_(module), var_id_(0) {
}
Var::~Var() {
}
-Var* Var::AsVar() {
- return this;
-}
-
// static
-PP_Var Var::NPVariantToPPVar(PluginModule* module, const NPVariant* variant) {
+PP_Var Var::NPVariantToPPVar(PluginInstance* instance,
+ const NPVariant* variant) {
switch (variant->type) {
case NPVariantType_Void:
return PP_MakeUndefined();
@@ -684,11 +684,12 @@ PP_Var Var::NPVariantToPPVar(PluginModule* module, const NPVariant* variant) {
return PP_MakeDouble(NPVARIANT_TO_DOUBLE(*variant));
case NPVariantType_String:
return StringVar::StringToPPVar(
- module,
+ instance->module(),
NPVARIANT_TO_STRING(*variant).UTF8Characters,
NPVARIANT_TO_STRING(*variant).UTF8Length);
case NPVariantType_Object:
- return ObjectVar::NPObjectToPPVar(module, NPVARIANT_TO_OBJECT(*variant));
+ return ObjectVar::NPObjectToPPVar(instance,
+ NPVARIANT_TO_OBJECT(*variant));
}
NOTREACHED();
return PP_MakeUndefined();
@@ -725,22 +726,16 @@ PP_Var Var::NPIdentifierToPPVar(PluginModule* module, NPIdentifier id) {
// static
void Var::PluginAddRefPPVar(PP_Var var) {
if (var.type == PP_VARTYPE_STRING || var.type == PP_VARTYPE_OBJECT) {
- // TODO(brettw) consider checking that the ID is actually a var ID rather
- // than some random other resource ID.
- PP_Resource resource = static_cast<PP_Resource>(var.value.as_id);
- if (!ResourceTracker::Get()->AddRefResource(resource))
- DLOG(WARNING) << "AddRefVar()ing a nonexistant string/object var.";
+ if (!ResourceTracker::Get()->AddRefVar(static_cast<int32>(var.value.as_id)))
+ DLOG(WARNING) << "AddRefVar()ing a nonexistent string/object var.";
}
}
// static
void Var::PluginReleasePPVar(PP_Var var) {
if (var.type == PP_VARTYPE_STRING || var.type == PP_VARTYPE_OBJECT) {
- // TODO(brettw) consider checking that the ID is actually a var ID rather
- // than some random other resource ID.
- PP_Resource resource = static_cast<PP_Resource>(var.value.as_id);
- if (!ResourceTracker::Get()->UnrefResource(resource))
- DLOG(WARNING) << "ReleaseVar()ing a nonexistant string/object var.";
+ if (!ResourceTracker::Get()->UnrefVar(static_cast<int32>(var.value.as_id)))
+ DLOG(WARNING) << "ReleaseVar()ing a nonexistent string/object var.";
}
}
@@ -753,6 +748,27 @@ const PPB_Var* Var::GetInterface() {
return &var_interface;
}
+StringVar* Var::AsStringVar() {
+ return NULL;
+}
+
+ObjectVar* Var::AsObjectVar() {
+ return NULL;
+}
+
+int32 Var::GetID() {
+ // This should only be called for objects and strings. POD vars like integers
+ // have no identifiers.
+ DCHECK(AsStringVar() || AsObjectVar());
+
+ ResourceTracker *tracker = ResourceTracker::Get();
+ if (var_id_)
+ tracker->AddRefVar(var_id_);
+ else
+ var_id_ = tracker->AddVar(this);
+ return var_id_;
+}
+
// StringVar -------------------------------------------------------------------
StringVar::StringVar(PluginModule* module, const char* str, uint32 len)
@@ -783,29 +799,33 @@ PP_Var StringVar::StringToPPVar(PluginModule* module,
ret.type = PP_VARTYPE_STRING;
// The caller takes ownership now.
- ret.value.as_id = str->GetReference();
+ ret.value.as_id = str->GetID();
return ret;
}
// static
scoped_refptr<StringVar> StringVar::FromPPVar(PP_Var var) {
if (var.type != PP_VARTYPE_STRING)
- return scoped_refptr<StringVar>(NULL);
- PP_Resource resource = static_cast<PP_Resource>(var.value.as_id);
- return Resource::GetAs<StringVar>(resource);
+ return scoped_refptr<StringVar>();
+ scoped_refptr<Var> var_object(
+ ResourceTracker::Get()->GetVar(static_cast<int32>(var.value.as_id)));
+ if (!var_object)
+ return scoped_refptr<StringVar>();
+ return scoped_refptr<StringVar>(var_object->AsStringVar());
}
// ObjectVar -------------------------------------------------------------
-ObjectVar::ObjectVar(PluginModule* module, NPObject* np_object)
- : Var(module),
+ObjectVar::ObjectVar(PluginInstance* instance, NPObject* np_object)
+ : Var(instance->module()),
+ instance_(instance),
np_object_(np_object) {
WebBindings::retainObject(np_object_);
- module->AddNPObjectVar(this);
+ instance->AddNPObjectVar(this);
}
ObjectVar::~ObjectVar() {
- module()->RemoveNPObjectVar(this);
+ instance_->RemoveNPObjectVar(this);
WebBindings::releaseObject(np_object_);
}
@@ -814,10 +834,10 @@ ObjectVar* ObjectVar::AsObjectVar() {
}
// static
-PP_Var ObjectVar::NPObjectToPPVar(PluginModule* module, NPObject* object) {
- scoped_refptr<ObjectVar> object_var(module->ObjectVarForNPObject(object));
+PP_Var ObjectVar::NPObjectToPPVar(PluginInstance* instance, NPObject* object) {
+ scoped_refptr<ObjectVar> object_var(instance->ObjectVarForNPObject(object));
if (!object_var) // No object for this module yet, make a new one.
- object_var = new ObjectVar(module, object);
+ object_var = new ObjectVar(instance, object);
if (!object_var)
return PP_MakeUndefined();
@@ -825,7 +845,7 @@ PP_Var ObjectVar::NPObjectToPPVar(PluginModule* module, NPObject* object) {
// Convert to a PP_Var, GetReference will AddRef for us.
PP_Var result;
result.type = PP_VARTYPE_OBJECT;
- result.value.as_id = object_var->GetReference();
+ result.value.as_id = object_var->GetID();
return result;
}
@@ -833,8 +853,11 @@ PP_Var ObjectVar::NPObjectToPPVar(PluginModule* module, NPObject* object) {
scoped_refptr<ObjectVar> ObjectVar::FromPPVar(PP_Var var) {
if (var.type != PP_VARTYPE_OBJECT)
return scoped_refptr<ObjectVar>(NULL);
- PP_Resource resource = static_cast<PP_Resource>(var.value.as_id);
- return Resource::GetAs<ObjectVar>(resource);
+ scoped_refptr<Var> var_object(
+ ResourceTracker::Get()->GetVar(static_cast<int32>(var.value.as_id)));
+ if (!var_object)
+ return scoped_refptr<ObjectVar>();
+ return scoped_refptr<ObjectVar>(var_object->AsObjectVar());
}
// TryCatch --------------------------------------------------------------------
diff --git a/webkit/plugins/ppapi/var.h b/webkit/plugins/ppapi/var.h
index 8f74733..ef3613f 100644
--- a/webkit/plugins/ppapi/var.h
+++ b/webkit/plugins/ppapi/var.h
@@ -7,7 +7,8 @@
#include <string>
-#include "webkit/plugins/ppapi/resource.h"
+#include "base/compiler_specific.h"
+#include "base/ref_counted.h"
struct PP_Var;
struct PPB_Var;
@@ -19,18 +20,20 @@ typedef void* NPIdentifier;
namespace webkit {
namespace ppapi {
+class ObjectVar;
+class PluginInstance;
+class PluginModule;
+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.
-class Var : public Resource {
+class Var : public base::RefCounted<Var> {
public:
virtual ~Var();
- // Resource overrides.
- virtual Var* AsVar();
-
// Returns a PP_Var that corresponds to the given NPVariant. The contents of
// the NPVariant will be copied unless the NPVariant corresponds to an
// object. This will handle all Variant types including POD, strings, and
@@ -38,7 +41,7 @@ class Var : public Resource {
//
// The returned PP_Var will have a refcount of 1, this passing ownership of
// the reference to the caller. This is suitable for returning to a plugin.
- static PP_Var NPVariantToPPVar(PluginModule* module,
+ static PP_Var NPVariantToPPVar(PluginInstance* instance,
const NPVariant* variant);
// Returns a NPIdentifier that corresponds to the given PP_Var. The contents
@@ -87,11 +90,26 @@ class Var : public Resource {
// Returns the PPB_Var interface for the plugin to use.
static const PPB_Var* GetInterface();
+ virtual StringVar* AsStringVar();
+ virtual ObjectVar* AsObjectVar();
+
+ PluginModule* module() const { return module_; }
+
+ // Returns the unique ID associated with this string or object. The object
+ // must be a string or an object var, and the return value is guaranteed
+ // nonzero.
+ int32 GetID();
+
protected:
// This can only be constructed as a StringVar or an ObjectVar.
explicit Var(PluginModule* module);
private:
+ PluginModule* module_;
+
+ // This will be 0 if no ID has been assigned (this happens lazily).
+ int32 var_id_;
+
DISALLOW_COPY_AND_ASSIGN(Var);
};
@@ -114,8 +132,8 @@ class StringVar : public Var {
const std::string& value() const { return value_; }
- // Resource overrides.
- virtual StringVar* AsStringVar();
+ // Var override.
+ virtual StringVar* AsStringVar() OVERRIDE;
// Helper function to create a PP_Var of type string that contains a copy of
// the given string. The input data must be valid UTF-8 encoded text, if it
@@ -154,8 +172,8 @@ class ObjectVar : public Var {
public:
virtual ~ObjectVar();
- // Resource overrides.
- virtual ObjectVar* AsObjectVar();
+ // Var overrides.
+ virtual ObjectVar* AsObjectVar() OVERRIDE;
// Returns the underlying NPObject corresponding to this ObjectVar.
// Guaranteed non-NULL.
@@ -172,19 +190,23 @@ class ObjectVar : public Var {
//
// If no ObjectVar currently exists corresponding to the NPObject, one is
// created associated with the given module.
- static PP_Var NPObjectToPPVar(PluginModule* module, NPObject* object);
+ static PP_Var NPObjectToPPVar(PluginInstance* instance, NPObject* object);
// Helper function that converts a PP_Var to an object. This will return NULL
// if the PP_Var is not of object type or the object is invalid.
static scoped_refptr<ObjectVar> FromPPVar(PP_Var var);
+ PluginInstance* instance() const { return instance_; }
+
protected:
// You should always use FromNPObject to create an ObjectVar. This function
// guarantees that we maintain the 1:1 mapping between NPObject and
// ObjectVar.
- ObjectVar(PluginModule* module, NPObject* np_object);
+ ObjectVar(PluginInstance* instance, NPObject* np_object);
private:
+ PluginInstance* instance_;
+
// Guaranteed non-NULL, this is the underlying object used by WebKit. We
// hold a reference to this object.
NPObject* np_object_;
diff --git a/webkit/plugins/ppapi/var_object_class.cc b/webkit/plugins/ppapi/var_object_class.cc
index 282ad72..d75002a 100644
--- a/webkit/plugins/ppapi/var_object_class.cc
+++ b/webkit/plugins/ppapi/var_object_class.cc
@@ -26,9 +26,9 @@ class VarObjectAccessorWithIdentifier {
public:
VarObjectAccessorWithIdentifier(NPObject* object, NPIdentifier identifier)
: exists_(false),
- instance_(static_cast<VarObjectClass::InstanceData*>(object)),
+ instance_data_(static_cast<VarObjectClass::InstanceData*>(object)),
property_(NULL) {
- if (instance_) {
+ if (instance_data_) {
const NPUTF8* string_value = NULL;
int32_t int_value = 0;
bool is_string = false;
@@ -38,7 +38,7 @@ class VarObjectAccessorWithIdentifier {
property_name_ = string_value;
const VarObjectClass::PropertyMap& properties =
- instance_->object_class->properties();
+ instance_data_->object_class->properties();
VarObjectClass::PropertyMap::const_iterator it =
properties.find(property_name_);
if (it != properties.end()) {
@@ -57,15 +57,17 @@ class VarObjectAccessorWithIdentifier {
bool is_writable() const {
return exists() && property_->setter && property_->writable;
}
- const VarObjectClass::InstanceData* instance() const { return instance_; }
+ const VarObjectClass::InstanceData* instance_data() const {
+ return instance_data_;
+ }
const VarObjectClass::Property* property() const { return property_; }
- PluginModule* module() const {
- return instance_ ? instance_->object_class->module() : NULL;
+ PluginInstance* instance() const {
+ return instance_data_ ? instance_data_->object_class->instance() : NULL;
}
private:
bool exists_;
- const VarObjectClass::InstanceData* instance_;
+ const VarObjectClass::InstanceData* instance_data_;
std::string property_name_;
const VarObjectClass::Property* property_;
@@ -97,12 +99,12 @@ bool VarObjectClassInvoke(NPObject* np_obj, NPIdentifier name,
return false;
PPResultAndExceptionToNPResult result_converter(np_obj, result);
- PPVarArrayFromNPVariantArray arguments(accessor.module(), arg_count, args);
- PPVarFromNPObject self(accessor.module(), np_obj);
+ PPVarArrayFromNPVariantArray arguments(accessor.instance(), arg_count, args);
+ PPVarFromNPObject self(accessor.instance(), np_obj);
return result_converter.SetResult(accessor.property()->method(
- accessor.instance()->native_data, self.var(), arguments.array(), arg_count,
- result_converter.exception()));
+ accessor.instance_data()->native_data, self.var(), arguments.array(),
+ arg_count, result_converter.exception()));
}
bool VarObjectClassInvokeDefault(NPObject* np_obj,
@@ -115,9 +117,9 @@ bool VarObjectClassInvokeDefault(NPObject* np_obj,
return false;
PPResultAndExceptionToNPResult result_converter(np_obj, result);
- PPVarArrayFromNPVariantArray arguments(instance->object_class->module(),
+ PPVarArrayFromNPVariantArray arguments(instance->object_class->instance(),
arg_count, args);
- PPVarFromNPObject self(instance->object_class->module(), np_obj);
+ PPVarFromNPObject self(instance->object_class->instance(), np_obj);
return result_converter.SetResult(instance->object_class->instance_invoke()(
instance->native_data, self.var(), arguments.array(), arg_count,
@@ -137,27 +139,27 @@ bool VarObjectClassGetProperty(NPObject* np_obj, NPIdentifier name,
}
PPResultAndExceptionToNPResult result_converter(np_obj, result);
- PPVarFromNPObject self(accessor.module(), np_obj);
+ PPVarFromNPObject self(accessor.instance(), np_obj);
return result_converter.SetResult(accessor.property()->getter(
- accessor.instance()->native_data, self.var(), 0, 0,
- result_converter.exception()));
+ accessor.instance_data()->native_data, self.var(), 0, 0,
+ result_converter.exception()));
}
bool VarObjectClassSetProperty(NPObject* np_obj, NPIdentifier name,
- const NPVariant* variant) {
+ const NPVariant* variant) {
VarObjectAccessorWithIdentifier accessor(np_obj, name);
if (!accessor.is_writable()) {
return false;
}
PPResultAndExceptionToNPResult result_converter(np_obj, NULL);
- PPVarArrayFromNPVariantArray arguments(accessor.module(), 1, variant);
- PPVarFromNPObject self(accessor.module(), np_obj);
+ PPVarArrayFromNPVariantArray arguments(accessor.instance(), 1, variant);
+ PPVarFromNPObject self(accessor.instance(), np_obj);
// Ignore return value.
Var::PluginReleasePPVar(accessor.property()->setter(
- accessor.instance()->native_data, self.var(), arguments.array(), 1,
+ accessor.instance_data()->native_data, self.var(), arguments.array(), 1,
result_converter.exception()));
return result_converter.CheckExceptionForNoResult();
@@ -207,12 +209,12 @@ NPClass objectclassvar_class = {
// PPB_Class -------------------------------------------------------------------
-PP_Resource Create(PP_Module module, PP_ClassDestructor destruct,
+PP_Resource Create(PP_Instance instance_id, PP_ClassDestructor destruct,
PP_ClassFunction invoke, PP_ClassProperty* properties) {
- PluginModule* plugin_module = ResourceTracker::Get()->GetModule(module);
- if (!properties || !plugin_module)
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!properties || !instance)
return 0;
- scoped_refptr<VarObjectClass> cls = new VarObjectClass(plugin_module,
+ scoped_refptr<VarObjectClass> cls = new VarObjectClass(instance,
destruct,
invoke,
properties);
@@ -232,7 +234,7 @@ PP_Var Instantiate(PP_Resource class_object, void* native_data,
static_cast<VarObjectClass::InstanceData*>(obj);
instance_data->object_class = object_class;
instance_data->native_data = native_data;
- return ObjectVar::NPObjectToPPVar(object_class->module(), obj);
+ return ObjectVar::NPObjectToPPVar(object_class->instance(), obj);
}
} // namespace
@@ -250,11 +252,11 @@ VarObjectClass::Property::Property(const PP_ClassProperty& prop)
VarObjectClass::InstanceData::InstanceData() : native_data(NULL) {
}
-VarObjectClass::VarObjectClass(PluginModule* module,
+VarObjectClass::VarObjectClass(PluginInstance* instance,
PP_ClassDestructor destruct,
PP_ClassFunction invoke,
PP_ClassProperty* properties)
- : Resource(module),
+ : Resource(instance),
instance_native_destructor_(destruct),
instance_invoke_(invoke) {
PP_ClassProperty* prop = properties;
diff --git a/webkit/plugins/ppapi/var_object_class.h b/webkit/plugins/ppapi/var_object_class.h
index 7f9cb98..bcee3cb 100644
--- a/webkit/plugins/ppapi/var_object_class.h
+++ b/webkit/plugins/ppapi/var_object_class.h
@@ -17,7 +17,7 @@
namespace webkit {
namespace ppapi {
-class PluginModule;
+class PluginInstance;
class VarObjectClass : public Resource {
public:
@@ -40,7 +40,7 @@ class VarObjectClass : public Resource {
typedef base::hash_map<std::string, Property> PropertyMap;
- VarObjectClass(PluginModule* module, PP_ClassDestructor destruct,
+ VarObjectClass(PluginInstance* instance, PP_ClassDestructor destruct,
PP_ClassFunction invoke, PP_ClassProperty* properties);
virtual ~VarObjectClass();