Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1759)

Unified Diff: content/common/plugin_list.cc

Issue 128773002: Restart plugin loading only if the plugin list has actually become stale. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/plugin_list.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/plugin_list.cc
diff --git a/content/common/plugin_list.cc b/content/common/plugin_list.cc
index df1f77b3441bc52fe15986729dfbe41a4789b55f..ea74a706fe41da0848d1765d18c6a9dba10372e3 100644
--- a/content/common/plugin_list.cc
+++ b/content/common/plugin_list.cc
@@ -173,14 +173,18 @@ PluginList::PluginList()
plugins_discovery_disabled_(false) {
}
-void PluginList::LoadPlugins(bool include_npapi) {
- {
- base::AutoLock lock(lock_);
- if (loading_state_ == LOADING_STATE_UP_TO_DATE)
- return;
+bool PluginList::PrepareForPluginLoading() {
+ base::AutoLock lock(lock_);
+ if (loading_state_ == LOADING_STATE_UP_TO_DATE)
+ return false;
- loading_state_ = LOADING_STATE_REFRESHING;
- }
+ loading_state_ = LOADING_STATE_REFRESHING;
+ return true;
+}
+
+void PluginList::LoadPlugins(bool include_npapi) {
+ if (!PrepareForPluginLoading())
+ return;
std::vector<WebPluginInfo> new_plugins;
base::Closure will_load_callback;
@@ -201,13 +205,7 @@ void PluginList::LoadPlugins(bool include_npapi) {
LoadPluginIntoPluginList(*it, &new_plugins, &plugin_info);
}
- base::AutoLock lock(lock_);
- plugins_list_.swap(new_plugins);
-
- // 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;
+ SetPlugins(new_plugins);
}
bool PluginList::LoadPluginIntoPluginList(
@@ -280,11 +278,12 @@ void PluginList::GetPluginPathsToLoad(std::vector<base::FilePath>* plugin_paths,
void PluginList::SetPlugins(const std::vector<WebPluginInfo>& plugins) {
base::AutoLock lock(lock_);
- DCHECK_NE(LOADING_STATE_REFRESHING, loading_state_);
- loading_state_ = LOADING_STATE_UP_TO_DATE;
+ // 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;
- plugins_list_.clear();
- plugins_list_.insert(plugins_list_.end(), plugins.begin(), plugins.end());
+ plugins_list_ = plugins;
}
void PluginList::set_will_load_plugins_callback(const base::Closure& callback) {
« no previous file with comments | « content/common/plugin_list.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698