OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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_DISPATCHER_H_ |
| 6 #define PPAPI_PROXY_PLUGIN_DISPATCHER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/scoped_ptr.h" |
| 11 #include "ppapi/proxy/callback_tracker.h" |
| 12 #include "ppapi/proxy/dispatcher.h" |
| 13 #include "ppapi/proxy/plugin_resource_tracker.h" |
| 14 #include "ppapi/proxy/plugin_var_tracker.h" |
| 15 |
| 16 class MessageLoop; |
| 17 |
| 18 namespace base { |
| 19 class WaitableEvent; |
| 20 } |
| 21 |
| 22 namespace pp { |
| 23 namespace proxy { |
| 24 |
| 25 class PluginDispatcher : public Dispatcher { |
| 26 public: |
| 27 // Constructor for the plugin side. The init and shutdown functions will be |
| 28 // will be automatically called when requested by the renderer side. The |
| 29 // module ID will be set upon receipt of the InitializeModule message. |
| 30 // |
| 31 // You must call Dispatcher::InitWithChannel after the constructor. |
| 32 PluginDispatcher(GetInterfaceFunc get_interface, |
| 33 InitModuleFunc init_module, |
| 34 ShutdownModuleFunc shutdown_module); |
| 35 ~PluginDispatcher(); |
| 36 |
| 37 // The plugin maintains a global Dispatcher pointer. There is only one since |
| 38 // there is only one connection to the browser. Don't call this on the |
| 39 // browser side, see GetForInstnace. |
| 40 static PluginDispatcher* Get(); |
| 41 static void SetGlobal(PluginDispatcher* dispatcher); |
| 42 |
| 43 // Dispatcher overrides. |
| 44 virtual bool IsPlugin() const { return true; } |
| 45 |
| 46 // IPC::Channel::Listener implementation. |
| 47 virtual void OnMessageReceived(const IPC::Message& msg); |
| 48 |
| 49 // Returns the resource tracker for the plugin. In the browser process this |
| 50 // will return NULL. |
| 51 PluginResourceTracker* plugin_resource_tracker() { |
| 52 return plugin_resource_tracker_.get(); |
| 53 } |
| 54 |
| 55 // Returns the var tracker for the plugin. In the browser process this |
| 56 // will return NULL. |
| 57 PluginVarTracker* plugin_var_tracker() { |
| 58 return plugin_var_tracker_.get(); |
| 59 } |
| 60 |
| 61 private: |
| 62 void OnInitializeModule(PP_Module pp_module, bool* result); |
| 63 |
| 64 InitModuleFunc init_module_; |
| 65 ShutdownModuleFunc shutdown_module_; |
| 66 |
| 67 scoped_ptr<PluginResourceTracker> plugin_resource_tracker_; |
| 68 scoped_ptr<PluginVarTracker> plugin_var_tracker_; |
| 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(PluginDispatcher); |
| 71 }; |
| 72 |
| 73 } // namespace proxy |
| 74 } // namespace pp |
| 75 |
| 76 #endif // PPAPI_PROXY_PLUGIN_DISPATCHER_H_ |
OLD | NEW |