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 CONTENT_RENDERER_PEPPER_PLUGIN_MODULE_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PLUGIN_MODULE_H_ |
6 #define CONTENT_RENDERER_PEPPER_PLUGIN_MODULE_H_ | 6 #define CONTENT_RENDERER_PEPPER_PLUGIN_MODULE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 class PepperBroker; | 51 class PepperBroker; |
52 class RendererPpapiHostImpl; | 52 class RendererPpapiHostImpl; |
53 class RenderFrameImpl; | 53 class RenderFrameImpl; |
54 struct WebPluginInfo; | 54 struct WebPluginInfo; |
55 | 55 |
56 // Represents one plugin library loaded into one renderer. This library may | 56 // Represents one plugin library loaded into one renderer. This library may |
57 // have multiple instances. | 57 // have multiple instances. |
58 // | 58 // |
59 // Note: to get from a PP_Instance to a PepperPluginInstance*, use the | 59 // Note: to get from a PP_Instance to a PepperPluginInstance*, use the |
60 // ResourceTracker. | 60 // ResourceTracker. |
61 class CONTENT_EXPORT PluginModule : | 61 class CONTENT_EXPORT PluginModule : public base::RefCounted<PluginModule>, |
62 public base::RefCounted<PluginModule>, | 62 public base::SupportsWeakPtr<PluginModule> { |
63 public base::SupportsWeakPtr<PluginModule> { | |
64 public: | 63 public: |
65 typedef std::set<PepperPluginInstanceImpl*> PluginInstanceSet; | 64 typedef std::set<PepperPluginInstanceImpl*> PluginInstanceSet; |
66 | 65 |
67 // You must call one of the Init functions after the constructor to create a | 66 // You must call one of the Init functions after the constructor to create a |
68 // module of the type you desire. | 67 // module of the type you desire. |
69 // | 68 // |
70 // The module lifetime delegate is a non-owning pointer that must outlive | 69 // The module lifetime delegate is a non-owning pointer that must outlive |
71 // all plugin modules. In practice it will be a global singleton that | 70 // all plugin modules. In practice it will be a global singleton that |
72 // tracks which modules are alive. | 71 // tracks which modules are alive. |
73 PluginModule(const std::string& name, | 72 PluginModule(const std::string& name, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 130 } |
132 | 131 |
133 // Returns the module handle. This may be used before Init() is called (the | 132 // Returns the module handle. This may be used before Init() is called (the |
134 // proxy needs this information to set itself up properly). | 133 // proxy needs this information to set itself up properly). |
135 PP_Module pp_module() const { return pp_module_; } | 134 PP_Module pp_module() const { return pp_module_; } |
136 | 135 |
137 const std::string& name() const { return name_; } | 136 const std::string& name() const { return name_; } |
138 const base::FilePath& path() const { return path_; } | 137 const base::FilePath& path() const { return path_; } |
139 const ppapi::PpapiPermissions& permissions() const { return permissions_; } | 138 const ppapi::PpapiPermissions& permissions() const { return permissions_; } |
140 | 139 |
141 PepperPluginInstanceImpl* CreateInstance( | 140 PepperPluginInstanceImpl* CreateInstance(RenderFrameImpl* render_frame, |
142 RenderFrameImpl* render_frame, | 141 blink::WebPluginContainer* container, |
143 blink::WebPluginContainer* container, | 142 const GURL& plugin_url); |
144 const GURL& plugin_url); | |
145 | 143 |
146 // Returns "some" plugin instance associated with this module. This is not | 144 // Returns "some" plugin instance associated with this module. This is not |
147 // guaranteed to be any one in particular. This is normally used to execute | 145 // guaranteed to be any one in particular. This is normally used to execute |
148 // callbacks up to the browser layer that are not inherently per-instance, | 146 // callbacks up to the browser layer that are not inherently per-instance, |
149 // but the helper lives only on the plugin instance so we need one of them. | 147 // but the helper lives only on the plugin instance so we need one of them. |
150 PepperPluginInstanceImpl* GetSomeInstance() const; | 148 PepperPluginInstanceImpl* GetSomeInstance() const; |
151 | 149 |
152 const PluginInstanceSet& GetAllInstances() const { return instances_; } | 150 const PluginInstanceSet& GetAllInstances() const { return instances_; } |
153 | 151 |
154 // Calls the plugin's GetInterface and returns the given interface pointer, | 152 // Calls the plugin's GetInterface and returns the given interface pointer, |
(...skipping 16 matching lines...) Expand all Loading... |
171 bool is_crashed() const { return is_crashed_; } | 169 bool is_crashed() const { return is_crashed_; } |
172 | 170 |
173 // Reserves the given instance is unique within the plugin, checking for | 171 // Reserves the given instance is unique within the plugin, checking for |
174 // collisions. See PPB_Proxy_Private for more information. | 172 // collisions. See PPB_Proxy_Private for more information. |
175 // | 173 // |
176 // The setter will set the callback which is set up when the proxy | 174 // The setter will set the callback which is set up when the proxy |
177 // initializes. The Reserve function will call the previously set callback if | 175 // initializes. The Reserve function will call the previously set callback if |
178 // it exists to validate the ID. If the callback has not been set (such as | 176 // it exists to validate the ID. If the callback has not been set (such as |
179 // for in-process plugins), the Reserve function will assume that the ID is | 177 // for in-process plugins), the Reserve function will assume that the ID is |
180 // usable and will return true. | 178 // usable and will return true. |
181 void SetReserveInstanceIDCallback( | 179 void SetReserveInstanceIDCallback(PP_Bool (*reserve)(PP_Module, PP_Instance)); |
182 PP_Bool (*reserve)(PP_Module, PP_Instance)); | |
183 bool ReserveInstanceID(PP_Instance instance); | 180 bool ReserveInstanceID(PP_Instance instance); |
184 | 181 |
185 // These should only be called from the main thread. | 182 // These should only be called from the main thread. |
186 void SetBroker(PepperBroker* broker); | 183 void SetBroker(PepperBroker* broker); |
187 PepperBroker* GetBroker(); | 184 PepperBroker* GetBroker(); |
188 | 185 |
189 // Create a new HostDispatcher for proxying, hook it to the PluginModule, | 186 // Create a new HostDispatcher for proxying, hook it to the PluginModule, |
190 // and perform other common initialization. | 187 // and perform other common initialization. |
191 RendererPpapiHostImpl* CreateOutOfProcessModule( | 188 RendererPpapiHostImpl* CreateOutOfProcessModule( |
192 RenderFrameImpl* render_frame, | 189 RenderFrameImpl* render_frame, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 PluginInstanceSet instances_; | 267 PluginInstanceSet instances_; |
271 | 268 |
272 PP_Bool (*reserve_instance_id_)(PP_Module, PP_Instance); | 269 PP_Bool (*reserve_instance_id_)(PP_Module, PP_Instance); |
273 | 270 |
274 DISALLOW_COPY_AND_ASSIGN(PluginModule); | 271 DISALLOW_COPY_AND_ASSIGN(PluginModule); |
275 }; | 272 }; |
276 | 273 |
277 } // namespace content | 274 } // namespace content |
278 | 275 |
279 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_MODULE_H_ | 276 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_MODULE_H_ |
OLD | NEW |