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

Side by Side Diff: ppapi/proxy/plugin_resource_callback.h

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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef PPAPI_PROXY_PLUGIN_RESOURCE_CALLBACK_H_
6 #define PPAPI_PROXY_PLUGIN_RESOURCE_CALLBACK_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "ipc/ipc_message.h"
10 #include "ppapi/proxy/dispatch_reply_message.h"
11 #include "ppapi/proxy/resource_message_params.h"
12
13 namespace ppapi {
14 namespace proxy {
15
16 // |PluginResourceCallback| wraps a |base::Callback| on the plugin side which
17 // will be triggered in response to a particular message type being received.
18 // |MsgClass| is the reply message type that the callback will be called with
19 // and |CallbackType| is the type of the |base::Callback| that will be called.
20 class PluginResourceCallbackBase
21 : public base::RefCounted<PluginResourceCallbackBase> {
22 public:
23 virtual void Run(const ResourceMessageReplyParams& params,
24 const IPC::Message& msg) = 0;
yzshen1 2012/10/01 23:41:24 indent to align with the first parameter, please.
raymes 2012/10/02 16:13:36 Done.
25 protected:
26 friend class base::RefCounted<PluginResourceCallbackBase>;
27 virtual ~PluginResourceCallbackBase() {}
28 };
29
30 template<typename MsgClass, typename CallbackType>
31 class PluginResourceCallback : public PluginResourceCallbackBase {
32 public:
33 PluginResourceCallback(const CallbackType& callback) : callback_(callback) {}
yzshen1 2012/10/01 23:41:24 explicit, please.
raymes 2012/10/02 16:13:36 Done.
34
35 virtual void Run(
36 const ResourceMessageReplyParams& reply_params,
37 const IPC::Message& msg) {
yzshen1 2012/10/01 23:41:24 Please use OVERRIDE.
raymes 2012/10/02 16:13:36 Done.
38 DispatchResourceReplyOrDefaultParams<MsgClass>(
39 &callback_, &CallbackType::Run, reply_params, msg);
40 }
41
42 private:
43 friend class base::RefCounted<PluginResourceCallback>;
yzshen1 2012/10/01 23:41:24 Is this necessary?
raymes 2012/10/02 16:13:36 Done.
44 virtual ~PluginResourceCallback() {}
45
46 CallbackType callback_;
47 };
48
49 } // namespace proxy
50 } // namespace ppapi
51
52 #endif // PPAPI_PROXY_PLUGIN_RESOURCE_CALLBACK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698