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