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

Unified Diff: ppapi/proxy/plugin_resource.cc

Issue 11022005: Converted PluginResource reply message handling to use base::Callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 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
« no previous file with comments | « ppapi/proxy/plugin_resource.h ('k') | ppapi/proxy/plugin_resource_callback.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/plugin_resource.cc
diff --git a/ppapi/proxy/plugin_resource.cc b/ppapi/proxy/plugin_resource.cc
index f86bc3db9f4fce0e247fa6318f287d5d7f7405e9..1cfc3f10c6e695d3b7f0384fce7b654827b43d93 100644
--- a/ppapi/proxy/plugin_resource.cc
+++ b/ppapi/proxy/plugin_resource.cc
@@ -30,6 +30,20 @@ PluginResource::~PluginResource() {
}
}
+void PluginResource::OnReplyReceived(
+ const proxy::ResourceMessageReplyParams& params,
+ const IPC::Message& msg) {
+ // Grab the callback for the reply sequence number and run it with |msg|.
+ CallbackMap::iterator it = callbacks_.find(params.sequence());
+ if (it == callbacks_.end()) {
+ DCHECK(false) << "Callback does not exist for an expected sequence number.";
+ } else {
+ scoped_refptr<PluginResourceCallbackBase> callback = it->second;
+ callbacks_.erase(it);
+ callback->Run(params, msg);
+ }
+}
+
void PluginResource::SendCreateToBrowser(const IPC::Message& msg) {
DCHECK(!sent_create_to_browser_);
sent_create_to_browser_ = true;
@@ -51,29 +65,20 @@ void PluginResource::SendCreateToRenderer(const IPC::Message& msg) {
void PluginResource::PostToBrowser(const IPC::Message& msg) {
ResourceMessageCallParams params(pp_resource(),
next_sequence_number_++);
- connection_.browser_sender->Send(new PpapiHostMsg_ResourceCall(params, msg));
+ SendResourceCall(connection_.browser_sender, params, msg);
}
void PluginResource::PostToRenderer(const IPC::Message& msg) {
ResourceMessageCallParams params(pp_resource(),
next_sequence_number_++);
- connection_.renderer_sender->Send(new PpapiHostMsg_ResourceCall(params, msg));
+ SendResourceCall(connection_.renderer_sender, params, msg);
}
-int32_t PluginResource::CallBrowser(const IPC::Message& msg) {
- ResourceMessageCallParams params(pp_resource(),
- next_sequence_number_++);
- params.set_has_callback();
- connection_.browser_sender->Send(new PpapiHostMsg_ResourceCall(params, msg));
- return params.sequence();
-}
-
-int32_t PluginResource::CallRenderer(const IPC::Message& msg) {
- ResourceMessageCallParams params(pp_resource(),
- next_sequence_number_++);
- params.set_has_callback();
- connection_.renderer_sender->Send(new PpapiHostMsg_ResourceCall(params, msg));
- return params.sequence();
+bool PluginResource::SendResourceCall(
+ IPC::Sender* sender,
+ const ResourceMessageCallParams& call_params,
+ const IPC::Message& nested_msg) {
+ return sender->Send(new PpapiHostMsg_ResourceCall(call_params, nested_msg));
}
int32_t PluginResource::CallBrowserSync(const IPC::Message& msg,
« no previous file with comments | « ppapi/proxy/plugin_resource.h ('k') | ppapi/proxy/plugin_resource_callback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698