Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/metrics/variations/variations_service.h" | 5 #include "chrome/browser/metrics/variations/variations_service.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/build_time.h" | 9 #include "base/build_time.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 variations::VariationsSeedProcessor().CreateTrialsFromSeed( | 269 variations::VariationsSeedProcessor().CreateTrialsFromSeed( |
| 270 seed, | 270 seed, |
| 271 g_browser_process->GetApplicationLocale(), | 271 g_browser_process->GetApplicationLocale(), |
| 272 GetReferenceDateForExpiryChecks(local_state_), | 272 GetReferenceDateForExpiryChecks(local_state_), |
| 273 current_version, | 273 current_version, |
| 274 GetChannelForVariations(), | 274 GetChannelForVariations(), |
| 275 GetCurrentFormFactor(), | 275 GetCurrentFormFactor(), |
| 276 GetHardwareClass(), | 276 GetHardwareClass(), |
| 277 base::Bind(&OverrideUIString)); | 277 base::Bind(&OverrideUIString)); |
| 278 | 278 |
| 279 const base::Time now = base::Time::Now(); | |
| 280 | |
| 279 // Log the "freshness" of the seed that was just used. The freshness is the | 281 // Log the "freshness" of the seed that was just used. The freshness is the |
| 280 // time between the last successful seed download and now. | 282 // time between the last successful seed download and now. |
| 281 const int64 last_fetch_time_internal = | 283 const int64 last_fetch_time_internal = |
| 282 local_state_->GetInt64(prefs::kVariationsLastFetchTime); | 284 local_state_->GetInt64(prefs::kVariationsLastFetchTime); |
| 283 if (last_fetch_time_internal) { | 285 if (last_fetch_time_internal) { |
| 284 const base::Time now = base::Time::Now(); | |
| 285 const base::TimeDelta delta = | 286 const base::TimeDelta delta = |
| 286 now - base::Time::FromInternalValue(last_fetch_time_internal); | 287 now - base::Time::FromInternalValue(last_fetch_time_internal); |
| 287 // Log the value in number of minutes. | 288 // Log the value in number of minutes. |
| 288 UMA_HISTOGRAM_CUSTOM_COUNTS("Variations.SeedFreshness", delta.InMinutes(), | 289 UMA_HISTOGRAM_CUSTOM_COUNTS("Variations.SeedFreshness", delta.InMinutes(), |
| 289 1, base::TimeDelta::FromDays(30).InMinutes(), 50); | 290 1, base::TimeDelta::FromDays(30).InMinutes(), 50); |
| 290 } | 291 } |
| 291 | 292 |
| 293 // Log the skew between the seed date and the system clock/build time to | |
| 294 // analyze whether either could be used to make old variations seeds expire | |
| 295 // after some time. | |
| 296 const int64 seed_date_internal = | |
| 297 local_state_->GetInt64(prefs::kVariationsSeedDate); | |
|
Alexei Svitkine (slow)
2014/10/02 13:00:32
Note that if we do start using this to make decisi
gab
2014/10/02 14:03:23
Right that makes sense, we can discuss implementat
| |
| 298 if (seed_date_internal) { | |
| 299 const base::Time seed_date = | |
| 300 base::Time::FromInternalValue(seed_date_internal); | |
| 301 const int system_clock_delta_days = (now - seed_date).InDays(); | |
| 302 if (system_clock_delta_days < 0) { | |
| 303 UMA_HISTOGRAM_CUSTOM_COUNTS("Variations.SeedDateSkew.SystemClockBehindBy", | |
| 304 -system_clock_delta_days, | |
| 305 1, | |
| 306 100, | |
| 307 30); | |
| 308 } else { | |
| 309 UMA_HISTOGRAM_CUSTOM_COUNTS("Variations.SeedDateSkew.SystemClockAheadBy", | |
| 310 system_clock_delta_days, | |
| 311 0, | |
| 312 100, | |
| 313 30); | |
| 314 } | |
| 315 | |
| 316 const int build_time_delta_days = | |
| 317 (base::GetBuildTime() - seed_date).InDays(); | |
| 318 if (build_time_delta_days < 0) { | |
| 319 UMA_HISTOGRAM_CUSTOM_COUNTS("Variations.SeedDateSkew.BuildTimeBehindBy", | |
| 320 -build_time_delta_days, | |
| 321 1, | |
| 322 100, | |
| 323 30); | |
| 324 } else { | |
| 325 UMA_HISTOGRAM_CUSTOM_COUNTS("Variations.SeedDateSkew.BuildTimeAheadBy", | |
|
Alexei Svitkine (slow)
2014/10/02 13:00:32
I suggest using UMA_HISTOGRAM_COUNTS_100() for all
gab
2014/10/02 14:03:23
UMA_HISTOGRAM_COUNTS_100 is from 1 to 100; I assum
Alexei Svitkine (slow)
2014/10/02 14:05:00
Yes, there's always an underflow bucket - in this
| |
| 326 build_time_delta_days, | |
| 327 0, | |
| 328 100, | |
| 329 30); | |
| 330 } | |
| 331 } | |
| 332 | |
| 292 return true; | 333 return true; |
| 293 } | 334 } |
| 294 | 335 |
| 295 void VariationsService::StartRepeatedVariationsSeedFetch() { | 336 void VariationsService::StartRepeatedVariationsSeedFetch() { |
| 296 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 337 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 297 | 338 |
| 298 // Initialize the Variations server URL. | 339 // Initialize the Variations server URL. |
| 299 variations_server_url_ = GetVariationsServerURL(policy_pref_service_); | 340 variations_server_url_ = GetVariationsServerURL(policy_pref_service_); |
| 300 | 341 |
| 301 // Check that |CreateTrialsFromSeed| was called, which is necessary to | 342 // Check that |CreateTrialsFromSeed| was called, which is necessary to |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 601 | 642 |
| 602 void VariationsService::RecordLastFetchTime() { | 643 void VariationsService::RecordLastFetchTime() { |
| 603 // local_state_ is NULL in tests, so check it first. | 644 // local_state_ is NULL in tests, so check it first. |
| 604 if (local_state_) { | 645 if (local_state_) { |
| 605 local_state_->SetInt64(prefs::kVariationsLastFetchTime, | 646 local_state_->SetInt64(prefs::kVariationsLastFetchTime, |
| 606 base::Time::Now().ToInternalValue()); | 647 base::Time::Now().ToInternalValue()); |
| 607 } | 648 } |
| 608 } | 649 } |
| 609 | 650 |
| 610 } // namespace chrome_variations | 651 } // namespace chrome_variations |
| OLD | NEW |