summaryrefslogtreecommitdiffstats
path: root/chrome/browser/metrics/metrics_service.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/metrics/metrics_service.cc')
-rw-r--r--chrome/browser/metrics/metrics_service.cc57
1 files changed, 25 insertions, 32 deletions
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index 82cdeac..5839171 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -174,7 +174,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_model.h"
@@ -285,38 +284,34 @@ class MetricsMemoryDetails : public MemoryDetails {
DISALLOW_EVIL_CONSTRUCTORS(MetricsMemoryDetails);
};
-// This object and its static functions manage the calls to and from
-// the plugin service. It lives on the IO thread. It only lives long
-// enough to handle the callback, then it deletes itself.
-class GetPluginListClient : public PluginService::GetPluginListClient {
+class MetricsService::GetPluginListTaskComplete : public Task {
public:
- // Call GetPluginList on a GetPluginListClient. Used to proxy this call
- // from the UI thread to the IO thread.
- static void CallGetPluginList(GetPluginListClient* client) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
- PluginService::GetInstance()->GetPluginList(false, client);
+ explicit GetPluginListTaskComplete(
+ const std::vector<WebPluginInfo>& plugins) : plugins_(plugins) { }
+ virtual void Run() {
+ g_browser_process->metrics_service()->OnGetPluginListTaskComplete(plugins_);
}
- // Callback from the PluginService when the plugin list has been retrieved.
- virtual void OnGetPluginList(const std::vector<WebPluginInfo>& plugins) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
- // Forward back to the UI thread.
- ChromeThread::PostTask(
- ChromeThread::UI, FROM_HERE,
- NewRunnableFunction(&GetPluginListClient::GetPluginListComplete,
- plugins));
- delete this;
- }
+ private:
+ std::vector<WebPluginInfo> plugins_;
+};
+
+class MetricsService::GetPluginListTask : public Task {
+ public:
+ explicit GetPluginListTask(MessageLoop* callback_loop)
+ : callback_loop_(callback_loop) {}
- // A function to proxy the plugin list back from the IO thread to the UI
- // thread to call the metrics service.
- // |plugins| is intentionally pass by value.
- static void GetPluginListComplete(const std::vector<WebPluginInfo> plugins) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
- g_browser_process->metrics_service()->OnGetPluginListComplete(plugins);
+ virtual void Run() {
+ std::vector<WebPluginInfo> plugins;
+ NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins);
+
+ callback_loop_->PostTask(
+ FROM_HERE, new GetPluginListTaskComplete(plugins));
}
-};
+ private:
+ MessageLoop* callback_loop_;
+};
// static
void MetricsService::RegisterPrefs(PrefService* local_state) {
@@ -750,7 +745,7 @@ void MetricsService::InitializeMetricsState() {
ScheduleNextStateSave();
}
-void MetricsService::OnGetPluginListComplete(
+void MetricsService::OnGetPluginListTaskComplete(
const std::vector<WebPluginInfo>& plugins) {
DCHECK(state_ == PLUGIN_LIST_REQUESTED);
plugins_ = plugins;
@@ -831,10 +826,8 @@ void MetricsService::StartRecording() {
// Make sure the plugin list is loaded before the inital log is sent, so
// that the main thread isn't blocked generating the list.
- ChromeThread::PostDelayedTask(
- ChromeThread::IO, FROM_HERE,
- NewRunnableFunction(&GetPluginListClient::CallGetPluginList,
- new GetPluginListClient),
+ g_browser_process->file_thread()->message_loop()->PostDelayedTask(FROM_HERE,
+ new GetPluginListTask(MessageLoop::current()),
kInitialInterlogDuration * 1000 / 2);
}
}