| 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/process.h" | 11 #include "base/process.h" |
| 11 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "ppapi/c/pp_rect.h" |
| 12 #include "ppapi/c/pp_instance.h" | 14 #include "ppapi/c/pp_instance.h" |
| 13 #include "ppapi/proxy/dispatcher.h" | 15 #include "ppapi/proxy/dispatcher.h" |
| 14 | 16 |
| 15 class MessageLoop; | 17 class MessageLoop; |
| 16 | 18 |
| 17 namespace base { | 19 namespace base { |
| 18 class WaitableEvent; | 20 class WaitableEvent; |
| 19 } | 21 } |
| 20 | 22 |
| 21 namespace pp { | 23 namespace pp { |
| 22 namespace proxy { | 24 namespace proxy { |
| 23 | 25 |
| 26 // Used to keep track of per-instance data. |
| 27 struct InstanceData { |
| 28 PP_Rect position; |
| 29 }; |
| 30 |
| 24 class PluginDispatcher : public Dispatcher { | 31 class PluginDispatcher : public Dispatcher { |
| 25 public: | 32 public: |
| 26 // Constructor for the plugin side. The init and shutdown functions will be | 33 // Constructor for the plugin side. The init and shutdown functions will be |
| 27 // will be automatically called when requested by the renderer side. The | 34 // will be automatically called when requested by the renderer side. The |
| 28 // module ID will be set upon receipt of the InitializeModule message. | 35 // module ID will be set upon receipt of the InitializeModule message. |
| 29 // | 36 // |
| 30 // You must call Dispatcher::InitWithChannel after the constructor. | 37 // You must call Dispatcher::InitWithChannel after the constructor. |
| 31 PluginDispatcher(base::ProcessHandle remote_process_handle, | 38 PluginDispatcher(base::ProcessHandle remote_process_handle, |
| 32 GetInterfaceFunc get_interface, | 39 GetInterfaceFunc get_interface, |
| 33 InitModuleFunc init_module, | 40 InitModuleFunc init_module, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 51 PluginDispatcher* dispatcher); | 58 PluginDispatcher* dispatcher); |
| 52 static void RemoveForInstance(PP_Instance instance); | 59 static void RemoveForInstance(PP_Instance instance); |
| 53 */ | 60 */ |
| 54 | 61 |
| 55 // Dispatcher overrides. | 62 // Dispatcher overrides. |
| 56 virtual bool IsPlugin() const; | 63 virtual bool IsPlugin() const; |
| 57 | 64 |
| 58 // IPC::Channel::Listener implementation. | 65 // IPC::Channel::Listener implementation. |
| 59 virtual bool OnMessageReceived(const IPC::Message& msg); | 66 virtual bool OnMessageReceived(const IPC::Message& msg); |
| 60 | 67 |
| 68 // Keep track of all active instances to associate data with it, like the |
| 69 // current size. |
| 70 void DidCreateInstance(PP_Instance instance); |
| 71 void DidDestroyInstance(PP_Instance instance); |
| 72 |
| 73 // Gets the data for an existing instance, or NULL if the instance id doesn't |
| 74 // correspond to a known instance. |
| 75 InstanceData* GetInstanceData(PP_Instance instance); |
| 76 |
| 61 private: | 77 private: |
| 62 // IPC message handlers. | 78 // IPC message handlers. |
| 63 void OnMsgInitializeModule(PP_Module pp_module, bool* result); | 79 void OnMsgInitializeModule(PP_Module pp_module, bool* result); |
| 64 void OnMsgShutdown(); | 80 void OnMsgShutdown(); |
| 65 | 81 |
| 66 InitModuleFunc init_module_; | 82 InitModuleFunc init_module_; |
| 67 ShutdownModuleFunc shutdown_module_; | 83 ShutdownModuleFunc shutdown_module_; |
| 68 | 84 |
| 85 typedef base::hash_map<PP_Instance, InstanceData> InstanceDataMap; |
| 86 InstanceDataMap instance_map_; |
| 87 |
| 69 DISALLOW_COPY_AND_ASSIGN(PluginDispatcher); | 88 DISALLOW_COPY_AND_ASSIGN(PluginDispatcher); |
| 70 }; | 89 }; |
| 71 | 90 |
| 72 } // namespace proxy | 91 } // namespace proxy |
| 73 } // namespace pp | 92 } // namespace pp |
| 74 | 93 |
| 75 #endif // PPAPI_PROXY_PLUGIN_DISPATCHER_H_ | 94 #endif // PPAPI_PROXY_PLUGIN_DISPATCHER_H_ |
| OLD | NEW |