Commit 690d3e34 authored by tzik@chromium.org's avatar tzik@chromium.org

Revert of Reduce plugin_metrics_provider_ usage in MetricsService...

Revert of Reduce plugin_metrics_provider_ usage in MetricsService (https://codereview.chromium.org/308433004/)

Reason for revert:
This CL seems to cause bot failure on CI:
http://build.chromium.org/p/chromium.memory/builders/Linux%20ASan%20LSan%20Tests%20%281%29/builds/2745

Original issue's description:
> 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
> 
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=274403

TBR=asvitkine@chromium.org,isherman@chromium.org,jochen@chromium.org,blundell@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=375776

Review URL: https://codereview.chromium.org/314583002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274418 0039d316-1c4b-4281-b951-d872f2087c98
parent de46a6d6
...@@ -29,7 +29,6 @@ class IntranetRedirectDetector; ...@@ -29,7 +29,6 @@ class IntranetRedirectDetector;
class IOThread; class IOThread;
class MediaFileSystemRegistry; class MediaFileSystemRegistry;
class MetricsService; class MetricsService;
class MetricsServicesManager;
class NetworkTimeTracker; class NetworkTimeTracker;
class NotificationUIManager; class NotificationUIManager;
class PrefRegistrySimple; class PrefRegistrySimple;
...@@ -103,10 +102,6 @@ class BrowserProcess { ...@@ -103,10 +102,6 @@ class BrowserProcess {
// continue shutdown. // continue shutdown.
virtual void EndSession() = 0; 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 // Services: any of these getters may return NULL
virtual MetricsService* metrics_service() = 0; virtual MetricsService* metrics_service() = 0;
virtual rappor::RapporService* rappor_service() = 0; virtual rappor::RapporService* rappor_service() = 0;
......
...@@ -423,13 +423,6 @@ void BrowserProcessImpl::EndSession() { ...@@ -423,13 +423,6 @@ void BrowserProcessImpl::EndSession() {
#endif #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() { MetricsService* BrowserProcessImpl::metrics_service() {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
return GetMetricsServicesManager()->GetMetricsService(); return GetMetricsServicesManager()->GetMetricsService();
...@@ -993,6 +986,13 @@ void BrowserProcessImpl::CreateSafeBrowsingService() { ...@@ -993,6 +986,13 @@ void BrowserProcessImpl::CreateSafeBrowsingService() {
#endif #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() { void BrowserProcessImpl::ApplyDefaultBrowserPolicy() {
if (local_state()->GetBoolean(prefs::kDefaultBrowserSettingEnabled)) { if (local_state()->GetBoolean(prefs::kDefaultBrowserSettingEnabled)) {
scoped_refptr<ShellIntegration::DefaultWebClientWorker> scoped_refptr<ShellIntegration::DefaultWebClientWorker>
......
...@@ -73,7 +73,6 @@ class BrowserProcessImpl : public BrowserProcess, ...@@ -73,7 +73,6 @@ class BrowserProcessImpl : public BrowserProcess,
// BrowserProcess implementation. // BrowserProcess implementation.
virtual void ResourceDispatcherHostCreated() OVERRIDE; virtual void ResourceDispatcherHostCreated() OVERRIDE;
virtual void EndSession() OVERRIDE; virtual void EndSession() OVERRIDE;
virtual MetricsServicesManager* GetMetricsServicesManager() OVERRIDE;
virtual MetricsService* metrics_service() OVERRIDE; virtual MetricsService* metrics_service() OVERRIDE;
virtual rappor::RapporService* rappor_service() OVERRIDE; virtual rappor::RapporService* rappor_service() OVERRIDE;
virtual IOThread* io_thread() OVERRIDE; virtual IOThread* io_thread() OVERRIDE;
...@@ -153,6 +152,8 @@ class BrowserProcessImpl : public BrowserProcess, ...@@ -153,6 +152,8 @@ class BrowserProcessImpl : public BrowserProcess,
void CreateStatusTray(); void CreateStatusTray();
void CreateBackgroundModeManager(); void CreateBackgroundModeManager();
MetricsServicesManager* GetMetricsServicesManager();
void ApplyAllowCrossOriginAuthPromptPolicy(); void ApplyAllowCrossOriginAuthPromptPolicy();
void ApplyDefaultBrowserPolicy(); void ApplyDefaultBrowserPolicy();
void ApplyMetricsReportingPolicy(); void ApplyMetricsReportingPolicy();
......
...@@ -1313,6 +1313,7 @@ void MetricsService::LogCleanShutdown() { ...@@ -1313,6 +1313,7 @@ void MetricsService::LogCleanShutdown() {
void MetricsService::LogPluginLoadingError(const base::FilePath& plugin_path) { void MetricsService::LogPluginLoadingError(const base::FilePath& plugin_path) {
#if defined(ENABLE_PLUGINS) #if defined(ENABLE_PLUGINS)
// TODO(asvitkine): Move this out of here.
plugin_metrics_provider_->LogPluginLoadingError(plugin_path); plugin_metrics_provider_->LogPluginLoadingError(plugin_path);
#endif #endif
} }
...@@ -1333,6 +1334,7 @@ void MetricsService::RecordBooleanPrefValue(const char* path, bool value) { ...@@ -1333,6 +1334,7 @@ void MetricsService::RecordBooleanPrefValue(const char* path, bool value) {
void MetricsService::RecordCurrentState(PrefService* pref) { void MetricsService::RecordCurrentState(PrefService* pref) {
pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT()); pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT());
for (size_t i = 0; i < metrics_providers_.size(); ++i) #if defined(ENABLE_PLUGINS)
metrics_providers_[i]->RecordCurrentState(); plugin_metrics_provider_->RecordPluginChanges();
#endif
} }
...@@ -206,7 +206,6 @@ class MetricsService ...@@ -206,7 +206,6 @@ class MetricsService
bool recording_active() const; bool recording_active() const;
bool reporting_active() const; bool reporting_active() const;
// TODO(blundell): Move this to ChromeMetricsServiceClient.
void LogPluginLoadingError(const base::FilePath& plugin_path); void LogPluginLoadingError(const base::FilePath& plugin_path);
// Redundant test to ensure that we are notified of a clean exit. // Redundant test to ensure that we are notified of a clean exit.
......
...@@ -58,11 +58,6 @@ MetricsServicesManager::GetVariationsService() { ...@@ -58,11 +58,6 @@ MetricsServicesManager::GetVariationsService() {
return variations_service_.get(); return variations_service_.get();
} }
void MetricsServicesManager::OnPluginLoadingError(
const base::FilePath& plugin_path) {
GetMetricsService()->LogPluginLoadingError(plugin_path);
}
metrics::MetricsStateManager* MetricsServicesManager::GetMetricsStateManager() { metrics::MetricsStateManager* MetricsServicesManager::GetMetricsStateManager() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
if (!metrics_state_manager_) { if (!metrics_state_manager_) {
......
...@@ -13,10 +13,6 @@ class ChromeMetricsServiceClient; ...@@ -13,10 +13,6 @@ class ChromeMetricsServiceClient;
class MetricsService; class MetricsService;
class PrefService; class PrefService;
namespace base {
class FilePath;
}
namespace metrics { namespace metrics {
class MetricsStateManager; class MetricsStateManager;
} }
...@@ -47,9 +43,6 @@ class MetricsServicesManager { ...@@ -47,9 +43,6 @@ class MetricsServicesManager {
// Returns the VariationsService, creating it if it hasn't been created yet. // Returns the VariationsService, creating it if it hasn't been created yet.
chrome_variations::VariationsService* GetVariationsService(); chrome_variations::VariationsService* GetVariationsService();
// Should be called when a plugin loading error occurs.
void OnPluginLoadingError(const base::FilePath& plugin_path);
private: private:
metrics::MetricsStateManager* GetMetricsStateManager(); metrics::MetricsStateManager* GetMetricsStateManager();
......
...@@ -191,9 +191,7 @@ void PluginMetricsProvider::ProvideStabilityMetrics( ...@@ -191,9 +191,7 @@ void PluginMetricsProvider::ProvideStabilityMetrics(
local_state_->ClearPref(prefs::kStabilityPluginStats); local_state_->ClearPref(prefs::kStabilityPluginStats);
} }
// Saves plugin-related updates from the in-object buffer to Local State void PluginMetricsProvider::RecordPluginChanges() {
// for retrieval next time we send a Profile log (generally next launch).
void PluginMetricsProvider::RecordCurrentState() {
ListPrefUpdate update(local_state_, prefs::kStabilityPluginStats); ListPrefUpdate update(local_state_, prefs::kStabilityPluginStats);
base::ListValue* plugins = update.Get(); base::ListValue* plugins = update.Get();
DCHECK(plugins); DCHECK(plugins);
......
...@@ -42,7 +42,10 @@ class PluginMetricsProvider : public metrics::MetricsProvider, ...@@ -42,7 +42,10 @@ class PluginMetricsProvider : public metrics::MetricsProvider,
metrics::SystemProfileProto* system_profile_proto) OVERRIDE; metrics::SystemProfileProto* system_profile_proto) OVERRIDE;
virtual void ProvideStabilityMetrics( virtual void ProvideStabilityMetrics(
metrics::SystemProfileProto* system_profile_proto) OVERRIDE; metrics::SystemProfileProto* system_profile_proto) OVERRIDE;
virtual void RecordCurrentState() 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();
// Notifies the provider about an error loading the plugin at |plugin_path|. // Notifies the provider about an error loading the plugin at |plugin_path|.
void LogPluginLoadingError(const base::FilePath& plugin_path); void LogPluginLoadingError(const base::FilePath& plugin_path);
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/infobars/simple_alert_infobar_delegate.h" #include "chrome/browser/infobars/simple_alert_infobar_delegate.h"
#include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/metrics/metrics_services_manager.h" #include "chrome/browser/metrics/metrics_service.h"
#include "chrome/browser/plugins/plugin_finder.h" #include "chrome/browser/plugins/plugin_finder.h"
#include "chrome/browser/plugins/plugin_infobar_delegates.h" #include "chrome/browser/plugins/plugin_infobar_delegates.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
...@@ -458,8 +458,7 @@ void PluginObserver::OnOpenAboutPlugins() { ...@@ -458,8 +458,7 @@ void PluginObserver::OnOpenAboutPlugins() {
} }
void PluginObserver::OnCouldNotLoadPlugin(const base::FilePath& plugin_path) { void PluginObserver::OnCouldNotLoadPlugin(const base::FilePath& plugin_path) {
g_browser_process->GetMetricsServicesManager()->OnPluginLoadingError( g_browser_process->metrics_service()->LogPluginLoadingError(plugin_path);
plugin_path);
base::string16 plugin_name = base::string16 plugin_name =
PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path); PluginService::GetInstance()->GetPluginDisplayNameByPath(plugin_path);
SimpleAlertInfoBarDelegate::Create( SimpleAlertInfoBarDelegate::Create(
......
...@@ -96,10 +96,6 @@ void TestingBrowserProcess::ResourceDispatcherHostCreated() { ...@@ -96,10 +96,6 @@ void TestingBrowserProcess::ResourceDispatcherHostCreated() {
void TestingBrowserProcess::EndSession() { void TestingBrowserProcess::EndSession() {
} }
MetricsServicesManager* TestingBrowserProcess::GetMetricsServicesManager() {
return NULL;
}
MetricsService* TestingBrowserProcess::metrics_service() { MetricsService* TestingBrowserProcess::metrics_service() {
return NULL; return NULL;
} }
......
...@@ -56,7 +56,6 @@ class TestingBrowserProcess : public BrowserProcess { ...@@ -56,7 +56,6 @@ class TestingBrowserProcess : public BrowserProcess {
virtual void ResourceDispatcherHostCreated() OVERRIDE; virtual void ResourceDispatcherHostCreated() OVERRIDE;
virtual void EndSession() OVERRIDE; virtual void EndSession() OVERRIDE;
virtual MetricsServicesManager* GetMetricsServicesManager() OVERRIDE;
virtual MetricsService* metrics_service() OVERRIDE; virtual MetricsService* metrics_service() OVERRIDE;
virtual rappor::RapporService* rappor_service() OVERRIDE; virtual rappor::RapporService* rappor_service() OVERRIDE;
virtual IOThread* io_thread() OVERRIDE; virtual IOThread* io_thread() OVERRIDE;
......
...@@ -44,9 +44,6 @@ class MetricsProvider { ...@@ -44,9 +44,6 @@ class MetricsProvider {
virtual void ProvideGeneralMetrics( virtual void ProvideGeneralMetrics(
ChromeUserMetricsExtension* uma_proto) {} ChromeUserMetricsExtension* uma_proto) {}
// TODO(asvitkine): Remove this method. http://crbug.com/379148
virtual void RecordCurrentState() {}
private: private:
DISALLOW_COPY_AND_ASSIGN(MetricsProvider); DISALLOW_COPY_AND_ASSIGN(MetricsProvider);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment