| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 } // namespace ppapi | 42 } // namespace ppapi |
| 43 | 43 |
| 44 namespace WebKit { | 44 namespace WebKit { |
| 45 class WebPluginContainer; | 45 class WebPluginContainer; |
| 46 } // namespace WebKit | 46 } // namespace WebKit |
| 47 | 47 |
| 48 namespace webkit { | 48 namespace webkit { |
| 49 namespace ppapi { | 49 namespace ppapi { |
| 50 | 50 |
| 51 class PluginDelegate; | 51 class PluginDelegate; |
| 52 class PluginInstance; | 52 class PluginInstanceImpl; |
| 53 | 53 |
| 54 // Represents one plugin library loaded into one renderer. This library may | 54 // Represents one plugin library loaded into one renderer. This library may |
| 55 // have multiple instances. | 55 // have multiple instances. |
| 56 // | 56 // |
| 57 // Note: to get from a PP_Instance to a PluginInstance*, use the | 57 // Note: to get from a PP_Instance to a PluginInstance*, use the |
| 58 // ResourceTracker. | 58 // ResourceTracker. |
| 59 class WEBKIT_PLUGINS_EXPORT PluginModule : | 59 class WEBKIT_PLUGINS_EXPORT PluginModule : |
| 60 public base::RefCounted<PluginModule>, | 60 public base::RefCounted<PluginModule>, |
| 61 public base::SupportsWeakPtr<PluginModule> { | 61 public base::SupportsWeakPtr<PluginModule> { |
| 62 public: | 62 public: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 // Allows the embedder to associate a class with this module. This is opaque | 76 // Allows the embedder to associate a class with this module. This is opaque |
| 77 // from the PluginModule's perspective (see Set/GetEmbedderState below) but | 77 // from the PluginModule's perspective (see Set/GetEmbedderState below) but |
| 78 // the module is in charge of deleting the class. | 78 // the module is in charge of deleting the class. |
| 79 class EmbedderState { | 79 class EmbedderState { |
| 80 public: | 80 public: |
| 81 virtual ~EmbedderState() {} | 81 virtual ~EmbedderState() {} |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 typedef std::set<PluginInstance*> PluginInstanceSet; | 84 typedef std::set<PluginInstanceImpl*> PluginInstanceSet; |
| 85 | 85 |
| 86 // You must call one of the Init functions after the constructor to create a | 86 // You must call one of the Init functions after the constructor to create a |
| 87 // module of the type you desire. | 87 // module of the type you desire. |
| 88 // | 88 // |
| 89 // The module lifetime delegate is a non-owning pointer that must outlive | 89 // The module lifetime delegate is a non-owning pointer that must outlive |
| 90 // all plugin modules. In practice it will be a global singleton that | 90 // all plugin modules. In practice it will be a global singleton that |
| 91 // tracks which modules are alive. | 91 // tracks which modules are alive. |
| 92 PluginModule(const std::string& name, | 92 PluginModule(const std::string& name, |
| 93 const base::FilePath& path, | 93 const base::FilePath& path, |
| 94 PluginDelegate::ModuleLifetime* lifetime_delegate, | 94 PluginDelegate::ModuleLifetime* lifetime_delegate, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 119 | 119 |
| 120 // Creates a new module for an external plugin instance that will be using the | 120 // Creates a new module for an external plugin instance that will be using the |
| 121 // IPC proxy. We can't use the existing module, or new instances of the plugin | 121 // IPC proxy. We can't use the existing module, or new instances of the plugin |
| 122 // can't be created. | 122 // can't be created. |
| 123 scoped_refptr<PluginModule> CreateModuleForExternalPluginInstance(); | 123 scoped_refptr<PluginModule> CreateModuleForExternalPluginInstance(); |
| 124 | 124 |
| 125 // Initializes the external plugin module for the out of process proxy. | 125 // Initializes the external plugin module for the out of process proxy. |
| 126 // InitAsProxied must be called before calling InitAsProxiedExternalPlugin. | 126 // InitAsProxied must be called before calling InitAsProxiedExternalPlugin. |
| 127 // Returns a result code indicating whether the proxy started successfully or | 127 // Returns a result code indicating whether the proxy started successfully or |
| 128 // there was an error. | 128 // there was an error. |
| 129 PP_ExternalPluginResult InitAsProxiedExternalPlugin(PluginInstance* instance); | 129 PP_ExternalPluginResult InitAsProxiedExternalPlugin( |
| 130 PluginInstanceImpl* instance); |
| 130 | 131 |
| 131 bool IsProxied() const; | 132 bool IsProxied() const; |
| 132 | 133 |
| 133 // Returns the peer process ID if the plugin is running out of process; | 134 // Returns the peer process ID if the plugin is running out of process; |
| 134 // returns |base::kNullProcessId| otherwise. | 135 // returns |base::kNullProcessId| otherwise. |
| 135 base::ProcessId GetPeerProcessId(); | 136 base::ProcessId GetPeerProcessId(); |
| 136 | 137 |
| 137 // Returns the plugin child process ID if the plugin is running out of | 138 // Returns the plugin child process ID if the plugin is running out of |
| 138 // process. Returns 0 otherwise. This is the ID that the browser process uses | 139 // process. Returns 0 otherwise. This is the ID that the browser process uses |
| 139 // to idetify the child process for the plugin. This isn't directly useful | 140 // to idetify the child process for the plugin. This isn't directly useful |
| (...skipping 15 matching lines...) Expand all Loading... |
| 155 static bool SupportsInterface(const char* name); | 156 static bool SupportsInterface(const char* name); |
| 156 | 157 |
| 157 // Returns the module handle. This may be used before Init() is called (the | 158 // Returns the module handle. This may be used before Init() is called (the |
| 158 // proxy needs this information to set itself up properly). | 159 // proxy needs this information to set itself up properly). |
| 159 PP_Module pp_module() const { return pp_module_; } | 160 PP_Module pp_module() const { return pp_module_; } |
| 160 | 161 |
| 161 const std::string& name() const { return name_; } | 162 const std::string& name() const { return name_; } |
| 162 const base::FilePath& path() const { return path_; } | 163 const base::FilePath& path() const { return path_; } |
| 163 const ::ppapi::PpapiPermissions& permissions() const { return permissions_; } | 164 const ::ppapi::PpapiPermissions& permissions() const { return permissions_; } |
| 164 | 165 |
| 165 PluginInstance* CreateInstance(PluginDelegate* delegate, | 166 PluginInstanceImpl* CreateInstance(PluginDelegate* delegate, |
| 166 content::RenderView* render_view, | 167 content::RenderView* render_view, |
| 167 WebKit::WebPluginContainer* container, | 168 WebKit::WebPluginContainer* container, |
| 168 const GURL& plugin_url); | 169 const GURL& plugin_url); |
| 169 | 170 |
| 170 // Returns "some" plugin instance associated with this module. This is not | 171 // Returns "some" plugin instance associated with this module. This is not |
| 171 // guaranteed to be any one in particular. This is normally used to execute | 172 // guaranteed to be any one in particular. This is normally used to execute |
| 172 // callbacks up to the browser layer that are not inherently per-instance, | 173 // callbacks up to the browser layer that are not inherently per-instance, |
| 173 // but the delegate lives only on the plugin instance so we need one of them. | 174 // but the delegate lives only on the plugin instance so we need one of them. |
| 174 PluginInstance* GetSomeInstance() const; | 175 PluginInstanceImpl* GetSomeInstance() const; |
| 175 | 176 |
| 176 const PluginInstanceSet& GetAllInstances() const { return instances_; } | 177 const PluginInstanceSet& GetAllInstances() const { return instances_; } |
| 177 | 178 |
| 178 // Calls the plugin's GetInterface and returns the given interface pointer, | 179 // Calls the plugin's GetInterface and returns the given interface pointer, |
| 179 // which could be NULL. | 180 // which could be NULL. |
| 180 const void* GetPluginInterface(const char* name) const; | 181 const void* GetPluginInterface(const char* name) const; |
| 181 | 182 |
| 182 // This module is associated with a set of instances. The PluginInstance | 183 // This module is associated with a set of instances. The PluginInstance |
| 183 // object declares its association with this module in its destructor and | 184 // object declares its association with this module in its destructor and |
| 184 // releases us in its destructor. | 185 // releases us in its destructor. |
| 185 void InstanceCreated(PluginInstance* instance); | 186 void InstanceCreated(PluginInstanceImpl* instance); |
| 186 void InstanceDeleted(PluginInstance* instance); | 187 void InstanceDeleted(PluginInstanceImpl* instance); |
| 187 | 188 |
| 188 scoped_refptr< ::ppapi::CallbackTracker> GetCallbackTracker(); | 189 scoped_refptr< ::ppapi::CallbackTracker> GetCallbackTracker(); |
| 189 | 190 |
| 190 // Called when running out of process and the plugin crashed. This will | 191 // Called when running out of process and the plugin crashed. This will |
| 191 // release relevant resources and update all affected instances. | 192 // release relevant resources and update all affected instances. |
| 192 void PluginCrashed(); | 193 void PluginCrashed(); |
| 193 | 194 |
| 194 bool is_in_destructor() const { return is_in_destructor_; } | 195 bool is_in_destructor() const { return is_in_destructor_; } |
| 195 bool is_crashed() const { return is_crashed_; } | 196 bool is_crashed() const { return is_crashed_; } |
| 196 | 197 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 274 |
| 274 PP_Bool (*reserve_instance_id_)(PP_Module, PP_Instance); | 275 PP_Bool (*reserve_instance_id_)(PP_Module, PP_Instance); |
| 275 | 276 |
| 276 DISALLOW_COPY_AND_ASSIGN(PluginModule); | 277 DISALLOW_COPY_AND_ASSIGN(PluginModule); |
| 277 }; | 278 }; |
| 278 | 279 |
| 279 } // namespace ppapi | 280 } // namespace ppapi |
| 280 } // namespace webkit | 281 } // namespace webkit |
| 281 | 282 |
| 282 #endif // WEBKIT_PLUGINS_PPAPI_PLUGIN_MODULE_H_ | 283 #endif // WEBKIT_PLUGINS_PPAPI_PLUGIN_MODULE_H_ |
| OLD | NEW |