From c2c901bf406a50085002f8f1d6d63288d6e28c05 Mon Sep 17 00:00:00 2001 From: "jam@chromium.org" Date: Fri, 14 Aug 2009 05:24:21 +0000 Subject: 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 --- chrome/browser/metrics/metrics_service.cc | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'chrome/browser/metrics/metrics_service.cc') 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& plugins) : plugins_(plugins) { } virtual void Run() { - g_browser_process->metrics_service()->OnGetPluginListTaskComplete(); + g_browser_process->metrics_service()->OnGetPluginListTaskComplete(plugins_); } + + private: + std::vector plugins_; }; class MetricsService::GetPluginListTask : public Task { @@ -300,9 +306,10 @@ class MetricsService::GetPluginListTask : public Task { virtual void Run() { std::vector 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& 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 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_; -- cgit v1.1