summaryrefslogtreecommitdiffstats
path: root/webkit/plugins/ppapi
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/plugins/ppapi')
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc12
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc26
-rw-r--r--webkit/plugins/ppapi/ppb_broker_impl.cc84
-rw-r--r--webkit/plugins/ppapi/ppb_broker_impl.h21
-rw-r--r--webkit/plugins/ppapi/ppb_buffer_impl.cc87
-rw-r--r--webkit/plugins/ppapi/ppb_buffer_impl.h59
-rw-r--r--webkit/plugins/ppapi/ppb_char_set_impl.cc58
-rw-r--r--webkit/plugins/ppapi/ppb_char_set_impl.h36
-rw-r--r--webkit/plugins/ppapi/ppb_cursor_control_impl.cc70
-rw-r--r--webkit/plugins/ppapi/ppb_cursor_control_impl.h36
-rw-r--r--webkit/plugins/ppapi/ppb_font_impl.cc3
-rw-r--r--webkit/plugins/ppapi/ppb_font_impl.h4
-rw-r--r--webkit/plugins/ppapi/ppb_video_decoder_impl.cc18
-rw-r--r--webkit/plugins/ppapi/resource_creation_impl.cc14
-rw-r--r--webkit/plugins/ppapi/resource_creation_impl.h9
-rw-r--r--webkit/plugins/ppapi/resource_tracker.cc63
-rw-r--r--webkit/plugins/ppapi/resource_tracker.h8
17 files changed, 331 insertions, 277 deletions
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index e9555cf..a0f0339 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -73,12 +73,8 @@
#include "webkit/plugins/ppapi/callbacks.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
-#include "webkit/plugins/ppapi/ppb_broker_impl.h"
-#include "webkit/plugins/ppapi/ppb_buffer_impl.h"
-#include "webkit/plugins/ppapi/ppb_char_set_impl.h"
#include "webkit/plugins/ppapi/ppb_console_impl.h"
#include "webkit/plugins/ppapi/ppb_crypto_impl.h"
-#include "webkit/plugins/ppapi/ppb_cursor_control_impl.h"
#include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
#include "webkit/plugins/ppapi/ppb_file_chooser_impl.h"
#include "webkit/plugins/ppapi/ppb_file_io_impl.h"
@@ -252,11 +248,11 @@ const void* GetInterface(const char* name) {
if (strcmp(name, PPB_AUDIO_TRUSTED_INTERFACE) == 0)
return ::ppapi::thunk::GetPPB_AudioTrusted_Thunk();
if (strcmp(name, PPB_BROKER_TRUSTED_INTERFACE) == 0)
- return PPB_Broker_Impl::GetTrustedInterface();
+ return ::ppapi::thunk::GetPPB_Broker_Thunk();
if (strcmp(name, PPB_BUFFER_DEV_INTERFACE) == 0)
- return PPB_Buffer_Impl::GetInterface();
+ return ::ppapi::thunk::GetPPB_Buffer_Thunk();
if (strcmp(name, PPB_CHAR_SET_DEV_INTERFACE) == 0)
- return PPB_CharSet_Impl::GetInterface();
+ return ::ppapi::thunk::GetPPB_CharSet_Thunk();
if (strcmp(name, PPB_CONSOLE_DEV_INTERFACE) == 0)
return PPB_Console_Impl::GetInterface();
if (strcmp(name, PPB_CORE_INTERFACE) == 0)
@@ -264,7 +260,7 @@ const void* GetInterface(const char* name) {
if (strcmp(name, PPB_CRYPTO_DEV_INTERFACE) == 0)
return PPB_Crypto_Impl::GetInterface();
if (strcmp(name, PPB_CURSOR_CONTROL_DEV_INTERFACE) == 0)
- return GetCursorControlInterface();
+ return ::ppapi::thunk::GetPPB_CursorControl_Thunk();
if (strcmp(name, PPB_DIRECTORYREADER_DEV_INTERFACE) == 0)
return PPB_DirectoryReader_Impl::GetInterface();
if (strcmp(name, PPB_FILECHOOSER_DEV_INTERFACE) == 0)
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index b704869..9668544 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -27,6 +27,8 @@
#include "ppapi/c/ppp_messaging.h"
#include "ppapi/c/private/ppb_instance_private.h"
#include "ppapi/c/private/ppp_instance_private.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_buffer_api.h"
#include "printing/units.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
@@ -82,6 +84,7 @@
#include "skia/ext/skia_utils_mac.h"
#endif
+using ::ppapi::thunk::PPB_Buffer_API;
using WebKit::WebBindings;
using WebKit::WebCanvas;
using WebKit::WebCursorInfo;
@@ -1304,9 +1307,12 @@ PluginDelegate::PlatformContext3D* PluginInstance::CreateContext3D() {
bool PluginInstance::PrintPDFOutput(PP_Resource print_output,
WebKit::WebCanvas* canvas) {
- scoped_refptr<PPB_Buffer_Impl> buffer(
- Resource::GetAs<PPB_Buffer_Impl>(print_output));
- if (!buffer.get() || !buffer->is_mapped() || !buffer->size()) {
+ ::ppapi::thunk::EnterResourceNoLock<PPB_Buffer_API> enter(print_output, true);
+ if (enter.failed())
+ return false;
+
+ BufferAutoMapper mapper(enter.object());
+ if (!mapper.data() || !mapper.size()) {
NOTREACHED();
return false;
}
@@ -1328,14 +1334,14 @@ bool PluginInstance::PrintPDFOutput(PP_Resource print_output,
// (NativeMetafile and PreviewMetafile must have compatible formats,
// i.e. both PDF for this to work).
printing::Metafile* metafile =
- printing::MetafileSkiaWrapper::GetMetafileFromCanvas(canvas);
+ printing::MetafileSkiaWrapper::GetMetafileFromCanvas(canvas);
DCHECK(metafile != NULL);
if (metafile)
- ret = metafile->InitFromData(buffer->mapped_buffer(), buffer->size());
+ ret = metafile->InitFromData(mapper.data(), mapper.size());
#elif defined(OS_MACOSX)
printing::NativeMetafile metafile;
// Create a PDF metafile and render from there into the passed in context.
- if (metafile.InitFromData(buffer->mapped_buffer(), buffer->size())) {
+ if (metafile.InitFromData(mapper.data(), mapper.size())) {
// Flip the transform.
#if defined(USE_SKIA)
gfx::SkiaBitLocker bit_locker(canvas);
@@ -1362,7 +1368,7 @@ bool PluginInstance::PrintPDFOutput(PP_Resource print_output,
if (metafile) {
// We only have a metafile when doing print preview, so we just want to
// pass the PDF off to preview.
- ret = metafile->InitFromData(buffer->mapped_buffer(), buffer->size());
+ ret = metafile->InitFromData(mapper.data(), mapper.size());
} else {
// On Windows, we now need to render the PDF to the DC that backs the
// supplied canvas.
@@ -1384,9 +1390,9 @@ bool PluginInstance::PrintPDFOutput(PP_Resource print_output,
static_cast<float>(current_print_settings_.dpi);
ModifyWorldTransform(dc, &xform, MWT_LEFTMULTIPLY);
- ret = render_proc(buffer->mapped_buffer(), buffer->size(), 0, dc,
- current_print_settings_.dpi, current_print_settings_.dpi,
- 0, 0, size_in_pixels.width(),
+ ret = render_proc(static_cast<unsigned char*>(mapper.data()), mapper.size(),
+ 0, dc, current_print_settings_.dpi,
+ current_print_settings_.dpi, 0, 0, size_in_pixels.width(),
size_in_pixels.height(), true, false, true, true);
skia::EndPlatformPaint(canvas);
}
diff --git a/webkit/plugins/ppapi/ppb_broker_impl.cc b/webkit/plugins/ppapi/ppb_broker_impl.cc
index d188ac7..2da35d6 100644
--- a/webkit/plugins/ppapi/ppb_broker_impl.cc
+++ b/webkit/plugins/ppapi/ppb_broker_impl.cc
@@ -8,57 +8,13 @@
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/plugin_module.h"
+using ::ppapi::thunk::PPB_Broker_API;
+
namespace webkit {
namespace ppapi {
namespace {
-// PPB_BrokerTrusted ----------------------------------------------------
-
-PP_Resource CreateTrusted(PP_Instance instance_id) {
- PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
- if (!instance)
- return 0;
- scoped_refptr<PPB_Broker_Impl> broker(new PPB_Broker_Impl(instance));
- return broker->GetReference();
-}
-
-PP_Bool IsBrokerTrusted(PP_Resource resource) {
- scoped_refptr<PPB_Broker_Impl> broker =
- Resource::GetAs<PPB_Broker_Impl>(resource);
- return BoolToPPBool(!!broker);
-}
-
-int32_t Connect(PP_Resource broker_id,
- PP_CompletionCallback connect_callback) {
- scoped_refptr<PPB_Broker_Impl> broker =
- Resource::GetAs<PPB_Broker_Impl>(broker_id);
- if (!broker)
- return PP_ERROR_BADRESOURCE;
- if (!connect_callback.func) {
- // Synchronous calls are not supported.
- return PP_ERROR_BADARGUMENT;
- }
- return broker->Connect(broker->instance()->delegate(), connect_callback);
-}
-
-int32_t GetHandle(PP_Resource broker_id, int32_t* handle) {
- scoped_refptr<PPB_Broker_Impl> broker =
- Resource::GetAs<PPB_Broker_Impl>(broker_id);
- if (!broker)
- return PP_ERROR_BADRESOURCE;
- if (!handle)
- return PP_ERROR_BADARGUMENT;
- return broker->GetHandle(handle);
-}
-
-const PPB_BrokerTrusted ppb_brokertrusted = {
- &CreateTrusted,
- &IsBrokerTrusted,
- &Connect,
- &GetHandle,
-};
-
// TODO(ddorwin): Put conversion functions in a common place and/or add an
// invalid value to sync_socket.h.
int32_t PlatformFileToInt(base::PlatformFile handle) {
@@ -92,13 +48,29 @@ PPB_Broker_Impl::~PPB_Broker_Impl() {
pipe_handle_ = PlatformFileToInt(base::kInvalidPlatformFileValue);
}
-const PPB_BrokerTrusted* PPB_Broker_Impl::GetTrustedInterface() {
- return &ppb_brokertrusted;
+// static
+PP_Resource PPB_Broker_Impl::Create(PP_Instance instance_id) {
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!instance)
+ return 0;
+ scoped_refptr<PPB_Broker_Impl> broker(new PPB_Broker_Impl(instance));
+ return broker->GetReference();
}
-int32_t PPB_Broker_Impl::Connect(
- PluginDelegate* plugin_delegate,
- PP_CompletionCallback connect_callback) {
+PPB_Broker_Impl* PPB_Broker_Impl::AsPPB_Broker_Impl() {
+ return this;
+}
+
+PPB_Broker_API* PPB_Broker_Impl::AsBroker_API() {
+ return this;
+}
+
+int32_t PPB_Broker_Impl::Connect(PP_CompletionCallback connect_callback) {
+ if (!connect_callback.func) {
+ // Synchronous calls are not supported.
+ return PP_ERROR_BADARGUMENT;
+ }
+
// TODO(ddorwin): Return PP_ERROR_FAILED if plugin is in-process.
if (broker_) {
@@ -116,7 +88,7 @@ int32_t PPB_Broker_Impl::Connect(
instance()->module()->GetCallbackTracker(), resource_id,
connect_callback);
- broker_ = plugin_delegate->ConnectToPpapiBroker(this);
+ broker_ = instance()->delegate()->ConnectToPpapiBroker(this);
if (!broker_) {
scoped_refptr<TrackedCompletionCallback> callback;
callback.swap(connect_callback_);
@@ -128,16 +100,16 @@ int32_t PPB_Broker_Impl::Connect(
}
int32_t PPB_Broker_Impl::GetHandle(int32_t* handle) {
+ if (pipe_handle_ == PlatformFileToInt(base::kInvalidPlatformFileValue))
+ return PP_ERROR_FAILED; // Handle not set yet.
*handle = pipe_handle_;
return PP_OK;
}
-PPB_Broker_Impl* PPB_Broker_Impl::AsPPB_Broker_Impl() {
- return this;
-}
-
// Transfers ownership of the handle to the plugin.
void PPB_Broker_Impl::BrokerConnected(int32_t handle, int32_t result) {
+ DCHECK(pipe_handle_ ==
+ PlatformFileToInt(base::kInvalidPlatformFileValue));
DCHECK(result == PP_OK ||
handle == PlatformFileToInt(base::kInvalidPlatformFileValue));
diff --git a/webkit/plugins/ppapi/ppb_broker_impl.h b/webkit/plugins/ppapi/ppb_broker_impl.h
index 111fba9..c569c1c 100644
--- a/webkit/plugins/ppapi/ppb_broker_impl.h
+++ b/webkit/plugins/ppapi/ppb_broker_impl.h
@@ -9,6 +9,7 @@
#include "base/memory/weak_ptr.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/trusted/ppb_broker_trusted.h"
+#include "ppapi/thunk/ppb_broker_api.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/callbacks.h"
@@ -20,24 +21,28 @@ namespace ppapi {
class PluginInstance;
class PPB_Broker_Impl : public Resource,
+ public ::ppapi::thunk::PPB_Broker_API,
public base::SupportsWeakPtr<PPB_Broker_Impl> {
public:
- explicit PPB_Broker_Impl(PluginInstance* instance);
virtual ~PPB_Broker_Impl();
- static const PPB_BrokerTrusted* GetTrustedInterface();
-
- // PPB_BrokerTrusted implementation.
- int32_t Connect(PluginDelegate* plugin_delegate,
- PP_CompletionCallback connect_callback);
- int32_t GetHandle(int32_t* handle);
+ static PP_Resource Create(PP_Instance instance_id);
// Resource override.
- virtual PPB_Broker_Impl* AsPPB_Broker_Impl();
+ virtual PPB_Broker_Impl* AsPPB_Broker_Impl() OVERRIDE;
+
+ // ResourceObjectBase override.
+ virtual ::ppapi::thunk::PPB_Broker_API* AsBroker_API() OVERRIDE;
+
+ // PPB_BrokerTrusted implementation.
+ virtual int32_t Connect(PP_CompletionCallback connect_callback) OVERRIDE;
+ virtual int32_t GetHandle(int32_t* handle) OVERRIDE;
void BrokerConnected(int32_t handle, int32_t result);
private:
+ explicit PPB_Broker_Impl(PluginInstance* instance);
+
// PluginDelegate ppapi broker object.
// We don't own this pointer but are responsible for calling Disconnect on it.
PluginDelegate::PpapiBroker* broker_;
diff --git a/webkit/plugins/ppapi/ppb_buffer_impl.cc b/webkit/plugins/ppapi/ppb_buffer_impl.cc
index b834e41..182738f 100644
--- a/webkit/plugins/ppapi/ppb_buffer_impl.cc
+++ b/webkit/plugins/ppapi/ppb_buffer_impl.cc
@@ -14,62 +14,11 @@
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
+using ::ppapi::thunk::PPB_Buffer_API;
+
namespace webkit {
namespace ppapi {
-namespace {
-
-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(instance));
- if (!buffer->Init(size))
- return 0;
-
- return buffer->GetReference();
-}
-
-PP_Bool IsPPB_Buffer_Impl(PP_Resource resource) {
- return BoolToPPBool(!!Resource::GetAs<PPB_Buffer_Impl>(resource));
-}
-
-PP_Bool Describe(PP_Resource resource, uint32_t* size_in_bytes) {
- scoped_refptr<PPB_Buffer_Impl> buffer(
- Resource::GetAs<PPB_Buffer_Impl>(resource));
- if (!buffer)
- return PP_FALSE;
- buffer->Describe(size_in_bytes);
- return PP_TRUE;
-}
-
-void* Map(PP_Resource resource) {
- scoped_refptr<PPB_Buffer_Impl> buffer(
- Resource::GetAs<PPB_Buffer_Impl>(resource));
- if (!buffer)
- return NULL;
- return buffer->Map();
-}
-
-void Unmap(PP_Resource resource) {
- scoped_refptr<PPB_Buffer_Impl> buffer(
- Resource::GetAs<PPB_Buffer_Impl>(resource));
- if (!buffer)
- return;
- return buffer->Unmap();
-}
-
-const PPB_Buffer_Dev ppb_buffer = {
- &Create,
- &IsPPB_Buffer_Impl,
- &Describe,
- &Map,
- &Unmap,
-};
-
-} // namespace
-
PPB_Buffer_Impl::PPB_Buffer_Impl(PluginInstance* instance)
: Resource(instance), size_(0) {
}
@@ -78,14 +27,24 @@ PPB_Buffer_Impl::~PPB_Buffer_Impl() {
}
// static
-const PPB_Buffer_Dev* PPB_Buffer_Impl::GetInterface() {
- return &ppb_buffer;
+PP_Resource PPB_Buffer_Impl::Create(PP_Instance pp_instance, uint32_t size) {
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance);
+ if (!instance)
+ return 0;
+ scoped_refptr<PPB_Buffer_Impl> buffer(new PPB_Buffer_Impl(instance));
+ if (!buffer->Init(size))
+ return 0;
+ return buffer->GetReference();
}
PPB_Buffer_Impl* PPB_Buffer_Impl::AsPPB_Buffer_Impl() {
return this;
}
+PPB_Buffer_API* PPB_Buffer_Impl::AsBuffer_API() {
+ return this;
+}
+
bool PPB_Buffer_Impl::Init(uint32_t size) {
if (size == 0 || !instance())
return false;
@@ -95,8 +54,13 @@ bool PPB_Buffer_Impl::Init(uint32_t size) {
return shared_memory_.get() != NULL;
}
-void PPB_Buffer_Impl::Describe(uint32_t* size_in_bytes) const {
+PP_Bool PPB_Buffer_Impl::Describe(uint32_t* size_in_bytes) {
*size_in_bytes = size_;
+ return PP_TRUE;
+}
+
+PP_Bool PPB_Buffer_Impl::IsMapped() {
+ return PP_FromBool(!!shared_memory_->memory());
}
void* PPB_Buffer_Impl::Map() {
@@ -111,5 +75,16 @@ void PPB_Buffer_Impl::Unmap() {
shared_memory_->Unmap();
}
+BufferAutoMapper::BufferAutoMapper(PPB_Buffer_API* api) : api_(api) {
+ needs_unmap_ = !PP_ToBool(api->IsMapped());
+ data_ = api->Map();
+ api->Describe(&size_);
+}
+
+BufferAutoMapper::~BufferAutoMapper() {
+ if (needs_unmap_)
+ api_->Unmap();
+}
+
} // namespace ppapi
} // namespace webkit
diff --git a/webkit/plugins/ppapi/ppb_buffer_impl.h b/webkit/plugins/ppapi/ppb_buffer_impl.h
index e7d83f9..f68c825 100644
--- a/webkit/plugins/ppapi/ppb_buffer_impl.h
+++ b/webkit/plugins/ppapi/ppb_buffer_impl.h
@@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/shared_memory.h"
+#include "ppapi/thunk/ppb_buffer_api.h"
#include "webkit/plugins/ppapi/resource.h"
struct PPB_Buffer_Dev;
@@ -17,41 +18,59 @@ namespace ppapi {
class PluginInstance;
-class PPB_Buffer_Impl : public Resource {
+class PPB_Buffer_Impl : public Resource,
+ public ::ppapi::thunk::PPB_Buffer_API {
public:
- explicit PPB_Buffer_Impl(PluginInstance* instance);
virtual ~PPB_Buffer_Impl();
- uint32_t size() const { return size_; }
- unsigned char* mapped_buffer() const {
- return static_cast<unsigned char*>(shared_memory_->memory());
- }
- base::SharedMemoryHandle handle() const { return shared_memory_->handle(); }
+ static PP_Resource Create(PP_Instance instance, uint32_t size);
- // Returns true if this buffer is mapped. False means that the buffer is
- // either invalid or not mapped.
- bool is_mapped() const { return mapped_buffer() != NULL; }
+ virtual PPB_Buffer_Impl* AsPPB_Buffer_Impl();
- // Returns a pointer to the interface implementing PPB_Buffer_Impl that is
- // exposed to the plugin.
- static const PPB_Buffer_Dev* GetInterface();
+ base::SharedMemory* shared_memory() const { return shared_memory_.get(); }
+ uint32_t size() const { return size_; }
- // Resource overrides.
- virtual PPB_Buffer_Impl* AsPPB_Buffer_Impl();
+ // ResourceObjectBase overries.
+ virtual ::ppapi::thunk::PPB_Buffer_API* AsBuffer_API() OVERRIDE;
- // PPB_Buffer_Impl implementation.
- bool Init(uint32_t size);
- void Describe(uint32_t* size_in_bytes) const;
- void* Map();
- void Unmap();
+ // PPB_Buffer_API implementation.
+ virtual PP_Bool Describe(uint32_t* size_in_bytes) OVERRIDE;
+ virtual PP_Bool IsMapped() OVERRIDE;
+ virtual void* Map() OVERRIDE;
+ virtual void Unmap() OVERRIDE;
private:
+ explicit PPB_Buffer_Impl(PluginInstance* instance);
+ bool Init(uint32_t size);
+
scoped_ptr<base::SharedMemory> shared_memory_;
uint32_t size_;
DISALLOW_COPY_AND_ASSIGN(PPB_Buffer_Impl);
};
+// Ensures that the given buffer is mapped, and retursn it to its previous
+// mapped state in the destructor.
+class BufferAutoMapper {
+ public:
+ BufferAutoMapper(::ppapi::thunk::PPB_Buffer_API* api);
+ ~BufferAutoMapper();
+
+ // Will be NULL on failure to map.
+ void* data() { return data_; }
+ uint32_t size() { return size_; }
+
+ private:
+ ::ppapi::thunk::PPB_Buffer_API* api_;
+
+ bool needs_unmap_;
+
+ void* data_;
+ uint32_t size_;
+
+ DISALLOW_COPY_AND_ASSIGN(BufferAutoMapper);
+};
+
} // namespace ppapi
} // namespace webkit
diff --git a/webkit/plugins/ppapi/ppb_char_set_impl.cc b/webkit/plugins/ppapi/ppb_char_set_impl.cc
index 5f9b54e..fcabf2f 100644
--- a/webkit/plugins/ppapi/ppb_char_set_impl.cc
+++ b/webkit/plugins/ppapi/ppb_char_set_impl.cc
@@ -12,51 +12,47 @@
#include "webkit/plugins/ppapi/resource_tracker.h"
#include "webkit/plugins/ppapi/var.h"
+using ::ppapi::thunk::PPB_CharSet_FunctionAPI;
+
namespace webkit {
namespace ppapi {
-namespace {
+PPB_CharSet_Impl::PPB_CharSet_Impl(PluginInstance* instance)
+ : instance_(instance) {
+}
+
+PPB_CharSet_Impl::~PPB_CharSet_Impl() {
+}
+
+PPB_CharSet_FunctionAPI* PPB_CharSet_Impl::AsCharSet_FunctionAPI() {
+ return this;
+}
-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) {
+char* PPB_CharSet_Impl::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) {
return ::ppapi::CharSetImpl::UTF16ToCharSet(
PluginModule::GetCore(), utf16, utf16_len, output_char_set, on_error,
output_length);
}
-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) {
+uint16_t* PPB_CharSet_Impl::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) {
return ::ppapi::CharSetImpl::CharSetToUTF16(
PluginModule::GetCore(), input, input_len, input_char_set, on_error,
output_length);
}
-PP_Var GetDefaultCharSet(PP_Instance instance_id) {
- PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
- if (!instance)
- return PP_MakeUndefined();
-
- std::string encoding = instance->delegate()->GetDefaultEncoding();
- return StringVar::StringToPPVar(instance->module(), encoding);
-}
-
-const PPB_CharSet_Dev ppb_charset = {
- &UTF16ToCharSet,
- &CharSetToUTF16,
- &GetDefaultCharSet
-};
-
-} // namespace
-
-// static
-const struct PPB_CharSet_Dev* PPB_CharSet_Impl::GetInterface() {
- return &ppb_charset;
+PP_Var PPB_CharSet_Impl::GetDefaultCharSet(PP_Instance instance) {
+ std::string encoding = instance_->delegate()->GetDefaultEncoding();
+ return StringVar::StringToPPVar(instance_->module(), encoding);
}
} // namespace ppapi
diff --git a/webkit/plugins/ppapi/ppb_char_set_impl.h b/webkit/plugins/ppapi/ppb_char_set_impl.h
index 9c16e05..5787317 100644
--- a/webkit/plugins/ppapi/ppb_char_set_impl.h
+++ b/webkit/plugins/ppapi/ppb_char_set_impl.h
@@ -5,16 +5,42 @@
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_CHAR_SET_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_CHAR_SET_IMPL_H_
-struct PPB_CharSet_Dev;
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "ppapi/shared_impl/function_group_base.h"
+#include "ppapi/thunk/ppb_char_set_api.h"
namespace webkit {
namespace ppapi {
-class PPB_CharSet_Impl {
+class PluginInstance;
+
+class PPB_CharSet_Impl : public ::ppapi::FunctionGroupBase,
+ public ::ppapi::thunk::PPB_CharSet_FunctionAPI {
public:
- // Returns a pointer to the interface implementing PPB_CharSet that is
- // exposed to the plugin.
- static const PPB_CharSet_Dev* GetInterface();
+ PPB_CharSet_Impl(PluginInstance* instance);
+ ~PPB_CharSet_Impl();
+
+ // FunctionGroupBase overrides.
+ virtual ::ppapi::thunk::PPB_CharSet_FunctionAPI* AsCharSet_FunctionAPI();
+
+ // PPB_CharSet_FunctionAPI implementation.
+ virtual 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) OVERRIDE;
+ virtual 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) OVERRIDE;
+ virtual PP_Var GetDefaultCharSet(PP_Instance instance) OVERRIDE;
+
+ private:
+ PluginInstance* instance_;
+
+ DISALLOW_COPY_AND_ASSIGN(PPB_CharSet_Impl);
};
} // namespace ppapi
diff --git a/webkit/plugins/ppapi/ppb_cursor_control_impl.cc b/webkit/plugins/ppapi/ppb_cursor_control_impl.cc
index 05ff7925..4bfb081 100644
--- a/webkit/plugins/ppapi/ppb_cursor_control_impl.cc
+++ b/webkit/plugins/ppapi/ppb_cursor_control_impl.cc
@@ -15,70 +15,48 @@
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/resource.h"
+using ::ppapi::thunk::PPB_CursorControl_FunctionAPI;
+
namespace webkit {
namespace ppapi {
-namespace {
-
-PP_Bool SetCursor(PP_Instance instance_id,
- PP_CursorType_Dev type,
- PP_Resource custom_image_id,
- const PP_Point* hot_spot) {
- PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
- if (!instance)
- return PP_FALSE;
-
- return BoolToPPBool(instance->SetCursor(type, custom_image_id, hot_spot));
+PPB_CursorControl_Impl::PPB_CursorControl_Impl(PluginInstance* instance)
+ : instance_(instance) {
}
-PP_Bool LockCursor(PP_Instance instance_id) {
- PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
- if (!instance)
- return PP_FALSE;
+PPB_CursorControl_Impl::~PPB_CursorControl_Impl() {
+}
- // TODO(neb): implement cursor locking.
- return PP_FALSE;
+PPB_CursorControl_FunctionAPI*
+PPB_CursorControl_Impl::AsCursorControl_FunctionAPI() {
+ return this;
}
-PP_Bool UnlockCursor(PP_Instance instance_id) {
- PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
- if (!instance)
- return PP_FALSE;
+PP_Bool PPB_CursorControl_Impl::SetCursor(PP_Instance instance,
+ PP_CursorType_Dev type,
+ PP_Resource custom_image_id,
+ const PP_Point* hot_spot) {
+ return PP_FromBool(instance_->SetCursor(type, custom_image_id, hot_spot));
+}
- // TODO(neb): implement cursor locking.
+PP_Bool PPB_CursorControl_Impl::LockCursor(PP_Instance instance) {
+ // TODO: implement cursor locking.
return PP_FALSE;
}
-PP_Bool HasCursorLock(PP_Instance instance_id) {
- PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
- if (!instance)
- return PP_FALSE;
-
- // TODO(neb): implement cursor locking.
+PP_Bool PPB_CursorControl_Impl::UnlockCursor(PP_Instance instance) {
+ // TODO: implement cursor locking.
return PP_FALSE;
}
-PP_Bool CanLockCursor(PP_Instance instance_id) {
- PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
- if (!instance)
- return PP_FALSE;
-
- // TODO(neb): implement cursor locking.
+PP_Bool PPB_CursorControl_Impl::HasCursorLock(PP_Instance instance) {
+ // TODO: implement cursor locking.
return PP_FALSE;
}
-const PPB_CursorControl_Dev cursor_control_interface = {
- &SetCursor,
- &LockCursor,
- &UnlockCursor,
- &HasCursorLock,
- &CanLockCursor
-};
-
-} // namespace
-
-const PPB_CursorControl_Dev* GetCursorControlInterface() {
- return &cursor_control_interface;
+PP_Bool PPB_CursorControl_Impl::CanLockCursor(PP_Instance instance) {
+ // TODO: implement cursor locking.
+ return PP_FALSE;
}
} // namespace ppapi
diff --git a/webkit/plugins/ppapi/ppb_cursor_control_impl.h b/webkit/plugins/ppapi/ppb_cursor_control_impl.h
index dcce132a..7891fe1 100644
--- a/webkit/plugins/ppapi/ppb_cursor_control_impl.h
+++ b/webkit/plugins/ppapi/ppb_cursor_control_impl.h
@@ -5,14 +5,42 @@
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_CURSOR_CONTROL_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_CURSOR_CONTROL_IMPL_H_
-struct PPB_CursorControl_Dev;
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "ppapi/shared_impl/function_group_base.h"
+#include "ppapi/thunk/ppb_cursor_control_api.h"
namespace webkit {
namespace ppapi {
-// There's no class implementing CursorControl so we just expose a getter for
-// the interface implemented in the .cc file here.
-const PPB_CursorControl_Dev* GetCursorControlInterface();
+class PluginInstance;
+
+class PPB_CursorControl_Impl
+ : public ::ppapi::FunctionGroupBase,
+ public ::ppapi::thunk::PPB_CursorControl_FunctionAPI {
+ public:
+ PPB_CursorControl_Impl(PluginInstance* instance);
+ ~PPB_CursorControl_Impl();
+
+ // FunctionGroupBase overrides.
+ virtual ::ppapi::thunk::PPB_CursorControl_FunctionAPI*
+ AsCursorControl_FunctionAPI() OVERRIDE;
+
+ // PPB_CursorControl_FunctionAPI implementation.
+ virtual PP_Bool SetCursor(PP_Instance instance,
+ PP_CursorType_Dev type,
+ PP_Resource custom_image_id,
+ const PP_Point* hot_spot) OVERRIDE;
+ virtual PP_Bool LockCursor(PP_Instance instance) OVERRIDE;
+ virtual PP_Bool UnlockCursor(PP_Instance instance) OVERRIDE;
+ virtual PP_Bool HasCursorLock(PP_Instance instance) OVERRIDE;
+ virtual PP_Bool CanLockCursor(PP_Instance instance) OVERRIDE;
+
+ private:
+ PluginInstance* instance_;
+
+ DISALLOW_COPY_AND_ASSIGN(PPB_CursorControl_Impl);
+};
} // namespace ppapi
} // namespace webkit
diff --git a/webkit/plugins/ppapi/ppb_font_impl.cc b/webkit/plugins/ppapi/ppb_font_impl.cc
index 6d596fe..6ff6928b 100644
--- a/webkit/plugins/ppapi/ppb_font_impl.cc
+++ b/webkit/plugins/ppapi/ppb_font_impl.cc
@@ -127,7 +127,8 @@ int32_t PPB_Font_Impl::PixelOffsetForCharacter(const PP_TextRun_Dev* text,
return result;
}
-PPB_Font_FunctionImpl::PPB_Font_FunctionImpl() {
+PPB_Font_FunctionImpl::PPB_Font_FunctionImpl(PluginInstance* instance)
+ : instance_(instance) {
}
PPB_Font_FunctionImpl::~PPB_Font_FunctionImpl() {
diff --git a/webkit/plugins/ppapi/ppb_font_impl.h b/webkit/plugins/ppapi/ppb_font_impl.h
index 86a6c8a..a07816b 100644
--- a/webkit/plugins/ppapi/ppb_font_impl.h
+++ b/webkit/plugins/ppapi/ppb_font_impl.h
@@ -57,7 +57,7 @@ class PPB_Font_Impl : public Resource,
class PPB_Font_FunctionImpl : public ::ppapi::FunctionGroupBase,
public ::ppapi::thunk::PPB_Font_FunctionAPI {
public:
- PPB_Font_FunctionImpl();
+ PPB_Font_FunctionImpl(PluginInstance* instance);
~PPB_Font_FunctionImpl();
// FunctionGroupBase overrides.
@@ -67,6 +67,8 @@ class PPB_Font_FunctionImpl : public ::ppapi::FunctionGroupBase,
virtual PP_Var GetFontFamilies(PP_Instance instance) OVERRIDE;
private:
+ PluginInstance* instance_;
+
DISALLOW_COPY_AND_ASSIGN(PPB_Font_FunctionImpl);
};
diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
index cf59502..cb9acb4 100644
--- a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
+++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
@@ -13,6 +13,7 @@
#include "ppapi/c/dev/ppp_video_decoder_dev.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
+#include "ppapi/thunk/enter.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
@@ -239,10 +240,15 @@ bool PPB_VideoDecoder_Impl::Decode(
if (!platform_video_decoder_.get())
return false;
- media::BitstreamBuffer decode_buffer(
- bitstream_buffer->id,
- Resource::GetAs<PPB_Buffer_Impl>(bitstream_buffer->data)->handle(),
- bitstream_buffer->size);
+ ::ppapi::thunk::EnterResourceNoLock< ::ppapi::thunk::PPB_Buffer_API>
+ enter(bitstream_buffer->data, true);
+ if (enter.failed())
+ return false;
+
+ PPB_Buffer_Impl* buffer = static_cast<PPB_Buffer_Impl*>(enter.object());
+ media::BitstreamBuffer decode_buffer(bitstream_buffer->id,
+ buffer->shared_memory()->handle(),
+ static_cast<size_t>(buffer->size()));
// Store the callback to inform when bitstream buffer has been processed.
// TODO(vmr): handle simultaneous decodes + callbacks.
@@ -423,8 +429,8 @@ SysmemBuffer::SysmemBuffer(const PP_SysmemBuffer_Dev& buffer)
scoped_refptr<webkit::ppapi::PPB_Buffer_Impl> pepper_buffer =
webkit::ppapi::Resource::GetAs<webkit::ppapi::PPB_Buffer_Impl>(
buffer.data);
- assert(pepper_buffer->is_mapped());
- data_ = pepper_buffer->mapped_buffer();
+ CHECK(pepper_buffer->IsMapped());
+ data_ = pepper_buffer->Map();
}
Picture::Picture(const PP_Picture_Dev& picture)
diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc
index e00c546..6e4ef7d 100644
--- a/webkit/plugins/ppapi/resource_creation_impl.cc
+++ b/webkit/plugins/ppapi/resource_creation_impl.cc
@@ -8,6 +8,8 @@
#include "ppapi/shared_impl/font_impl.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/ppb_audio_impl.h"
+#include "webkit/plugins/ppapi/ppb_broker_impl.h"
+#include "webkit/plugins/ppapi/ppb_buffer_impl.h"
#include "webkit/plugins/ppapi/ppb_font_impl.h"
#include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
@@ -15,7 +17,8 @@
namespace webkit {
namespace ppapi {
-ResourceCreationImpl::ResourceCreationImpl() {
+ResourceCreationImpl::ResourceCreationImpl(PluginInstance* instance)
+ : instance_(instance) {
}
ResourceCreationImpl::~ResourceCreationImpl() {
@@ -63,6 +66,15 @@ PP_Resource ResourceCreationImpl::CreateAudioTrusted(
return audio->GetReference();
}
+PP_Resource ResourceCreationImpl::CreateBroker(PP_Instance instance) {
+ return PPB_Broker_Impl::Create(instance);
+}
+
+PP_Resource ResourceCreationImpl::CreateBuffer(PP_Instance instance,
+ uint32_t size) {
+ return PPB_Buffer_Impl::Create(instance, size);
+}
+
PP_Resource ResourceCreationImpl::CreateFontObject(
PP_Instance pp_instance,
const PP_FontDescription_Dev* description) {
diff --git a/webkit/plugins/ppapi/resource_creation_impl.h b/webkit/plugins/ppapi/resource_creation_impl.h
index 8b8e551..9569620 100644
--- a/webkit/plugins/ppapi/resource_creation_impl.h
+++ b/webkit/plugins/ppapi/resource_creation_impl.h
@@ -13,10 +13,12 @@
namespace webkit {
namespace ppapi {
+class PluginInstance;
+
class ResourceCreationImpl : public ::ppapi::FunctionGroupBase,
public ::ppapi::thunk::ResourceCreationAPI {
public:
- ResourceCreationImpl();
+ ResourceCreationImpl(PluginInstance* instance);
virtual ~ResourceCreationImpl();
// FunctionGroupBase implementation.
@@ -31,6 +33,9 @@ class ResourceCreationImpl : public ::ppapi::FunctionGroupBase,
virtual PP_Resource CreateAudioConfig(PP_Instance instance,
PP_AudioSampleRate sample_rate,
uint32_t sample_frame_count) OVERRIDE;
+ virtual PP_Resource CreateBroker(PP_Instance instance) OVERRIDE;
+ virtual PP_Resource CreateBuffer(PP_Instance instance,
+ uint32_t size) OVERRIDE;
virtual PP_Resource CreateFontObject(
PP_Instance instance,
const PP_FontDescription_Dev* description) OVERRIDE;
@@ -43,6 +48,8 @@ class ResourceCreationImpl : public ::ppapi::FunctionGroupBase,
PP_Bool init_to_zero) OVERRIDE;
private:
+ PluginInstance* instance_;
+
DISALLOW_COPY_AND_ASSIGN(ResourceCreationImpl);
};
diff --git a/webkit/plugins/ppapi/resource_tracker.cc b/webkit/plugins/ppapi/resource_tracker.cc
index 452b845..7e04f61 100644
--- a/webkit/plugins/ppapi/resource_tracker.cc
+++ b/webkit/plugins/ppapi/resource_tracker.cc
@@ -11,9 +11,12 @@
#include "base/rand_util.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_var.h"
+#include "ppapi/shared_impl/function_group_base.h"
#include "ppapi/shared_impl/tracker_base.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
+#include "webkit/plugins/ppapi/ppb_char_set_impl.h"
+#include "webkit/plugins/ppapi/ppb_cursor_control_impl.h"
#include "webkit/plugins/ppapi/ppb_font_impl.h"
#include "webkit/plugins/ppapi/resource.h"
#include "webkit/plugins/ppapi/resource_creation_impl.h"
@@ -64,6 +67,10 @@ struct ResourceTracker::InstanceData {
// Resources and object vars associated with the instance.
ResourceSet resources;
VarSet object_vars;
+
+ // Lazily allocated function proxies for the different interfaces.
+ scoped_ptr< ::ppapi::FunctionGroupBase >
+ function_proxies[::pp::proxy::INTERFACE_ID_COUNT];
};
scoped_refptr<Resource> ResourceTracker::GetResource(PP_Resource res) const {
@@ -112,7 +119,7 @@ PP_Resource ResourceTracker::AddResource(Resource* resource) {
// Track associated with the instance.
PP_Instance pp_instance = resource->instance()->pp_instance();
DCHECK(instance_map_.find(pp_instance) != instance_map_.end());
- instance_map_[pp_instance].resources.insert(new_id);
+ instance_map_[pp_instance]->resources.insert(new_id);
return new_id;
}
@@ -130,7 +137,7 @@ int32 ResourceTracker::AddVar(Var* var) {
if (object_var) {
PP_Instance instance = object_var->instance()->pp_instance();
DCHECK(instance_map_.find(instance) != instance_map_.end());
- instance_map_[instance].object_vars.insert(new_id);
+ instance_map_[instance]->object_vars.insert(new_id);
}
return new_id;
@@ -163,7 +170,7 @@ bool ResourceTracker::UnrefResource(PP_Resource res) {
PP_Instance instance = to_release->instance()->pp_instance();
to_release->LastPluginRefWasDeleted(false);
- instance_map_[instance].resources.erase(res);
+ instance_map_[instance]->resources.erase(res);
live_resources_.erase(i);
}
return true;
@@ -181,7 +188,7 @@ void ResourceTracker::CleanupInstanceData(PP_Instance instance,
NOTREACHED();
return;
}
- InstanceData& data = found->second;
+ InstanceData& data = *found->second;
// Force release all plugin references to resources associated with the
// deleted instance.
@@ -235,8 +242,8 @@ uint32 ResourceTracker::GetLiveObjectsForInstance(
InstanceMap::const_iterator found = instance_map_.find(instance);
if (found == instance_map_.end())
return 0;
- return static_cast<uint32>(found->second.resources.size() +
- found->second.object_vars.size());
+ return static_cast<uint32>(found->second->resources.size() +
+ found->second->object_vars.size());
}
::ppapi::ResourceObjectBase* ResourceTracker::GetResourceAPI(
@@ -250,18 +257,37 @@ uint32 ResourceTracker::GetLiveObjectsForInstance(
}
::ppapi::FunctionGroupBase* ResourceTracker::GetFunctionAPI(
- PP_Instance inst,
+ PP_Instance pp_instance,
pp::proxy::InterfaceID id) {
- if (function_proxies_[id].get())
- return function_proxies_[id].get();
+ // Get the instance object. This also ensures that the instance data is in
+ // the map, since we need it below.
+ PluginInstance* instance = GetInstance(pp_instance);
+ if (!instance)
+ return NULL;
- // TODO(brettw) we need a better system for doing this.
- if (id == ::pp::proxy::INTERFACE_ID_RESOURCE_CREATION)
- function_proxies_[id].reset(new ResourceCreationImpl());
- else if (id == ::pp::proxy::INTERFACE_ID_PPB_FONT)
- function_proxies_[id].reset(new PPB_Font_FunctionImpl);
+ scoped_ptr< ::ppapi::FunctionGroupBase >& proxy =
+ instance_map_[pp_instance]->function_proxies[id];
+ if (proxy.get())
+ return proxy.get();
+
+ switch (id) {
+ case pp::proxy::INTERFACE_ID_PPB_CHAR_SET:
+ proxy.reset(new PPB_CharSet_Impl(instance));
+ break;
+ case pp::proxy::INTERFACE_ID_PPB_CURSORCONTROL:
+ proxy.reset(new PPB_CursorControl_Impl(instance));
+ break;
+ case pp::proxy::INTERFACE_ID_PPB_FONT:
+ proxy.reset(new PPB_Font_FunctionImpl(instance));
+ break;
+ case pp::proxy::INTERFACE_ID_RESOURCE_CREATION:
+ proxy.reset(new ResourceCreationImpl(instance));
+ break;
+ default:
+ NOTREACHED();
+ }
- return function_proxies_[id].get();
+ return proxy.get();
}
scoped_refptr<Var> ResourceTracker::GetVar(int32 var_id) const {
@@ -295,7 +321,7 @@ bool ResourceTracker::UnrefVar(int32 var_id) {
if (!--i->second.second) {
ObjectVar* object_var = i->second.first->AsObjectVar();
if (object_var) {
- instance_map_[object_var->instance()->pp_instance()].object_vars.erase(
+ instance_map_[object_var->instance()->pp_instance()]->object_vars.erase(
var_id);
}
live_vars_.erase(i);
@@ -320,7 +346,8 @@ PP_Instance ResourceTracker::AddInstance(PluginInstance* instance) {
instance_map_.find(new_instance) != instance_map_.end() ||
!instance->module()->ReserveInstanceID(new_instance));
- instance_map_[new_instance].instance = instance;
+ instance_map_[new_instance] = linked_ptr<InstanceData>(new InstanceData);
+ instance_map_[new_instance]->instance = instance;
return new_instance;
}
@@ -338,7 +365,7 @@ PluginInstance* ResourceTracker::GetInstance(PP_Instance instance) {
InstanceMap::iterator found = instance_map_.find(instance);
if (found == instance_map_.end())
return NULL;
- return found->second.instance;
+ return found->second->instance;
}
PP_Module ResourceTracker::AddModule(PluginModule* module) {
diff --git a/webkit/plugins/ppapi/resource_tracker.h b/webkit/plugins/ppapi/resource_tracker.h
index dca40eb..2d008f9 100644
--- a/webkit/plugins/ppapi/resource_tracker.h
+++ b/webkit/plugins/ppapi/resource_tracker.h
@@ -12,6 +12,7 @@
#include "base/basictypes.h"
#include "base/gtest_prod_util.h"
#include "base/hash_tables.h"
+#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "ppapi/c/pp_instance.h"
@@ -60,7 +61,7 @@ class ResourceTracker : public ::ppapi::TrackerBase {
virtual ::ppapi::ResourceObjectBase* GetResourceAPI(
PP_Resource res);
virtual ::ppapi::FunctionGroupBase* GetFunctionAPI(
- PP_Instance inst,
+ PP_Instance pp_instance,
pp::proxy::InterfaceID id);
// PP_Vars -------------------------------------------------------------------
@@ -180,7 +181,7 @@ class ResourceTracker : public ::ppapi::TrackerBase {
VarMap live_vars_;
// Tracks all live instances and their associated data.
- typedef std::map<PP_Instance, InstanceData> InstanceMap;
+ typedef std::map<PP_Instance, linked_ptr<InstanceData> > InstanceMap;
InstanceMap instance_map_;
// Tracks all live modules. The pointers are non-owning, the PluginModule
@@ -188,9 +189,6 @@ class ResourceTracker : public ::ppapi::TrackerBase {
typedef std::map<PP_Module, PluginModule*> ModuleMap;
ModuleMap module_map_;
- scoped_ptr< ::ppapi::FunctionGroupBase >
- function_proxies_[::pp::proxy::INTERFACE_ID_COUNT];
-
DISALLOW_COPY_AND_ASSIGN(ResourceTracker);
};