diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-14 05:24:21 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-14 05:24:21 +0000 |
commit | c2c901bf406a50085002f8f1d6d63288d6e28c05 (patch) | |
tree | 7eb876216d6c541404fb73c3eaa32f387c8b9e6b /chrome/browser/metrics/metrics_service.cc | |
parent | 684970b638fbfe1a2137fd162f630c86d2859828 (diff) | |
download | chromium_src-c2c901bf406a50085002f8f1d6d63288d6e28c05.zip chromium_src-c2c901bf406a50085002f8f1d6d63288d6e28c05.tar.gz chromium_src-c2c901bf406a50085002f8f1d6d63288d6e28c05.tar.bz2 |
Ensure we don't load plugins on the IO thread.
I had to move the locks from PluginService to PluginList, so that a lock (which can block other threads) isn't held while loading the plugins.
BUG=17938
TEST=added asserts which crash if plugins loaded on IO thread, current UI tests exercise them
Review URL: http://codereview.chromium.org/164305
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23420 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/metrics/metrics_service.cc')
-rw-r--r-- | chrome/browser/metrics/metrics_service.cc | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc index ae4330d..71b162c 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/chrome/browser/metrics/metrics_service.cc @@ -181,7 +181,6 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/load_notification_details.h" #include "chrome/browser/memory_details.h" -#include "chrome/browser/plugin_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/browser/search_engines/template_url.h" @@ -197,6 +196,7 @@ #include "chrome/common/render_messages.h" #include "googleurl/src/gurl.h" #include "net/base/load_flags.h" +#include "webkit/glue/plugins/plugin_list.h" #if defined(OS_POSIX) // TODO(port): Move these headers above as they are ported. @@ -288,9 +288,15 @@ class MetricsMemoryDetails : public MemoryDetails { }; class MetricsService::GetPluginListTaskComplete : public Task { + public: + explicit GetPluginListTaskComplete( + const std::vector<WebPluginInfo>& plugins) : plugins_(plugins) { } virtual void Run() { - g_browser_process->metrics_service()->OnGetPluginListTaskComplete(); + g_browser_process->metrics_service()->OnGetPluginListTaskComplete(plugins_); } + + private: + std::vector<WebPluginInfo> plugins_; }; class MetricsService::GetPluginListTask : public Task { @@ -300,9 +306,10 @@ class MetricsService::GetPluginListTask : public Task { virtual void Run() { std::vector<WebPluginInfo> plugins; - PluginService::GetInstance()->GetPlugins(false, &plugins); + NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins); - callback_loop_->PostTask(FROM_HERE, new GetPluginListTaskComplete()); + callback_loop_->PostTask( + FROM_HERE, new GetPluginListTaskComplete(plugins)); } private: @@ -751,8 +758,10 @@ void MetricsService::InitializeMetricsState() { ScheduleNextStateSave(); } -void MetricsService::OnGetPluginListTaskComplete() { +void MetricsService::OnGetPluginListTaskComplete( + const std::vector<WebPluginInfo>& plugins) { DCHECK(state_ == PLUGIN_LIST_REQUESTED); + plugins_ = plugins; if (state_ == PLUGIN_LIST_REQUESTED) state_ = PLUGIN_LIST_ARRIVED; } @@ -1122,11 +1131,9 @@ bool MetricsService::TransmissionPermitted() const { void MetricsService::PrepareInitialLog() { DCHECK(state_ == PLUGIN_LIST_ARRIVED); - std::vector<WebPluginInfo> plugins; - PluginService::GetInstance()->GetPlugins(false, &plugins); MetricsLog* log = new MetricsLog(client_id_, session_id_); - log->RecordEnvironment(plugins, profile_dictionary_.get()); + log->RecordEnvironment(plugins_, profile_dictionary_.get()); // Histograms only get written to current_log_, so setup for the write. MetricsLog* save_log = current_log_; |