| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_GLUE_PLUGINS_PEPPER_PLUGIN_MODULE_H_ | 5 #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_MODULE_H_ |
| 6 #define WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_MODULE_H_ | 6 #define WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_MODULE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/native_library.h" | 12 #include "base/native_library.h" |
| 13 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
| 14 #include "base/weak_ptr.h" | 14 #include "base/weak_ptr.h" |
| 15 #include "ppapi/c/pp_module.h" | 15 #include "ppapi/c/pp_module.h" |
| 16 #include "ppapi/c/ppb.h" | 16 #include "ppapi/c/ppb.h" |
| 17 | 17 |
| 18 class FilePath; | 18 class FilePath; |
| 19 class MessageLoop; |
| 19 typedef struct NPObject NPObject; | 20 typedef struct NPObject NPObject; |
| 20 struct PPB_Core; | 21 struct PPB_Core; |
| 21 typedef void* NPIdentifier; | 22 typedef void* NPIdentifier; |
| 22 | 23 |
| 24 namespace base { |
| 25 class WaitableEvent; |
| 26 } |
| 27 |
| 28 namespace pp { |
| 29 namespace proxy { |
| 30 class HostDispatcher; |
| 31 } // proxy |
| 32 } // pp |
| 33 |
| 34 namespace IPC { |
| 35 struct ChannelHandle; |
| 36 } |
| 37 |
| 23 namespace pepper { | 38 namespace pepper { |
| 24 | 39 |
| 25 class ObjectVar; | 40 class ObjectVar; |
| 26 class PluginDelegate; | 41 class PluginDelegate; |
| 27 class PluginInstance; | 42 class PluginInstance; |
| 28 class PluginObject; | 43 class PluginObject; |
| 29 | 44 |
| 30 // Represents one plugin library loaded into one renderer. This library may | 45 // Represents one plugin library loaded into one renderer. This library may |
| 31 // have multiple instances. | 46 // have multiple instances. |
| 32 // | 47 // |
| (...skipping 16 matching lines...) Expand all Loading... |
| 49 PPP_GetInterfaceFunc get_interface; | 64 PPP_GetInterfaceFunc get_interface; |
| 50 PPP_InitializeModuleFunc initialize_module; | 65 PPP_InitializeModuleFunc initialize_module; |
| 51 PPP_ShutdownModuleFunc shutdown_module; | 66 PPP_ShutdownModuleFunc shutdown_module; |
| 52 }; | 67 }; |
| 53 | 68 |
| 54 ~PluginModule(); | 69 ~PluginModule(); |
| 55 | 70 |
| 56 static scoped_refptr<PluginModule> CreateModule(const FilePath& path); | 71 static scoped_refptr<PluginModule> CreateModule(const FilePath& path); |
| 57 static scoped_refptr<PluginModule> CreateInternalModule( | 72 static scoped_refptr<PluginModule> CreateInternalModule( |
| 58 EntryPoints entry_points); | 73 EntryPoints entry_points); |
| 74 static scoped_refptr<PluginModule> CreateOutOfProcessModule( |
| 75 MessageLoop* ipc_message_loop, |
| 76 const IPC::ChannelHandle& handle, |
| 77 base::WaitableEvent* shutdown_event); |
| 59 | 78 |
| 60 static const PPB_Core* GetCore(); | 79 static const PPB_Core* GetCore(); |
| 61 | 80 |
| 62 PP_Module pp_module() const { return pp_module_; } | 81 PP_Module pp_module() const { return pp_module_; } |
| 63 | 82 |
| 64 void set_name(const std::string& name) { name_ = name; } | 83 void set_name(const std::string& name) { name_ = name; } |
| 65 const std::string& name() const { return name_; } | 84 const std::string& name() const { return name_; } |
| 66 | 85 |
| 67 PluginInstance* CreateInstance(PluginDelegate* delegate); | 86 PluginInstance* CreateInstance(PluginDelegate* delegate); |
| 68 | 87 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 94 | 113 |
| 95 // Tracks all live PluginObjects. | 114 // Tracks all live PluginObjects. |
| 96 void AddPluginObject(PluginObject* plugin_object); | 115 void AddPluginObject(PluginObject* plugin_object); |
| 97 void RemovePluginObject(PluginObject* plugin_object); | 116 void RemovePluginObject(PluginObject* plugin_object); |
| 98 | 117 |
| 99 private: | 118 private: |
| 100 PluginModule(); | 119 PluginModule(); |
| 101 | 120 |
| 102 bool InitFromEntryPoints(const EntryPoints& entry_points); | 121 bool InitFromEntryPoints(const EntryPoints& entry_points); |
| 103 bool InitFromFile(const FilePath& path); | 122 bool InitFromFile(const FilePath& path); |
| 123 bool InitForOutOfProcess(MessageLoop* ipc_message_loop, |
| 124 const IPC::ChannelHandle& handle, |
| 125 base::WaitableEvent* shutdown_event); |
| 104 static bool LoadEntryPoints(const base::NativeLibrary& library, | 126 static bool LoadEntryPoints(const base::NativeLibrary& library, |
| 105 EntryPoints* entry_points); | 127 EntryPoints* entry_points); |
| 106 | 128 |
| 129 // Dispatcher for out-of-process plugins. This will be null when the plugin |
| 130 // is being run in-process. |
| 131 scoped_ptr<pp::proxy::HostDispatcher> dispatcher_; |
| 132 |
| 107 PP_Module pp_module_; | 133 PP_Module pp_module_; |
| 108 | 134 |
| 109 bool initialized_; | 135 bool initialized_; |
| 110 | 136 |
| 111 // Holds a reference to the base::NativeLibrary handle if this PluginModule | 137 // Holds a reference to the base::NativeLibrary handle if this PluginModule |
| 112 // instance wraps functions loaded from a library. Can be NULL. If | 138 // instance wraps functions loaded from a library. Can be NULL. If |
| 113 // |library_| is non-NULL, PluginModule will attempt to unload the library | 139 // |library_| is non-NULL, PluginModule will attempt to unload the library |
| 114 // during destruction. | 140 // during destruction. |
| 115 base::NativeLibrary library_; | 141 base::NativeLibrary library_; |
| 116 | 142 |
| 117 // Contains pointers to the entry points of the actual plugin | 143 // Contains pointers to the entry points of the actual plugin |
| 118 // implementation. | 144 // implementation. These will be NULL for out-of-process plugins. |
| 119 EntryPoints entry_points_; | 145 EntryPoints entry_points_; |
| 120 | 146 |
| 121 // The name of the module. | 147 // The name of the module. |
| 122 std::string name_; | 148 std::string name_; |
| 123 | 149 |
| 124 // Non-owning pointers to all instances associated with this module. When | 150 // Non-owning pointers to all instances associated with this module. When |
| 125 // there are no more instances, this object should be deleted. | 151 // there are no more instances, this object should be deleted. |
| 126 typedef std::set<PluginInstance*> PluginInstanceSet; | 152 typedef std::set<PluginInstance*> PluginInstanceSet; |
| 127 PluginInstanceSet instances_; | 153 PluginInstanceSet instances_; |
| 128 | 154 |
| 129 // Tracks all live ObjectVars used by this module so we can map NPObjects to | 155 // Tracks all live ObjectVars used by this module so we can map NPObjects to |
| 130 // the corresponding object. These are non-owning references. | 156 // the corresponding object. These are non-owning references. |
| 131 typedef std::map<NPObject*, ObjectVar*> NPObjectToObjectVarMap;; | 157 typedef std::map<NPObject*, ObjectVar*> NPObjectToObjectVarMap;; |
| 132 NPObjectToObjectVarMap np_object_to_object_var_; | 158 NPObjectToObjectVarMap np_object_to_object_var_; |
| 133 | 159 |
| 134 typedef std::set<PluginObject*> PluginObjectSet; | 160 typedef std::set<PluginObject*> PluginObjectSet; |
| 135 PluginObjectSet live_plugin_objects_; | 161 PluginObjectSet live_plugin_objects_; |
| 136 | 162 |
| 137 DISALLOW_COPY_AND_ASSIGN(PluginModule); | 163 DISALLOW_COPY_AND_ASSIGN(PluginModule); |
| 138 }; | 164 }; |
| 139 | 165 |
| 140 } // namespace pepper | 166 } // namespace pepper |
| 141 | 167 |
| 142 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_MODULE_H_ | 168 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_MODULE_H_ |
| OLD | NEW |