| 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 "components/data_use_measurement/core/data_use_user_data.h" |
| 18 #include "components/metrics/metrics_state_manager.h" | 19 #include "components/metrics/metrics_state_manager.h" |
| 19 #include "components/network_time/network_time_tracker.h" | 20 #include "components/network_time/network_time_tracker.h" |
| 20 #include "components/pref_registry/pref_registry_syncable.h" | 21 #include "components/pref_registry/pref_registry_syncable.h" |
| 21 #include "components/variations/pref_names.h" | 22 #include "components/variations/pref_names.h" |
| 22 #include "components/variations/proto/variations_seed.pb.h" | 23 #include "components/variations/proto/variations_seed.pb.h" |
| 23 #include "components/variations/variations_seed_processor.h" | 24 #include "components/variations/variations_seed_processor.h" |
| 24 #include "components/variations/variations_seed_simulator.h" | 25 #include "components/variations/variations_seed_simulator.h" |
| 25 #include "components/variations/variations_switches.h" | 26 #include "components/variations/variations_switches.h" |
| 26 #include "components/variations/variations_url_constants.h" | 27 #include "components/variations/variations_url_constants.h" |
| 27 #include "components/version_info/version_info.h" | 28 #include "components/version_info/version_info.h" |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 local_state, state_manager)); | 442 local_state, state_manager)); |
| 442 return result.Pass(); | 443 return result.Pass(); |
| 443 } | 444 } |
| 444 | 445 |
| 445 void VariationsService::DoActualFetch() { | 446 void VariationsService::DoActualFetch() { |
| 446 DCHECK(thread_checker_.CalledOnValidThread()); | 447 DCHECK(thread_checker_.CalledOnValidThread()); |
| 447 DCHECK(!pending_seed_request_); | 448 DCHECK(!pending_seed_request_); |
| 448 | 449 |
| 449 pending_seed_request_ = net::URLFetcher::Create(0, variations_server_url_, | 450 pending_seed_request_ = net::URLFetcher::Create(0, variations_server_url_, |
| 450 net::URLFetcher::GET, this); | 451 net::URLFetcher::GET, this); |
| 452 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 453 pending_seed_request_.get(), |
| 454 data_use_measurement::DataUseUserData::VARIATIONS); |
| 451 pending_seed_request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 455 pending_seed_request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 452 net::LOAD_DO_NOT_SAVE_COOKIES); | 456 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 453 pending_seed_request_->SetRequestContext(client_->GetURLRequestContext()); | 457 pending_seed_request_->SetRequestContext(client_->GetURLRequestContext()); |
| 454 pending_seed_request_->SetMaxRetriesOn5xx(kMaxRetrySeedFetch); | 458 pending_seed_request_->SetMaxRetriesOn5xx(kMaxRetrySeedFetch); |
| 455 if (!seed_store_.variations_serial_number().empty() && | 459 if (!seed_store_.variations_serial_number().empty() && |
| 456 !disable_deltas_for_next_request_) { | 460 !disable_deltas_for_next_request_) { |
| 457 // If the current seed includes a country code, deltas are not supported (as | 461 // If the current seed includes a country code, deltas are not supported (as |
| 458 // the serial number doesn't take into account the country code). The server | 462 // the serial number doesn't take into account the country code). The server |
| 459 // will update us with a seed that doesn't include a country code which will | 463 // will update us with a seed that doesn't include a country code which will |
| 460 // enable deltas to work. | 464 // enable deltas to work. |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 // Otherwise, update the pref with the current Chrome version and country. | 752 // Otherwise, update the pref with the current Chrome version and country. |
| 749 base::ListValue new_list_value; | 753 base::ListValue new_list_value; |
| 750 new_list_value.AppendString(version.GetString()); | 754 new_list_value.AppendString(version.GetString()); |
| 751 new_list_value.AppendString(latest_country); | 755 new_list_value.AppendString(latest_country); |
| 752 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, | 756 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, |
| 753 new_list_value); | 757 new_list_value); |
| 754 return latest_country; | 758 return latest_country; |
| 755 } | 759 } |
| 756 | 760 |
| 757 } // namespace chrome_variations | 761 } // namespace chrome_variations |
| OLD | NEW |