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 <memory> |
9 #include <set> | 10 #include <set> |
10 #include <string> | 11 #include <string> |
11 | 12 |
12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/native_library.h" | 17 #include "base/native_library.h" |
18 #include "base/process/process.h" | 18 #include "base/process/process.h" |
19 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
20 #include "content/public/common/pepper_plugin_info.h" | 20 #include "content/public/common/pepper_plugin_info.h" |
21 #include "ppapi/c/pp_bool.h" | 21 #include "ppapi/c/pp_bool.h" |
22 #include "ppapi/c/pp_instance.h" | 22 #include "ppapi/c/pp_instance.h" |
23 #include "ppapi/c/ppb_core.h" | 23 #include "ppapi/c/ppb_core.h" |
24 #include "ppapi/c/private/ppb_instance_private.h" | 24 #include "ppapi/c/private/ppb_instance_private.h" |
25 #include "ppapi/shared_impl/ppapi_permissions.h" | 25 #include "ppapi/shared_impl/ppapi_permissions.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // 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 |
71 // tracks which modules are alive. | 71 // tracks which modules are alive. |
72 PluginModule(const std::string& name, | 72 PluginModule(const std::string& name, |
73 const std::string& version, | 73 const std::string& version, |
74 const base::FilePath& path, | 74 const base::FilePath& path, |
75 const ppapi::PpapiPermissions& perms); | 75 const ppapi::PpapiPermissions& perms); |
76 | 76 |
77 // Sets the given class as being associated with this module. It will be | 77 // Sets the given class as being associated with this module. It will be |
78 // deleted when the module is destroyed. You can only set it once, subsequent | 78 // deleted when the module is destroyed. You can only set it once, subsequent |
79 // sets will assert. | 79 // sets will assert. |
80 void SetRendererPpapiHost(scoped_ptr<RendererPpapiHostImpl> host); | 80 void SetRendererPpapiHost(std::unique_ptr<RendererPpapiHostImpl> host); |
81 | 81 |
82 // Initializes this module as an internal plugin with the given entrypoints. | 82 // Initializes this module as an internal plugin with the given entrypoints. |
83 // This is used for "plugins" compiled into Chrome. Returns true on success. | 83 // This is used for "plugins" compiled into Chrome. Returns true on success. |
84 // False means that the plugin can not be used. | 84 // False means that the plugin can not be used. |
85 bool InitAsInternalPlugin(const PepperPluginInfo::EntryPoints& entry_points); | 85 bool InitAsInternalPlugin(const PepperPluginInfo::EntryPoints& entry_points); |
86 | 86 |
87 // Initializes this module using the given library path as the plugin. | 87 // Initializes this module using the given library path as the plugin. |
88 // Returns true on success. False means that the plugin can not be used. | 88 // Returns true on success. False means that the plugin can not be used. |
89 bool InitAsLibrary(const base::FilePath& path); | 89 bool InitAsLibrary(const base::FilePath& path); |
90 | 90 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 bool* pepper_plugin_was_registered); | 216 bool* pepper_plugin_was_registered); |
217 | 217 |
218 private: | 218 private: |
219 friend class base::RefCounted<PluginModule>; | 219 friend class base::RefCounted<PluginModule>; |
220 ~PluginModule(); | 220 ~PluginModule(); |
221 // Calls the InitializeModule entrypoint. The entrypoint must have been | 221 // Calls the InitializeModule entrypoint. The entrypoint must have been |
222 // set and the plugin must not be out of process (we don't maintain | 222 // set and the plugin must not be out of process (we don't maintain |
223 // entrypoints in that case). | 223 // entrypoints in that case). |
224 bool InitializeModule(const PepperPluginInfo::EntryPoints& entry_points); | 224 bool InitializeModule(const PepperPluginInfo::EntryPoints& entry_points); |
225 | 225 |
226 scoped_ptr<RendererPpapiHostImpl> renderer_ppapi_host_; | 226 std::unique_ptr<RendererPpapiHostImpl> renderer_ppapi_host_; |
227 | 227 |
228 // Tracker for completion callbacks, used mainly to ensure that all callbacks | 228 // Tracker for completion callbacks, used mainly to ensure that all callbacks |
229 // are properly aborted on module shutdown. | 229 // are properly aborted on module shutdown. |
230 scoped_refptr<ppapi::CallbackTracker> callback_tracker_; | 230 scoped_refptr<ppapi::CallbackTracker> callback_tracker_; |
231 | 231 |
232 PP_Module pp_module_; | 232 PP_Module pp_module_; |
233 | 233 |
234 // True when we're running in the destructor. This allows us to write some | 234 // True when we're running in the destructor. This allows us to write some |
235 // assertions. | 235 // assertions. |
236 bool is_in_destructor_; | 236 bool is_in_destructor_; |
237 | 237 |
238 // True if the plugin is running out-of-process and has crashed. | 238 // True if the plugin is running out-of-process and has crashed. |
239 bool is_crashed_; | 239 bool is_crashed_; |
240 | 240 |
241 // Manages the out of process proxy interface. The presence of this | 241 // Manages the out of process proxy interface. The presence of this |
242 // pointer indicates that the plugin is running out of process and that the | 242 // pointer indicates that the plugin is running out of process and that the |
243 // entry_points_ aren't valid. | 243 // entry_points_ aren't valid. |
244 scoped_ptr<HostDispatcherWrapper> host_dispatcher_wrapper_; | 244 std::unique_ptr<HostDispatcherWrapper> host_dispatcher_wrapper_; |
245 | 245 |
246 // Non-owning pointer to the broker for this plugin module, if one exists. | 246 // Non-owning pointer to the broker for this plugin module, if one exists. |
247 // It is populated and cleared in the main thread. | 247 // It is populated and cleared in the main thread. |
248 PepperBroker* broker_; | 248 PepperBroker* broker_; |
249 | 249 |
250 // Holds a reference to the base::NativeLibrary handle if this PluginModule | 250 // Holds a reference to the base::NativeLibrary handle if this PluginModule |
251 // instance wraps functions loaded from a library. Can be NULL. If | 251 // instance wraps functions loaded from a library. Can be NULL. If |
252 // |library_| is non-NULL, PluginModule will attempt to unload the library | 252 // |library_| is non-NULL, PluginModule will attempt to unload the library |
253 // during destruction. | 253 // during destruction. |
254 base::NativeLibrary library_; | 254 base::NativeLibrary library_; |
(...skipping 15 matching lines...) Expand all Loading... |
270 PluginInstanceSet instances_; | 270 PluginInstanceSet instances_; |
271 | 271 |
272 PP_Bool (*reserve_instance_id_)(PP_Module, PP_Instance); | 272 PP_Bool (*reserve_instance_id_)(PP_Module, PP_Instance); |
273 | 273 |
274 DISALLOW_COPY_AND_ASSIGN(PluginModule); | 274 DISALLOW_COPY_AND_ASSIGN(PluginModule); |
275 }; | 275 }; |
276 | 276 |
277 } // namespace content | 277 } // namespace content |
278 | 278 |
279 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_MODULE_H_ | 279 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_MODULE_H_ |
OLD | NEW |