Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5191)

Unified Diff: chrome/browser/metrics/chrome_stability_metrics_provider.cc

Issue 1321313002: Revert of Add tests for Chrome Stability Metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/metrics/chrome_stability_metrics_provider.cc
diff --git a/chrome/browser/metrics/chrome_stability_metrics_provider.cc b/chrome/browser/metrics/chrome_stability_metrics_provider.cc
index d1da84c00b52c9958b2b5415db01f40a9d708099..a26d263d3f6913906dcaef38f4e92358f05fdc64 100644
--- a/chrome/browser/metrics/chrome_stability_metrics_provider.cc
+++ b/chrome/browser/metrics/chrome_stability_metrics_provider.cc
@@ -11,6 +11,7 @@
#include "base/metrics/sparse_histogram.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/pref_names.h"
@@ -41,6 +42,20 @@
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) {
@@ -105,10 +120,7 @@
} // namespace
-ChromeStabilityMetricsProvider::ChromeStabilityMetricsProvider(
- PrefService* local_state)
- : local_state_(local_state) {
- DCHECK(local_state_);
+ChromeStabilityMetricsProvider::ChromeStabilityMetricsProvider() {
BrowserChildProcessObserver::Add(this);
}
@@ -134,38 +146,38 @@
void ChromeStabilityMetricsProvider::ProvideStabilityMetrics(
metrics::SystemProfileProto* system_profile_proto) {
+ PrefService* pref = g_browser_process->local_state();
metrics::SystemProfileProto_Stability* stability_proto =
system_profile_proto->mutable_stability();
- int count = local_state_->GetInteger(prefs::kStabilityPageLoadCount);
+ int count = pref->GetInteger(prefs::kStabilityPageLoadCount);
if (count) {
stability_proto->set_page_load_count(count);
- local_state_->SetInteger(prefs::kStabilityPageLoadCount, 0);
- }
-
- count = local_state_->GetInteger(prefs::kStabilityChildProcessCrashCount);
+ pref->SetInteger(prefs::kStabilityPageLoadCount, 0);
+ }
+
+ count = pref->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);
+ pref->SetInteger(prefs::kStabilityChildProcessCrashCount, 0);
+ }
+
+ count = pref->GetInteger(prefs::kStabilityRendererCrashCount);
if (count) {
stability_proto->set_renderer_crash_count(count);
- local_state_->SetInteger(prefs::kStabilityRendererCrashCount, 0);
- }
-
- count =
- local_state_->GetInteger(prefs::kStabilityExtensionRendererCrashCount);
+ pref->SetInteger(prefs::kStabilityRendererCrashCount, 0);
+ }
+
+ count = pref->GetInteger(prefs::kStabilityExtensionRendererCrashCount);
if (count) {
stability_proto->set_extension_renderer_crash_count(count);
- local_state_->SetInteger(prefs::kStabilityExtensionRendererCrashCount, 0);
- }
-
- count = local_state_->GetInteger(prefs::kStabilityRendererHangCount);
+ pref->SetInteger(prefs::kStabilityExtensionRendererCrashCount, 0);
+ }
+
+ count = pref->GetInteger(prefs::kStabilityRendererHangCount);
if (count) {
stability_proto->set_renderer_hang_count(count);
- local_state_->SetInteger(prefs::kStabilityRendererHangCount, 0);
+ pref->SetInteger(prefs::kStabilityRendererHangCount, 0);
}
#if defined(OS_WIN)
@@ -174,13 +186,15 @@
}
void ChromeStabilityMetricsProvider::ClearSavedStabilityMetrics() {
+ PrefService* local_state = g_browser_process->local_state();
+
// 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::kStabilityPageLoadCount, 0);
- local_state_->SetInteger(prefs::kStabilityRendererCrashCount, 0);
- local_state_->SetInteger(prefs::kStabilityRendererHangCount, 0);
+ local_state->SetInteger(prefs::kStabilityChildProcessCrashCount, 0);
+ local_state->SetInteger(prefs::kStabilityExtensionRendererCrashCount, 0);
+ local_state->SetInteger(prefs::kStabilityPageLoadCount, 0);
+ local_state->SetInteger(prefs::kStabilityRendererCrashCount, 0);
+ local_state->SetInteger(prefs::kStabilityRendererHangCount, 0);
}
// static
@@ -299,16 +313,6 @@
}
}
-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);
}

Powered by Google App Engine
This is Rietveld 408576698