diff options
author | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-23 07:16:41 +0000 |
---|---|---|
committer | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-23 07:16:41 +0000 |
commit | 29de18fcf349c07bf2c1ec9f1193b17c0a3e09a2 (patch) | |
tree | 693ab97a3061da3e6af24784edeb75fba899bed9 | |
parent | 7d00032db3ba7ce3b34942ade23e4eba596cf9c8 (diff) | |
download | chromium_src-29de18fcf349c07bf2c1ec9f1193b17c0a3e09a2.zip chromium_src-29de18fcf349c07bf2c1ec9f1193b17c0a3e09a2.tar.gz chromium_src-29de18fcf349c07bf2c1ec9f1193b17c0a3e09a2.tar.bz2 |
Introduce ChromeStabilityMetricsProvider
This class provides Chrome-specific stability metrics, enabling moving code
related to these metrics out of MetricsLog and MetricsService. It also
eliminates all notification listening from MetricsService. As part of the
latter change, ThreadWatcherObserver now registers explicitly for the
notifications it is concerned with rather than going through MetricsService for
this purpose.
BUG=375237
Review URL: https://codereview.chromium.org/289283011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272426 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/metrics/chrome_stability_metrics_provider.cc | 188 | ||||
-rw-r--r-- | chrome/browser/metrics/chrome_stability_metrics_provider.h | 58 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_log.cc | 25 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_service.cc | 116 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_service.h | 32 | ||||
-rw-r--r-- | chrome/browser/metrics/thread_watcher.cc | 33 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 |
7 files changed, 284 insertions, 170 deletions
diff --git a/chrome/browser/metrics/chrome_stability_metrics_provider.cc b/chrome/browser/metrics/chrome_stability_metrics_provider.cc new file mode 100644 index 0000000..0af26ef --- /dev/null +++ b/chrome/browser/metrics/chrome_stability_metrics_provider.cc @@ -0,0 +1,188 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/metrics/chrome_stability_metrics_provider.h" + +#include <vector> + +#include "base/logging.h" +#include "base/metrics/histogram.h" +#include "base/metrics/sparse_histogram.h" +#include "base/prefs/pref_service.h" +#include "chrome/browser/browser_process.h" +#include "chrome/browser/chrome_notification_types.h" +#include "chrome/common/pref_names.h" +#include "components/metrics/proto/system_profile.pb.h" +#include "content/public/browser/notification_service.h" +#include "content/public/browser/render_process_host.h" +#include "content/public/browser/user_metrics.h" +#include "content/public/browser/web_contents.h" +#include "extensions/browser/process_map.h" + +#if defined(OS_WIN) +#include <windows.h> // Needed for STATUS_* codes +#endif + +namespace { + +void IncrementPrefValue(const char* path) { + PrefService* pref = g_browser_process->local_state(); + DCHECK(pref); + int value = pref->GetInteger(path); + pref->SetInteger(path, value + 1); +} + +void IncrementLongPrefsValue(const char* path) { + PrefService* pref = g_browser_process->local_state(); + DCHECK(pref); + int64 value = pref->GetInt64(path); + pref->SetInt64(path, value + 1); +} + +// Converts an exit code into something that can be inserted into our +// histograms (which expect non-negative numbers less than MAX_INT). +int MapCrashExitCodeForHistogram(int exit_code) { +#if defined(OS_WIN) + // Since |abs(STATUS_GUARD_PAGE_VIOLATION) == MAX_INT| it causes problems in + // histograms.cc. Solve this by remapping it to a smaller value, which + // hopefully doesn't conflict with other codes. + if (exit_code == STATUS_GUARD_PAGE_VIOLATION) + return 0x1FCF7EC3; // Randomly picked number. +#endif + + return std::abs(exit_code); +} + +} // namespace + +ChromeStabilityMetricsProvider::ChromeStabilityMetricsProvider() { +} + +ChromeStabilityMetricsProvider::~ChromeStabilityMetricsProvider() { +} + +void ChromeStabilityMetricsProvider::OnRecordingEnabled() { + registrar_.Add(this, + content::NOTIFICATION_LOAD_START, + content::NotificationService::AllSources()); + registrar_.Add(this, + content::NOTIFICATION_RENDERER_PROCESS_CLOSED, + content::NotificationService::AllSources()); + registrar_.Add(this, + content::NOTIFICATION_RENDER_WIDGET_HOST_HANG, + content::NotificationService::AllSources()); +} + +void ChromeStabilityMetricsProvider::OnRecordingDisabled() { + registrar_.RemoveAll(); +} + +void ChromeStabilityMetricsProvider::ProvideStabilityMetrics( + metrics::SystemProfileProto_Stability* stability_proto) { + PrefService* pref = g_browser_process->local_state(); + + int count = pref->GetInteger(prefs::kStabilityPageLoadCount); + if (count) { + stability_proto->set_page_load_count(count); + pref->SetInteger(prefs::kStabilityPageLoadCount, 0); + } + + count = pref->GetInteger(prefs::kStabilityRendererCrashCount); + if (count) { + stability_proto->set_renderer_crash_count(count); + pref->SetInteger(prefs::kStabilityRendererCrashCount, 0); + } + + count = pref->GetInteger(prefs::kStabilityExtensionRendererCrashCount); + if (count) { + stability_proto->set_extension_renderer_crash_count(count); + pref->SetInteger(prefs::kStabilityExtensionRendererCrashCount, 0); + } + + count = pref->GetInteger(prefs::kStabilityRendererHangCount); + if (count) { + stability_proto->set_renderer_hang_count(count); + pref->SetInteger(prefs::kStabilityRendererHangCount, 0); + } +} + +void ChromeStabilityMetricsProvider::Observe( + int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) { + switch (type) { + case content::NOTIFICATION_LOAD_START: { + content::NavigationController* controller = + content::Source<content::NavigationController>(source).ptr(); + content::WebContents* web_contents = controller->GetWebContents(); + LogLoadStarted(web_contents); + break; + } + + case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { + content::RenderProcessHost::RendererClosedDetails* process_details = + content::Details<content::RenderProcessHost::RendererClosedDetails>( + details).ptr(); + content::RenderProcessHost* host = + content::Source<content::RenderProcessHost>(source).ptr(); + LogRendererCrash( + host, process_details->status, process_details->exit_code); + break; + } + + case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG: + LogRendererHang(); + break; + + default: + NOTREACHED(); + break; + } +} + +void ChromeStabilityMetricsProvider::LogLoadStarted( + content::WebContents* web_contents) { + content::RecordAction(base::UserMetricsAction("PageLoad")); + HISTOGRAM_ENUMERATION("Chrome.UmaPageloadCounter", 1, 2); + IncrementPrefValue(prefs::kStabilityPageLoadCount); + IncrementLongPrefsValue(prefs::kUninstallMetricsPageLoadCount); + // We need to save the prefs, as page load count is a critical stat, and it + // might be lost due to a crash :-(. +} + +void ChromeStabilityMetricsProvider::LogRendererCrash( + content::RenderProcessHost* host, + base::TerminationStatus status, + int exit_code) { + bool was_extension_process = + extensions::ProcessMap::Get(host->GetBrowserContext()) + ->Contains(host->GetID()); + if (status == base::TERMINATION_STATUS_PROCESS_CRASHED || + status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { + if (was_extension_process) { + IncrementPrefValue(prefs::kStabilityExtensionRendererCrashCount); + + UMA_HISTOGRAM_SPARSE_SLOWLY("CrashExitCodes.Extension", + MapCrashExitCodeForHistogram(exit_code)); + } else { + IncrementPrefValue(prefs::kStabilityRendererCrashCount); + + UMA_HISTOGRAM_SPARSE_SLOWLY("CrashExitCodes.Renderer", + MapCrashExitCodeForHistogram(exit_code)); + } + + UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes", + was_extension_process ? 2 : 1); + } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { + UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKills", + was_extension_process ? 2 : 1); + } else if (status == base::TERMINATION_STATUS_STILL_RUNNING) { + UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.DisconnectedAlive", + was_extension_process ? 2 : 1); + } +} + +void ChromeStabilityMetricsProvider::LogRendererHang() { + IncrementPrefValue(prefs::kStabilityRendererHangCount); +} diff --git a/chrome/browser/metrics/chrome_stability_metrics_provider.h b/chrome/browser/metrics/chrome_stability_metrics_provider.h new file mode 100644 index 0000000..246f7d7 --- /dev/null +++ b/chrome/browser/metrics/chrome_stability_metrics_provider.h @@ -0,0 +1,58 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_METRICS_CHROME_STABILITY_METRICS_PROVIDER_H_ +#define CHROME_BROWSER_METRICS_CHROME_STABILITY_METRICS_PROVIDER_H_ + +#include "base/basictypes.h" +#include "base/metrics/user_metrics.h" +#include "base/process/kill.h" +#include "components/metrics/metrics_provider.h" +#include "content/public/browser/notification_observer.h" +#include "content/public/browser/notification_registrar.h" + +namespace content { +class RenderProcessHost; +class WebContents; +} + +// ChromeStabilityMetricsProvider gathers and logs Chrome-specific stability- +// related metrics. +class ChromeStabilityMetricsProvider : public metrics::MetricsProvider, + public content::NotificationObserver { + public: + ChromeStabilityMetricsProvider(); + virtual ~ChromeStabilityMetricsProvider(); + + // metrics::MetricsDataProvider: + virtual void OnRecordingEnabled() OVERRIDE; + virtual void OnRecordingDisabled() OVERRIDE; + virtual void ProvideStabilityMetrics( + metrics::SystemProfileProto_Stability* stability_proto) OVERRIDE; + + private: + // content::NotificationObserver: + virtual void Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) OVERRIDE; + + // Logs the initiation of a page load and uses |web_contents| to do + // additional logging of the type of page loaded. + void LogLoadStarted(content::WebContents* web_contents); + + // Records a renderer process crash. + void LogRendererCrash(content::RenderProcessHost* host, + base::TerminationStatus status, + int exit_code); + + // Records a renderer process hang. + void LogRendererHang(); + + // Registrar for receiving stability-related notifications. + content::NotificationRegistrar registrar_; + + DISALLOW_COPY_AND_ASSIGN(ChromeStabilityMetricsProvider); +}; + +#endif // CHROME_BROWSER_METRICS_CHROME_STABILITY_METRICS_PROVIDER_H_ diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc index 27c1295..f4ae797 100644 --- a/chrome/browser/metrics/metrics_log.cc +++ b/chrome/browser/metrics/metrics_log.cc @@ -478,31 +478,8 @@ void MetricsLog::WriteRealtimeStabilityAttributes( SystemProfileProto::Stability* stability = uma_proto()->mutable_system_profile()->mutable_stability(); - int count = pref->GetInteger(prefs::kStabilityPageLoadCount); - if (count) { - stability->set_page_load_count(count); - pref->SetInteger(prefs::kStabilityPageLoadCount, 0); - } - - count = pref->GetInteger(prefs::kStabilityRendererCrashCount); - if (count) { - stability->set_renderer_crash_count(count); - pref->SetInteger(prefs::kStabilityRendererCrashCount, 0); - } - - count = pref->GetInteger(prefs::kStabilityExtensionRendererCrashCount); - if (count) { - stability->set_extension_renderer_crash_count(count); - pref->SetInteger(prefs::kStabilityExtensionRendererCrashCount, 0); - } - - count = pref->GetInteger(prefs::kStabilityRendererHangCount); - if (count) { - stability->set_renderer_hang_count(count); - pref->SetInteger(prefs::kStabilityRendererHangCount, 0); - } - count = pref->GetInteger(prefs::kStabilityChildProcessCrashCount); + int count = pref->GetInteger(prefs::kStabilityChildProcessCrashCount); if (count) { stability->set_child_process_crash_count(count); pref->SetInteger(prefs::kStabilityChildProcessCrashCount, 0); diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc index 8a9367e..063f12f 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/chrome/browser/metrics/metrics_service.cc @@ -185,6 +185,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/io_thread.h" +#include "chrome/browser/metrics/chrome_stability_metrics_provider.h" #include "chrome/browser/metrics/compression_utils.h" #include "chrome/browser/metrics/metrics_log.h" #include "chrome/browser/metrics/metrics_state_manager.h" @@ -202,15 +203,11 @@ #include "components/variations/entropy_provider.h" #include "components/variations/metrics_util.h" #include "content/public/browser/child_process_data.h" -#include "content/public/browser/load_notification_details.h" -#include "content/public/browser/notification_service.h" #include "content/public/browser/plugin_service.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/user_metrics.h" -#include "content/public/browser/web_contents.h" #include "content/public/common/process_type.h" #include "content/public/common/webplugininfo.h" -#include "extensions/browser/process_map.h" #include "net/base/load_flags.h" #include "net/url_request/url_fetcher.h" @@ -233,7 +230,6 @@ using base::Time; using content::BrowserThread; using content::ChildProcessData; -using content::LoadNotificationDetails; using content::PluginService; using metrics::MetricsLogManager; @@ -298,20 +294,6 @@ ResponseStatus ResponseCodeToStatus(int response_code) { } } -// Converts an exit code into something that can be inserted into our -// histograms (which expect non-negative numbers less than MAX_INT). -int MapCrashExitCodeForHistogram(int exit_code) { -#if defined(OS_WIN) - // Since |abs(STATUS_GUARD_PAGE_VIOLATION) == MAX_INT| it causes problems in - // histograms.cc. Solve this by remapping it to a smaller value, which - // hopefully doesn't conflict with other codes. - if (exit_code == STATUS_GUARD_PAGE_VIOLATION) - return 0x1FCF7EC3; // Randomly picked number. -#endif - - return std::abs(exit_code); -} - void MarkAppCleanShutdownAndCommit() { PrefService* pref = g_browser_process->local_state(); pref->SetBoolean(prefs::kStabilityExitedCleanly, true); @@ -468,6 +450,8 @@ MetricsService::MetricsService(metrics::MetricsStateManager* state_manager, scoped_ptr<metrics::MetricsProvider>(new NetworkMetricsProvider)); RegisterMetricsProvider( scoped_ptr<metrics::MetricsProvider>(new OmniboxMetricsProvider)); + RegisterMetricsProvider( + scoped_ptr<metrics::MetricsProvider>(new ChromeStabilityMetricsProvider)); #if defined(OS_WIN) google_update_metrics_provider_ = new GoogleUpdateMetricsProviderWin; @@ -553,7 +537,6 @@ void MetricsService::EnableRecording() { for (size_t i = 0; i < metrics_providers_.size(); ++i) metrics_providers_[i]->OnRecordingEnabled(); - SetUpNotifications(®istrar_, this); base::RemoveActionCallback(action_callback_); action_callback_ = base::Bind(&MetricsService::OnUserAction, base::Unretained(this)); @@ -568,7 +551,6 @@ void MetricsService::DisableRecording() { recording_active_ = false; base::RemoveActionCallback(action_callback_); - registrar_.RemoveAll(); for (size_t i = 0; i < metrics_providers_.size(); ++i) metrics_providers_[i]->OnRecordingDisabled(); @@ -587,18 +569,6 @@ bool MetricsService::reporting_active() const { return reporting_active_; } -// static -void MetricsService::SetUpNotifications( - content::NotificationRegistrar* registrar, - content::NotificationObserver* observer) { - registrar->Add(observer, content::NOTIFICATION_LOAD_START, - content::NotificationService::AllSources()); - registrar->Add(observer, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, - content::NotificationService::AllSources()); - registrar->Add(observer, content::NOTIFICATION_RENDER_WIDGET_HOST_HANG, - content::NotificationService::AllSources()); -} - void MetricsService::RecordDelta(const base::HistogramBase& histogram, const base::HistogramSamples& snapshot) { log_manager_.current_log()->RecordHistogramDelta(histogram.histogram_name(), @@ -641,42 +611,6 @@ void MetricsService::BrowserChildProcessInstanceCreated( GetChildProcessStats(data).instances++; } -void MetricsService::Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) { - DCHECK(log_manager_.current_log()); - DCHECK(IsSingleThreaded()); - - switch (type) { - case content::NOTIFICATION_LOAD_START: { - content::NavigationController* controller = - content::Source<content::NavigationController>(source).ptr(); - content::WebContents* web_contents = controller->GetWebContents(); - LogLoadStarted(web_contents); - break; - } - - case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { - content::RenderProcessHost::RendererClosedDetails* process_details = - content::Details< - content::RenderProcessHost::RendererClosedDetails>( - details).ptr(); - content::RenderProcessHost* host = - content::Source<content::RenderProcessHost>(source).ptr(); - LogRendererCrash( - host, process_details->status, process_details->exit_code); - break; - } - - case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG: - LogRendererHang(); - break; - - default: - NOTREACHED(); - } -} - void MetricsService::HandleIdleSinceLastTransmission(bool in_idle) { // If there wasn't a lot of action, maybe the computer was asleep, in which // case, the log transmissions should have stopped. Here we start them up @@ -1504,50 +1438,6 @@ void MetricsService::IncrementLongPrefsValue(const char* path) { pref->SetInt64(path, value + 1); } -void MetricsService::LogLoadStarted(content::WebContents* web_contents) { - content::RecordAction(base::UserMetricsAction("PageLoad")); - HISTOGRAM_ENUMERATION("Chrome.UmaPageloadCounter", 1, 2); - IncrementPrefValue(prefs::kStabilityPageLoadCount); - IncrementLongPrefsValue(prefs::kUninstallMetricsPageLoadCount); - // We need to save the prefs, as page load count is a critical stat, and it - // might be lost due to a crash :-(. -} - -void MetricsService::LogRendererCrash(content::RenderProcessHost* host, - base::TerminationStatus status, - int exit_code) { - bool was_extension_process = - extensions::ProcessMap::Get(host->GetBrowserContext()) - ->Contains(host->GetID()); - if (status == base::TERMINATION_STATUS_PROCESS_CRASHED || - status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { - if (was_extension_process) { - IncrementPrefValue(prefs::kStabilityExtensionRendererCrashCount); - - UMA_HISTOGRAM_SPARSE_SLOWLY("CrashExitCodes.Extension", - MapCrashExitCodeForHistogram(exit_code)); - } else { - IncrementPrefValue(prefs::kStabilityRendererCrashCount); - - UMA_HISTOGRAM_SPARSE_SLOWLY("CrashExitCodes.Renderer", - MapCrashExitCodeForHistogram(exit_code)); - } - - UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes", - was_extension_process ? 2 : 1); - } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { - UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKills", - was_extension_process ? 2 : 1); - } else if (status == base::TERMINATION_STATUS_STILL_RUNNING) { - UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.DisconnectedAlive", - was_extension_process ? 2 : 1); - } -} - -void MetricsService::LogRendererHang() { - IncrementPrefValue(prefs::kStabilityRendererHangCount); -} - bool MetricsService::UmaMetricsProperlyShutdown() { CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN || clean_shutdown_status_ == NEED_TO_SHUTDOWN); diff --git a/chrome/browser/metrics/metrics_service.h b/chrome/browser/metrics/metrics_service.h index af6dc9d..f229028 100644 --- a/chrome/browser/metrics/metrics_service.h +++ b/chrome/browser/metrics/metrics_service.h @@ -13,6 +13,7 @@ #include <vector> #include "base/basictypes.h" +#include "base/files/file_path.h" #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" @@ -22,7 +23,6 @@ #include "base/metrics/histogram_snapshot_manager.h" #include "base/metrics/user_metrics.h" #include "base/observer_list.h" -#include "base/process/kill.h" #include "base/threading/thread_checker.h" #include "base/time/time.h" #include "chrome/browser/metrics/metrics_log.h" @@ -32,8 +32,6 @@ #include "components/metrics/metrics_service_observer.h" #include "components/variations/active_field_trials.h" #include "content/public/browser/browser_child_process_observer.h" -#include "content/public/browser/notification_observer.h" -#include "content/public/browser/notification_registrar.h" #include "content/public/browser/user_metrics.h" #include "net/url_request/url_fetcher_delegate.h" @@ -53,8 +51,6 @@ struct ActiveGroupId; } namespace content { -class RenderProcessHost; -class WebContents; struct WebPluginInfo; } @@ -95,7 +91,6 @@ class MetricsService : public base::HistogramFlattener, public chrome_browser_metrics::TrackingSynchronizerObserver, public content::BrowserChildProcessObserver, - public content::NotificationObserver, public net::URLFetcherDelegate { public: // The execution phase of the browser. @@ -166,12 +161,6 @@ class MetricsService // types we'll be using. static void RegisterPrefs(PrefRegistrySimple* registry); - // Set up notifications which indicate that a user is performing work. This is - // useful to allow some features to sleep, until the machine becomes active, - // such as precluding UMA uploads unless there was recent activity. - static void SetUpNotifications(content::NotificationRegistrar* registrar, - content::NotificationObserver* observer); - // HistogramFlattener: virtual void RecordDelta(const base::HistogramBase& histogram, const base::HistogramSamples& snapshot) OVERRIDE; @@ -189,11 +178,6 @@ class MetricsService virtual void BrowserChildProcessInstanceCreated( const content::ChildProcessData& data) OVERRIDE; - // content::NotificationObserver: - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) OVERRIDE; - // This should be called when the application is not idle, i.e. the user seems // to be interacting with the application. void OnApplicationNotIdle(); @@ -413,14 +397,6 @@ class MetricsService // stored as a string. void IncrementLongPrefsValue(const char* path); - // Records a renderer process crash. - void LogRendererCrash(content::RenderProcessHost* host, - base::TerminationStatus status, - int exit_code); - - // Records a renderer process hang. - void LogRendererHang(); - // Records that the browser was shut down cleanly. void LogCleanShutdown(); @@ -436,10 +412,6 @@ class MetricsService // buffered plugin stability statistics. void RecordCurrentState(PrefService* pref); - // Logs the initiation of a page load and uses |web_contents| to do - // additional logging of the type of page loaded. - void LogLoadStarted(content::WebContents* web_contents); - // Checks whether events should currently be logged. bool ShouldLogEvents(); @@ -485,8 +457,6 @@ class MetricsService base::ActionCallback action_callback_; - content::NotificationRegistrar registrar_; - // Indicate whether recording and reporting are currently happening. // These should not be set directly, but by calling SetRecording and // SetReporting. diff --git a/chrome/browser/metrics/thread_watcher.cc b/chrome/browser/metrics/thread_watcher.cc index 75c7d5c..ca5395e 100644 --- a/chrome/browser/metrics/thread_watcher.cc +++ b/chrome/browser/metrics/thread_watcher.cc @@ -11,16 +11,18 @@ #include "base/debug/alias.h" #include "base/debug/dump_without_crashing.h" #include "base/lazy_instance.h" +#include "base/metrics/field_trial.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" #include "base/strings/string_tokenizer.h" #include "base/strings/stringprintf.h" #include "base/threading/thread_restrictions.h" #include "build/build_config.h" -#include "chrome/browser/metrics/metrics_service.h" +#include "chrome/browser/chrome_notification_types.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_version_info.h" #include "chrome/common/logging_chrome.h" +#include "content/public/browser/notification_service.h" #if defined(OS_WIN) #include "base/win/windows_version.h" @@ -783,7 +785,34 @@ void ThreadWatcherObserver::SetupNotifications( const base::TimeDelta& wakeup_interval) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); ThreadWatcherObserver* observer = new ThreadWatcherObserver(wakeup_interval); - MetricsService::SetUpNotifications(&observer->registrar_, observer); + observer->registrar_.Add( + observer, + chrome::NOTIFICATION_BROWSER_OPENED, + content::NotificationService::AllBrowserContextsAndSources()); + observer->registrar_.Add(observer, + chrome::NOTIFICATION_BROWSER_CLOSED, + content::NotificationService::AllSources()); + observer->registrar_.Add(observer, + chrome::NOTIFICATION_TAB_PARENTED, + content::NotificationService::AllSources()); + observer->registrar_.Add(observer, + chrome::NOTIFICATION_TAB_CLOSING, + content::NotificationService::AllSources()); + observer->registrar_.Add(observer, + content::NOTIFICATION_LOAD_START, + content::NotificationService::AllSources()); + observer->registrar_.Add(observer, + content::NOTIFICATION_LOAD_STOP, + content::NotificationService::AllSources()); + observer->registrar_.Add(observer, + content::NOTIFICATION_RENDERER_PROCESS_CLOSED, + content::NotificationService::AllSources()); + observer->registrar_.Add(observer, + content::NOTIFICATION_RENDER_WIDGET_HOST_HANG, + content::NotificationService::AllSources()); + observer->registrar_.Add(observer, + chrome::NOTIFICATION_OMNIBOX_OPENED_URL, + content::NotificationService::AllSources()); } // static diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 180f68b..e191450 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1189,6 +1189,8 @@ 'browser/metrics/chrome_metrics_service_accessor.h', 'browser/metrics/chrome_metrics_service_client.cc', 'browser/metrics/chrome_metrics_service_client.h', + 'browser/metrics/chrome_stability_metrics_provider.cc', + 'browser/metrics/chrome_stability_metrics_provider.h', 'browser/metrics/compression_utils.cc', 'browser/metrics/compression_utils.h', 'browser/metrics/extension_metrics.cc', |