| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 WEBKIT_PLUGINS_PPAPI_PLUGIN_MODULE_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PLUGIN_MODULE_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_PLUGIN_MODULE_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PLUGIN_MODULE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 struct EntryPoints { | 55 struct EntryPoints { |
| 56 // This structure is POD, with the constructor initializing to NULL. | 56 // This structure is POD, with the constructor initializing to NULL. |
| 57 WEBKIT_PLUGINS_EXPORT EntryPoints(); | 57 WEBKIT_PLUGINS_EXPORT EntryPoints(); |
| 58 | 58 |
| 59 GetInterfaceFunc get_interface; | 59 GetInterfaceFunc get_interface; |
| 60 PPP_InitializeModuleFunc initialize_module; | 60 PPP_InitializeModuleFunc initialize_module; |
| 61 PPP_ShutdownModuleFunc shutdown_module; // Optional, may be NULL. | 61 PPP_ShutdownModuleFunc shutdown_module; // Optional, may be NULL. |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 // Allows the embedder to associate a class with this module. This is opaque |
| 65 // from the PluginModule's perspective (see Set/GetEmbedderState below) but |
| 66 // the module is in charge of deleting the class. |
| 67 class EmbedderState { |
| 68 public: |
| 69 virtual ~EmbedderState() {} |
| 70 }; |
| 71 |
| 64 typedef std::set<PluginInstance*> PluginInstanceSet; | 72 typedef std::set<PluginInstance*> PluginInstanceSet; |
| 65 | 73 |
| 66 // You must call one of the Init functions after the constructor to create a | 74 // You must call one of the Init functions after the constructor to create a |
| 67 // module of the type you desire. | 75 // module of the type you desire. |
| 68 // | 76 // |
| 69 // The module lifetime delegate is a non-owning pointer that must outlive | 77 // The module lifetime delegate is a non-owning pointer that must outlive |
| 70 // all plugin modules. In practice it will be a global singleton that | 78 // all plugin modules. In practice it will be a global singleton that |
| 71 // tracks which modules are alive. | 79 // tracks which modules are alive. |
| 72 PluginModule(const std::string& name, | 80 PluginModule(const std::string& name, |
| 73 const FilePath& path, | 81 const FilePath& path, |
| 74 PluginDelegate::ModuleLifetime* lifetime_delegate, | 82 PluginDelegate::ModuleLifetime* lifetime_delegate, |
| 75 const ::ppapi::PpapiPermissions& perms); | 83 const ::ppapi::PpapiPermissions& perms); |
| 76 | 84 |
| 77 ~PluginModule(); | 85 ~PluginModule(); |
| 78 | 86 |
| 87 // Sets the given class as being associated with this module. It will be |
| 88 // deleted when the module is destroyed. You can only set it once, subsequent |
| 89 // sets will assert. |
| 90 // |
| 91 // See EmbedderState above for more. |
| 92 void SetEmbedderState(scoped_ptr<EmbedderState> state); |
| 93 EmbedderState* GetEmbedderState(); |
| 94 |
| 79 // Initializes this module as an internal plugin with the given entrypoints. | 95 // Initializes this module as an internal plugin with the given entrypoints. |
| 80 // This is used for "plugins" compiled into Chrome. Returns true on success. | 96 // This is used for "plugins" compiled into Chrome. Returns true on success. |
| 81 // False means that the plugin can not be used. | 97 // False means that the plugin can not be used. |
| 82 bool InitAsInternalPlugin(const EntryPoints& entry_points); | 98 bool InitAsInternalPlugin(const EntryPoints& entry_points); |
| 83 | 99 |
| 84 // Initializes this module using the given library path as the plugin. | 100 // Initializes this module using the given library path as the plugin. |
| 85 // Returns true on success. False means that the plugin can not be used. | 101 // Returns true on success. False means that the plugin can not be used. |
| 86 bool InitAsLibrary(const FilePath& path); | 102 bool InitAsLibrary(const FilePath& path); |
| 87 | 103 |
| 88 // Initializes this module for the given out of process proxy. This takes | 104 // Initializes this module for the given out of process proxy. This takes |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 172 |
| 157 private: | 173 private: |
| 158 // Calls the InitializeModule entrypoint. The entrypoint must have been | 174 // Calls the InitializeModule entrypoint. The entrypoint must have been |
| 159 // set and the plugin must not be out of process (we don't maintain | 175 // set and the plugin must not be out of process (we don't maintain |
| 160 // entrypoints in that case). | 176 // entrypoints in that case). |
| 161 bool InitializeModule(const EntryPoints& entry_points); | 177 bool InitializeModule(const EntryPoints& entry_points); |
| 162 | 178 |
| 163 // Note: This may be null. | 179 // Note: This may be null. |
| 164 PluginDelegate::ModuleLifetime* lifetime_delegate_; | 180 PluginDelegate::ModuleLifetime* lifetime_delegate_; |
| 165 | 181 |
| 182 // See EmbedderState above. |
| 183 scoped_ptr<EmbedderState> embedder_state_; |
| 184 |
| 166 // Tracker for completion callbacks, used mainly to ensure that all callbacks | 185 // Tracker for completion callbacks, used mainly to ensure that all callbacks |
| 167 // are properly aborted on module shutdown. | 186 // are properly aborted on module shutdown. |
| 168 scoped_refptr< ::ppapi::CallbackTracker> callback_tracker_; | 187 scoped_refptr< ::ppapi::CallbackTracker> callback_tracker_; |
| 169 | 188 |
| 170 PP_Module pp_module_; | 189 PP_Module pp_module_; |
| 171 | 190 |
| 172 // True when we're running in the destructor. This allows us to write some | 191 // True when we're running in the destructor. This allows us to write some |
| 173 // assertions. | 192 // assertions. |
| 174 bool is_in_destructor_; | 193 bool is_in_destructor_; |
| 175 | 194 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 229 |
| 211 bool nacl_ipc_proxy_; | 230 bool nacl_ipc_proxy_; |
| 212 | 231 |
| 213 DISALLOW_COPY_AND_ASSIGN(PluginModule); | 232 DISALLOW_COPY_AND_ASSIGN(PluginModule); |
| 214 }; | 233 }; |
| 215 | 234 |
| 216 } // namespace ppapi | 235 } // namespace ppapi |
| 217 } // namespace webkit | 236 } // namespace webkit |
| 218 | 237 |
| 219 #endif // WEBKIT_PLUGINS_PPAPI_PLUGIN_MODULE_H_ | 238 #endif // WEBKIT_PLUGINS_PPAPI_PLUGIN_MODULE_H_ |
| OLD | NEW |