diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-16 11:35:44 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-16 11:35:44 +0000 |
commit | df51faef2439747f2d7616ca73eff8db5ae20c11 (patch) | |
tree | 4241c135616b00d803ac28ec9c08e2586719dbc9 /webkit/plugins | |
parent | e9c5d5d43ceb19a46f8a76d1bd7ae5aaa669c1c5 (diff) | |
download | chromium_src-df51faef2439747f2d7616ca73eff8db5ae20c11.zip chromium_src-df51faef2439747f2d7616ca73eff8db5ae20c11.tar.gz chromium_src-df51faef2439747f2d7616ca73eff8db5ae20c11.tar.bz2 |
Sequentialize calls to PluginList::GetPlugins from PluginService.
BUG=105987
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10381087
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137396 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins')
-rw-r--r-- | webkit/plugins/npapi/plugin_list.cc | 25 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_list.h | 23 |
2 files changed, 30 insertions, 18 deletions
diff --git a/webkit/plugins/npapi/plugin_list.cc b/webkit/plugins/npapi/plugin_list.cc index 0b04b31..6023fee 100644 --- a/webkit/plugins/npapi/plugin_list.cc +++ b/webkit/plugins/npapi/plugin_list.cc @@ -232,7 +232,7 @@ bool PluginList::DebugPluginLoading() { void PluginList::RefreshPlugins() { base::AutoLock lock(lock_); - plugins_need_refresh_ = true; + loading_state_ = LOADING_STATE_NEEDS_REFRESH; } void PluginList::AddExtraPluginPath(const FilePath& plugin_path) { @@ -371,7 +371,7 @@ bool PluginList::ParseMimeTypes( } PluginList::PluginList() - : plugins_need_refresh_(true) { + : loading_state_(LOADING_STATE_NEEDS_REFRESH) { PlatformInit(); AddHardcodedPluginGroups(kGroupDefinitions, ARRAYSIZE_UNSAFE(kGroupDefinitions)); @@ -379,7 +379,7 @@ PluginList::PluginList() PluginList::PluginList(const PluginGroupDefinition* definitions, size_t num_definitions) - : plugins_need_refresh_(true) { + : loading_state_(LOADING_STATE_NEEDS_REFRESH) { // Don't do platform-dependend initialization in unit tests. AddHardcodedPluginGroups(definitions, num_definitions); } @@ -398,12 +398,8 @@ void PluginList::LoadPluginsInternal(ScopedVector<PluginGroup>* plugin_groups) { base::Closure will_load_callback; { base::AutoLock lock(lock_); - // Clear the refresh bit now, because it might get set again before we - // reach the end of the method. - plugins_need_refresh_ = false; will_load_callback = will_load_plugins_callback_; } - if (!will_load_callback.is_null()) will_load_callback.Run(); @@ -421,8 +417,10 @@ void PluginList::LoadPluginsInternal(ScopedVector<PluginGroup>* plugin_groups) { void PluginList::LoadPlugins() { { base::AutoLock lock(lock_); - if (!plugins_need_refresh_) + if (loading_state_ == LOADING_STATE_UP_TO_DATE) return; + + loading_state_ = LOADING_STATE_REFRESHING; } ScopedVector<PluginGroup> new_plugin_groups; @@ -431,6 +429,10 @@ void PluginList::LoadPlugins() { base::AutoLock lock(lock_); plugin_groups_.swap(new_plugin_groups); + // If we haven't been invalidated in the mean time, mark the plug-in list as + // up-to-date. + if (loading_state_ != LOADING_STATE_NEEDS_REFRESH) + loading_state_ = LOADING_STATE_UP_TO_DATE; } bool PluginList::LoadPlugin(const FilePath& path, @@ -504,7 +506,8 @@ const std::vector<PluginGroup*>& PluginList::GetHardcodedPluginGroups() const { void PluginList::SetPlugins(const std::vector<webkit::WebPluginInfo>& plugins) { base::AutoLock lock(lock_); - plugins_need_refresh_ = false; + DCHECK_NE(LOADING_STATE_REFRESHING, loading_state_); + loading_state_ = LOADING_STATE_UP_TO_DATE; plugin_groups_.reset(); for (std::vector<webkit::WebPluginInfo>::const_iterator it = plugins.begin(); @@ -532,7 +535,7 @@ void PluginList::GetPlugins(std::vector<WebPluginInfo>* plugins) { bool PluginList::GetPluginsIfNoRefreshNeeded( std::vector<webkit::WebPluginInfo>* plugins) { base::AutoLock lock(lock_); - if (plugins_need_refresh_) + if (loading_state_ != LOADING_STATE_UP_TO_DATE) return false; for (size_t i = 0; i < plugin_groups_.size(); ++i) { @@ -557,7 +560,7 @@ void PluginList::GetPluginInfoArray( LoadPlugins(); base::AutoLock lock(lock_); if (use_stale) - *use_stale = plugins_need_refresh_; + *use_stale = (loading_state_ != LOADING_STATE_UP_TO_DATE); info->clear(); if (actual_mime_types) actual_mime_types->clear(); diff --git a/webkit/plugins/npapi/plugin_list.h b/webkit/plugins/npapi/plugin_list.h index d01b38f..a948782 100644 --- a/webkit/plugins/npapi/plugin_list.h +++ b/webkit/plugins/npapi/plugin_list.h @@ -121,7 +121,7 @@ class WEBKIT_PLUGINS_EXPORT PluginList { const string16& mime_type_descriptions, std::vector<webkit::WebPluginMimeType>* parsed_mime_types); - // Get all the plugins synchronously. + // Get all the plugins synchronously, loading them if necessary. void GetPlugins(std::vector<webkit::WebPluginInfo>* plugins); // Returns true if the list of plugins is cached and is copied into the out @@ -195,6 +195,17 @@ class WEBKIT_PLUGINS_EXPORT PluginList { ScopedVector<PluginGroup>* plugin_groups); private: + enum LoadingState { + LOADING_STATE_NEEDS_REFRESH, + LOADING_STATE_REFRESHING, + LOADING_STATE_UP_TO_DATE, + }; + + struct InternalPlugin { + webkit::WebPluginInfo info; + PluginEntryPoints entry_points; + }; + friend class PluginListTest; friend struct base::DefaultLazyInstanceTraits<PluginList>; FRIEND_TEST_ALL_PREFIXES(PluginGroupTest, PluginGroupDefinition); @@ -268,8 +279,10 @@ class WEBKIT_PLUGINS_EXPORT PluginList { // Internals // - // If true, we reload plugins even if they've been loaded already. - bool plugins_need_refresh_; + // States whether we will load the plug-in list the next time we try to access + // it, whether we are currently in the process of loading it, or whether we + // consider it up-to-date. + LoadingState loading_state_; // Extra plugin paths that we want to search when loading. std::vector<FilePath> extra_plugin_paths_; @@ -277,10 +290,6 @@ class WEBKIT_PLUGINS_EXPORT PluginList { // Extra plugin directories that we want to search when loading. std::vector<FilePath> extra_plugin_dirs_; - struct InternalPlugin { - webkit::WebPluginInfo info; - PluginEntryPoints entry_points; - }; // Holds information about internal plugins. std::vector<InternalPlugin> internal_plugins_; |