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

Side by Side Diff: ppapi/proxy/ppb_graphics_2d_proxy.cc

Issue 10081020: PPAPI: Make blocking completion callbacks work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: export AssertLockHeld Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/ppb_flash_menu_proxy.cc ('k') | ppapi/proxy/ppb_instance_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/proxy/ppb_graphics_2d_proxy.h" 5 #include "ppapi/proxy/ppb_graphics_2d_proxy.h"
6 6
7 #include <string.h> // For memset. 7 #include <string.h> // For memset.
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 25 matching lines...) Expand all
36 virtual PPB_Graphics2D_API* AsPPB_Graphics2D_API(); 36 virtual PPB_Graphics2D_API* AsPPB_Graphics2D_API();
37 37
38 // PPB_Graphics_2D_API. 38 // PPB_Graphics_2D_API.
39 PP_Bool Describe(PP_Size* size, PP_Bool* is_always_opaque); 39 PP_Bool Describe(PP_Size* size, PP_Bool* is_always_opaque);
40 void PaintImageData(PP_Resource image_data, 40 void PaintImageData(PP_Resource image_data,
41 const PP_Point* top_left, 41 const PP_Point* top_left,
42 const PP_Rect* src_rect); 42 const PP_Rect* src_rect);
43 void Scroll(const PP_Rect* clip_rect, 43 void Scroll(const PP_Rect* clip_rect,
44 const PP_Point* amount); 44 const PP_Point* amount);
45 void ReplaceContents(PP_Resource image_data); 45 void ReplaceContents(PP_Resource image_data);
46 int32_t Flush(PP_CompletionCallback callback); 46 int32_t Flush(scoped_refptr<TrackedCallback> callback);
47 47
48 // Notification that the host has sent an ACK for a pending Flush. 48 // Notification that the host has sent an ACK for a pending Flush.
49 void FlushACK(int32_t result_code); 49 void FlushACK(int32_t result_code);
50 50
51 private: 51 private:
52 PluginDispatcher* GetDispatcher() const { 52 PluginDispatcher* GetDispatcher() const {
53 return PluginDispatcher::GetForResource(this); 53 return PluginDispatcher::GetForResource(this);
54 } 54 }
55 55
56 static const ApiID kApiID = API_ID_PPB_GRAPHICS_2D; 56 static const ApiID kApiID = API_ID_PPB_GRAPHICS_2D;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 if (!image_object || pp_instance() != image_object->pp_instance()) { 119 if (!image_object || pp_instance() != image_object->pp_instance()) {
120 Log(PP_LOGLEVEL_ERROR, 120 Log(PP_LOGLEVEL_ERROR,
121 "PPB_Graphics2D.PaintImageData: Bad image resource."); 121 "PPB_Graphics2D.PaintImageData: Bad image resource.");
122 return; 122 return;
123 } 123 }
124 124
125 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_ReplaceContents( 125 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_ReplaceContents(
126 kApiID, host_resource(), image_object->host_resource())); 126 kApiID, host_resource(), image_object->host_resource()));
127 } 127 }
128 128
129 int32_t Graphics2D::Flush(PP_CompletionCallback callback) { 129 int32_t Graphics2D::Flush(scoped_refptr<TrackedCallback> callback) {
130 // For now, disallow blocking calls. We'll need to add support for other
131 // threads to this later.
132 if (!callback.func)
133 return PP_ERROR_BLOCKS_MAIN_THREAD;
134
135 if (TrackedCallback::IsPending(current_flush_callback_)) 130 if (TrackedCallback::IsPending(current_flush_callback_))
136 return PP_ERROR_INPROGRESS; // Can't have >1 flush pending. 131 return PP_ERROR_INPROGRESS; // Can't have >1 flush pending.
137 current_flush_callback_ = new TrackedCallback(this, callback); 132 current_flush_callback_ = callback;
138 133
139 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_Flush(kApiID, 134 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_Flush(kApiID,
140 host_resource())); 135 host_resource()));
141 return PP_OK_COMPLETIONPENDING; 136 return PP_OK_COMPLETIONPENDING;
142 } 137 }
143 138
144 void Graphics2D::FlushACK(int32_t result_code) { 139 void Graphics2D::FlushACK(int32_t result_code) {
145 TrackedCallback::ClearAndRun(&current_flush_callback_, result_code); 140 TrackedCallback::ClearAndRun(&current_flush_callback_, result_code);
146 } 141 }
147 142
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 249
255 void PPB_Graphics2D_Proxy::SendFlushACKToPlugin( 250 void PPB_Graphics2D_Proxy::SendFlushACKToPlugin(
256 int32_t result, 251 int32_t result,
257 const HostResource& graphics_2d) { 252 const HostResource& graphics_2d) {
258 dispatcher()->Send(new PpapiMsg_PPBGraphics2D_FlushACK(kApiID, graphics_2d, 253 dispatcher()->Send(new PpapiMsg_PPBGraphics2D_FlushACK(kApiID, graphics_2d,
259 result)); 254 result));
260 } 255 }
261 256
262 } // namespace proxy 257 } // namespace proxy
263 } // namespace ppapi 258 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_flash_menu_proxy.cc ('k') | ppapi/proxy/ppb_instance_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698