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

Unified Diff: components/startup_metric_utils/browser/startup_metric_utils.cc

Issue 1619273003: Add Startup.SameVersionStartupCount histogram (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@b0_lukewarm_startup_stats
Patch Set: merge Created 4 years, 11 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: components/startup_metric_utils/browser/startup_metric_utils.cc
diff --git a/components/startup_metric_utils/browser/startup_metric_utils.cc b/components/startup_metric_utils/browser/startup_metric_utils.cc
index 36196e4beca65518707038d1158bceab5a038a9f..53dfba3259f95255ad2de3f13df47e76240c1dae 100644
--- a/components/startup_metric_utils/browser/startup_metric_utils.cc
+++ b/components/startup_metric_utils/browser/startup_metric_utils.cc
@@ -19,6 +19,8 @@
#include "base/threading/platform_thread.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
+#include "components/startup_metric_utils/browser/pref_names.h"
+#include "components/version_info/version_info.h"
#if defined(OS_WIN)
#include <winternl.h>
@@ -30,9 +32,6 @@ namespace startup_metric_utils {
namespace {
-const char kLastStartupTimestampPref[] =
- "startup_metric.last_startup_timestamp";
-
// Mark as volatile to defensively make sure usage is thread-safe.
// Note that at the time of this writing, access is only on the UI thread.
volatile bool g_non_browser_ui_displayed = false;
@@ -406,7 +405,9 @@ bool GetHardFaultCountForCurrentProcess(uint32_t* hard_fault_count) {
void RegisterPrefs(PrefRegistrySimple* registry) {
DCHECK(registry);
- registry->RegisterInt64Pref(kLastStartupTimestampPref, 0);
+ registry->RegisterInt64Pref(prefs::kLastStartupTimestamp, 0);
+ registry->RegisterStringPref(prefs::kLastStartupVersion, std::string());
+ registry->RegisterIntegerPref(prefs::kSameVersionStartupCount, 0);
}
bool WasNonBrowserUIDisplayed() {
@@ -514,7 +515,7 @@ void RecordTimeSinceLastStartup(PrefService* pref_service) {
// Get the timestamp of the last startup from |pref_service|.
const int64_t last_startup_timestamp_internal =
- pref_service->GetInt64(kLastStartupTimestampPref);
+ pref_service->GetInt64(prefs::kLastStartupTimestamp);
if (last_startup_timestamp_internal != 0) {
// Log the Startup.TimeSinceLastStartup histogram.
const base::Time last_startup_timestamp =
@@ -532,11 +533,33 @@ void RecordTimeSinceLastStartup(PrefService* pref_service) {
}
// Write the timestamp of the current startup in |pref_service|.
- pref_service->SetInt64(kLastStartupTimestampPref,
+ pref_service->SetInt64(prefs::kLastStartupTimestamp,
process_start_time.ToInternalValue());
#endif // defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX)
}
+void RecordStartupCount(PrefService* pref_service) {
+ DCHECK(pref_service);
+
+ const std::string current_version = version_info::GetVersionNumber();
+
+ int startups_with_current_version = 0;
+ if (current_version == pref_service->GetString(prefs::kLastStartupVersion)) {
+ startups_with_current_version =
+ pref_service->GetInteger(prefs::kSameVersionStartupCount);
+ ++startups_with_current_version;
+ pref_service->SetInteger(prefs::kSameVersionStartupCount,
+ startups_with_current_version);
+ } else {
+ startups_with_current_version = 1;
+ pref_service->SetString(prefs::kLastStartupVersion, current_version);
+ pref_service->SetInteger(prefs::kSameVersionStartupCount, 1);
+ }
+
+ UMA_HISTOGRAM_COUNTS_100("Startup.SameVersionStartupCount",
+ startups_with_current_version);
+}
+
void RecordBrowserWindowDisplay(const base::TimeTicks& ticks) {
static bool is_first_call = true;
if (!is_first_call || ticks.is_null())
« no previous file with comments | « components/startup_metric_utils/browser/startup_metric_utils.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698