| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_COMMON_PEPPER_PLUGIN_REGISTRY_H_ | 5 #ifndef CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_ |
| 6 #define CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_ | 6 #define CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 15 #include "ppapi/proxy/dispatcher.h" | 15 #include "ppapi/proxy/proxy_channel.h" |
| 16 #include "webkit/plugins/npapi/webplugininfo.h" | 16 #include "webkit/plugins/npapi/webplugininfo.h" |
| 17 #include "webkit/plugins/ppapi/plugin_delegate.h" | 17 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 18 #include "webkit/plugins/ppapi/plugin_module.h" | 18 #include "webkit/plugins/ppapi/plugin_module.h" |
| 19 | 19 |
| 20 struct PepperPluginInfo { | 20 struct PepperPluginInfo { |
| 21 PepperPluginInfo(); | 21 PepperPluginInfo(); |
| 22 ~PepperPluginInfo(); | 22 ~PepperPluginInfo(); |
| 23 | 23 |
| 24 webkit::npapi::WebPluginInfo ToWebPluginInfo() const; | 24 webkit::npapi::WebPluginInfo ToWebPluginInfo() const; |
| 25 | 25 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 46 webkit::ppapi::PluginModule::EntryPoints internal_entry_points; | 46 webkit::ppapi::PluginModule::EntryPoints internal_entry_points; |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 // This class holds references to all of the known pepper plugin modules. | 49 // This class holds references to all of the known pepper plugin modules. |
| 50 // | 50 // |
| 51 // It keeps two lists. One list of preloaded in-process modules, and one list | 51 // It keeps two lists. One list of preloaded in-process modules, and one list |
| 52 // is a list of all live modules (some of which may be out-of-process and hence | 52 // is a list of all live modules (some of which may be out-of-process and hence |
| 53 // not preloaded). | 53 // not preloaded). |
| 54 class PepperPluginRegistry | 54 class PepperPluginRegistry |
| 55 : public webkit::ppapi::PluginDelegate::ModuleLifetime, | 55 : public webkit::ppapi::PluginDelegate::ModuleLifetime, |
| 56 public pp::proxy::Dispatcher::Delegate { | 56 public pp::proxy::ProxyChannel::Delegate { |
| 57 public: | 57 public: |
| 58 ~PepperPluginRegistry(); | 58 ~PepperPluginRegistry(); |
| 59 | 59 |
| 60 static PepperPluginRegistry* GetInstance(); | 60 static PepperPluginRegistry* GetInstance(); |
| 61 | 61 |
| 62 // Computes the list of known pepper plugins. | 62 // Computes the list of known pepper plugins. |
| 63 // | 63 // |
| 64 // This method is static so that it can be used by the browser process, which | 64 // This method is static so that it can be used by the browser process, which |
| 65 // has no need to load the pepper plugin modules. It will re-compute the | 65 // has no need to load the pepper plugin modules. It will re-compute the |
| 66 // plugin list every time it is called. Generally, code in the registry should | 66 // plugin list every time it is called. Generally, code in the registry should |
| (...skipping 22 matching lines...) Expand all Loading... |
| 89 // the module is available to be returned by GetModule(). The module will | 89 // the module is available to be returned by GetModule(). The module will |
| 90 // automatically unregister itself by calling PluginModuleDestroyed(). | 90 // automatically unregister itself by calling PluginModuleDestroyed(). |
| 91 void AddLiveModule(const FilePath& path, webkit::ppapi::PluginModule* module); | 91 void AddLiveModule(const FilePath& path, webkit::ppapi::PluginModule* module); |
| 92 | 92 |
| 93 // ModuleLifetime implementation. | 93 // ModuleLifetime implementation. |
| 94 virtual void PluginModuleDead(webkit::ppapi::PluginModule* dead_module); | 94 virtual void PluginModuleDead(webkit::ppapi::PluginModule* dead_module); |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 PepperPluginRegistry(); | 97 PepperPluginRegistry(); |
| 98 | 98 |
| 99 // Dispatcher::Delegate implementation. | 99 // ProxyChannel::Delegate implementation. |
| 100 virtual base::MessageLoopProxy* GetIPCMessageLoop(); | 100 virtual base::MessageLoopProxy* GetIPCMessageLoop(); |
| 101 virtual base::WaitableEvent* GetShutdownEvent(); | 101 virtual base::WaitableEvent* GetShutdownEvent(); |
| 102 virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet(); | |
| 103 virtual ppapi::WebKitForwarding* GetWebKitForwarding(); | |
| 104 virtual void PostToWebKitThread(const tracked_objects::Location& from_here, | |
| 105 const base::Closure& task); | |
| 106 | 102 |
| 107 // All known pepper plugins. | 103 // All known pepper plugins. |
| 108 std::vector<PepperPluginInfo> plugin_list_; | 104 std::vector<PepperPluginInfo> plugin_list_; |
| 109 | 105 |
| 110 // Plugins that have been preloaded so they can be executed in-process in | 106 // Plugins that have been preloaded so they can be executed in-process in |
| 111 // the renderer (the sandbox prevents on-demand loading). | 107 // the renderer (the sandbox prevents on-demand loading). |
| 112 typedef std::map<FilePath, scoped_refptr<webkit::ppapi::PluginModule> > | 108 typedef std::map<FilePath, scoped_refptr<webkit::ppapi::PluginModule> > |
| 113 OwningModuleMap; | 109 OwningModuleMap; |
| 114 OwningModuleMap preloaded_modules_; | 110 OwningModuleMap preloaded_modules_; |
| 115 | 111 |
| 116 // A list of non-owning pointers to all currently-live plugin modules. This | 112 // A list of non-owning pointers to all currently-live plugin modules. This |
| 117 // includes both preloaded ones in preloaded_modules_, and out-of-process | 113 // includes both preloaded ones in preloaded_modules_, and out-of-process |
| 118 // modules whose lifetime is managed externally. This will contain only | 114 // modules whose lifetime is managed externally. This will contain only |
| 119 // non-crashed modules. If an out-of-process module crashes, it may | 115 // non-crashed modules. If an out-of-process module crashes, it may |
| 120 // continue as long as there are WebKit references to it, but it will not | 116 // continue as long as there are WebKit references to it, but it will not |
| 121 // appear in this list. | 117 // appear in this list. |
| 122 typedef std::map<FilePath, webkit::ppapi::PluginModule*> NonOwningModuleMap; | 118 typedef std::map<FilePath, webkit::ppapi::PluginModule*> NonOwningModuleMap; |
| 123 NonOwningModuleMap live_modules_; | 119 NonOwningModuleMap live_modules_; |
| 124 | 120 |
| 125 DISALLOW_COPY_AND_ASSIGN(PepperPluginRegistry); | 121 DISALLOW_COPY_AND_ASSIGN(PepperPluginRegistry); |
| 126 }; | 122 }; |
| 127 | 123 |
| 128 #endif // CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_ | 124 #endif // CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_ |
| OLD | NEW |