summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorblundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-03 01:19:49 +0000
committerblundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-03 01:19:49 +0000
commitdb683c912eaf6b81ba64d49d4b3d796450609c90 (patch)
tree1df96ee27e4cdf4ece4897ed9c59554fa0f854d9
parentfebabf5b375a681dc96d239b5d6d218708ac2a37 (diff)
downloadchromium_src-db683c912eaf6b81ba64d49d4b3d796450609c90.zip
chromium_src-db683c912eaf6b81ba64d49d4b3d796450609c90.tar.gz
chromium_src-db683c912eaf6b81ba64d49d4b3d796450609c90.tar.bz2
Reduce plugin_metrics_provider_ usage in MetricsService
This CL eliminates MetricsService's call to PluginMetricsProvider::RecordPluginChanges (replaced by a new API on MetricsProvider). It additionally adds a MetricsServicesManager::OnPluginLoadingError() API and has the plugin observer call that API rather than calling MetricsService directly. This change will enable easily moving MetricsService::LogPluginLoadingError() to ChromeMetricsServiceClient once the latter is the class that keeps a weak pointer to the plugin metrics provider. BUG=375776 Review URL: https://codereview.chromium.org/308433004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274403 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_process.h5
-rw-r--r--chrome/browser/browser_process_impl.cc14
-rw-r--r--chrome/browser/browser_process_impl.h3
-rw-r--r--chrome/browser/metrics/metrics_service.cc6
-rw-r--r--chrome/browser/metrics/metrics_service.h1
-rw-r--r--chrome/browser/metrics/metrics_services_manager.cc5
-rw-r--r--chrome/browser/metrics/metrics_services_manager.h7
-rw-r--r--chrome/browser/metrics/plugin_metrics_provider.cc4
-rw-r--r--chrome/browser/metrics/plugin_metrics_provider.h5
-rw-r--r--chrome/browser/plugins/plugin_observer.cc5
-rw-r--r--chrome/test/base/testing_browser_process.cc4
-rw-r--r--chrome/test/base/testing_browser_process.h1
-rw-r--r--components/metrics/metrics_provider.h3
13 files changed, 43 insertions, 20 deletions
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h
index 8e46d93..cda9e23 100644
--- a/chrome/browser/browser_process.h
+++ b/chrome/browser/browser_process.h
@@ -29,6 +29,7 @@ class IntranetRedirectDetector;
class IOThread;
class MediaFileSystemRegistry;
class MetricsService;
+class MetricsServicesManager;
class NetworkTimeTracker;
class NotificationUIManager;
class PrefRegistrySimple;
@@ -102,6 +103,10 @@ class BrowserProcess {
// continue shutdown.
virtual void EndSession() = 0;
+ // Gets the manager for the various metrics-related services, constructing it
+ // if necessary.
+ virtual MetricsServicesManager* GetMetricsServicesManager() = 0;
+
// Services: any of these getters may return NULL
virtual MetricsService* metrics_service() = 0;
virtual rappor::RapporService* rappor_service() = 0;
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 33969aa..30f1c08 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -423,6 +423,13 @@ void BrowserProcessImpl::EndSession() {
#endif
}
+MetricsServicesManager* BrowserProcessImpl::GetMetricsServicesManager() {
+ DCHECK(CalledOnValidThread());
+ if (!metrics_services_manager_)
+ metrics_services_manager_.reset(new MetricsServicesManager(local_state()));
+ return metrics_services_manager_.get();
+}
+
MetricsService* BrowserProcessImpl::metrics_service() {
DCHECK(CalledOnValidThread());
return GetMetricsServicesManager()->GetMetricsService();
@@ -986,13 +993,6 @@ void BrowserProcessImpl::CreateSafeBrowsingService() {
#endif
}
-MetricsServicesManager* BrowserProcessImpl::GetMetricsServicesManager() {
- DCHECK(CalledOnValidThread());
- if (!metrics_services_manager_)
- metrics_services_manager_.reset(new MetricsServicesManager(local_state()));
- return metrics_services_manager_.get();
-}
-
void BrowserProcessImpl::ApplyDefaultBrowserPolicy() {
if (local_state()->GetBoolean(prefs::kDefaultBrowserSettingEnabled)) {
scoped_refptr<ShellIntegration::DefaultWebClientWorker>
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index 5631a5e..932ca15 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -73,6 +73,7 @@ class BrowserProcessImpl : public BrowserProcess,
// BrowserProcess implementation.
virtual void ResourceDispatcherHostCreated() OVERRIDE;
virtual void EndSession() OVERRIDE;
+ virtual MetricsServicesManager* GetMetricsServicesManager() OVERRIDE;
virtual MetricsService* metrics_service() OVERRIDE;
virtual rappor::RapporService* rappor_service() OVERRIDE;
virtual IOThread* io_thread() OVERRIDE;
@@ -152,8 +153,6 @@ class BrowserProcessImpl : public BrowserProcess,
void CreateStatusTray();
void CreateBackgroundModeManager();
- MetricsServicesManager* GetMetricsServicesManager();
-
void ApplyAllowCrossOriginAuthPromptPolicy();
void ApplyDefaultBrowserPolicy();
void ApplyMetricsReportingPolicy();
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index c616651..e380d71 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -1313,7 +1313,6 @@ void MetricsService::LogCleanShutdown() {
void MetricsService::LogPluginLoadingError(const base::FilePath& plugin_path) {
#if defined(ENABLE_PLUGINS)
- // TODO(asvitkine): Move this out of here.
plugin_metrics_provider_->LogPluginLoadingError(plugin_path);
#endif
}
@@ -1334,7 +1333,6 @@ void MetricsService::RecordBooleanPrefValue(const char* path, bool value) {
void MetricsService::RecordCurrentState(PrefService* pref) {
pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT());
-#if defined(ENABLE_PLUGINS)
- plugin_metrics_provider_->RecordPluginChanges();
-#endif
+ for (size_t i = 0; i < metrics_providers_.size(); ++i)
+ metrics_providers_[i]->RecordCurrentState();
}
diff --git a/chrome/browser/metrics/metrics_service.h b/chrome/browser/metrics/metrics_service.h
index 116fadf..57c5447 100644
--- a/chrome/browser/metrics/metrics_service.h
+++ b/chrome/browser/metrics/metrics_service.h
@@ -206,6 +206,7 @@ class MetricsService
bool recording_active() const;
bool reporting_active() const;
+ // TODO(blundell): Move this to ChromeMetricsServiceClient.
void LogPluginLoadingError(const base::FilePath& plugin_path);
// Redundant test to ensure that we are notified of a clean exit.
diff --git a/chrome/browser/metrics/metrics_services_manager.cc b/chrome/browser/metrics/metrics_services_manager.cc
index c560dcd..7a6295b 100644
--- a/chrome/browser/metrics/metrics_services_manager.cc
+++ b/chrome/browser/metrics/metrics_services_manager.cc
@@ -58,6 +58,11 @@ MetricsServicesManager::GetVariationsService() {
return variations_service_.get();
}
+void MetricsServicesManager::OnPluginLoadingError(
+ const base::FilePath& plugin_path) {
+ GetMetricsService()->LogPluginLoadingError(plugin_path);
+}
+
metrics::MetricsStateManager* MetricsServicesManager::GetMetricsStateManager() {
DCHECK(thread_checker_.CalledOnValidThread());
if (!metrics_state_manager_) {
diff --git a/chrome/browser/metrics/metrics_services_manager.h b/chrome/browser/metrics/metrics_services_manager.h
index 6e16b16..1d77177 100644
--- a/chrome/browser/metrics/metrics_services_manager.h
+++ b/chrome/browser/metrics/metrics_services_manager.h
@@ -13,6 +13,10 @@ class ChromeMetricsServiceClient;
class MetricsService;
class PrefService;
+namespace base {
+class FilePath;
+}
+
namespace metrics {
class MetricsStateManager;
}
@@ -43,6 +47,9 @@ class MetricsServicesManager {
// Returns the VariationsService, creating it if it hasn't been created yet.
chrome_variations::VariationsService* GetVariationsService();
+ // Should be called when a plugin loading error occurs.
+ void OnPluginLoadingError(const base::FilePath& plugin_path);
+
private:
metrics::MetricsStateManager* GetMetricsStateManager();
diff --git a/chrome/browser/metrics/plugin_metrics_provider.cc b/chrome/browser/metrics/plugin_metrics_provider.cc
index e7633cf..f7f5c1b 100644
--- a/chrome/browser/metrics/plugin_metrics_provider.cc
+++ b/chrome/browser/metrics/plugin_metrics_provider.cc
@@ -191,7 +191,9 @@ void PluginMetricsProvider::ProvideStabilityMetrics(
local_state_->ClearPref(prefs::kStabilityPluginStats);
}
-void PluginMetricsProvider::RecordPluginChanges() {
+// Saves plugin-related updates from the in-object buffer to Local State
+// for retrieval next time we send a Profile log (generally next launch).
+void PluginMetricsProvider::RecordCurrentState() {
ListPrefUpdate update(local_state_, prefs::kStabilityPluginStats);
base::ListValue* plugins = update.Get();
DCHECK(plugins);
diff --git a/chrome/browser/metrics/plugin_metrics_provider.h b/chrome/browser/metrics/plugin_metrics_provider.h
index 14ba222..baabcf7 100644
--- a/chrome/browser/metrics/plugin_metrics_provider.h
+++ b/chrome/browser/metrics/plugin_metrics_provider.h
@@ -42,10 +42,7 @@ class PluginMetricsProvider : public metrics::MetricsProvider,
metrics::SystemProfileProto* system_profile_proto) OVERRIDE;
virtual void ProvideStabilityMetrics(
metrics::SystemProfileProto* system_profile_proto) OVERRIDE;
-
- // Saves plugin-related updates from the in-object buffer to Local State
- // for retrieval next time we send a Profile log (generally next launch).
- void RecordPluginChanges();
+ virtual void RecordCurrentState() OVERRIDE;
// Notifies the provider about an error loading the plugin at |plugin_path|.
void LogPluginLoadingError(const base::FilePath& plugin_path);
diff --git a/chrome/browser/plugins/plugin_observer.cc b/chrome/browser/plugins/plugin_observer.cc
index 9c91704..9accbf8 100644
--- a/chrome/browser/plugins/plugin_observer.cc
+++ b/chrome/browser/plugins/plugin_observer.cc
@@ -15,7 +15,7 @@
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/infobars/simple_alert_infobar_delegate.h"
#include "chrome/browser/lifetime/application_lifetime.h"
-#include "chrome/browser/metrics/metrics_service.h"
+#include "chrome/browser/metrics/metrics_services_manager.h"
#include "chrome/browser/plugins/plugin_finder.h"
#include "chrome/browser/plugins/plugin_infobar_delegates.h"
#include "chrome/browser/profiles/profile.h"
@@ -458,7 +458,8 @@ void PluginObserver::OnOpenAboutPlugins() {
}
void PluginObserver::OnCouldNotLoadPlugin(const base::FilePath& plugin_path) {
- g_browser_process->metrics_service()->LogPluginLoadingError(plugin_path);
+ g_browser_process->GetMetricsServicesManager()->OnPluginLoadingError(
+ plugin_path);
base::string16 plugin_name =
PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path);
SimpleAlertInfoBarDelegate::Create(
diff --git a/chrome/test/base/testing_browser_process.cc b/chrome/test/base/testing_browser_process.cc
index 5960a0c..79acf4b 100644
--- a/chrome/test/base/testing_browser_process.cc
+++ b/chrome/test/base/testing_browser_process.cc
@@ -96,6 +96,10 @@ void TestingBrowserProcess::ResourceDispatcherHostCreated() {
void TestingBrowserProcess::EndSession() {
}
+MetricsServicesManager* TestingBrowserProcess::GetMetricsServicesManager() {
+ return NULL;
+}
+
MetricsService* TestingBrowserProcess::metrics_service() {
return NULL;
}
diff --git a/chrome/test/base/testing_browser_process.h b/chrome/test/base/testing_browser_process.h
index 3ecdf47..2bcb32a 100644
--- a/chrome/test/base/testing_browser_process.h
+++ b/chrome/test/base/testing_browser_process.h
@@ -56,6 +56,7 @@ class TestingBrowserProcess : public BrowserProcess {
virtual void ResourceDispatcherHostCreated() OVERRIDE;
virtual void EndSession() OVERRIDE;
+ virtual MetricsServicesManager* GetMetricsServicesManager() OVERRIDE;
virtual MetricsService* metrics_service() OVERRIDE;
virtual rappor::RapporService* rappor_service() OVERRIDE;
virtual IOThread* io_thread() OVERRIDE;
diff --git a/components/metrics/metrics_provider.h b/components/metrics/metrics_provider.h
index 001e66a..33bf61c 100644
--- a/components/metrics/metrics_provider.h
+++ b/components/metrics/metrics_provider.h
@@ -44,6 +44,9 @@ class MetricsProvider {
virtual void ProvideGeneralMetrics(
ChromeUserMetricsExtension* uma_proto) {}
+ // TODO(asvitkine): Remove this method. http://crbug.com/379148
+ virtual void RecordCurrentState() {}
+
private:
DISALLOW_COPY_AND_ASSIGN(MetricsProvider);
};