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..4c576d9101ec0bdb8d443f64632d22c6d90e64d9 100644 |
| --- a/chrome/browser/metrics/variations/variations_service.cc |
| +++ b/chrome/browser/metrics/variations/variations_service.cc |
| @@ -177,6 +177,20 @@ bool VariationsService::CreateTrialsFromSeed() { |
| } |
| } |
| + // Log the "freshness" of the seed that was just used. The freshness is the |
| + // time between the last successful seed download and now. |
| + base::Time now = base::Time::Now(); |
|
Alexei Svitkine (slow)
2013/02/22 16:26:25
Move this into the if statement. Make it const.
SteveT
2013/02/22 18:12:03
Done.
|
| + int64 last_fetch_time_internal = |
|
Alexei Svitkine (slow)
2013/02/22 16:26:25
Nit: const.
SteveT
2013/02/22 18:12:03
Done.
|
| + local_state_->GetInt64(prefs::kVariationsLastFetchTime); |
| + if (last_fetch_time_internal) { |
| + DCHECK_GE(now.ToInternalValue(), last_fetch_time_internal); |
|
Alexei Svitkine (slow)
2013/02/22 16:26:25
This may happen if the user changed his system tim
SteveT
2013/02/22 18:12:03
Removed the DCHECK.
I think the histogram might j
Ilya Sherman
2013/02/22 23:26:16
Yes, negative values end up in the lowest bucket,
|
| + base::TimeDelta delta = |
|
Alexei Svitkine (slow)
2013/02/22 16:26:25
Nit: const.
SteveT
2013/02/22 18:12:03
Done.
|
| + now - base::Time::FromInternalValue(last_fetch_time_internal); |
| + // Log the value in number of minutes. |
| + UMA_HISTOGRAM_CUSTOM_COUNTS("Variations.SeedFreshness", delta.InMinutes(), |
| + 1, base::TimeDelta::FromDays(7).InMinutes(), 50); |
|
Alexei Svitkine (slow)
2013/02/22 16:26:25
I would say let's use 30 days, just to get a more
SteveT
2013/02/22 18:12:03
Done.
|
| + } |
| + |
| return true; |
| } |
| @@ -215,6 +229,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 +303,10 @@ void VariationsService::OnURLFetchComplete(const net::URLFetcher* source) { |
| base::TimeDelta::FromMilliseconds(kServerTimeResolutionMs), |
| latency); |
| } |
| + |
| + // Record the time of the most recent successful fetch. |
| + local_state_->SetInt64(prefs::kVariationsLastFetchTime, |
| + base::Time::Now().ToInternalValue()); |
| } |
| if (response_code != net::HTTP_OK) { |