| 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" |
| 11 #include "base/prefs/pref_registry_simple.h" | 11 #include "base/prefs/pref_registry_simple.h" |
| 12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
| 14 #include "base/task_runner_util.h" | 14 #include "base/task_runner_util.h" |
| 15 #include "base/timer/elapsed_timer.h" | 15 #include "base/timer/elapsed_timer.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "base/version.h" | 17 #include "base/version.h" |
| 18 #include "chrome/browser/metrics/variations/generated_resources_map.h" | 18 #include "chrome/browser/metrics/variations/generated_resources_map.h" |
| 19 #include "chrome/common/channel_info.h" | 19 #include "chrome/common/channel_info.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "components/metrics/metrics_state_manager.h" | 21 #include "components/metrics/metrics_state_manager.h" |
| 22 #include "components/network_time/network_time_tracker.h" | 22 #include "components/network_time/network_time_tracker.h" |
| 23 #include "components/pref_registry/pref_registry_syncable.h" | 23 #include "components/pref_registry/pref_registry_syncable.h" |
| 24 #include "components/variations/pref_names.h" | 24 #include "components/variations/pref_names.h" |
| 25 #include "components/variations/proto/variations_seed.pb.h" | 25 #include "components/variations/proto/variations_seed.pb.h" |
| 26 #include "components/variations/variations_seed_processor.h" | 26 #include "components/variations/variations_seed_processor.h" |
| 27 #include "components/variations/variations_seed_simulator.h" | 27 #include "components/variations/variations_seed_simulator.h" |
| 28 #include "components/variations/variations_url_constants.h" | 28 #include "components/variations/variations_url_constants.h" |
| 29 #include "components/version_info/version_info.h" | 29 #include "components/version_info/version_info.h" |
| 30 #include "content/public/browser/browser_thread.h" | |
| 31 #include "net/base/load_flags.h" | 30 #include "net/base/load_flags.h" |
| 32 #include "net/base/net_errors.h" | 31 #include "net/base/net_errors.h" |
| 33 #include "net/base/network_change_notifier.h" | 32 #include "net/base/network_change_notifier.h" |
| 34 #include "net/base/url_util.h" | 33 #include "net/base/url_util.h" |
| 35 #include "net/http/http_response_headers.h" | 34 #include "net/http/http_response_headers.h" |
| 36 #include "net/http/http_status_code.h" | 35 #include "net/http/http_status_code.h" |
| 37 #include "net/http/http_util.h" | 36 #include "net/http/http_util.h" |
| 38 #include "net/url_request/url_fetcher.h" | 37 #include "net/url_request/url_fetcher.h" |
| 39 #include "net/url_request/url_request_status.h" | 38 #include "net/url_request/url_request_status.h" |
| 40 #include "ui/base/device_form_factor.h" | 39 #include "ui/base/device_form_factor.h" |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 return false; | 525 return false; |
| 527 } | 526 } |
| 528 RecordLastFetchTime(); | 527 RecordLastFetchTime(); |
| 529 | 528 |
| 530 // Perform seed simulation only if |state_manager_| is not-NULL. The state | 529 // Perform seed simulation only if |state_manager_| is not-NULL. The state |
| 531 // manager may be NULL for some unit tests. | 530 // manager may be NULL for some unit tests. |
| 532 if (!state_manager_) | 531 if (!state_manager_) |
| 533 return true; | 532 return true; |
| 534 | 533 |
| 535 base::PostTaskAndReplyWithResult( | 534 base::PostTaskAndReplyWithResult( |
| 536 content::BrowserThread::GetBlockingPool(), | 535 client_->GetBlockingPool(), |
| 537 FROM_HERE, | 536 FROM_HERE, |
| 538 base::Bind(&GetVersionForSimulation), | 537 base::Bind(&GetVersionForSimulation), |
| 539 base::Bind(&VariationsService::PerformSimulationWithVersion, | 538 base::Bind(&VariationsService::PerformSimulationWithVersion, |
| 540 weak_ptr_factory_.GetWeakPtr(), base::Passed(&seed))); | 539 weak_ptr_factory_.GetWeakPtr(), base::Passed(&seed))); |
| 541 return true; | 540 return true; |
| 542 } | 541 } |
| 543 | 542 |
| 544 void VariationsService::FetchVariationsSeed() { | 543 void VariationsService::FetchVariationsSeed() { |
| 545 DCHECK(thread_checker_.CalledOnValidThread()); | 544 DCHECK(thread_checker_.CalledOnValidThread()); |
| 546 | 545 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 // Otherwise, update the pref with the current Chrome version and country. | 776 // Otherwise, update the pref with the current Chrome version and country. |
| 778 base::ListValue new_list_value; | 777 base::ListValue new_list_value; |
| 779 new_list_value.AppendString(version.GetString()); | 778 new_list_value.AppendString(version.GetString()); |
| 780 new_list_value.AppendString(latest_country); | 779 new_list_value.AppendString(latest_country); |
| 781 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, | 780 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, |
| 782 new_list_value); | 781 new_list_value); |
| 783 return latest_country; | 782 return latest_country; |
| 784 } | 783 } |
| 785 | 784 |
| 786 } // namespace chrome_variations | 785 } // namespace chrome_variations |
| OLD | NEW |