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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 web_resource::ResourceRequestAllowedNotifier* notifier, | 237 web_resource::ResourceRequestAllowedNotifier* notifier, |
238 PrefService* local_state, | 238 PrefService* local_state, |
239 metrics::MetricsStateManager* state_manager) | 239 metrics::MetricsStateManager* state_manager) |
240 : local_state_(local_state), | 240 : local_state_(local_state), |
241 state_manager_(state_manager), | 241 state_manager_(state_manager), |
242 policy_pref_service_(local_state), | 242 policy_pref_service_(local_state), |
243 seed_store_(local_state), | 243 seed_store_(local_state), |
244 create_trials_from_seed_called_(false), | 244 create_trials_from_seed_called_(false), |
245 initial_request_completed_(false), | 245 initial_request_completed_(false), |
246 resource_request_allowed_notifier_(notifier), | 246 resource_request_allowed_notifier_(notifier), |
| 247 request_count_(0), |
247 weak_ptr_factory_(this) { | 248 weak_ptr_factory_(this) { |
248 resource_request_allowed_notifier_->Init(this); | 249 resource_request_allowed_notifier_->Init(this); |
249 } | 250 } |
250 | 251 |
251 VariationsService::~VariationsService() { | 252 VariationsService::~VariationsService() { |
252 } | 253 } |
253 | 254 |
254 bool VariationsService::CreateTrialsFromSeed() { | 255 bool VariationsService::CreateTrialsFromSeed() { |
255 create_trials_from_seed_called_ = true; | 256 create_trials_from_seed_called_ = true; |
256 | 257 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 pending_seed_request_->Start(); | 466 pending_seed_request_->Start(); |
466 | 467 |
467 const base::TimeTicks now = base::TimeTicks::Now(); | 468 const base::TimeTicks now = base::TimeTicks::Now(); |
468 base::TimeDelta time_since_last_fetch; | 469 base::TimeDelta time_since_last_fetch; |
469 // Record a time delta of 0 (default value) if there was no previous fetch. | 470 // Record a time delta of 0 (default value) if there was no previous fetch. |
470 if (!last_request_started_time_.is_null()) | 471 if (!last_request_started_time_.is_null()) |
471 time_since_last_fetch = now - last_request_started_time_; | 472 time_since_last_fetch = now - last_request_started_time_; |
472 UMA_HISTOGRAM_CUSTOM_COUNTS("Variations.TimeSinceLastFetchAttempt", | 473 UMA_HISTOGRAM_CUSTOM_COUNTS("Variations.TimeSinceLastFetchAttempt", |
473 time_since_last_fetch.InMinutes(), 0, | 474 time_since_last_fetch.InMinutes(), 0, |
474 base::TimeDelta::FromDays(7).InMinutes(), 50); | 475 base::TimeDelta::FromDays(7).InMinutes(), 50); |
| 476 UMA_HISTOGRAM_COUNTS_100("Variations.RequestCount", request_count_); |
| 477 ++request_count_; |
475 last_request_started_time_ = now; | 478 last_request_started_time_ = now; |
476 } | 479 } |
477 | 480 |
478 void VariationsService::StoreSeed(const std::string& seed_data, | 481 void VariationsService::StoreSeed(const std::string& seed_data, |
479 const std::string& seed_signature, | 482 const std::string& seed_signature, |
480 const base::Time& date_fetched) { | 483 const base::Time& date_fetched) { |
481 scoped_ptr<variations::VariationsSeed> seed(new variations::VariationsSeed); | 484 scoped_ptr<variations::VariationsSeed> seed(new variations::VariationsSeed); |
482 if (!seed_store_.StoreSeedData(seed_data, seed_signature, date_fetched, | 485 if (!seed_store_.StoreSeedData(seed_data, seed_signature, date_fetched, |
483 seed.get())) { | 486 seed.get())) { |
484 return; | 487 return; |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 // Otherwise, update the pref with the current Chrome version and country. | 719 // Otherwise, update the pref with the current Chrome version and country. |
717 base::ListValue new_list_value; | 720 base::ListValue new_list_value; |
718 new_list_value.AppendString(version.GetString()); | 721 new_list_value.AppendString(version.GetString()); |
719 new_list_value.AppendString(seed.country_code()); | 722 new_list_value.AppendString(seed.country_code()); |
720 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, | 723 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, |
721 new_list_value); | 724 new_list_value); |
722 return seed.country_code(); | 725 return seed.country_code(); |
723 } | 726 } |
724 | 727 |
725 } // namespace chrome_variations | 728 } // namespace chrome_variations |
OLD | NEW |