diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-25 00:12:33 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-25 00:12:33 +0000 |
commit | db36f36531fb10a46634ffc78a08fe17fdd039a1 (patch) | |
tree | 543a913686c08e7e5745bc666ecf0f2fb91f02b1 /ppapi/thunk/ppb_graphics_2d_thunk.cc | |
parent | 848080bffa1d80a18b9e0c11698e2e087a4ac32d (diff) | |
download | chromium_src-db36f36531fb10a46634ffc78a08fe17fdd039a1.zip chromium_src-db36f36531fb10a46634ffc78a08fe17fdd039a1.tar.gz chromium_src-db36f36531fb10a46634ffc78a08fe17fdd039a1.tar.bz2 |
Enhance the PPAPI enter tracking.
The goal here is to be able to add thread checking to the enter functions, which will require more types of failure than just "bad resource".
I folded completion callback force executing into this, which also simplifies the thunks a bit. If we like this method, I'll convert the rest and delete MayForceCallback.
I converted URLLoader and Graphics2D to use this.
Review URL: https://chromiumcodereview.appspot.com/9235003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118951 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/thunk/ppb_graphics_2d_thunk.cc')
-rw-r--r-- | ppapi/thunk/ppb_graphics_2d_thunk.cc | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/ppapi/thunk/ppb_graphics_2d_thunk.cc b/ppapi/thunk/ppb_graphics_2d_thunk.cc index e42d002..edb7ea9 100644 --- a/ppapi/thunk/ppb_graphics_2d_thunk.cc +++ b/ppapi/thunk/ppb_graphics_2d_thunk.cc @@ -16,24 +16,26 @@ namespace thunk { namespace { +typedef EnterResource<PPB_Graphics2D_API> EnterGraphics2D; + PP_Resource Create(PP_Instance instance, const PP_Size* size, PP_Bool is_always_opaque) { - EnterFunction<ResourceCreationAPI> enter(instance, true); + EnterResourceCreation enter(instance); if (enter.failed()) return 0; return enter.functions()->CreateGraphics2D(instance, *size, is_always_opaque); } PP_Bool IsGraphics2D(PP_Resource resource) { - EnterResource<PPB_Graphics2D_API> enter(resource, false); + EnterGraphics2D enter(resource, false); return enter.succeeded() ? PP_TRUE : PP_FALSE; } PP_Bool Describe(PP_Resource graphics_2d, PP_Size* size, PP_Bool* is_always_opaque) { - EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true); + EnterGraphics2D enter(graphics_2d, true); if (enter.failed()) { size->width = 0; size->height = 0; @@ -47,7 +49,7 @@ void PaintImageData(PP_Resource graphics_2d, PP_Resource image_data, const PP_Point* top_left, const PP_Rect* src_rect) { - EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true); + EnterGraphics2D enter(graphics_2d, true); if (enter.failed()) return; enter.object()->PaintImageData(image_data, top_left, src_rect); @@ -56,14 +58,14 @@ void PaintImageData(PP_Resource graphics_2d, void Scroll(PP_Resource graphics_2d, const PP_Rect* clip_rect, const PP_Point* amount) { - EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true); + EnterGraphics2D enter(graphics_2d, true); if (enter.failed()) return; enter.object()->Scroll(clip_rect, amount); } void ReplaceContents(PP_Resource graphics_2d, PP_Resource image_data) { - EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true); + EnterGraphics2D enter(graphics_2d, true); if (enter.failed()) return; enter.object()->ReplaceContents(image_data); @@ -71,11 +73,10 @@ void ReplaceContents(PP_Resource graphics_2d, PP_Resource image_data) { int32_t Flush(PP_Resource graphics_2d, PP_CompletionCallback callback) { - EnterResource<PPB_Graphics2D_API> enter(graphics_2d, true); + EnterGraphics2D enter(graphics_2d, callback, true); if (enter.failed()) - return MayForceCallback(callback, PP_ERROR_BADRESOURCE); - int32_t result = enter.object()->Flush(callback); - return MayForceCallback(callback, result); + return enter.retval(); + return enter.SetResult(enter.object()->Flush(callback)); } const PPB_Graphics2D g_ppb_graphics_2d_thunk = { |