Chromium Code Reviews| 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..9037bf0ee09e179bff5275f0f8377a77c92d2758 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(); |
|
Ilya Sherman
2013/02/22 02:05:05
nit: I'd recommend writing this as
base::Time now
SteveT
2013/02/22 16:14:36
Done.
|
| + 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); |
|
Ilya Sherman
2013/02/22 02:05:05
nit: I'd write this as
base::TimeDelta delta =
SteveT
2013/02/22 16:14:36
Done.
|
| + // Log the value in number of minutes. |
| + UMA_HISTOGRAM_CUSTOM_COUNTS("Variations.SeedFreshness", delta.InMinutes(), |
|
Alexei Svitkine (slow)
2013/02/22 14:13:10
Doing this here will not give us as much info as d
SteveT
2013/02/22 15:17:55
I see, so what we're measuring here is "how recent
|
| + 1, base::TimeDelta::FromDays(7).InMinutes(), 50); |
| + } |
| + |
| + // Record the time of the most recent successful fetch. |
| + local_state_->SetInt64(prefs::kVariationsLastFetchTime, |
| + internal_now); |
| } |
| if (response_code != net::HTTP_OK) { |