OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_MODULE_H_ |
| 6 #define WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_MODULE_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/file_path.h" |
| 10 #include "base/native_library.h" |
| 11 #include "base/ref_counted.h" |
| 12 |
| 13 #include <set> |
| 14 |
| 15 typedef struct _pp_Module PP_Module; |
| 16 |
| 17 namespace pepper { |
| 18 |
| 19 class PluginDelegate; |
| 20 class PluginInstance; |
| 21 |
| 22 class PluginModule : public base::RefCounted<PluginModule> { |
| 23 public: |
| 24 ~PluginModule(); |
| 25 |
| 26 static scoped_refptr<PluginModule> CreateModule(const FilePath& filename); |
| 27 |
| 28 // Converts the given module ID to an actual module object. Will return NULL |
| 29 // if the module is invalid. |
| 30 static PluginModule* FromPPModule(PP_Module module); |
| 31 |
| 32 PP_Module GetPPModule() const; |
| 33 |
| 34 PluginInstance* CreateInstance(PluginDelegate* delegate); |
| 35 |
| 36 // Returns "some" plugin instance associated with this module. This is not |
| 37 // guaranteed to be any one in particular. This is normally used to execute |
| 38 // callbacks up to the browser layer that are not inherently per-instance, |
| 39 // but the delegate lives only on the plugin instance so we need one of them. |
| 40 PluginInstance* GetSomeInstance() const; |
| 41 |
| 42 const void* GetPluginInterface(const char* name) const; |
| 43 |
| 44 // This module is associated with a set of instances. The PluginInstance |
| 45 // object declares its association with this module in its destructor and |
| 46 // releases us in its destructor. |
| 47 void InstanceCreated(PluginInstance* instance); |
| 48 void InstanceDeleted(PluginInstance* instance); |
| 49 |
| 50 private: |
| 51 typedef const void* (*PPP_GetInterfaceFunc)(const char*); |
| 52 |
| 53 PluginModule(const FilePath& filename); |
| 54 |
| 55 bool Load(); |
| 56 |
| 57 FilePath filename_; |
| 58 |
| 59 bool initialized_; |
| 60 base::NativeLibrary library_; |
| 61 |
| 62 PPP_GetInterfaceFunc ppp_get_interface_; |
| 63 |
| 64 // Non-owning pointers to all instances associated with this module. When |
| 65 // there are no more instances, this object should be deleted. |
| 66 typedef std::set<PluginInstance*> PluginInstanceSet; |
| 67 PluginInstanceSet instances_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(PluginModule); |
| 70 }; |
| 71 |
| 72 } // namespace pepper |
| 73 |
| 74 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_MODULE_H_ |
OLD | NEW |