Chromium Code Reviews| OLD | NEW |
|---|---|
| (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; | |
| 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 explicit PluginResourceCallback( | |
| 34 const CallbackType& callback) : callback_(callback) {} | |
|
brettw
2012/10/02 19:40:00
The : should go on the next line when not everythi
raymes
2012/10/03 21:43:50
Done.
| |
| 35 | |
| 36 virtual void Run( | |
| 37 const ResourceMessageReplyParams& reply_params, | |
| 38 const IPC::Message& msg) OVERRIDE { | |
| 39 DispatchResourceReplyOrDefaultParams<MsgClass>( | |
| 40 &callback_, &CallbackType::Run, reply_params, msg); | |
| 41 } | |
| 42 | |
| 43 private: | |
| 44 virtual ~PluginResourceCallback() {} | |
| 45 | |
| 46 CallbackType callback_; | |
| 47 }; | |
| 48 | |
| 49 } // namespace proxy | |
| 50 } // namespace ppapi | |
| 51 | |
| 52 #endif // PPAPI_PROXY_PLUGIN_RESOURCE_CALLBACK_H_ | |
| OLD | NEW |