diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-06 22:55:47 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-06 22:55:47 +0000 |
commit | 6239d34076222cbfe1d42770c604822b0ba894f4 (patch) | |
tree | d873cdf138b002bb2d2d4a554ba4fcd210251760 /webkit/plugins | |
parent | c50a948dd9c07a71524949a28a5347e11d80da47 (diff) | |
download | chromium_src-6239d34076222cbfe1d42770c604822b0ba894f4.zip chromium_src-6239d34076222cbfe1d42770c604822b0ba894f4.tar.gz chromium_src-6239d34076222cbfe1d42770c604822b0ba894f4.tar.bz2 |
This implements the new system for Graphics2D only.
This works by adding a new thunk layer that will forward to an "API" that's either per-instance (function APIs) or per-resource (resource APIs). The proxying and such is then implemented in terms of this C++ API.
Ideally the trackers of the PP_Resource/PP_Instance -> object mapping would be shared between the plugin and renderer processes. To keep this patch under control, I did this as a virtual base class which is implemented by ppapi::proxy::PluginResourceTracker and webkit::ppapi::ResourceTracker. Later, the functionality of these objects should be shared in a common tracker class.
Still to do it a lot of cleanup and merging of things. Also, the namespaces are a bit out of control.
Review URL: http://codereview.chromium.org/6905088
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84519 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins')
-rw-r--r-- | webkit/plugins/ppapi/DEPS | 5 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_graphics_2d_impl.cc | 85 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_graphics_2d_impl.h | 23 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_image_data_impl.cc | 78 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_image_data_impl.h | 21 | ||||
-rw-r--r-- | webkit/plugins/ppapi/resource.h | 4 | ||||
-rw-r--r-- | webkit/plugins/ppapi/resource_creation_impl.cc | 58 | ||||
-rw-r--r-- | webkit/plugins/ppapi/resource_creation_impl.h | 40 | ||||
-rw-r--r-- | webkit/plugins/ppapi/resource_tracker.cc | 36 | ||||
-rw-r--r-- | webkit/plugins/ppapi/resource_tracker.h | 16 |
10 files changed, 199 insertions, 167 deletions
diff --git a/webkit/plugins/ppapi/DEPS b/webkit/plugins/ppapi/DEPS index baf1b82..4b47d9c 100644 --- a/webkit/plugins/ppapi/DEPS +++ b/webkit/plugins/ppapi/DEPS @@ -2,8 +2,13 @@ include_rules = [ "+gpu/command_buffer", "+ppapi/c", "+ppapi/shared_impl", + "+ppapi/thunk", "+printing", "+media/video", "+skia", "+ui/base", + + # This should technically not be allowed. Brett is refactoring this and will + # move this file to a more proper shared location in a future iteration. + "+ppapi/proxy/interface_id.h", ] diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc index c1b6ab9..a3f1c0d 100644 --- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc +++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc @@ -15,6 +15,7 @@ #include "ppapi/c/pp_resource.h" #include "ppapi/c/ppb_graphics_2d.h" #include "ppapi/cpp/common.h" +#include "ppapi/thunk/thunk.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/blit.h" #include "ui/gfx/point.h" @@ -114,82 +115,6 @@ void ConvertImageData(PPB_ImageData_Impl* src_image, const SkIRect& src_rect, } } -PP_Resource Create(PP_Instance instance_id, - const PP_Size* size, - PP_Bool is_always_opaque) { - PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); - if (!instance) - return 0; - - 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(); -} - -PP_Bool IsGraphics2D(PP_Resource resource) { - return BoolToPPBool(!!Resource::GetAs<PPB_Graphics2D_Impl>(resource)); -} - -PP_Bool Describe(PP_Resource graphics_2d, - PP_Size* size, - PP_Bool* is_always_opaque) { - scoped_refptr<PPB_Graphics2D_Impl> context( - Resource::GetAs<PPB_Graphics2D_Impl>(graphics_2d)); - if (!context) { - *size = PP_MakeSize(0, 0); - *is_always_opaque = PP_FALSE; - return PP_FALSE; - } - return context->Describe(size, is_always_opaque); -} - -void PaintImageData(PP_Resource graphics_2d, - PP_Resource image_data, - const PP_Point* top_left, - const PP_Rect* src_rect) { - scoped_refptr<PPB_Graphics2D_Impl> context( - Resource::GetAs<PPB_Graphics2D_Impl>(graphics_2d)); - if (context) - context->PaintImageData(image_data, top_left, src_rect); -} - -void Scroll(PP_Resource graphics_2d, - const PP_Rect* clip_rect, - const PP_Point* amount) { - scoped_refptr<PPB_Graphics2D_Impl> context( - Resource::GetAs<PPB_Graphics2D_Impl>(graphics_2d)); - if (context) - context->Scroll(clip_rect, amount); -} - -void ReplaceContents(PP_Resource graphics_2d, PP_Resource image_data) { - scoped_refptr<PPB_Graphics2D_Impl> context( - Resource::GetAs<PPB_Graphics2D_Impl>(graphics_2d)); - if (context) - context->ReplaceContents(image_data); -} - -int32_t Flush(PP_Resource graphics_2d, - PP_CompletionCallback callback) { - scoped_refptr<PPB_Graphics2D_Impl> context( - Resource::GetAs<PPB_Graphics2D_Impl>(graphics_2d)); - if (!context) - return PP_ERROR_BADRESOURCE; - return context->Flush(callback); -} - -const PPB_Graphics2D ppb_graphics_2d = { - &Create, - &IsGraphics2D, - &Describe, - &PaintImageData, - &Scroll, - &ReplaceContents, - &Flush -}; - } // namespace struct PPB_Graphics2D_Impl::QueuedOperation { @@ -235,7 +160,7 @@ PPB_Graphics2D_Impl::~PPB_Graphics2D_Impl() { // static const PPB_Graphics2D* PPB_Graphics2D_Impl::GetInterface() { - return &ppb_graphics_2d; + return ::ppapi::thunk::GetPPB_Graphics2D_Thunk(); } bool PPB_Graphics2D_Impl::Init(int width, int height, bool is_always_opaque) { @@ -251,6 +176,10 @@ bool PPB_Graphics2D_Impl::Init(int width, int height, bool is_always_opaque) { return true; } +::ppapi::thunk::PPB_Graphics2D_API* PPB_Graphics2D_Impl::AsGraphics2D_API() { + return this; +} + PPB_Graphics2D_Impl* PPB_Graphics2D_Impl::AsPPB_Graphics2D_Impl() { return this; } @@ -340,7 +269,7 @@ void PPB_Graphics2D_Impl::ReplaceContents(PP_Resource image_data) { queued_operations_.push_back(operation); } -int32_t PPB_Graphics2D_Impl::Flush(const PP_CompletionCallback& callback) { +int32_t PPB_Graphics2D_Impl::Flush(PP_CompletionCallback callback) { // Don't allow more than one pending flush at a time. if (HasPendingFlush()) return PP_ERROR_INPROGRESS; diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.h b/webkit/plugins/ppapi/ppb_graphics_2d_impl.h index 9c1bbfd..66e3032 100644 --- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.h +++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/ppb_graphics_2d.h" +#include "ppapi/thunk/ppb_graphics_2d_api.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCanvas.h" #include "webkit/plugins/ppapi/resource.h" @@ -26,7 +27,9 @@ class PPB_ImageData_Impl; class PluginInstance; class PluginModule; -class PPB_Graphics2D_Impl : public Resource { +class PPB_Graphics2D_Impl + : public Resource, + public ::ppapi::thunk::PPB_Graphics2D_API { public: PPB_Graphics2D_Impl(PluginInstance* instance); virtual ~PPB_Graphics2D_Impl(); @@ -39,17 +42,19 @@ class PPB_Graphics2D_Impl : public Resource { bool is_always_opaque() const { return is_always_opaque_; } + virtual ::ppapi::thunk::PPB_Graphics2D_API* AsGraphics2D_API(); + // Resource override. virtual PPB_Graphics2D_Impl* AsPPB_Graphics2D_Impl(); // PPB_Graphics2D functions. - PP_Bool Describe(PP_Size* size, PP_Bool* is_always_opaque); - void PaintImageData(PP_Resource image_data, - const PP_Point* top_left, - const PP_Rect* src_rect); - void Scroll(const PP_Rect* clip_rect, const PP_Point* amount); - void ReplaceContents(PP_Resource image_data); - int32_t Flush(const PP_CompletionCallback& callback); + virtual PP_Bool Describe(PP_Size* size, PP_Bool* is_always_opaque); + virtual void PaintImageData(PP_Resource image_data, + const PP_Point* top_left, + const PP_Rect* src_rect); + virtual void Scroll(const PP_Rect* clip_rect, const PP_Point* amount); + virtual void ReplaceContents(PP_Resource image_data); + virtual int32_t Flush(PP_CompletionCallback callback); bool ReadImageData(PP_Resource image, const PP_Point* top_left); diff --git a/webkit/plugins/ppapi/ppb_image_data_impl.cc b/webkit/plugins/ppapi/ppb_image_data_impl.cc index 967a978..9f5c15c 100644 --- a/webkit/plugins/ppapi/ppb_image_data_impl.cc +++ b/webkit/plugins/ppapi/ppb_image_data_impl.cc @@ -14,6 +14,7 @@ #include "ppapi/c/pp_resource.h" #include "ppapi/c/ppb_image_data.h" #include "ppapi/c/trusted/ppb_image_data_trusted.h" +#include "ppapi/thunk/thunk.h" #include "third_party/skia/include/core/SkColorPriv.h" #include "webkit/plugins/ppapi/common.h" #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" @@ -23,64 +24,6 @@ namespace ppapi { namespace { -PP_ImageDataFormat GetNativeImageDataFormat() { - return PPB_ImageData_Impl::GetNativeImageDataFormat(); -} - -PP_Bool IsImageDataFormatSupported(PP_ImageDataFormat format) { - return BoolToPPBool(PPB_ImageData_Impl::IsImageDataFormatSupported(format)); -} - -PP_Resource Create(PP_Instance instance_id, - PP_ImageDataFormat format, - const PP_Size* size, - PP_Bool init_to_zero) { - PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); - if (!instance) - return 0; - - scoped_refptr<PPB_ImageData_Impl> data(new PPB_ImageData_Impl(instance)); - if (!data->Init(format, - size->width, - size->height, - PPBoolToBool(init_to_zero))) { - return 0; - } - - return data->GetReference(); -} - -PP_Bool IsImageData(PP_Resource resource) { - return BoolToPPBool(!!Resource::GetAs<PPB_ImageData_Impl>(resource)); -} - -PP_Bool Describe(PP_Resource resource, PP_ImageDataDesc* desc) { - // Give predictable values on failure. - memset(desc, 0, sizeof(PP_ImageDataDesc)); - - scoped_refptr<PPB_ImageData_Impl> image_data( - Resource::GetAs<PPB_ImageData_Impl>(resource)); - if (!image_data) - return PP_FALSE; - image_data->Describe(desc); - return PP_TRUE; -} - -void* Map(PP_Resource resource) { - scoped_refptr<PPB_ImageData_Impl> image_data( - Resource::GetAs<PPB_ImageData_Impl>(resource)); - if (!image_data) - return NULL; - return image_data->Map(); -} - -void Unmap(PP_Resource resource) { - scoped_refptr<PPB_ImageData_Impl> image_data( - Resource::GetAs<PPB_ImageData_Impl>(resource)); - if (image_data) - image_data->Unmap(); -} - int32_t GetSharedMemory(PP_Resource resource, int* handle, uint32_t* byte_count) { @@ -93,16 +36,6 @@ int32_t GetSharedMemory(PP_Resource resource, return PP_ERROR_BADRESOURCE; } -const PPB_ImageData ppb_imagedata = { - &GetNativeImageDataFormat, - &IsImageDataFormatSupported, - &Create, - &IsImageData, - &Describe, - &Map, - &Unmap, -}; - const PPB_ImageDataTrusted ppb_imagedata_trusted = { &GetSharedMemory, }; @@ -121,7 +54,7 @@ PPB_ImageData_Impl::~PPB_ImageData_Impl() { // static const PPB_ImageData* PPB_ImageData_Impl::GetInterface() { - return &ppb_imagedata; + return ::ppapi::thunk::GetPPB_ImageData_Thunk(); } // static @@ -129,6 +62,10 @@ const PPB_ImageDataTrusted* PPB_ImageData_Impl::GetTrustedInterface() { return &ppb_imagedata_trusted; } +::ppapi::thunk::PPB_ImageData_API* PPB_ImageData_Impl::AsImageData_API() { + return this; +} + PPB_ImageData_Impl* PPB_ImageData_Impl::AsPPB_ImageData_Impl() { return this; } @@ -154,11 +91,12 @@ bool PPB_ImageData_Impl::Init(PP_ImageDataFormat format, return !!platform_image_.get(); } -void PPB_ImageData_Impl::Describe(PP_ImageDataDesc* desc) const { +PP_Bool PPB_ImageData_Impl::Describe(PP_ImageDataDesc* desc) { desc->format = format_; desc->size.width = width_; desc->size.height = height_; desc->stride = width_ * 4; + return PP_TRUE; } void* PPB_ImageData_Impl::Map() { diff --git a/webkit/plugins/ppapi/ppb_image_data_impl.h b/webkit/plugins/ppapi/ppb_image_data_impl.h index 759da1a..69a7a65 100644 --- a/webkit/plugins/ppapi/ppb_image_data_impl.h +++ b/webkit/plugins/ppapi/ppb_image_data_impl.h @@ -9,6 +9,7 @@ #include "base/memory/scoped_ptr.h" #include "ppapi/c/ppb_image_data.h" #include "ppapi/shared_impl/image_data_impl.h" +#include "ppapi/thunk/ppb_image_data_api.h" #include "webkit/plugins/ppapi/plugin_delegate.h" #include "webkit/plugins/ppapi/resource.h" @@ -23,11 +24,16 @@ namespace webkit { namespace ppapi { class PPB_ImageData_Impl : public Resource, - public pp::shared_impl::ImageDataImpl { + public pp::shared_impl::ImageDataImpl, + public ::ppapi::thunk::PPB_ImageData_API { public: explicit PPB_ImageData_Impl(PluginInstance* instance); virtual ~PPB_ImageData_Impl(); + bool Init(PP_ImageDataFormat format, + int width, int height, + bool init_to_zero); + int width() const { return width_; } int height() const { return height_; } @@ -47,16 +53,15 @@ class PPB_ImageData_Impl : public Resource, static const PPB_ImageData* GetInterface(); static const PPB_ImageDataTrusted* GetTrustedInterface(); + virtual ::ppapi::thunk::PPB_ImageData_API* AsImageData_API(); + // Resource overrides. virtual PPB_ImageData_Impl* AsPPB_ImageData_Impl(); - // PPB_ImageData implementation. - bool Init(PP_ImageDataFormat format, - int width, int height, - bool init_to_zero); - void Describe(PP_ImageDataDesc* desc) const; - void* Map(); - void Unmap(); + // PPB_ImageData_API implementation. + virtual PP_Bool Describe(PP_ImageDataDesc* desc); + virtual void* Map(); + virtual void Unmap(); // PPB_ImageDataTrusted implementation. int GetSharedMemoryHandle(uint32* byte_count) const; diff --git a/webkit/plugins/ppapi/resource.h b/webkit/plugins/ppapi/resource.h index 8b08805..a263231 100644 --- a/webkit/plugins/ppapi/resource.h +++ b/webkit/plugins/ppapi/resource.h @@ -8,6 +8,7 @@ #include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "ppapi/c/pp_resource.h" +#include "ppapi/shared_impl/resource_object_base.h" #include "webkit/plugins/ppapi/resource_tracker.h" namespace webkit { @@ -49,7 +50,8 @@ namespace ppapi { FOR_ALL_RESOURCES(DECLARE_RESOURCE_CLASS) #undef DECLARE_RESOURCE_CLASS -class Resource : public base::RefCountedThreadSafe<Resource> { +class Resource : public base::RefCountedThreadSafe<Resource>, + public ::ppapi::shared_impl::ResourceObjectBase { public: explicit Resource(PluginInstance* instance); virtual ~Resource(); diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc new file mode 100644 index 0000000..674aee1 --- /dev/null +++ b/webkit/plugins/ppapi/resource_creation_impl.cc @@ -0,0 +1,58 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/plugins/ppapi/resource_creation_impl.h" + +#include "ppapi/c/pp_size.h" +#include "webkit/plugins/ppapi/common.h" +#include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" +#include "webkit/plugins/ppapi/ppb_image_data_impl.h" + +namespace webkit { +namespace ppapi { + +ResourceCreationImpl::ResourceCreationImpl() { +} + +ResourceCreationImpl::~ResourceCreationImpl() { +} + +::ppapi::thunk::ResourceCreationAPI* +ResourceCreationImpl::AsResourceCreation() { + return this; +} + +PP_Resource ResourceCreationImpl::CreateGraphics2D( + PP_Instance pp_instance, + const PP_Size& size, + PP_Bool is_always_opaque) { + PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); + if (!instance) + return 0; + + scoped_refptr<PPB_Graphics2D_Impl> graphics_2d( + new PPB_Graphics2D_Impl(instance)); + if (!graphics_2d->Init(size.width, size.height, + PPBoolToBool(is_always_opaque))) { + return 0; + } + return graphics_2d->GetReference(); +} + +PP_Resource ResourceCreationImpl::CreateImageData(PP_Instance pp_instance, + PP_ImageDataFormat format, + const PP_Size& size, + PP_Bool init_to_zero) { + PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); + if (!instance) + return 0; + + scoped_refptr<PPB_ImageData_Impl> data(new PPB_ImageData_Impl(instance)); + if (!data->Init(format, size.width, size.height, !!init_to_zero)) + return 0; + return data->GetReference(); +} + +} // namespace ppapi +} // namespace webkit diff --git a/webkit/plugins/ppapi/resource_creation_impl.h b/webkit/plugins/ppapi/resource_creation_impl.h new file mode 100644 index 0000000..4d89715 --- /dev/null +++ b/webkit/plugins/ppapi/resource_creation_impl.h @@ -0,0 +1,40 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_PLUGINS_PPAPI_RESOURCE_CREATION_IMPL_H_ +#define WEBKIT_PLUGINS_PPAPI_RESOURCE_CREATION_IMPL_H_ + +#include "base/basictypes.h" +#include "ppapi/shared_impl/function_group_base.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace webkit { +namespace ppapi { + +class ResourceCreationImpl : public ::ppapi::shared_impl::FunctionGroupBase, + public ::ppapi::thunk::ResourceCreationAPI { + public: + ResourceCreationImpl(); + virtual ~ResourceCreationImpl(); + + // FunctionGroupBase implementation. + virtual ::ppapi::thunk::ResourceCreationAPI* AsResourceCreation(); + + // ResourceCreationAPI implementation. + virtual PP_Resource CreateGraphics2D(PP_Instance pp_instance, + const PP_Size& size, + PP_Bool is_always_opaque); + virtual PP_Resource CreateImageData(PP_Instance instance, + PP_ImageDataFormat format, + const PP_Size& size, + PP_Bool init_to_zero); + + private: + DISALLOW_COPY_AND_ASSIGN(ResourceCreationImpl); +}; + +} // namespace ppapi +} // namespace webkit + +#endif // WEBKIT_PLUGINS_PPAPI_RESOURCE_CREATION_IMPL_H_ diff --git a/webkit/plugins/ppapi/resource_tracker.cc b/webkit/plugins/ppapi/resource_tracker.cc index 4642b63..1c4b3a1 100644 --- a/webkit/plugins/ppapi/resource_tracker.cc +++ b/webkit/plugins/ppapi/resource_tracker.cc @@ -11,9 +11,11 @@ #include "base/rand_util.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_var.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/resource.h" +#include "webkit/plugins/ppapi/resource_creation_impl.h" #include "webkit/plugins/ppapi/var.h" enum PPIdType { @@ -40,9 +42,19 @@ template <typename T> static inline bool CheckIdType(T id, PPIdType type) { return (id & mask) == type; } +namespace shared_impl = ::ppapi::shared_impl; + namespace webkit { namespace ppapi { +namespace { + +shared_impl::TrackerBase* GetTrackerBase() { + return ResourceTracker::Get(); +} + +} // namespace + struct ResourceTracker::InstanceData { InstanceData() : instance(0) {} @@ -72,6 +84,8 @@ ResourceTracker* ResourceTracker::singleton_override_ = NULL; ResourceTracker::ResourceTracker() : last_resource_id_(0), last_var_id_(0) { + // Wire up the new shared resource tracker base to use our implementation. + shared_impl::TrackerBase::Init(&GetTrackerBase); } ResourceTracker::~ResourceTracker() { @@ -226,6 +240,28 @@ uint32 ResourceTracker::GetLiveObjectsForInstance( found->second.object_vars.size()); } +shared_impl::ResourceObjectBase* ResourceTracker::GetResourceAPI( + PP_Resource res) { + DLOG_IF(ERROR, !CheckIdType(res, PP_ID_TYPE_RESOURCE)) + << res << " is not a PP_Resource."; + ResourceMap::const_iterator result = live_resources_.find(res); + if (result == live_resources_.end()) + return NULL; + return result->second.first.get(); +} + +shared_impl::FunctionGroupBase* ResourceTracker::GetFunctionAPI( + PP_Instance inst, + pp::proxy::InterfaceID id) { + if (function_proxies_[id].get()) + return function_proxies_[id].get(); + + if (id == ::pp::proxy::INTERFACE_ID_RESOURCE_CREATION) + function_proxies_[id].reset(new ResourceCreationImpl()); + + return function_proxies_[id].get(); +} + scoped_refptr<Var> ResourceTracker::GetVar(int32 var_id) const { DLOG_IF(ERROR, !CheckIdType(var_id, PP_ID_TYPE_VAR)) << var_id << " is not a PP_Var ID."; diff --git a/webkit/plugins/ppapi/resource_tracker.h b/webkit/plugins/ppapi/resource_tracker.h index a5cd70d..744d90c 100644 --- a/webkit/plugins/ppapi/resource_tracker.h +++ b/webkit/plugins/ppapi/resource_tracker.h @@ -13,9 +13,13 @@ #include "base/gtest_prod_util.h" #include "base/hash_tables.h" #include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" +#include "ppapi/proxy/interface_id.h" +#include "ppapi/shared_impl/function_group_base.h" +#include "ppapi/shared_impl/tracker_base.h" namespace webkit { namespace ppapi { @@ -30,7 +34,7 @@ class Var; // us to check resource ID validity and to map them to a specific module. // // This object is NOT threadsafe. -class ResourceTracker { +class ResourceTracker : public ::ppapi::shared_impl::TrackerBase { public: // Returns the pointer to the singleton object. static ResourceTracker* Get(); @@ -52,6 +56,13 @@ class ResourceTracker { // Returns the number of resources associated with this module. uint32 GetLiveObjectsForInstance(PP_Instance instance) const; + // ResourceTrackerBase. + virtual ::ppapi::shared_impl::ResourceObjectBase* GetResourceAPI( + PP_Resource res); + virtual ::ppapi::shared_impl::FunctionGroupBase* GetFunctionAPI( + PP_Instance inst, + pp::proxy::InterfaceID id); + // PP_Vars ------------------------------------------------------------------- scoped_refptr<Var> GetVar(int32 var_id) const; @@ -177,6 +188,9 @@ class ResourceTracker { typedef std::map<PP_Module, PluginModule*> ModuleMap; ModuleMap module_map_; + scoped_ptr< ::ppapi::shared_impl::FunctionGroupBase > + function_proxies_[::pp::proxy::INTERFACE_ID_COUNT]; + DISALLOW_COPY_AND_ASSIGN(ResourceTracker); }; |