Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(965)

Unified Diff: webkit/plugins/ppapi/ppb_widget_impl.cc

Issue 7206016: Convert most remaining resources to use the API/thunk system. The significant (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/plugins/ppapi/ppb_widget_impl.h ('k') | webkit/plugins/ppapi/resource.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppb_widget_impl.cc
===================================================================
--- webkit/plugins/ppapi/ppb_widget_impl.cc (revision 89672)
+++ webkit/plugins/ppapi/ppb_widget_impl.cc (working copy)
@@ -4,70 +4,19 @@
#include "webkit/plugins/ppapi/ppb_widget_impl.h"
-#include "base/logging.h"
-#include "ppapi/c/dev/ppb_widget_dev.h"
#include "ppapi/c/dev/ppp_widget_dev.h"
-#include "ppapi/c/pp_completion_callback.h"
-#include "ppapi/c/pp_errors.h"
-#include "webkit/plugins/ppapi/common.h"
+#include "ppapi/thunk/enter.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/plugin_module.h"
+using ppapi::thunk::EnterResourceNoLock;
+using ppapi::thunk::PPB_ImageData_API;
+using ppapi::thunk::PPB_Widget_API;
+
namespace webkit {
namespace ppapi {
-namespace {
-
-PP_Bool IsWidget(PP_Resource resource) {
- return BoolToPPBool(!!Resource::GetAs<PPB_Widget_Impl>(resource));
-}
-
-PP_Bool Paint(PP_Resource resource,
- const PP_Rect* rect,
- PP_Resource image_id) {
- scoped_refptr<PPB_Widget_Impl> widget(
- Resource::GetAs<PPB_Widget_Impl>(resource));
- if (!widget)
- return PP_FALSE;
-
- scoped_refptr<PPB_ImageData_Impl> image(
- Resource::GetAs<PPB_ImageData_Impl>(image_id));
- if (!image)
- return PP_FALSE;
-
- return BoolToPPBool(widget->Paint(rect, image));
-}
-
-PP_Bool HandleEvent(PP_Resource resource, const PP_InputEvent* event) {
- scoped_refptr<PPB_Widget_Impl> widget(
- Resource::GetAs<PPB_Widget_Impl>(resource));
- return BoolToPPBool(widget && widget->HandleEvent(event));
-}
-
-PP_Bool GetLocation(PP_Resource resource, PP_Rect* location) {
- scoped_refptr<PPB_Widget_Impl> widget(
- Resource::GetAs<PPB_Widget_Impl>(resource));
- return BoolToPPBool(widget && widget->GetLocation(location));
-}
-
-void SetLocation(PP_Resource resource, const PP_Rect* location) {
- scoped_refptr<PPB_Widget_Impl> widget(
- Resource::GetAs<PPB_Widget_Impl>(resource));
- if (widget)
- widget->SetLocation(location);
-}
-
-const PPB_Widget_Dev ppb_widget = {
- &IsWidget,
- &Paint,
- &HandleEvent,
- &GetLocation,
- &SetLocation,
-};
-
-} // namespace
-
PPB_Widget_Impl::PPB_Widget_Impl(PluginInstance* instance)
: Resource(instance) {
}
@@ -75,18 +24,22 @@
PPB_Widget_Impl::~PPB_Widget_Impl() {
}
-// static
-const PPB_Widget_Dev* PPB_Widget_Impl::GetInterface() {
- return &ppb_widget;
+PPB_Widget_API* PPB_Widget_Impl::AsPPB_Widget_API() {
+ return this;
}
-PPB_Widget_Impl* PPB_Widget_Impl::AsPPB_Widget_Impl() {
- return this;
+PP_Bool PPB_Widget_Impl::Paint(const PP_Rect* rect, PP_Resource image_id) {
+ EnterResourceNoLock<PPB_ImageData_API> enter(image_id, true);
+ if (enter.failed())
+ return PP_FALSE;
+ return PaintInternal(gfx::Rect(rect->point.x, rect->point.y,
+ rect->size.width, rect->size.height),
+ static_cast<PPB_ImageData_Impl*>(enter.object()));
}
-bool PPB_Widget_Impl::GetLocation(PP_Rect* location) {
+PP_Bool PPB_Widget_Impl::GetLocation(PP_Rect* location) {
*location = location_;
- return true;
+ return PP_TRUE;
}
void PPB_Widget_Impl::SetLocation(const PP_Rect* location) {
« no previous file with comments | « webkit/plugins/ppapi/ppb_widget_impl.h ('k') | webkit/plugins/ppapi/resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698