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

Unified Diff: ppapi/proxy/ppb_broker_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, 5 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
Index: ppapi/proxy/ppb_broker_proxy.cc
===================================================================
--- ppapi/proxy/ppb_broker_proxy.cc (revision 94913)
+++ ppapi/proxy/ppb_broker_proxy.cc (working copy)
@@ -14,6 +14,8 @@
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/thunk.h"
+using ppapi::thunk::PPB_Broker_API;
cpu_(ooo_6.6-7.5) 2011/08/03 00:57:21 wouldn't it make sense to use this using in the ot
brettw 2011/08/03 17:36:29 I'm not sure what you're saying here, I did the us
+
namespace pp {
namespace proxy {
@@ -46,14 +48,13 @@
} // namespace
-class Broker : public ppapi::thunk::PPB_Broker_API,
- public PluginResource {
+class Broker : public PPB_Broker_API, public PluginResource {
public:
explicit Broker(const HostResource& resource);
virtual ~Broker();
// ResourceObjectBase overries.
- virtual ppapi::thunk::PPB_Broker_API* AsPPB_Broker_API() OVERRIDE;
+ virtual PPB_Broker_API* AsPPB_Broker_API() OVERRIDE;
// PPB_Broker_API implementation.
virtual int32_t Connect(PP_CompletionCallback connect_callback) OVERRIDE;
@@ -96,7 +97,7 @@
socket_handle_ = base::kInvalidPlatformFileValue;
}
-ppapi::thunk::PPB_Broker_API* Broker::AsPPB_Broker_API() {
+PPB_Broker_API* Broker::AsPPB_Broker_API() {
return this;
}
@@ -204,14 +205,11 @@
}
void PPB_Broker_Proxy::OnMsgConnect(const HostResource& broker) {
- CompletionCallback callback = callback_factory_.NewOptionalCallback(
+ EnterHostFromHostResourceForceCallback<PPB_Broker_API> enter(
+ broker, callback_factory_,
&PPB_Broker_Proxy::ConnectCompleteInHost, broker);
-
- int32_t result = ppb_broker_target()->Connect(
- broker.host_resource(),
- callback.pp_completion_callback());
- if (result != PP_OK_COMPLETIONPENDING)
- callback.Run(result);
+ if (enter.succeeded())
+ enter.SetResult(enter.object()->Connect(enter.callback()));
}
// Called in the plugin to handle the connect callback.
@@ -225,7 +223,7 @@
DCHECK(result == PP_OK ||
socket_handle == IPC::InvalidPlatformFileForTransit());
- EnterPluginFromHostResource<ppapi::thunk::PPB_Broker_API> enter(resource);
+ EnterPluginFromHostResource<PPB_Broker_API> enter(resource);
if (enter.failed()) {
// As in Broker::ConnectComplete, we need to close the resource on error.
base::SyncSocket temp_socket(

Powered by Google App Engine
This is Rietveld 408576698