summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-23 21:49:48 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-23 21:49:48 +0000
commit0b94c614fe0d76578a84b4e0543f58650d3ad49c (patch)
treef08dab436f29cd17bff34e5b80bf14ad62f00a2c /webkit
parent4c75b2543443e1b9faca724fc665b0c0fc68c15f (diff)
downloadchromium_src-0b94c614fe0d76578a84b4e0543f58650d3ad49c.zip
chromium_src-0b94c614fe0d76578a84b4e0543f58650d3ad49c.tar.gz
chromium_src-0b94c614fe0d76578a84b4e0543f58650d3ad49c.tar.bz2
Make scrollbar GetThickness take a resource argument. This allows simlper
routing of the request using the new thunk system. Support for the old interface is kept to keep pdf and nacl building. This removes the old Resource type introspection since this was the last resource using it. TEST=it compiles BUG=non Review URL: http://codereview.chromium.org/7228003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90272 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/plugins/ppapi/mock_resource.cc13
-rw-r--r--webkit/plugins/ppapi/mock_resource.h2
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc4
-rw-r--r--webkit/plugins/ppapi/ppb_scrollbar_impl.cc63
-rw-r--r--webkit/plugins/ppapi/ppb_scrollbar_impl.h33
-rw-r--r--webkit/plugins/ppapi/resource.cc5
-rw-r--r--webkit/plugins/ppapi/resource.h40
-rw-r--r--webkit/plugins/ppapi/resource_creation_impl.cc6
-rw-r--r--webkit/plugins/ppapi/resource_creation_impl.h2
-rw-r--r--webkit/tools/test_shell/test_shell.gypi1
10 files changed, 58 insertions, 111 deletions
diff --git a/webkit/plugins/ppapi/mock_resource.cc b/webkit/plugins/ppapi/mock_resource.cc
deleted file mode 100644
index 4b1d666..0000000
--- a/webkit/plugins/ppapi/mock_resource.cc
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "webkit/plugins/ppapi/mock_resource.h"
-
-namespace webkit {
-namespace ppapi {
-
-MockResource* MockResource::AsMockResource() { return this; }
-
-} // namespace ppapi
-} // namespace webkit
diff --git a/webkit/plugins/ppapi/mock_resource.h b/webkit/plugins/ppapi/mock_resource.h
index cd84556..1368c4a 100644
--- a/webkit/plugins/ppapi/mock_resource.h
+++ b/webkit/plugins/ppapi/mock_resource.h
@@ -17,8 +17,6 @@ class MockResource : public Resource {
public:
MockResource(PluginInstance* instance) : Resource(instance) {}
virtual ~MockResource() {}
-
- virtual MockResource* AsMockResource();
};
} // namespace ppapi
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index d9db923..56bb1f7 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -303,7 +303,9 @@ const void* GetInterface(const char* name) {
if (strcmp(name, PPB_PROXY_PRIVATE_INTERFACE) == 0)
return PPB_Proxy_Impl::GetInterface();
if (strcmp(name, PPB_SCROLLBAR_DEV_INTERFACE) == 0)
- return PPB_Scrollbar_Impl::GetInterface();
+ return ::ppapi::thunk::GetPPB_Scrollbar_Thunk();
+ if (strcmp(name, PPB_SCROLLBAR_DEV_INTERFACE_0_3) == 0)
+ return PPB_Scrollbar_Impl::Get0_3Interface();
if (strcmp(name, PPB_UMA_PRIVATE_INTERFACE) == 0)
return PPB_UMA_Private_Impl::GetInterface();
if (strcmp(name, PPB_URLLOADER_INTERFACE) == 0)
diff --git a/webkit/plugins/ppapi/ppb_scrollbar_impl.cc b/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
index 1996bb8..4b4c07b 100644
--- a/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
+++ b/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "base/message_loop.h"
#include "ppapi/c/dev/ppp_scrollbar_dev.h"
+#include "ppapi/thunk/thunk.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h"
@@ -23,6 +24,7 @@
#include "base/win/windows_version.h"
#endif
+using ppapi::thunk::PPB_Scrollbar_API;
using WebKit::WebInputEvent;
using WebKit::WebRect;
using WebKit::WebScrollbar;
@@ -32,18 +34,18 @@ namespace ppapi {
namespace {
-PP_Resource Create(PP_Instance instance_id, PP_Bool vertical) {
- PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
- if (!instance)
- return 0;
+// Version 0.3 implementation --------------------------------------------------
+//
+// TODO(brettw) remove this when we remove support for version 0.3 interface.
+// This just forwards everything to the new version of the interface except for
+// the GetThickness call which has no parameters.
- scoped_refptr<PPB_Scrollbar_Impl> scrollbar(
- new PPB_Scrollbar_Impl(instance, PPBoolToBool(vertical)));
- return scrollbar->GetReference();
+PP_Resource Create(PP_Instance instance, PP_Bool vertical) {
+ return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->Create(instance, vertical);
}
PP_Bool IsScrollbar(PP_Resource resource) {
- return BoolToPPBool(!!Resource::GetAs<PPB_Scrollbar_Impl>(resource));
+ return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->IsScrollbar(resource);
}
uint32_t GetThickness() {
@@ -51,44 +53,33 @@ uint32_t GetThickness() {
}
uint32_t GetValue(PP_Resource resource) {
- scoped_refptr<PPB_Scrollbar_Impl> scrollbar(
- Resource::GetAs<PPB_Scrollbar_Impl>(resource));
- if (!scrollbar)
- return 0;
- return scrollbar->GetValue();
+ return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->GetValue(resource);
}
void SetValue(PP_Resource resource, uint32_t value) {
- scoped_refptr<PPB_Scrollbar_Impl> scrollbar(
- Resource::GetAs<PPB_Scrollbar_Impl>(resource));
- if (scrollbar)
- scrollbar->SetValue(value);
+ return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->SetValue(resource, value);
}
void SetDocumentSize(PP_Resource resource, uint32_t size) {
- scoped_refptr<PPB_Scrollbar_Impl> scrollbar(
- Resource::GetAs<PPB_Scrollbar_Impl>(resource));
- if (scrollbar)
- scrollbar->SetDocumentSize(size);
+ return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->SetDocumentSize(resource,
+ size);
}
void SetTickMarks(PP_Resource resource,
const PP_Rect* tick_marks,
uint32_t count) {
- scoped_refptr<PPB_Scrollbar_Impl> scrollbar(
- Resource::GetAs<PPB_Scrollbar_Impl>(resource));
- if (scrollbar)
- scrollbar->SetTickMarks(tick_marks, count);
+ return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->SetTickMarks(resource,
+ tick_marks,
+ count);
}
void ScrollBy(PP_Resource resource, PP_ScrollBy_Dev unit, int32_t multiplier) {
- scoped_refptr<PPB_Scrollbar_Impl> scrollbar(
- Resource::GetAs<PPB_Scrollbar_Impl>(resource));
- if (scrollbar)
- scrollbar->ScrollBy(unit, multiplier);
+ return ::ppapi::thunk::GetPPB_Scrollbar_Thunk()->ScrollBy(resource,
+ unit,
+ multiplier);
}
-const PPB_Scrollbar_Dev ppb_scrollbar = {
+const PPB_Scrollbar_0_3_Dev ppb_scrollbar_0_3 = {
&Create,
&IsScrollbar,
&GetThickness,
@@ -111,13 +102,17 @@ PPB_Scrollbar_Impl::PPB_Scrollbar_Impl(PluginInstance* instance, bool vertical)
PPB_Scrollbar_Impl::~PPB_Scrollbar_Impl() {
}
+PPB_Scrollbar_API* PPB_Scrollbar_Impl::AsPPB_Scrollbar_API() {
+ return this;
+}
+
// static
-const PPB_Scrollbar_Dev* PPB_Scrollbar_Impl::GetInterface() {
- return &ppb_scrollbar;
+const PPB_Scrollbar_0_3_Dev* PPB_Scrollbar_Impl::Get0_3Interface() {
+ return &ppb_scrollbar_0_3;
}
-PPB_Scrollbar_Impl* PPB_Scrollbar_Impl::AsPPB_Scrollbar_Impl() {
- return this;
+uint32_t PPB_Scrollbar_Impl::GetThickness() {
+ return WebScrollbar::defaultThickness();
}
uint32_t PPB_Scrollbar_Impl::GetValue() {
diff --git a/webkit/plugins/ppapi/ppb_scrollbar_impl.h b/webkit/plugins/ppapi/ppb_scrollbar_impl.h
index 6c1ca86..f9bdda3 100644
--- a/webkit/plugins/ppapi/ppb_scrollbar_impl.h
+++ b/webkit/plugins/ppapi/ppb_scrollbar_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.
@@ -7,7 +7,7 @@
#include <vector>
-#include "ppapi/c/dev/ppb_scrollbar_dev.h"
+#include "ppapi/thunk/ppb_scrollbar_api.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebScrollbarClient.h"
#include "ui/gfx/rect.h"
@@ -19,24 +19,27 @@ namespace ppapi {
class PluginInstance;
class PPB_Scrollbar_Impl : public PPB_Widget_Impl,
+ public ::ppapi::thunk::PPB_Scrollbar_API,
public WebKit::WebScrollbarClient {
public:
PPB_Scrollbar_Impl(PluginInstance* instance, bool vertical);
virtual ~PPB_Scrollbar_Impl();
- // Returns a pointer to the interface implementing PPB_Scrollbar that is
- // exposed to the plugin.
- static const PPB_Scrollbar_Dev* GetInterface();
-
- // Resource overrides.
- virtual PPB_Scrollbar_Impl* AsPPB_Scrollbar_Impl();
-
- // PPB_Scrollbar implementation.
- uint32_t GetValue();
- void SetValue(uint32_t value);
- void SetDocumentSize(uint32_t size);
- void SetTickMarks(const PP_Rect* tick_marks, uint32_t count);
- void ScrollBy(PP_ScrollBy_Dev unit, int32_t multiplier);
+ // ResourceObjectBase override.
+ virtual PPB_Scrollbar_API* AsPPB_Scrollbar_API() OVERRIDE;
+
+ // Returns a pointer to the interface implementing PPB_Scrollbar_0_3 that is
+ // exposed to the plugin. New code should use the thunk system for the new
+ // version of this API.
+ static const PPB_Scrollbar_0_3_Dev* Get0_3Interface();
+
+ // PPB_Scrollbar_API implementation.
+ virtual uint32_t GetThickness() OVERRIDE;
+ virtual uint32_t GetValue() OVERRIDE;
+ virtual void SetValue(uint32_t value) OVERRIDE;
+ virtual void SetDocumentSize(uint32_t size) OVERRIDE;
+ virtual void SetTickMarks(const PP_Rect* tick_marks, uint32_t count) OVERRIDE;
+ virtual void ScrollBy(PP_ScrollBy_Dev unit, int32_t multiplier) OVERRIDE;
// PPB_Widget public implementation.
virtual PP_Bool HandleEvent(const PP_InputEvent* event) OVERRIDE;
diff --git a/webkit/plugins/ppapi/resource.cc b/webkit/plugins/ppapi/resource.cc
index 81c7737..ac537a6 100644
--- a/webkit/plugins/ppapi/resource.cc
+++ b/webkit/plugins/ppapi/resource.cc
@@ -46,11 +46,6 @@ void Resource::LastPluginRefWasDeleted() {
resource_id_ = 0;
}
-#define DEFINE_TYPE_GETTER(RESOURCE) \
- RESOURCE* Resource::As##RESOURCE() { return NULL; }
-FOR_ALL_RESOURCES(DEFINE_TYPE_GETTER)
-#undef DEFINE_TYPE_GETTER
-
} // namespace ppapi
} // namespace webkit
diff --git a/webkit/plugins/ppapi/resource.h b/webkit/plugins/ppapi/resource.h
index 54af4c1..67c4652 100644
--- a/webkit/plugins/ppapi/resource.h
+++ b/webkit/plugins/ppapi/resource.h
@@ -14,30 +14,12 @@
namespace webkit {
namespace ppapi {
-// Support the old way of doing resource casts for those resources that have
-// not been converted to the new system.
-#define FOR_ALL_RESOURCES(F) \
- F(MockResource) \
- F(PPB_Scrollbar_Impl)
-
-// Forward declaration of Resource classes.
-#define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE;
-FOR_ALL_RESOURCES(DECLARE_RESOURCE_CLASS)
-#undef DECLARE_RESOURCE_CLASS
-
class Resource : public base::RefCountedThreadSafe<Resource>,
public ::ppapi::ResourceObjectBase {
public:
explicit Resource(PluginInstance* instance);
virtual ~Resource();
- // Returns NULL if the resource is invalid or is a different type.
- template<typename T>
- static scoped_refptr<T> GetAs(PP_Resource res) {
- scoped_refptr<Resource> resource = ResourceTracker::Get()->GetResource(res);
- return resource ? resource->Cast<T>() : NULL;
- }
-
// 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.
@@ -49,11 +31,6 @@ class Resource : public base::RefCountedThreadSafe<Resource>,
// If you override this, be sure to call the base class' implementation.
virtual void ClearInstance();
- // Cast the resource into a specified type. This will return NULL if the
- // resource does not match the specified type. Specializations of this
- // template call into As* functions.
- template <typename T> T* Cast() { return NULL; }
-
// Returns an resource id of this object. If the object doesn't have a
// resource id, new one is created with plugin refcount of 1. If it does,
// the refcount is incremented. Use this when you need to return a new
@@ -96,14 +73,6 @@ class Resource : public base::RefCountedThreadSafe<Resource>,
virtual void LastPluginRefWasDeleted();
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()
- // function.
- #define DEFINE_TYPE_GETTER(RESOURCE) \
- virtual RESOURCE* As##RESOURCE();
- FOR_ALL_RESOURCES(DEFINE_TYPE_GETTER)
- #undef DEFINE_TYPE_GETTER
-
// If referenced by a plugin, holds the id of this resource object. Do not
// access this member directly, because it is possible that the plugin holds
// no references to the object, and therefore the resource_id_ is zero. Use
@@ -118,15 +87,6 @@ class Resource : public base::RefCountedThreadSafe<Resource>,
DISALLOW_COPY_AND_ASSIGN(Resource);
};
-// Cast() specializations.
-#define DEFINE_RESOURCE_CAST(Type) \
- template <> inline Type* Resource::Cast<Type>() { \
- return As##Type(); \
- }
-
-FOR_ALL_RESOURCES(DEFINE_RESOURCE_CAST)
-#undef DEFINE_RESOURCE_CAST
-
} // namespace ppapi
} // namespace webkit
diff --git a/webkit/plugins/ppapi/resource_creation_impl.cc b/webkit/plugins/ppapi/resource_creation_impl.cc
index 5d72737..9dc2800 100644
--- a/webkit/plugins/ppapi/resource_creation_impl.cc
+++ b/webkit/plugins/ppapi/resource_creation_impl.cc
@@ -21,6 +21,7 @@
#include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
#include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
+#include "webkit/plugins/ppapi/ppb_scrollbar_impl.h"
#include "webkit/plugins/ppapi/ppb_surface_3d_impl.h"
#include "webkit/plugins/ppapi/ppb_transport_impl.h"
#include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
@@ -182,6 +183,11 @@ PP_Resource ResourceCreationImpl::CreateImageData(PP_Instance pp_instance,
return PPB_ImageData_Impl::Create(instance_, format, size, init_to_zero);
}
+PP_Resource ResourceCreationImpl::CreateScrollbar(PP_Instance instance,
+ PP_Bool vertical) {
+ return ReturnResource(new PPB_Scrollbar_Impl(instance_, PP_ToBool(vertical)));
+}
+
PP_Resource ResourceCreationImpl::CreateSurface3D(
PP_Instance instance,
PP_Config3D_Dev config,
diff --git a/webkit/plugins/ppapi/resource_creation_impl.h b/webkit/plugins/ppapi/resource_creation_impl.h
index 9f78f39..e970d57 100644
--- a/webkit/plugins/ppapi/resource_creation_impl.h
+++ b/webkit/plugins/ppapi/resource_creation_impl.h
@@ -70,6 +70,8 @@ class ResourceCreationImpl : public ::ppapi::FunctionGroupBase,
PP_ImageDataFormat format,
const PP_Size& size,
PP_Bool init_to_zero) OVERRIDE;
+ virtual PP_Resource CreateScrollbar(PP_Instance instance,
+ PP_Bool vertical) OVERRIDE;
virtual PP_Resource CreateSurface3D(PP_Instance instance,
PP_Config3D_Dev config,
const int32_t* attrib_list) OVERRIDE;
diff --git a/webkit/tools/test_shell/test_shell.gypi b/webkit/tools/test_shell/test_shell.gypi
index 311b6f4..c96b22e 100644
--- a/webkit/tools/test_shell/test_shell.gypi
+++ b/webkit/tools/test_shell/test_shell.gypi
@@ -439,7 +439,6 @@
'../../plugins/ppapi/callbacks_unittest.cc',
'../../plugins/ppapi/mock_plugin_delegate.cc',
'../../plugins/ppapi/mock_plugin_delegate.h',
- '../../plugins/ppapi/mock_resource.cc',
'../../plugins/ppapi/mock_resource.h',
'../../plugins/ppapi/ppapi_unittest.cc',
'../../plugins/ppapi/ppapi_unittest.h',