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

Side by Side Diff: ppapi/proxy/ppb_surface_3d_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
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_surface_3d_proxy.h" 5 #include "ppapi/proxy/ppb_surface_3d_proxy.h"
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 #include "ppapi/c/pp_errors.h" 8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/c/pp_resource.h" 9 #include "ppapi/c/pp_resource.h"
10 #include "ppapi/c/dev/ppb_surface_3d_dev.h" 10 #include "ppapi/c/dev/ppb_surface_3d_dev.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true); 171 EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true);
172 if (enter.succeeded()) { 172 if (enter.succeeded()) {
173 result->SetHostResource( 173 result->SetHostResource(
174 instance, 174 instance,
175 enter.functions()->CreateSurface3D(instance, config, &attribs.front())); 175 enter.functions()->CreateSurface3D(instance, config, &attribs.front()));
176 } 176 }
177 } 177 }
178 178
179 void PPB_Surface3D_Proxy::OnMsgSwapBuffers(const HostResource& surface_3d) { 179 void PPB_Surface3D_Proxy::OnMsgSwapBuffers(const HostResource& surface_3d) {
180 CompletionCallback callback = callback_factory_.NewOptionalCallback( 180 EnterHostFromHostResourceForceCallback<PPB_Surface3D_API> enter(
181 surface_3d, callback_factory_,
181 &PPB_Surface3D_Proxy::SendSwapBuffersACKToPlugin, surface_3d); 182 &PPB_Surface3D_Proxy::SendSwapBuffersACKToPlugin, surface_3d);
182
183 EnterHostFromHostResource<PPB_Surface3D_API> enter(surface_3d);
184 int32_t result = PP_ERROR_BADRESOURCE;
185 if (enter.succeeded()) 183 if (enter.succeeded())
186 result = enter.object()->SwapBuffers(callback.pp_completion_callback()); 184 enter.SetResult(enter.object()->SwapBuffers(enter.callback()));
187 if (result != PP_OK_COMPLETIONPENDING) {
188 // There was some error, so we won't get a flush callback. We need to now
189 // issue the ACK to the plugin hears about the error. This will also clean
190 // up the data associated with the callback.
191 callback.Run(result);
192 }
193 } 185 }
194 186
195 void PPB_Surface3D_Proxy::OnMsgSwapBuffersACK(const HostResource& resource, 187 void PPB_Surface3D_Proxy::OnMsgSwapBuffersACK(const HostResource& resource,
196 int32_t pp_error) { 188 int32_t pp_error) {
197 EnterPluginFromHostResource<PPB_Surface3D_API> enter(resource); 189 EnterPluginFromHostResource<PPB_Surface3D_API> enter(resource);
198 if (enter.succeeded()) 190 if (enter.succeeded())
199 static_cast<Surface3D*>(enter.object())->SwapBuffersACK(pp_error); 191 static_cast<Surface3D*>(enter.object())->SwapBuffersACK(pp_error);
200 } 192 }
201 193
202 void PPB_Surface3D_Proxy::SendSwapBuffersACKToPlugin( 194 void PPB_Surface3D_Proxy::SendSwapBuffersACKToPlugin(
203 int32_t result, 195 int32_t result,
204 const HostResource& surface_3d) { 196 const HostResource& surface_3d) {
205 dispatcher()->Send(new PpapiMsg_PPBSurface3D_SwapBuffersACK( 197 dispatcher()->Send(new PpapiMsg_PPBSurface3D_SwapBuffersACK(
206 INTERFACE_ID_PPB_SURFACE_3D, surface_3d, result)); 198 INTERFACE_ID_PPB_SURFACE_3D, surface_3d, result));
207 } 199 }
208 200
209 } // namespace proxy 201 } // namespace proxy
210 } // namespace pp 202 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698