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

Unified Diff: chrome/browser/metrics/variations/variations_service.cc

Issue 12314053: Log the freshness of the Variations seed in a histogram. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 10 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
« no previous file with comments | « no previous file | chrome/common/pref_names.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/variations/variations_service.cc
diff --git a/chrome/browser/metrics/variations/variations_service.cc b/chrome/browser/metrics/variations/variations_service.cc
index 00c7816705d3638bc190824bbf3f7101bc93150f..6807d3d3127056ac5993c59d873929bd16e3786a 100644
--- a/chrome/browser/metrics/variations/variations_service.cc
+++ b/chrome/browser/metrics/variations/variations_service.cc
@@ -215,6 +215,7 @@ void VariationsService::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterStringPref(prefs::kVariationsSeed, std::string());
registry->RegisterInt64Pref(prefs::kVariationsSeedDate,
base::Time().ToInternalValue());
+ registry->RegisterInt64Pref(prefs::kVariationsLastFetchTime, 0);
}
// static
@@ -288,6 +289,25 @@ void VariationsService::OnURLFetchComplete(const net::URLFetcher* source) {
base::TimeDelta::FromMilliseconds(kServerTimeResolutionMs),
latency);
}
+
+ // If this is not the first successful fetch, record the delta between now
+ // and the last successful fetch.
+ int64 internal_now = base::Time::Now().ToInternalValue();
+ int64 last_fetch_time =
+ local_state_->GetInt64(prefs::kVariationsLastFetchTime);
+ if (last_fetch_time) {
+ int64 internal_delta = internal_now - last_fetch_time;
+ DCHECK_GE(internal_delta, 0);
+ base::TimeDelta delta =
+ base::TimeDelta::FromInternalValue(internal_delta);
+ // Note that 10000 is approximately 7 days.
+ UMA_HISTOGRAM_COUNTS_10000("Variations.SeedFreshness",
Ilya Sherman 2013/02/22 00:31:28 You sure you don't want UMA_HISTOGRAM_CUSTOM_TIMES
SteveT 2013/02/22 00:38:37 Hmm, it's a little hard to parse what UMA_HISTOGRA
Ilya Sherman 2013/02/22 00:45:50 You give it bounds for the highest granularity of
SteveT 2013/02/22 01:01:02 So in my latest patch, I used UMA_HISTOGRAM_CUSTOM
Ilya Sherman 2013/02/22 01:12:07 Oh, I see what you mean. You're right, the units
SteveT 2013/02/22 01:26:41 Yeah, if the dashboard had a way to select the tim
+ delta.InMinutes());
+ }
+
+ // Record the time of the most recent successful fetch.
+ local_state_->SetInt64(prefs::kVariationsLastFetchTime,
+ internal_now);
}
if (response_code != net::HTTP_OK) {
« no previous file with comments | « no previous file | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698