Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: content/renderer/pepper/plugin_module.h

Issue 20165002: Move webkit/plugins/ppapi to content/renderer/pepper. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: more more clang fun Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/pepper/plugin_delegate.h ('k') | content/renderer/pepper/plugin_module.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 CONTENT_RENDERER_PEPPER_PLUGIN_MODULE_H_
6 #define WEBKIT_PLUGINS_PPAPI_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>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.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.h" 18 #include "base/process.h"
19 #include "content/common/content_export.h"
20 #include "content/public/common/pepper_plugin_info.h"
21 #include "content/renderer/pepper/plugin_delegate.h"
19 #include "ppapi/c/pp_bool.h" 22 #include "ppapi/c/pp_bool.h"
20 #include "ppapi/c/pp_instance.h" 23 #include "ppapi/c/pp_instance.h"
21 #include "ppapi/c/pp_module.h"
22 #include "ppapi/c/ppb.h"
23 #include "ppapi/c/ppb_core.h" 24 #include "ppapi/c/ppb_core.h"
24 #include "ppapi/c/private/ppb_instance_private.h" 25 #include "ppapi/c/private/ppb_instance_private.h"
25 #include "ppapi/shared_impl/ppapi_permissions.h" 26 #include "ppapi/shared_impl/ppapi_permissions.h"
26 #include "webkit/plugins/ppapi/plugin_delegate.h"
27 #include "webkit/plugins/webkit_plugins_export.h"
28 27
29 typedef void* NPIdentifier; 28 typedef void* NPIdentifier;
30 29
31 namespace base { 30 namespace base {
32 class FilePath; 31 class FilePath;
33 } 32 }
34 33
35 namespace content { 34 namespace content {
36 class RenderView; 35 class RenderView;
37 } 36 }
(...skipping 11 matching lines...) Expand all
49 namespace ppapi { 48 namespace ppapi {
50 49
51 class PluginDelegate; 50 class PluginDelegate;
52 class PluginInstanceImpl; 51 class PluginInstanceImpl;
53 52
54 // Represents one plugin library loaded into one renderer. This library may 53 // Represents one plugin library loaded into one renderer. This library may
55 // have multiple instances. 54 // have multiple instances.
56 // 55 //
57 // Note: to get from a PP_Instance to a PluginInstance*, use the 56 // Note: to get from a PP_Instance to a PluginInstance*, use the
58 // ResourceTracker. 57 // ResourceTracker.
59 class WEBKIT_PLUGINS_EXPORT PluginModule : 58 class CONTENT_EXPORT PluginModule :
60 public base::RefCounted<PluginModule>, 59 public base::RefCounted<PluginModule>,
61 public base::SupportsWeakPtr<PluginModule> { 60 public base::SupportsWeakPtr<PluginModule> {
62 public: 61 public:
63 typedef const void* (*GetInterfaceFunc)(const char*);
64 typedef int (*PPP_InitializeModuleFunc)(PP_Module, PPB_GetInterface);
65 typedef void (*PPP_ShutdownModuleFunc)();
66
67 struct EntryPoints {
68 // This structure is POD, with the constructor initializing to NULL.
69 WEBKIT_PLUGINS_EXPORT EntryPoints();
70
71 GetInterfaceFunc get_interface;
72 PPP_InitializeModuleFunc initialize_module;
73 PPP_ShutdownModuleFunc shutdown_module; // Optional, may be NULL.
74 };
75
76 // Allows the embedder to associate a class with this module. This is opaque 62 // Allows the embedder to associate a class with this module. This is opaque
77 // from the PluginModule's perspective (see Set/GetEmbedderState below) but 63 // from the PluginModule's perspective (see Set/GetEmbedderState below) but
78 // the module is in charge of deleting the class. 64 // the module is in charge of deleting the class.
79 class EmbedderState { 65 class EmbedderState {
80 public: 66 public:
81 virtual ~EmbedderState() {} 67 virtual ~EmbedderState() {}
82 }; 68 };
83 69
84 typedef std::set<PluginInstanceImpl*> PluginInstanceSet; 70 typedef std::set<PluginInstanceImpl*> PluginInstanceSet;
85 71
86 // You must call one of the Init functions after the constructor to create a 72 // You must call one of the Init functions after the constructor to create a
87 // module of the type you desire. 73 // module of the type you desire.
88 // 74 //
89 // The module lifetime delegate is a non-owning pointer that must outlive 75 // 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 76 // all plugin modules. In practice it will be a global singleton that
91 // tracks which modules are alive. 77 // tracks which modules are alive.
92 PluginModule(const std::string& name, 78 PluginModule(const std::string& name,
93 const base::FilePath& path, 79 const base::FilePath& path,
94 PluginDelegate::ModuleLifetime* lifetime_delegate,
95 const ::ppapi::PpapiPermissions& perms); 80 const ::ppapi::PpapiPermissions& perms);
96 81
97 ~PluginModule();
98
99 // Sets the given class as being associated with this module. It will be 82 // Sets the given class as being associated with this module. It will be
100 // deleted when the module is destroyed. You can only set it once, subsequent 83 // deleted when the module is destroyed. You can only set it once, subsequent
101 // sets will assert. 84 // sets will assert.
102 // 85 //
103 // See EmbedderState above for more. 86 // See EmbedderState above for more.
104 void SetEmbedderState(scoped_ptr<EmbedderState> state); 87 void SetEmbedderState(scoped_ptr<EmbedderState> state);
105 EmbedderState* GetEmbedderState(); 88 EmbedderState* GetEmbedderState();
106 89
107 // Initializes this module as an internal plugin with the given entrypoints. 90 // Initializes this module as an internal plugin with the given entrypoints.
108 // This is used for "plugins" compiled into Chrome. Returns true on success. 91 // This is used for "plugins" compiled into Chrome. Returns true on success.
109 // False means that the plugin can not be used. 92 // False means that the plugin can not be used.
110 bool InitAsInternalPlugin(const EntryPoints& entry_points); 93 bool InitAsInternalPlugin(
94 const content::PepperPluginInfo::EntryPoints& entry_points);
111 95
112 // Initializes this module using the given library path as the plugin. 96 // Initializes this module using the given library path as the plugin.
113 // Returns true on success. False means that the plugin can not be used. 97 // Returns true on success. False means that the plugin can not be used.
114 bool InitAsLibrary(const base::FilePath& path); 98 bool InitAsLibrary(const base::FilePath& path);
115 99
116 // Initializes this module for the given out of process proxy. This takes 100 // Initializes this module for the given out of process proxy. This takes
117 // ownership of the given pointer, even in the failure case. 101 // ownership of the given pointer, even in the failure case.
118 void InitAsProxied(PluginDelegate::OutOfProcessProxy* out_of_process_proxy); 102 void InitAsProxied(PluginDelegate::OutOfProcessProxy* out_of_process_proxy);
119 103
120 // Creates a new module for an external plugin instance that will be using the 104 // Creates a new module for an external plugin instance that will be using the
(...skipping 18 matching lines...) Expand all
139 // process. Returns 0 otherwise. This is the ID that the browser process uses 123 // process. Returns 0 otherwise. This is the ID that the browser process uses
140 // to idetify the child process for the plugin. This isn't directly useful 124 // to idetify the child process for the plugin. This isn't directly useful
141 // from our process (the renderer) except in messages to the browser to 125 // from our process (the renderer) except in messages to the browser to
142 // disambiguate plugins. 126 // disambiguate plugins.
143 int GetPluginChildId(); 127 int GetPluginChildId();
144 128
145 static const PPB_Core* GetCore(); 129 static const PPB_Core* GetCore();
146 130
147 // Returns a pointer to the local GetInterface function for retrieving 131 // Returns a pointer to the local GetInterface function for retrieving
148 // PPB interfaces. 132 // PPB interfaces.
149 static GetInterfaceFunc GetLocalGetInterfaceFunc(); 133 static content::PepperPluginInfo::GetInterfaceFunc GetLocalGetInterfaceFunc();
150 134
151 // Returns whether an interface is supported. This method can be called from 135 // Returns whether an interface is supported. This method can be called from
152 // the browser process and used for interface matching before plugin 136 // the browser process and used for interface matching before plugin
153 // registration. 137 // registration.
154 // NOTE: those custom interfaces provided by PpapiInterfaceFactoryManager 138 // NOTE: those custom interfaces provided by PpapiInterfaceFactoryManager
155 // will not be considered when called on the browser process. 139 // will not be considered when called on the browser process.
156 static bool SupportsInterface(const char* name); 140 static bool SupportsInterface(const char* name);
157 141
158 // Returns the module handle. This may be used before Init() is called (the 142 // Returns the module handle. This may be used before Init() is called (the
159 // proxy needs this information to set itself up properly). 143 // proxy needs this information to set itself up properly).
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 void SetBroker(PluginDelegate::Broker* broker); 195 void SetBroker(PluginDelegate::Broker* broker);
212 PluginDelegate::Broker* GetBroker(); 196 PluginDelegate::Broker* GetBroker();
213 197
214 // In production we purposely leak the HostGlobals object but in unittest 198 // In production we purposely leak the HostGlobals object but in unittest
215 // code, this can interfere with subsequent tests. This deletes the 199 // code, this can interfere with subsequent tests. This deletes the
216 // existing HostGlobals. A new one will be constructed when a PluginModule is 200 // existing HostGlobals. A new one will be constructed when a PluginModule is
217 // instantiated. 201 // instantiated.
218 static void ResetHostGlobalsForTest(); 202 static void ResetHostGlobalsForTest();
219 203
220 private: 204 private:
205 friend class base::RefCounted<PluginModule>;
206 ~PluginModule();
221 // Calls the InitializeModule entrypoint. The entrypoint must have been 207 // Calls the InitializeModule entrypoint. The entrypoint must have been
222 // set and the plugin must not be out of process (we don't maintain 208 // set and the plugin must not be out of process (we don't maintain
223 // entrypoints in that case). 209 // entrypoints in that case).
224 bool InitializeModule(const EntryPoints& entry_points); 210 bool InitializeModule(
225 211 const content::PepperPluginInfo::EntryPoints& entry_points);
226 // Note: This may be null.
227 PluginDelegate::ModuleLifetime* lifetime_delegate_;
228 212
229 // See EmbedderState above. 213 // See EmbedderState above.
230 scoped_ptr<EmbedderState> embedder_state_; 214 scoped_ptr<EmbedderState> embedder_state_;
231 215
232 // Tracker for completion callbacks, used mainly to ensure that all callbacks 216 // Tracker for completion callbacks, used mainly to ensure that all callbacks
233 // are properly aborted on module shutdown. 217 // are properly aborted on module shutdown.
234 scoped_refptr< ::ppapi::CallbackTracker> callback_tracker_; 218 scoped_refptr< ::ppapi::CallbackTracker> callback_tracker_;
235 219
236 PP_Module pp_module_; 220 PP_Module pp_module_;
237 221
(...skipping 15 matching lines...) Expand all
253 237
254 // Holds a reference to the base::NativeLibrary handle if this PluginModule 238 // Holds a reference to the base::NativeLibrary handle if this PluginModule
255 // instance wraps functions loaded from a library. Can be NULL. If 239 // instance wraps functions loaded from a library. Can be NULL. If
256 // |library_| is non-NULL, PluginModule will attempt to unload the library 240 // |library_| is non-NULL, PluginModule will attempt to unload the library
257 // during destruction. 241 // during destruction.
258 base::NativeLibrary library_; 242 base::NativeLibrary library_;
259 243
260 // Contains pointers to the entry points of the actual plugin implementation. 244 // Contains pointers to the entry points of the actual plugin implementation.
261 // These will be NULL for out-of-process plugins, which is indicated by the 245 // These will be NULL for out-of-process plugins, which is indicated by the
262 // presence of the out_of_process_proxy_ value. 246 // presence of the out_of_process_proxy_ value.
263 EntryPoints entry_points_; 247 content::PepperPluginInfo::EntryPoints entry_points_;
264 248
265 // The name and file location of the module. 249 // The name and file location of the module.
266 const std::string name_; 250 const std::string name_;
267 const base::FilePath path_; 251 const base::FilePath path_;
268 252
269 ::ppapi::PpapiPermissions permissions_; 253 ::ppapi::PpapiPermissions permissions_;
270 254
271 // Non-owning pointers to all instances associated with this module. When 255 // Non-owning pointers to all instances associated with this module. When
272 // there are no more instances, this object should be deleted. 256 // there are no more instances, this object should be deleted.
273 PluginInstanceSet instances_; 257 PluginInstanceSet instances_;
274 258
275 PP_Bool (*reserve_instance_id_)(PP_Module, PP_Instance); 259 PP_Bool (*reserve_instance_id_)(PP_Module, PP_Instance);
276 260
277 DISALLOW_COPY_AND_ASSIGN(PluginModule); 261 DISALLOW_COPY_AND_ASSIGN(PluginModule);
278 }; 262 };
279 263
280 } // namespace ppapi 264 } // namespace ppapi
281 } // namespace webkit 265 } // namespace webkit
282 266
283 #endif // WEBKIT_PLUGINS_PPAPI_PLUGIN_MODULE_H_ 267 #endif // CONTENT_RENDERER_PEPPER_PLUGIN_MODULE_H_
OLDNEW
« no previous file with comments | « content/renderer/pepper/plugin_delegate.h ('k') | content/renderer/pepper/plugin_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698