| 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 "base/build_time.h" | 7 #include "base/build_time.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/metrics/sparse_histogram.h" | 10 #include "base/metrics/sparse_histogram.h" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 -build_time_delta_days); | 326 -build_time_delta_days); |
| 327 } else { | 327 } else { |
| 328 UMA_HISTOGRAM_COUNTS_100("Variations.SeedDateSkew.BuildTimeAheadBy", | 328 UMA_HISTOGRAM_COUNTS_100("Variations.SeedDateSkew.BuildTimeAheadBy", |
| 329 build_time_delta_days); | 329 build_time_delta_days); |
| 330 } | 330 } |
| 331 } | 331 } |
| 332 | 332 |
| 333 return true; | 333 return true; |
| 334 } | 334 } |
| 335 | 335 |
| 336 void VariationsService::PerformPreMainMessageLoopStartup() { |
| 337 DCHECK(thread_checker_.CalledOnValidThread()); |
| 338 |
| 339 StartRepeatedVariationsSeedFetch(); |
| 340 client_->OnInitialStartup(); |
| 341 } |
| 342 |
| 336 void VariationsService::StartRepeatedVariationsSeedFetch() { | 343 void VariationsService::StartRepeatedVariationsSeedFetch() { |
| 337 DCHECK(thread_checker_.CalledOnValidThread()); | 344 DCHECK(thread_checker_.CalledOnValidThread()); |
| 338 | 345 |
| 339 // Initialize the Variations server URL. | 346 // Initialize the Variations server URL. |
| 340 variations_server_url_ = | 347 variations_server_url_ = |
| 341 GetVariationsServerURL(policy_pref_service_, restrict_mode_); | 348 GetVariationsServerURL(policy_pref_service_, restrict_mode_); |
| 342 | 349 |
| 343 // Check that |CreateTrialsFromSeed| was called, which is necessary to | 350 // Check that |CreateTrialsFromSeed| was called, which is necessary to |
| 344 // retrieve the serial number that will be sent to the server. | 351 // retrieve the serial number that will be sent to the server. |
| 345 DCHECK(create_trials_from_seed_called_); | 352 DCHECK(create_trials_from_seed_called_); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 367 void VariationsService::OnAppEnterForeground() { | 374 void VariationsService::OnAppEnterForeground() { |
| 368 DCHECK(thread_checker_.CalledOnValidThread()); | 375 DCHECK(thread_checker_.CalledOnValidThread()); |
| 369 | 376 |
| 370 // On mobile platforms, initialize the fetch scheduler when we receive the | 377 // On mobile platforms, initialize the fetch scheduler when we receive the |
| 371 // first app foreground notification. | 378 // first app foreground notification. |
| 372 if (!request_scheduler_) | 379 if (!request_scheduler_) |
| 373 StartRepeatedVariationsSeedFetch(); | 380 StartRepeatedVariationsSeedFetch(); |
| 374 request_scheduler_->OnAppEnterForeground(); | 381 request_scheduler_->OnAppEnterForeground(); |
| 375 } | 382 } |
| 376 | 383 |
| 377 #if defined(OS_WIN) | |
| 378 void VariationsService::StartGoogleUpdateRegistrySync() { | |
| 379 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 380 registry_syncer_.RequestRegistrySync(); | |
| 381 } | |
| 382 #endif | |
| 383 | |
| 384 void VariationsService::SetRestrictMode(const std::string& restrict_mode) { | 384 void VariationsService::SetRestrictMode(const std::string& restrict_mode) { |
| 385 DCHECK(thread_checker_.CalledOnValidThread()); | 385 DCHECK(thread_checker_.CalledOnValidThread()); |
| 386 | 386 |
| 387 // This should be called before the server URL has been computed. | 387 // This should be called before the server URL has been computed. |
| 388 DCHECK(variations_server_url_.is_empty()); | 388 DCHECK(variations_server_url_.is_empty()); |
| 389 restrict_mode_ = restrict_mode; | 389 restrict_mode_ = restrict_mode; |
| 390 } | 390 } |
| 391 | 391 |
| 392 void VariationsService::SetCreateTrialsFromSeedCalledForTesting(bool called) { | 392 void VariationsService::SetCreateTrialsFromSeedCalledForTesting(bool called) { |
| 393 DCHECK(thread_checker_.CalledOnValidThread()); | 393 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 // Otherwise, update the pref with the current Chrome version and country. | 777 // Otherwise, update the pref with the current Chrome version and country. |
| 778 base::ListValue new_list_value; | 778 base::ListValue new_list_value; |
| 779 new_list_value.AppendString(version.GetString()); | 779 new_list_value.AppendString(version.GetString()); |
| 780 new_list_value.AppendString(latest_country); | 780 new_list_value.AppendString(latest_country); |
| 781 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, | 781 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, |
| 782 new_list_value); | 782 new_list_value); |
| 783 return latest_country; | 783 return latest_country; |
| 784 } | 784 } |
| 785 | 785 |
| 786 } // namespace chrome_variations | 786 } // namespace chrome_variations |
| OLD | NEW |