Chromium Code Reviews| Index: chrome/browser/plugin_finder.h |
| diff --git a/chrome/browser/plugin_finder.h b/chrome/browser/plugin_finder.h |
| index b3fd718cf041dd9d4be616a3a4421c6841b8254b..8c6d2bb045d78c887ea0ce9c47698094251625c2 100644 |
| --- a/chrome/browser/plugin_finder.h |
| +++ b/chrome/browser/plugin_finder.h |
| @@ -10,7 +10,7 @@ |
| #include "base/callback.h" |
| #include "base/gtest_prod_util.h" |
| -#include "base/hash_tables.h" |
| +#include "base/synchronization/lock.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/memory/singleton.h" |
| #include "base/string16.h" |
| @@ -21,19 +21,25 @@ class DictionaryValue; |
| } |
| class GURL; |
| +class PluginMetadata; |
| + |
| +#if defined(ENABLE_PLUGIN_INSTALLATION) |
| class PluginInstaller; |
| +#endif |
| +// This class should be created by calling the |GetInstance()| on the UI |
| +// thread. After that it can be safely used on any other thread. |
| class PluginFinder { |
| public: |
| - typedef std::vector<webkit::WebPluginInfo> PluginVector; |
| - typedef base::Callback<void(const PluginVector&, PluginFinder*)> |
| - CombinedCallback; |
| - // Gets PluginFinder and vector of Plugins asynchronously. It then |
| - // calls |cb| once both are fetched. |
| - static void GetPluginsAndPluginFinder(const CombinedCallback& cb); |
| + static PluginFinder* GetInstance(); |
| + // It should be called on the UI thread. |
| + void Init(); |
| + |
| + // TODO(ibraaaa): DELETE. http://crbug.com/124396 |
| static void Get(const base::Callback<void(PluginFinder*)>& cb); |
| +#if defined(ENABLE_PLUGIN_INSTALLATION) |
| // Finds a plug-in for the given MIME type and language (specified as an IETF |
| // language tag, i.e. en-US) and returns the PluginInstaller for the plug-in, |
| // or NULL if no plug-in is found. |
| @@ -42,9 +48,14 @@ class PluginFinder { |
| // Returns the plug-in with the given identifier. |
| PluginInstaller* FindPluginWithIdentifier(const std::string& identifier); |
|
ibraaaa
2012/09/11 09:43:34
This is only used in plugin_observer.cc because it
|
| +#endif |
| + |
| + // Returns the plug-in metadata with the given identifier. |
| + PluginMetadata* FindPluginMetadataWithIdentifier( |
| + const std::string& identifier); |
| - // Gets a plug-in installer using |plugin|. |
| - PluginInstaller* GetPluginInstaller(const webkit::WebPluginInfo& plugin); |
| + // Gets plug-in metadata using |plugin|. |
| + PluginMetadata* GetPluginMetadata(const webkit::WebPluginInfo& plugin); |
| private: |
| friend struct DefaultSingletonTraits<PluginFinder>; |
| @@ -52,8 +63,6 @@ class PluginFinder { |
| FRIEND_TEST_ALL_PREFIXES(PluginFinderTest, JsonSyntax); |
| FRIEND_TEST_ALL_PREFIXES(PluginFinderTest, PluginGroups); |
| - static PluginFinder* GetInstance(); |
| - |
| PluginFinder(); |
| ~PluginFinder(); |
| @@ -61,16 +70,27 @@ class PluginFinder { |
| // Returns NULL if the plug-in list couldn't be parsed. |
| static base::DictionaryValue* LoadPluginList(); |
| - PluginInstaller* CreateInstaller(const std::string& identifier, |
| - const base::DictionaryValue* plugin_dict); |
| + PluginMetadata* CreatePluginMetadata( |
| + const std::string& identifier, |
| + const base::DictionaryValue* plugin_dict); |
| scoped_ptr<base::DictionaryValue> plugin_list_; |
| +#if defined(ENABLE_PLUGIN_INSTALLATION) |
| std::map<std::string, PluginInstaller*> installers_; |
| +#endif |
| + |
| + std::map<std::string, PluginMetadata*> identifier_plugin_; |
| - // Note: Don't free memory for |name_insallers_| values |
| + // Note: Don't free memory for |name_plugin_| values |
| // since it holds pointers to same instances |
| - // in |installers_| (Double De-allocation). |
| - base::hash_map<string16, PluginInstaller*> name_installers_; |
| + // in |identifier_plugin_| (Double De-allocation). |
| + std::map<string16, PluginMetadata*> name_plugin_; |
| + |
| + // Synchronization for |installers_|, |identifier_plugin_| and |
| + // |name_plugin_| are required since multiple threads |
| + // can be accessing them concurrently. No synchronization is needed |
| + // for |plugin_list_| since it is read-only after initialization. |
| + base::Lock mutex_; |
| DISALLOW_COPY_AND_ASSIGN(PluginFinder); |
| }; |