| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PPAPI_PROXY_PLUGIN_DISPATCHER_H_ | 5 #ifndef PPAPI_PROXY_PLUGIN_DISPATCHER_H_ |
| 6 #define PPAPI_PROXY_PLUGIN_DISPATCHER_H_ | 6 #define PPAPI_PROXY_PLUGIN_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // will be automatically called when requested by the renderer side. The | 34 // will be automatically called when requested by the renderer side. The |
| 35 // module ID will be set upon receipt of the InitializeModule message. | 35 // module ID will be set upon receipt of the InitializeModule message. |
| 36 // | 36 // |
| 37 // You must call Dispatcher::InitWithChannel after the constructor. | 37 // You must call Dispatcher::InitWithChannel after the constructor. |
| 38 PluginDispatcher(base::ProcessHandle remote_process_handle, | 38 PluginDispatcher(base::ProcessHandle remote_process_handle, |
| 39 GetInterfaceFunc get_interface, | 39 GetInterfaceFunc get_interface, |
| 40 InitModuleFunc init_module, | 40 InitModuleFunc init_module, |
| 41 ShutdownModuleFunc shutdown_module); | 41 ShutdownModuleFunc shutdown_module); |
| 42 ~PluginDispatcher(); | 42 ~PluginDispatcher(); |
| 43 | 43 |
| 44 // Sets/gets the global dispatcher pointer. New code should use the | |
| 45 // GetForInstance version below, this is currently here as a stopgap while | |
| 46 // the transition is being made. | |
| 47 // | |
| 48 // TODO(brettw) remove this. | |
| 49 static PluginDispatcher* Get(); | |
| 50 static void SetGlobal(PluginDispatcher* dispatcher); | |
| 51 | |
| 52 // The plugin side maintains a mapping from PP_Instance to Dispatcher so | 44 // The plugin side maintains a mapping from PP_Instance to Dispatcher so |
| 53 // that we can send the messages to the right channel if there are multiple | 45 // that we can send the messages to the right channel if there are multiple |
| 54 // renderers sharing the same plugin. | 46 // renderers sharing the same plugin. |
| 55 static PluginDispatcher* GetForInstance(PP_Instance instance); | 47 static PluginDispatcher* GetForInstance(PP_Instance instance); |
| 56 /* TODO(brettw) enable this when Get() is removed. | |
| 57 static void SetForInstance(PP_Instance instance, | 48 static void SetForInstance(PP_Instance instance, |
| 58 PluginDispatcher* dispatcher); | 49 PluginDispatcher* dispatcher); |
| 59 static void RemoveForInstance(PP_Instance instance); | 50 static void RemoveForInstance(PP_Instance instance); |
| 60 */ | |
| 61 | 51 |
| 62 // Dispatcher overrides. | 52 // Dispatcher overrides. |
| 63 virtual bool IsPlugin() const; | 53 virtual bool IsPlugin() const; |
| 64 | 54 |
| 65 // IPC::Channel::Listener implementation. | 55 // IPC::Channel::Listener implementation. |
| 66 virtual bool OnMessageReceived(const IPC::Message& msg); | 56 virtual bool OnMessageReceived(const IPC::Message& msg); |
| 67 | 57 |
| 68 // Keep track of all active instances to associate data with it, like the | 58 // Keep track of all active instances to associate data with it, like the |
| 69 // current size. | 59 // current size. |
| 70 void DidCreateInstance(PP_Instance instance); | 60 void DidCreateInstance(PP_Instance instance); |
| 71 void DidDestroyInstance(PP_Instance instance); | 61 void DidDestroyInstance(PP_Instance instance); |
| 72 | 62 |
| 73 // Gets the data for an existing instance, or NULL if the instance id doesn't | 63 // Gets the data for an existing instance, or NULL if the instance id doesn't |
| 74 // correspond to a known instance. | 64 // correspond to a known instance. |
| 75 InstanceData* GetInstanceData(PP_Instance instance); | 65 InstanceData* GetInstanceData(PP_Instance instance); |
| 76 | 66 |
| 77 private: | 67 private: |
| 68 friend class PluginDispatcherTest; |
| 69 |
| 78 // IPC message handlers. | 70 // IPC message handlers. |
| 79 void OnMsgInitializeModule(PP_Module pp_module, bool* result); | 71 void OnMsgInitializeModule(PP_Module pp_module, bool* result); |
| 80 void OnMsgShutdown(); | 72 void OnMsgShutdown(); |
| 73 void OnMsgSupportsInterface(const std::string& interface_name, bool* result); |
| 81 | 74 |
| 82 InitModuleFunc init_module_; | 75 InitModuleFunc init_module_; |
| 83 ShutdownModuleFunc shutdown_module_; | 76 ShutdownModuleFunc shutdown_module_; |
| 84 | 77 |
| 78 // All target proxies currently created. These are ones that receive |
| 79 // messages. |
| 80 scoped_ptr<InterfaceProxy> target_proxies_[INTERFACE_ID_COUNT]; |
| 81 |
| 85 typedef base::hash_map<PP_Instance, InstanceData> InstanceDataMap; | 82 typedef base::hash_map<PP_Instance, InstanceData> InstanceDataMap; |
| 86 InstanceDataMap instance_map_; | 83 InstanceDataMap instance_map_; |
| 87 | 84 |
| 88 DISALLOW_COPY_AND_ASSIGN(PluginDispatcher); | 85 DISALLOW_COPY_AND_ASSIGN(PluginDispatcher); |
| 89 }; | 86 }; |
| 90 | 87 |
| 91 } // namespace proxy | 88 } // namespace proxy |
| 92 } // namespace pp | 89 } // namespace pp |
| 93 | 90 |
| 94 #endif // PPAPI_PROXY_PLUGIN_DISPATCHER_H_ | 91 #endif // PPAPI_PROXY_PLUGIN_DISPATCHER_H_ |
| OLD | NEW |