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

Side by Side Diff: chrome/browser/metrics/variations/variations_service.cc

Issue 617263007: Add 4 Variations.SeedDateSkew.* histograms to analyze whether the system clock or the build time co… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review:asvitkine Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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);
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_COUNTS_100("Variations.SeedDateSkew.SystemClockBehindBy",
304 -system_clock_delta_days);
305 } else {
306 UMA_HISTOGRAM_COUNTS_100("Variations.SeedDateSkew.SystemClockAheadBy",
307 system_clock_delta_days);
308 }
309
310 const int build_time_delta_days =
311 (base::GetBuildTime() - seed_date).InDays();
312 if (build_time_delta_days < 0) {
313 UMA_HISTOGRAM_COUNTS_100("Variations.SeedDateSkew.BuildTimeBehindBy",
314 -build_time_delta_days);
315 } else {
316 UMA_HISTOGRAM_COUNTS_100("Variations.SeedDateSkew.BuildTimeAheadBy",
317 build_time_delta_days);
318 }
319 }
320
292 return true; 321 return true;
293 } 322 }
294 323
295 void VariationsService::StartRepeatedVariationsSeedFetch() { 324 void VariationsService::StartRepeatedVariationsSeedFetch() {
296 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 325 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
297 326
298 // Initialize the Variations server URL. 327 // Initialize the Variations server URL.
299 variations_server_url_ = GetVariationsServerURL(policy_pref_service_); 328 variations_server_url_ = GetVariationsServerURL(policy_pref_service_);
300 329
301 // Check that |CreateTrialsFromSeed| was called, which is necessary to 330 // Check that |CreateTrialsFromSeed| was called, which is necessary to
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 630
602 void VariationsService::RecordLastFetchTime() { 631 void VariationsService::RecordLastFetchTime() {
603 // local_state_ is NULL in tests, so check it first. 632 // local_state_ is NULL in tests, so check it first.
604 if (local_state_) { 633 if (local_state_) {
605 local_state_->SetInt64(prefs::kVariationsLastFetchTime, 634 local_state_->SetInt64(prefs::kVariationsLastFetchTime,
606 base::Time::Now().ToInternalValue()); 635 base::Time::Now().ToInternalValue());
607 } 636 }
608 } 637 }
609 638
610 } // namespace chrome_variations 639 } // namespace chrome_variations
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698