diff options
author | blundell <blundell@chromium.org> | 2015-09-28 01:34:16 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-28 08:34:59 +0000 |
commit | 8ae15621b008c8df6a71af4f6a5a3ff28b6131d0 (patch) | |
tree | 75770170a6464cf6f2d31868e537cc2be0e72d2c | |
parent | 07be839f30d97158b803a2cc6dc6509b06c834e1 (diff) | |
download | chromium_src-8ae15621b008c8df6a71af4f6a5a3ff28b6131d0.zip chromium_src-8ae15621b008c8df6a71af4f6a5a3ff28b6131d0.tar.gz chromium_src-8ae15621b008c8df6a71af4f6a5a3ff28b6131d0.tar.bz2 |
Extract guts of ChromeStabilityMetricsProvider into helper class
The iOS port needs to turn down its usage of ChromeStabilityMetricsProvider in
favor of using its own stability metrics provider. To minimize code duplication
between the two providers, this CL extracts the code that will be common
between the two into a shared helper class.
As a necessary dependence, this CL also componentizes
system_memory_stats_recorder*. Those files can be componentized as-is.
BUG=512422
Review URL: https://codereview.chromium.org/1366643002
Cr-Commit-Position: refs/heads/master@{#351036}
21 files changed, 473 insertions, 299 deletions
diff --git a/chrome/browser/android/metrics/uma_session_stats.cc b/chrome/browser/android/metrics/uma_session_stats.cc index 0021a0c..ba80cda 100644 --- a/chrome/browser/android/metrics/uma_session_stats.cc +++ b/chrome/browser/android/metrics/uma_session_stats.cc @@ -119,8 +119,8 @@ static void LogRendererCrash(JNIEnv*, const JavaParamRef<jclass>&) { // Increment the renderer crash count in stability metrics. PrefService* pref = g_browser_process->local_state(); DCHECK(pref); - int value = pref->GetInteger(prefs::kStabilityRendererCrashCount); - pref->SetInteger(prefs::kStabilityRendererCrashCount, value + 1); + int value = pref->GetInteger(metrics::prefs::kStabilityRendererCrashCount); + pref->SetInteger(metrics::prefs::kStabilityRendererCrashCount, value + 1); } static void RegisterExternalExperiment(JNIEnv* env, diff --git a/chrome/browser/memory/tab_manager.cc b/chrome/browser/memory/tab_manager.cc index d21700f..63000f6 100644 --- a/chrome/browser/memory/tab_manager.cc +++ b/chrome/browser/memory/tab_manager.cc @@ -26,7 +26,6 @@ #include "build/build_config.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/memory/oom_memory_details.h" -#include "chrome/browser/memory/system_memory_stats_recorder.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_iterator.h" #include "chrome/browser/ui/browser_list.h" @@ -37,6 +36,7 @@ #include "chrome/browser/ui/tabs/tab_utils.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/url_constants.h" +#include "components/metrics/system_memory_stats_recorder.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/web_contents.h" @@ -293,7 +293,7 @@ void TabManager::RecordDiscardStatistics() { // all platforms. #if defined(OS_WIN) || defined(OS_CHROMEOS) // Record system memory usage at the time of the discard. - RecordMemoryStats(RECORD_MEMORY_STATS_TAB_DISCARDED); + metrics::RecordMemoryStats(metrics::RECORD_MEMORY_STATS_TAB_DISCARDED); #endif // Set up to record the next interval. last_discard_time_ = TimeTicks::Now(); diff --git a/chrome/browser/metrics/chrome_metrics_service_client.cc b/chrome/browser/metrics/chrome_metrics_service_client.cc index 752d0ac..e9858a6 100644 --- a/chrome/browser/metrics/chrome_metrics_service_client.cc +++ b/chrome/browser/metrics/chrome_metrics_service_client.cc @@ -38,6 +38,7 @@ #include "components/metrics/net/version_utils.h" #include "components/metrics/profiler/profiler_metrics_provider.h" #include "components/metrics/profiler/tracking_synchronizer.h" +#include "components/metrics/stability_metrics_helper.h" #include "components/metrics/url_constants.h" #include "components/omnibox/browser/omnibox_metrics_provider.h" #include "components/variations/variations_associated_data.h" @@ -168,7 +169,7 @@ void ChromeMetricsServiceClient::RegisterPrefs(PrefRegistrySimple* registry) { registry->RegisterInt64Pref(prefs::kUninstallLastObservedRunTimeSec, 0); metrics::MetricsService::RegisterPrefs(registry); - ChromeStabilityMetricsProvider::RegisterPrefs(registry); + metrics::StabilityMetricsHelper::RegisterPrefs(registry); #if defined(OS_ANDROID) AndroidMetricsProvider::RegisterPrefs(registry); diff --git a/chrome/browser/metrics/chrome_stability_metrics_provider.cc b/chrome/browser/metrics/chrome_stability_metrics_provider.cc index 823a5bd..35ff811 100644 --- a/chrome/browser/metrics/chrome_stability_metrics_provider.cc +++ b/chrome/browser/metrics/chrome_stability_metrics_provider.cc @@ -9,17 +9,11 @@ #include "base/logging.h" #include "base/metrics/histogram.h" #include "base/metrics/sparse_histogram.h" -#include "base/prefs/pref_registry_simple.h" -#include "base/prefs/pref_service.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/common/chrome_constants.h" -#include "chrome/common/pref_names.h" -#include "components/metrics/proto/system_profile.pb.h" #include "content/public/browser/child_process_data.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" #if defined(ENABLE_EXTENSIONS) #include "extensions/browser/process_map.h" @@ -35,35 +29,8 @@ #include "components/browser_watcher/crash_reporting_metrics_win.h" #endif -#if defined(OS_CHROMEOS) -#include "chrome/browser/memory/system_memory_stats_recorder.h" -#endif - namespace { -enum RendererType { - RENDERER_TYPE_RENDERER = 1, - RENDERER_TYPE_EXTENSION, - // NOTE: Add new action types only immediately above this line. Also, - // make sure the enum list in tools/metrics/histograms/histograms.xml is - // updated with any change in here. - RENDERER_TYPE_COUNT -}; - -// 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); -} - #if defined(OS_WIN) void CountBrowserCrashDumpAttempts() { enum Outcome { @@ -107,17 +74,11 @@ void CountBrowserCrashDumpAttempts() { } #endif // defined(OS_WIN) -void RecordChildKills(int histogram_type) { - UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.ChildKills", - histogram_type, RENDERER_TYPE_COUNT); -} - } // namespace ChromeStabilityMetricsProvider::ChromeStabilityMetricsProvider( PrefService* local_state) - : local_state_(local_state) { - DCHECK(local_state_); + : helper_(local_state) { BrowserChildProcessObserver::Add(this); } @@ -143,53 +104,7 @@ void ChromeStabilityMetricsProvider::OnRecordingDisabled() { void ChromeStabilityMetricsProvider::ProvideStabilityMetrics( metrics::SystemProfileProto* system_profile_proto) { - metrics::SystemProfileProto_Stability* stability_proto = - system_profile_proto->mutable_stability(); - - int count = local_state_->GetInteger(prefs::kStabilityPageLoadCount); - if (count) { - stability_proto->set_page_load_count(count); - local_state_->SetInteger(prefs::kStabilityPageLoadCount, 0); - } - - count = local_state_->GetInteger(prefs::kStabilityChildProcessCrashCount); - if (count) { - stability_proto->set_child_process_crash_count(count); - local_state_->SetInteger(prefs::kStabilityChildProcessCrashCount, 0); - } - - count = local_state_->GetInteger(prefs::kStabilityRendererCrashCount); - if (count) { - stability_proto->set_renderer_crash_count(count); - local_state_->SetInteger(prefs::kStabilityRendererCrashCount, 0); - } - - count = local_state_->GetInteger(prefs::kStabilityRendererFailedLaunchCount); - if (count) { - stability_proto->set_renderer_failed_launch_count(count); - local_state_->SetInteger(prefs::kStabilityRendererFailedLaunchCount, 0); - } - - count = - local_state_->GetInteger(prefs::kStabilityExtensionRendererCrashCount); - if (count) { - stability_proto->set_extension_renderer_crash_count(count); - local_state_->SetInteger(prefs::kStabilityExtensionRendererCrashCount, 0); - } - - count = local_state_->GetInteger( - prefs::kStabilityExtensionRendererFailedLaunchCount); - if (count) { - stability_proto->set_extension_renderer_failed_launch_count(count); - local_state_->SetInteger( - prefs::kStabilityExtensionRendererFailedLaunchCount, 0); - } - - count = local_state_->GetInteger(prefs::kStabilityRendererHangCount); - if (count) { - stability_proto->set_renderer_hang_count(count); - local_state_->SetInteger(prefs::kStabilityRendererHangCount, 0); - } + helper_.ProvideStabilityMetrics(system_profile_proto); #if defined(OS_WIN) CountBrowserCrashDumpAttempts(); @@ -197,32 +112,7 @@ void ChromeStabilityMetricsProvider::ProvideStabilityMetrics( } void ChromeStabilityMetricsProvider::ClearSavedStabilityMetrics() { - // Clear all the prefs used in this class in UMA reports (which doesn't - // include |kUninstallMetricsPageLoadCount| as it's not sent up by UMA). - local_state_->SetInteger(prefs::kStabilityChildProcessCrashCount, 0); - local_state_->SetInteger(prefs::kStabilityExtensionRendererCrashCount, 0); - local_state_->SetInteger(prefs::kStabilityExtensionRendererFailedLaunchCount, - 0); - local_state_->SetInteger(prefs::kStabilityPageLoadCount, 0); - local_state_->SetInteger(prefs::kStabilityRendererCrashCount, 0); - local_state_->SetInteger(prefs::kStabilityRendererFailedLaunchCount, 0); - local_state_->SetInteger(prefs::kStabilityRendererHangCount, 0); -} - -// static -void ChromeStabilityMetricsProvider::RegisterPrefs( - PrefRegistrySimple* registry) { - registry->RegisterIntegerPref(prefs::kStabilityChildProcessCrashCount, 0); - registry->RegisterIntegerPref(prefs::kStabilityExtensionRendererCrashCount, - 0); - registry->RegisterIntegerPref( - prefs::kStabilityExtensionRendererFailedLaunchCount, 0); - registry->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); - registry->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); - registry->RegisterIntegerPref(prefs::kStabilityRendererFailedLaunchCount, 0); - registry->RegisterIntegerPref(prefs::kStabilityRendererHangCount, 0); - - registry->RegisterInt64Pref(prefs::kUninstallMetricsPageLoadCount, 0); + helper_.ClearSavedStabilityMetrics(); } void ChromeStabilityMetricsProvider::Observe( @@ -231,10 +121,7 @@ void ChromeStabilityMetricsProvider::Observe( 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); + helper_.LogLoadStarted(); break; } @@ -242,15 +129,22 @@ void ChromeStabilityMetricsProvider::Observe( content::RenderProcessHost::RendererClosedDetails* process_details = content::Details<content::RenderProcessHost::RendererClosedDetails>( details).ptr(); + bool was_extension_process = false; +#if defined(ENABLE_EXTENSIONS) content::RenderProcessHost* host = content::Source<content::RenderProcessHost>(source).ptr(); - LogRendererCrash( - host, process_details->status, process_details->exit_code); + if (extensions::ProcessMap::Get(host->GetBrowserContext()) + ->Contains(host->GetID())) { + was_extension_process = true; + } +#endif + helper_.LogRendererCrash(was_extension_process, process_details->status, + process_details->exit_code); break; } case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG: - LogRendererHang(); + helper_.LogRendererHang(); break; default: @@ -269,85 +163,5 @@ void ChromeStabilityMetricsProvider::BrowserChildProcessCrashed( return; #endif - IncrementPrefValue(prefs::kStabilityChildProcessCrashCount); -} - -void ChromeStabilityMetricsProvider::LogLoadStarted( - content::WebContents* web_contents) { - content::RecordAction(base::UserMetricsAction("PageLoad")); - // TODO(asvitkine): Check if this is used for anything and if not, remove. - LOCAL_HISTOGRAM_BOOLEAN("Chrome.UmaPageloadCounter", true); - 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) { - int histogram_type = RENDERER_TYPE_RENDERER; - bool was_extension_process = false; -#if defined(ENABLE_EXTENSIONS) - if (extensions::ProcessMap::Get(host->GetBrowserContext()) - ->Contains(host->GetID())) { - histogram_type = RENDERER_TYPE_EXTENSION; - was_extension_process = true; - } -#endif - 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_ENUMERATION("BrowserRenderProcessHost.ChildCrashes", - histogram_type, RENDERER_TYPE_COUNT); - } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { - RecordChildKills(histogram_type); -#if defined(OS_CHROMEOS) - } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM) { - RecordChildKills(histogram_type); - UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.ChildKills.OOM", - was_extension_process ? 2 : 1, - 3); - memory::RecordMemoryStats( - was_extension_process - ? memory::RECORD_MEMORY_STATS_EXTENSIONS_OOM_KILLED - : memory::RECORD_MEMORY_STATS_CONTENTS_OOM_KILLED); -#endif - } else if (status == base::TERMINATION_STATUS_STILL_RUNNING) { - UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.DisconnectedAlive", - histogram_type, RENDERER_TYPE_COUNT); - } else if (status == base::TERMINATION_STATUS_LAUNCH_FAILED) { - UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.ChildLaunchFailures", - histogram_type, RENDERER_TYPE_COUNT); - if (was_extension_process) - IncrementPrefValue(prefs::kStabilityExtensionRendererFailedLaunchCount); - else - IncrementPrefValue(prefs::kStabilityRendererFailedLaunchCount); - } -} - -void ChromeStabilityMetricsProvider::IncrementPrefValue(const char* path) { - int value = local_state_->GetInteger(path); - local_state_->SetInteger(path, value + 1); -} - -void ChromeStabilityMetricsProvider::IncrementLongPrefsValue(const char* path) { - int64 value = local_state_->GetInt64(path); - local_state_->SetInt64(path, value + 1); -} - -void ChromeStabilityMetricsProvider::LogRendererHang() { - IncrementPrefValue(prefs::kStabilityRendererHangCount); + helper_.BrowserChildProcessCrashed(); } diff --git a/chrome/browser/metrics/chrome_stability_metrics_provider.h b/chrome/browser/metrics/chrome_stability_metrics_provider.h index 5ac8547..d9bd23f 100644 --- a/chrome/browser/metrics/chrome_stability_metrics_provider.h +++ b/chrome/browser/metrics/chrome_stability_metrics_provider.h @@ -10,17 +10,11 @@ #include "base/metrics/user_metrics.h" #include "base/process/kill.h" #include "components/metrics/metrics_provider.h" +#include "components/metrics/stability_metrics_helper.h" #include "content/public/browser/browser_child_process_observer.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" -class PrefRegistrySimple; - -namespace content { -class RenderProcessHost; -class WebContents; -} - class PrefService; // ChromeStabilityMetricsProvider gathers and logs Chrome-specific stability- @@ -40,9 +34,6 @@ class ChromeStabilityMetricsProvider metrics::SystemProfileProto* system_profile_proto) override; void ClearSavedStabilityMetrics() override; - // Registers local state prefs used by this class. - static void RegisterPrefs(PrefRegistrySimple* registry); - private: FRIEND_TEST_ALL_PREFIXES(ChromeStabilityMetricsProviderTest, BrowserChildProcessObserver); @@ -59,25 +50,7 @@ class ChromeStabilityMetricsProvider const content::ChildProcessData& data, int exit_code) 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); - - // Increment an Integer pref value specified by |path|. - void IncrementPrefValue(const char* path); - - // Increment a 64-bit Integer pref value specified by |path|. - void IncrementLongPrefsValue(const char* path); - - // Records a renderer process hang. - void LogRendererHang(); - - PrefService* local_state_; + metrics::StabilityMetricsHelper helper_; // Registrar for receiving stability-related notifications. content::NotificationRegistrar registrar_; diff --git a/chrome/browser/metrics/chrome_stability_metrics_provider_unittest.cc b/chrome/browser/metrics/chrome_stability_metrics_provider_unittest.cc index 31a9ad4..e5032ee 100644 --- a/chrome/browser/metrics/chrome_stability_metrics_provider_unittest.cc +++ b/chrome/browser/metrics/chrome_stability_metrics_provider_unittest.cc @@ -33,7 +33,7 @@ namespace { class ChromeStabilityMetricsProviderTest : public testing::Test { protected: ChromeStabilityMetricsProviderTest() : prefs_(new TestingPrefServiceSimple) { - ChromeStabilityMetricsProvider::RegisterPrefs(prefs()->registry()); + metrics::StabilityMetricsHelper::RegisterPrefs(prefs()->registry()); } TestingPrefServiceSimple* prefs() { return prefs_.get(); } diff --git a/chrome/browser/metrics/metrics_service_browsertest.cc b/chrome/browser/metrics/metrics_service_browsertest.cc index f77221c..b3ca37f 100644 --- a/chrome/browser/metrics/metrics_service_browsertest.cc +++ b/chrome/browser/metrics/metrics_service_browsertest.cc @@ -65,8 +65,8 @@ IN_PROC_BROWSER_TEST_F(MetricsServiceBrowserTest, CloseRenderersNormally) { // Verify that the expected stability metrics were recorded. const PrefService* prefs = g_browser_process->local_state(); EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityLaunchCount)); - EXPECT_EQ(3, prefs->GetInteger(prefs::kStabilityPageLoadCount)); - EXPECT_EQ(0, prefs->GetInteger(prefs::kStabilityRendererCrashCount)); + EXPECT_EQ(3, prefs->GetInteger(metrics::prefs::kStabilityPageLoadCount)); + EXPECT_EQ(0, prefs->GetInteger(metrics::prefs::kStabilityRendererCrashCount)); // TODO(isherman): We should also verify that // metrics::prefs::kStabilityExitedCleanly // is set to true, but this preference isn't set until the browser @@ -98,14 +98,14 @@ IN_PROC_BROWSER_TEST_F(MetricsServiceBrowserTest, MAYBE_CrashRenderers) { // since the notification is posted to all observers essentially // simultaneously... so busy waiting here shouldn't be too bad. const PrefService* prefs = g_browser_process->local_state(); - while (!prefs->GetInteger(prefs::kStabilityRendererCrashCount)) { + while (!prefs->GetInteger(metrics::prefs::kStabilityRendererCrashCount)) { content::RunAllPendingInMessageLoop(); } // Verify that the expected stability metrics were recorded. EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityLaunchCount)); - EXPECT_EQ(4, prefs->GetInteger(prefs::kStabilityPageLoadCount)); - EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityRendererCrashCount)); + EXPECT_EQ(4, prefs->GetInteger(metrics::prefs::kStabilityPageLoadCount)); + EXPECT_EQ(1, prefs->GetInteger(metrics::prefs::kStabilityRendererCrashCount)); // TODO(isherman): We should also verify that // metrics::prefs::kStabilityExitedCleanly // is set to true, but this preference isn't set until the browser diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index bae2b8f..d59f73f 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -645,9 +645,6 @@ 'browser/media/webrtc_log_list.h', 'browser/memory/oom_memory_details.cc', 'browser/memory/oom_memory_details.h', - 'browser/memory/system_memory_stats_recorder.h', - 'browser/memory/system_memory_stats_recorder_linux.cc', - 'browser/memory/system_memory_stats_recorder_win.cc', 'browser/memory/tab_manager.cc', 'browser/memory/tab_manager.h', 'browser/memory/tab_manager_delegate_chromeos.cc', @@ -2743,10 +2740,10 @@ 'browser/ssl/chrome_ssl_host_state_delegate_factory.h', 'browser/ssl/common_name_mismatch_handler.cc', 'browser/ssl/common_name_mismatch_handler.h', - 'browser/ssl/security_state_model_android.cc', - 'browser/ssl/security_state_model_android.h', 'browser/ssl/security_state_model.cc', 'browser/ssl/security_state_model.h', + 'browser/ssl/security_state_model_android.cc', + 'browser/ssl/security_state_model_android.h', 'browser/ssl/ssl_blocking_page.cc', 'browser/ssl/ssl_blocking_page.h', 'browser/ssl/ssl_cert_reporter.h', diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 84c4e41..544da59 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -1266,42 +1266,10 @@ const char kCrashReportingEnabled[] = "user_experience_metrics_crash.reporting_enabled"; #endif -// Number of times a page load event occurred since the last report. -const char kStabilityPageLoadCount[] = - "user_experience_metrics.stability.page_load_count"; - -// Number of times a renderer process crashed since the last report. -const char kStabilityRendererCrashCount[] = - "user_experience_metrics.stability.renderer_crash_count"; - -// Number of times a renderer process failed to launch since the last report. -const char kStabilityRendererFailedLaunchCount[] = - "user_experience_metrics.stability.renderer_failed_launch_count"; - -// Number of times an extension renderer process crashed since the last report. -const char kStabilityExtensionRendererCrashCount[] = - "user_experience_metrics.stability.extension_renderer_crash_count"; - -// Number of times an extension renderer process failed to launch since the last -// report. -const char kStabilityExtensionRendererFailedLaunchCount[] = - "user_experience_metrics.stability.extension_renderer_failed_launch_count"; - // This is the location of a list of dictionaries of plugin stability stats. const char kStabilityPluginStats[] = "user_experience_metrics.stability.plugin_stats2"; -// Number of times the renderer has become non-responsive since the last -// report. -const char kStabilityRendererHangCount[] = - "user_experience_metrics.stability.renderer_hang_count"; - -// Total number of child process crashes (other than renderer / extension -// renderer ones, and plugin children, which are counted separately) since the -// last report. -const char kStabilityChildProcessCrashCount[] = - "user_experience_metrics.stability.child_process_crash_count"; - // On Chrome OS, total number of non-Chrome user process crashes // since the last report. const char kStabilityOtherUserCrashCount[] = @@ -1350,8 +1318,6 @@ const char kStabilityPluginLoadingErrors[] = "loading_errors"; // The keys below are strictly increasing counters over the lifetime of // a chrome installation. They are (optionally) sent up to the uninstall // survey in the event of uninstallation. -const char kUninstallMetricsPageLoadCount[] = - "uninstall_metrics.page_load_count"; const char kUninstallLastLaunchTimeSec[] = "uninstall_metrics.last_launch_time_sec"; const char kUninstallLastObservedRunTimeSec[] = diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 6bb6e33..2eae559 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -452,13 +452,6 @@ extern const char kProfileInfoCache[]; extern const char kProfileCreatedByVersion[]; extern const char kProfileResetPromptMementosInLocalState[]; -extern const char kStabilityPageLoadCount[]; -extern const char kStabilityRendererCrashCount[]; -extern const char kStabilityRendererFailedLaunchCount[]; -extern const char kStabilityExtensionRendererCrashCount[]; -extern const char kStabilityExtensionRendererFailedLaunchCount[]; -extern const char kStabilityRendererHangCount[]; -extern const char kStabilityChildProcessCrashCount[]; extern const char kStabilityOtherUserCrashCount[]; extern const char kStabilityKernelCrashCount[]; extern const char kStabilitySystemUncleanShutdownCount[]; @@ -476,7 +469,6 @@ extern const char kStabilityPluginInstances[]; extern const char kStabilityPluginCrashes[]; extern const char kStabilityPluginLoadingErrors[]; -extern const char kUninstallMetricsPageLoadCount[]; extern const char kUninstallLastLaunchTimeSec[]; extern const char kUninstallLastObservedRunTimeSec[]; diff --git a/components/components_tests.gyp b/components/components_tests.gyp index 19a78ae..e0b7077 100644 --- a/components/components_tests.gyp +++ b/components/components_tests.gyp @@ -340,6 +340,7 @@ 'metrics/persisted_logs_unittest.cc', 'metrics/profiler/profiler_metrics_provider_unittest.cc', 'metrics/profiler/tracking_synchronizer_unittest.cc', + 'metrics/stability_metrics_helper_unittest.cc', ], 'mime_util_unittest_sources': [ 'mime_util/mime_util_unittest.cc', diff --git a/components/metrics.gypi b/components/metrics.gypi index e446c88..5910f74 100644 --- a/components/metrics.gypi +++ b/components/metrics.gypi @@ -71,6 +71,11 @@ 'metrics/metrics_switches.h', 'metrics/persisted_logs.cc', 'metrics/persisted_logs.h', + 'metrics/stability_metrics_helper.cc', + 'metrics/stability_metrics_helper.h', + 'metrics/system_memory_stats_recorder.h', + 'metrics/system_memory_stats_recorder_linux.cc', + 'metrics/system_memory_stats_recorder_win.cc', 'metrics/url_constants.cc', 'metrics/url_constants.h', ], diff --git a/components/metrics/BUILD.gn b/components/metrics/BUILD.gn index 3a40392..52ab51d 100644 --- a/components/metrics/BUILD.gn +++ b/components/metrics/BUILD.gn @@ -53,6 +53,11 @@ source_set("metrics") { "metrics_switches.h", "persisted_logs.cc", "persisted_logs.h", + "stability_metrics_helper.cc", + "stability_metrics_helper.h", + "system_memory_stats_recorder.h", + "system_memory_stats_recorder_linux.cc", + "system_memory_stats_recorder_win.cc", "url_constants.cc", "url_constants.h", ] @@ -196,6 +201,7 @@ source_set("unit_tests") { "metrics_state_manager_unittest.cc", "net/net_metrics_log_uploader_unittest.cc", "persisted_logs_unittest.cc", + "stability_metrics_helper_unittest.cc", ] deps = [ diff --git a/components/metrics/metrics_pref_names.cc b/components/metrics/metrics_pref_names.cc index 187b904..3cdebab 100644 --- a/components/metrics/metrics_pref_names.cc +++ b/components/metrics/metrics_pref_names.cc @@ -59,6 +59,12 @@ const char kStabilityBreakpadRegistrationSuccess[] = const char kStabilityBreakpadRegistrationFail[] = "user_experience_metrics.stability.breakpad_registration_fail"; +// Total number of child process crashes (other than renderer / extension +// renderer ones, and plugin children, which are counted separately) since the +// last report. +const char kStabilityChildProcessCrashCount[] = + "user_experience_metrics.stability.child_process_crash_count"; + // Number of times the application exited uncleanly since the last report. const char kStabilityCrashCount[] = "user_experience_metrics.stability.crash_count"; @@ -79,6 +85,15 @@ const char kStabilityExecutionPhase[] = const char kStabilityExitedCleanly[] = "user_experience_metrics.stability.exited_cleanly"; +// Number of times an extension renderer process crashed since the last report. +const char kStabilityExtensionRendererCrashCount[] = + "user_experience_metrics.stability.extension_renderer_crash_count"; + +// Number of times an extension renderer process failed to launch since the last +// report. +const char kStabilityExtensionRendererFailedLaunchCount[] = + "user_experience_metrics.stability.extension_renderer_failed_launch_count"; + // Number of times the session end did not complete. const char kStabilityIncompleteSessionEndCount[] = "user_experience_metrics.stability.incomplete_session_end_count"; @@ -96,6 +111,23 @@ const char kStabilityLaunchCount[] = const char kStabilityLaunchTimeSec[] = "user_experience_metrics.stability.launch_time_sec"; +// Number of times a page load event occurred since the last report. +const char kStabilityPageLoadCount[] = + "user_experience_metrics.stability.page_load_count"; + +// Number of times a renderer process crashed since the last report. +const char kStabilityRendererCrashCount[] = + "user_experience_metrics.stability.renderer_crash_count"; + +// Number of times a renderer process failed to launch since the last report. +const char kStabilityRendererFailedLaunchCount[] = + "user_experience_metrics.stability.renderer_failed_launch_count"; + +// Number of times the renderer has become non-responsive since the last +// report. +const char kStabilityRendererHangCount[] = + "user_experience_metrics.stability.renderer_hang_count"; + // Base64 encoded serialized UMA system profile proto from the previous session. const char kStabilitySavedSystemProfile[] = "user_experience_metrics.stability.saved_system_profile"; @@ -123,6 +155,8 @@ const char kStabilityStatsVersion[] = // a chrome installation. They are (optionally) sent up to the uninstall // survey in the event of uninstallation. const char kUninstallLaunchCount[] = "uninstall_metrics.launch_count"; +const char kUninstallMetricsPageLoadCount[] = + "uninstall_metrics.page_load_count"; const char kUninstallMetricsUptimeSec[] = "uninstall_metrics.uptime_sec"; } // namespace prefs diff --git a/components/metrics/metrics_pref_names.h b/components/metrics/metrics_pref_names.h index 7913a24..f4456a5 100644 --- a/components/metrics/metrics_pref_names.h +++ b/components/metrics/metrics_pref_names.h @@ -21,21 +21,29 @@ extern const char kMetricsReportingEnabledTimestamp[]; extern const char kMetricsSessionID[]; extern const char kStabilityBreakpadRegistrationSuccess[]; extern const char kStabilityBreakpadRegistrationFail[]; +extern const char kStabilityChildProcessCrashCount[]; extern const char kStabilityCrashCount[]; extern const char kStabilityDebuggerPresent[]; extern const char kStabilityDebuggerNotPresent[]; extern const char kStabilityExecutionPhase[]; +extern const char kStabilityExtensionRendererCrashCount[]; +extern const char kStabilityExtensionRendererFailedLaunchCount[]; extern const char kStabilityExitedCleanly[]; extern const char kStabilityIncompleteSessionEndCount[]; extern const char kStabilityLastTimestampSec[]; extern const char kStabilityLaunchCount[]; extern const char kStabilityLaunchTimeSec[]; +extern const char kStabilityPageLoadCount[]; +extern const char kStabilityRendererCrashCount[]; +extern const char kStabilityRendererFailedLaunchCount[]; +extern const char kStabilityRendererHangCount[]; extern const char kStabilitySavedSystemProfile[]; extern const char kStabilitySavedSystemProfileHash[]; extern const char kStabilitySessionEndCompleted[]; extern const char kStabilityStatsBuildTime[]; extern const char kStabilityStatsVersion[]; extern const char kUninstallLaunchCount[]; +extern const char kUninstallMetricsPageLoadCount[]; extern const char kUninstallMetricsUptimeSec[]; } // namespace prefs } // namespace metrics diff --git a/components/metrics/stability_metrics_helper.cc b/components/metrics/stability_metrics_helper.cc new file mode 100644 index 0000000..73aaeec --- /dev/null +++ b/components/metrics/stability_metrics_helper.cc @@ -0,0 +1,218 @@ +// Copyright 2015 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 "components/metrics/stability_metrics_helper.h" + +#include <vector> + +#include "base/logging.h" +#include "base/metrics/histogram.h" +#include "base/metrics/sparse_histogram.h" +#include "base/prefs/pref_registry_simple.h" +#include "base/prefs/pref_service.h" +#include "components/metrics/metrics_pref_names.h" +#include "components/metrics/proto/system_profile.pb.h" + +#if defined(OS_WIN) +#include <windows.h> // Needed for STATUS_* codes +#endif + +#if defined(OS_CHROMEOS) +#include "components/metrics/system_memory_stats_recorder.h" +#endif + +namespace metrics { + +namespace { + +enum RendererType { + RENDERER_TYPE_RENDERER = 1, + RENDERER_TYPE_EXTENSION, + // NOTE: Add new action types only immediately above this line. Also, + // make sure the enum list in tools/metrics/histograms/histograms.xml is + // updated with any change in here. + RENDERER_TYPE_COUNT +}; + +// 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 RecordChildKills(int histogram_type) { + UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.ChildKills", + histogram_type, RENDERER_TYPE_COUNT); +} + +} // namespace + +StabilityMetricsHelper::StabilityMetricsHelper(PrefService* local_state) + : local_state_(local_state) { + DCHECK(local_state_); +} + +StabilityMetricsHelper::~StabilityMetricsHelper() {} + +void StabilityMetricsHelper::ProvideStabilityMetrics( + SystemProfileProto* system_profile_proto) { + SystemProfileProto_Stability* stability_proto = + system_profile_proto->mutable_stability(); + + int count = local_state_->GetInteger(prefs::kStabilityPageLoadCount); + if (count) { + stability_proto->set_page_load_count(count); + local_state_->SetInteger(prefs::kStabilityPageLoadCount, 0); + } + + count = local_state_->GetInteger(prefs::kStabilityChildProcessCrashCount); + if (count) { + stability_proto->set_child_process_crash_count(count); + local_state_->SetInteger(prefs::kStabilityChildProcessCrashCount, 0); + } + + count = local_state_->GetInteger(prefs::kStabilityRendererCrashCount); + if (count) { + stability_proto->set_renderer_crash_count(count); + local_state_->SetInteger(prefs::kStabilityRendererCrashCount, 0); + } + + count = local_state_->GetInteger(prefs::kStabilityRendererFailedLaunchCount); + if (count) { + stability_proto->set_renderer_failed_launch_count(count); + local_state_->SetInteger(prefs::kStabilityRendererFailedLaunchCount, 0); + } + + count = + local_state_->GetInteger(prefs::kStabilityExtensionRendererCrashCount); + if (count) { + stability_proto->set_extension_renderer_crash_count(count); + local_state_->SetInteger(prefs::kStabilityExtensionRendererCrashCount, 0); + } + + count = local_state_->GetInteger( + prefs::kStabilityExtensionRendererFailedLaunchCount); + if (count) { + stability_proto->set_extension_renderer_failed_launch_count(count); + local_state_->SetInteger( + prefs::kStabilityExtensionRendererFailedLaunchCount, 0); + } + + count = local_state_->GetInteger(prefs::kStabilityRendererHangCount); + if (count) { + stability_proto->set_renderer_hang_count(count); + local_state_->SetInteger(prefs::kStabilityRendererHangCount, 0); + } +} + +void StabilityMetricsHelper::ClearSavedStabilityMetrics() { + // Clear all the prefs used in this class in UMA reports (which doesn't + // include |kUninstallMetricsPageLoadCount| as it's not sent up by UMA). + local_state_->SetInteger(prefs::kStabilityChildProcessCrashCount, 0); + local_state_->SetInteger(prefs::kStabilityExtensionRendererCrashCount, 0); + local_state_->SetInteger(prefs::kStabilityExtensionRendererFailedLaunchCount, + 0); + local_state_->SetInteger(prefs::kStabilityPageLoadCount, 0); + local_state_->SetInteger(prefs::kStabilityRendererCrashCount, 0); + local_state_->SetInteger(prefs::kStabilityRendererFailedLaunchCount, 0); + local_state_->SetInteger(prefs::kStabilityRendererHangCount, 0); +} + +// static +void StabilityMetricsHelper::RegisterPrefs(PrefRegistrySimple* registry) { + registry->RegisterIntegerPref(prefs::kStabilityChildProcessCrashCount, 0); + registry->RegisterIntegerPref(prefs::kStabilityExtensionRendererCrashCount, + 0); + registry->RegisterIntegerPref( + prefs::kStabilityExtensionRendererFailedLaunchCount, 0); + registry->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); + registry->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); + registry->RegisterIntegerPref(prefs::kStabilityRendererFailedLaunchCount, 0); + registry->RegisterIntegerPref(prefs::kStabilityRendererHangCount, 0); + + registry->RegisterInt64Pref(prefs::kUninstallMetricsPageLoadCount, 0); +} + +void StabilityMetricsHelper::BrowserChildProcessCrashed() { + IncrementPrefValue(prefs::kStabilityChildProcessCrashCount); +} + +void StabilityMetricsHelper::LogLoadStarted() { + base::RecordAction(base::UserMetricsAction("PageLoad")); + // TODO(asvitkine): Check if this is used for anything and if not, remove. + LOCAL_HISTOGRAM_BOOLEAN("Chrome.UmaPageloadCounter", true); + 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 StabilityMetricsHelper::LogRendererCrash(bool was_extension_process, + base::TerminationStatus status, + int exit_code) { + int histogram_type = + was_extension_process ? RENDERER_TYPE_EXTENSION : RENDERER_TYPE_RENDERER; + 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_ENUMERATION("BrowserRenderProcessHost.ChildCrashes", + histogram_type, RENDERER_TYPE_COUNT); + } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { + RecordChildKills(histogram_type); +#if defined(OS_CHROMEOS) + } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM) { + RecordChildKills(histogram_type); + UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.ChildKills.OOM", + was_extension_process ? 2 : 1, 3); + RecordMemoryStats(was_extension_process + ? RECORD_MEMORY_STATS_EXTENSIONS_OOM_KILLED + : RECORD_MEMORY_STATS_CONTENTS_OOM_KILLED); +#endif + } else if (status == base::TERMINATION_STATUS_STILL_RUNNING) { + UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.DisconnectedAlive", + histogram_type, RENDERER_TYPE_COUNT); + } else if (status == base::TERMINATION_STATUS_LAUNCH_FAILED) { + UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.ChildLaunchFailures", + histogram_type, RENDERER_TYPE_COUNT); + if (was_extension_process) + IncrementPrefValue(prefs::kStabilityExtensionRendererFailedLaunchCount); + else + IncrementPrefValue(prefs::kStabilityRendererFailedLaunchCount); + } +} + +void StabilityMetricsHelper::IncrementPrefValue(const char* path) { + int value = local_state_->GetInteger(path); + local_state_->SetInteger(path, value + 1); +} + +void StabilityMetricsHelper::IncrementLongPrefsValue(const char* path) { + int64 value = local_state_->GetInt64(path); + local_state_->SetInt64(path, value + 1); +} + +void StabilityMetricsHelper::LogRendererHang() { + IncrementPrefValue(prefs::kStabilityRendererHangCount); +} + +} // namespace metrics diff --git a/components/metrics/stability_metrics_helper.h b/components/metrics/stability_metrics_helper.h new file mode 100644 index 0000000..868a842 --- /dev/null +++ b/components/metrics/stability_metrics_helper.h @@ -0,0 +1,63 @@ +// Copyright 2015 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 COMPONENTS_METRICS_STABILITY_METRICS_HELPER_H_ +#define COMPONENTS_METRICS_STABILITY_METRICS_HELPER_H_ + +#include "base/basictypes.h" +#include "base/metrics/user_metrics.h" +#include "base/process/kill.h" + +class PrefRegistrySimple; +class PrefService; + +namespace metrics { + +class SystemProfileProto; + +// StabilityMetricsHelper is a class that providers functionality common to +// different embedders' stability metrics providers. +class StabilityMetricsHelper { + public: + explicit StabilityMetricsHelper(PrefService* local_state); + ~StabilityMetricsHelper(); + + // Provides stability metrics. + void ProvideStabilityMetrics(SystemProfileProto* system_profile_proto); + + // Clears the gathered stability metrics. + void ClearSavedStabilityMetrics(); + + // Records a browser child process crash. + void BrowserChildProcessCrashed(); + + // Logs the initiation of a page load. + void LogLoadStarted(); + + // Records a renderer process crash. + void LogRendererCrash(bool was_exception_process, + base::TerminationStatus status, + int exit_code); + + // Records a renderer process hang. + void LogRendererHang(); + + // Registers local state prefs used by this class. + static void RegisterPrefs(PrefRegistrySimple* registry); + + private: + // Increment an Integer pref value specified by |path|. + void IncrementPrefValue(const char* path); + + // Increment a 64-bit Integer pref value specified by |path|. + void IncrementLongPrefsValue(const char* path); + + PrefService* local_state_; + + DISALLOW_COPY_AND_ASSIGN(StabilityMetricsHelper); +}; + +} // namespace metrics + +#endif // COMPONENTS_METRICS_STABILITY_METRICS_HELPER_H_ diff --git a/components/metrics/stability_metrics_helper_unittest.cc b/components/metrics/stability_metrics_helper_unittest.cc new file mode 100644 index 0000000..a580361 --- /dev/null +++ b/components/metrics/stability_metrics_helper_unittest.cc @@ -0,0 +1,96 @@ +// Copyright 2015 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 "components/metrics/stability_metrics_helper.h" + +#include "base/basictypes.h" +#include "base/prefs/pref_service.h" +#include "base/prefs/scoped_user_pref_update.h" +#include "base/prefs/testing_pref_service.h" +#include "components/metrics/proto/system_profile.pb.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace metrics { + +namespace { + +class StabilityMetricsHelperTest : public testing::Test { + protected: + StabilityMetricsHelperTest() : prefs_(new TestingPrefServiceSimple) { + StabilityMetricsHelper::RegisterPrefs(prefs()->registry()); + } + + TestingPrefServiceSimple* prefs() { return prefs_.get(); } + + private: + scoped_ptr<TestingPrefServiceSimple> prefs_; + + DISALLOW_COPY_AND_ASSIGN(StabilityMetricsHelperTest); +}; + +} // namespace + +TEST_F(StabilityMetricsHelperTest, BrowserChildProcessCrashed) { + StabilityMetricsHelper helper(prefs()); + + helper.BrowserChildProcessCrashed(); + helper.BrowserChildProcessCrashed(); + + // Call ProvideStabilityMetrics to check that it will force pending tasks to + // be executed immediately. + metrics::SystemProfileProto system_profile; + + helper.ProvideStabilityMetrics(&system_profile); + + // Check current number of instances created. + const metrics::SystemProfileProto_Stability& stability = + system_profile.stability(); + + EXPECT_EQ(2, stability.child_process_crash_count()); +} + +TEST_F(StabilityMetricsHelperTest, LogRendererCrash) { + StabilityMetricsHelper helper(prefs()); + + // Crash and abnormal termination should increment renderer crash count. + helper.LogRendererCrash(false, base::TERMINATION_STATUS_PROCESS_CRASHED, 1); + + helper.LogRendererCrash(false, base::TERMINATION_STATUS_ABNORMAL_TERMINATION, + 1); + + // Kill does not increment renderer crash count. + helper.LogRendererCrash(false, base::TERMINATION_STATUS_PROCESS_WAS_KILLED, + 1); + + // Failed launch increments failed launch count. + helper.LogRendererCrash(false, base::TERMINATION_STATUS_LAUNCH_FAILED, 1); + + metrics::SystemProfileProto system_profile; + + // Call ProvideStabilityMetrics to check that it will force pending tasks to + // be executed immediately. + helper.ProvideStabilityMetrics(&system_profile); + + EXPECT_EQ(2, system_profile.stability().renderer_crash_count()); + EXPECT_EQ(1, system_profile.stability().renderer_failed_launch_count()); + EXPECT_EQ(0, system_profile.stability().extension_renderer_crash_count()); + + helper.ClearSavedStabilityMetrics(); + + // Crash and abnormal termination should increment extension crash count. + helper.LogRendererCrash(true, base::TERMINATION_STATUS_PROCESS_CRASHED, 1); + + // Failed launch increments extension failed launch count. + helper.LogRendererCrash(true, base::TERMINATION_STATUS_LAUNCH_FAILED, 1); + + system_profile.Clear(); + helper.ProvideStabilityMetrics(&system_profile); + + EXPECT_EQ(0, system_profile.stability().renderer_crash_count()); + EXPECT_EQ(1, system_profile.stability().extension_renderer_crash_count()); + EXPECT_EQ( + 1, system_profile.stability().extension_renderer_failed_launch_count()); +} + +} // namespace metrics diff --git a/chrome/browser/memory/system_memory_stats_recorder.h b/components/metrics/system_memory_stats_recorder.h index 5dc3540..bdd30f0 100644 --- a/chrome/browser/memory/system_memory_stats_recorder.h +++ b/components/metrics/system_memory_stats_recorder.h @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_MEMORY_SYSTEM_MEMORY_STATS_RECORDER_H_ -#define CHROME_BROWSER_MEMORY_SYSTEM_MEMORY_STATS_RECORDER_H_ +#ifndef COMPONENTS_METRICS_SYSTEM_MEMORY_STATS_RECORDER_H_ +#define COMPONENTS_METRICS_SYSTEM_MEMORY_STATS_RECORDER_H_ -namespace memory { +namespace metrics { // Record a memory size in megabytes, over a potential interval up to 32 GB. #define UMA_HISTOGRAM_LARGE_MEMORY_MB(name, sample) \ @@ -25,6 +25,6 @@ enum RecordMemoryStatsType { void RecordMemoryStats(RecordMemoryStatsType type); -} // namespace memory +} // namespace metrics -#endif // CHROME_BROWSER_MEMORY_SYSTEM_MEMORY_STATS_RECORDER_H_ +#endif // COMPONENTS_METRICS_SYSTEM_MEMORY_STATS_RECORDER_H_ diff --git a/chrome/browser/memory/system_memory_stats_recorder_linux.cc b/components/metrics/system_memory_stats_recorder_linux.cc index fbec6ef..b5b2641 100644 --- a/chrome/browser/memory/system_memory_stats_recorder_linux.cc +++ b/components/metrics/system_memory_stats_recorder_linux.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/memory/system_memory_stats_recorder.h" +#include "components/metrics/system_memory_stats_recorder.h" #include "base/metrics/histogram_macros.h" #include "base/process/process_metrics.h" -namespace memory { +namespace metrics { // Record a size in megabytes, a potential interval from 250MB up to 32 GB. #define UMA_HISTOGRAM_ALLOCATED_MEGABYTES(name, sample) \ @@ -94,4 +94,4 @@ void RecordMemoryStats(RecordMemoryStatsType type) { } } -} // namespace memory +} // namespace metrics diff --git a/chrome/browser/memory/system_memory_stats_recorder_win.cc b/components/metrics/system_memory_stats_recorder_win.cc index b909498..34ff7bc 100644 --- a/chrome/browser/memory/system_memory_stats_recorder_win.cc +++ b/components/metrics/system_memory_stats_recorder_win.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/memory/system_memory_stats_recorder.h" +#include "components/metrics/system_memory_stats_recorder.h" #include <windows.h> #include "base/metrics/histogram_macros.h" #include "base/process/process_metrics.h" -namespace memory { +namespace metrics { void RecordMemoryStats(RecordMemoryStatsType type) { MEMORYSTATUSEX mem_status; @@ -41,4 +41,4 @@ void RecordMemoryStats(RecordMemoryStatsType type) { } } -} // namespace memory +} // namespace metrics |