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

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

Issue 7551032: Add a template to handle properly issuing completion callbacks. This fixes (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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_graphics_3d_proxy.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 void PPB_Graphics2D_Proxy::OnMsgReplaceContents( 233 void PPB_Graphics2D_Proxy::OnMsgReplaceContents(
234 const HostResource& graphics_2d, 234 const HostResource& graphics_2d,
235 const HostResource& image_data) { 235 const HostResource& image_data) {
236 EnterHostFromHostResource<PPB_Graphics2D_API> enter(graphics_2d); 236 EnterHostFromHostResource<PPB_Graphics2D_API> enter(graphics_2d);
237 if (enter.failed()) 237 if (enter.failed())
238 return; 238 return;
239 enter.object()->ReplaceContents(image_data.host_resource()); 239 enter.object()->ReplaceContents(image_data.host_resource());
240 } 240 }
241 241
242 void PPB_Graphics2D_Proxy::OnMsgFlush(const HostResource& graphics_2d) { 242 void PPB_Graphics2D_Proxy::OnMsgFlush(const HostResource& graphics_2d) {
243 CompletionCallback callback = callback_factory_.NewOptionalCallback( 243 EnterHostFromHostResourceForceCallback<PPB_Graphics2D_API> enter(
244 graphics_2d, callback_factory_,
244 &PPB_Graphics2D_Proxy::SendFlushACKToPlugin, graphics_2d); 245 &PPB_Graphics2D_Proxy::SendFlushACKToPlugin, graphics_2d);
245 int32_t result = ppb_graphics_2d_target()->Flush( 246 if (enter.failed())
246 graphics_2d.host_resource(), callback.pp_completion_callback()); 247 return;
247 if (result != PP_OK_COMPLETIONPENDING) { 248 enter.SetResult(enter.object()->Flush(enter.callback()));
248 // There was some error, so we won't get a flush callback. We need to now
249 // issue the ACK to the plugin hears about the error. This will also clean
250 // up the data associated with the callback.
251 callback.Run(result);
252 }
253 } 249 }
254 250
255 void PPB_Graphics2D_Proxy::OnMsgFlushACK(const HostResource& host_resource, 251 void PPB_Graphics2D_Proxy::OnMsgFlushACK(const HostResource& host_resource,
256 int32_t pp_error) { 252 int32_t pp_error) {
257 EnterPluginFromHostResource<PPB_Graphics2D_API> enter(host_resource); 253 EnterPluginFromHostResource<PPB_Graphics2D_API> enter(host_resource);
258 if (enter.succeeded()) 254 if (enter.succeeded())
259 static_cast<Graphics2D*>(enter.object())->FlushACK(pp_error); 255 static_cast<Graphics2D*>(enter.object())->FlushACK(pp_error);
260 } 256 }
261 257
262 void PPB_Graphics2D_Proxy::SendFlushACKToPlugin( 258 void PPB_Graphics2D_Proxy::SendFlushACKToPlugin(
263 int32_t result, 259 int32_t result,
264 const HostResource& graphics_2d) { 260 const HostResource& graphics_2d) {
265 dispatcher()->Send(new PpapiMsg_PPBGraphics2D_FlushACK( 261 dispatcher()->Send(new PpapiMsg_PPBGraphics2D_FlushACK(
266 INTERFACE_ID_PPB_GRAPHICS_2D, graphics_2d, result)); 262 INTERFACE_ID_PPB_GRAPHICS_2D, graphics_2d, result));
267 } 263 }
268 264
269 } // namespace proxy 265 } // namespace proxy
270 } // namespace pp 266 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_flash_menu_proxy.cc ('k') | ppapi/proxy/ppb_graphics_3d_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698