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 "components/variations/service/variations_service.h" | 5 #include "components/variations/service/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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 local_state, nullptr)), | 445 local_state, nullptr)), |
445 local_state, nullptr)); | 446 local_state, nullptr)); |
446 } | 447 } |
447 | 448 |
448 void VariationsService::DoActualFetch() { | 449 void VariationsService::DoActualFetch() { |
449 DCHECK(thread_checker_.CalledOnValidThread()); | 450 DCHECK(thread_checker_.CalledOnValidThread()); |
450 DCHECK(!pending_seed_request_); | 451 DCHECK(!pending_seed_request_); |
451 | 452 |
452 pending_seed_request_ = net::URLFetcher::Create(0, variations_server_url_, | 453 pending_seed_request_ = net::URLFetcher::Create(0, variations_server_url_, |
453 net::URLFetcher::GET, this); | 454 net::URLFetcher::GET, this); |
| 455 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 456 pending_seed_request_.get(), |
| 457 data_use_measurement::DataUseUserData::VARIATIONS); |
454 pending_seed_request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 458 pending_seed_request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
455 net::LOAD_DO_NOT_SAVE_COOKIES); | 459 net::LOAD_DO_NOT_SAVE_COOKIES); |
456 pending_seed_request_->SetRequestContext(client_->GetURLRequestContext()); | 460 pending_seed_request_->SetRequestContext(client_->GetURLRequestContext()); |
457 pending_seed_request_->SetMaxRetriesOn5xx(kMaxRetrySeedFetch); | 461 pending_seed_request_->SetMaxRetriesOn5xx(kMaxRetrySeedFetch); |
458 if (!seed_store_.variations_serial_number().empty() && | 462 if (!seed_store_.variations_serial_number().empty() && |
459 !disable_deltas_for_next_request_) { | 463 !disable_deltas_for_next_request_) { |
460 // If the current seed includes a country code, deltas are not supported (as | 464 // If the current seed includes a country code, deltas are not supported (as |
461 // the serial number doesn't take into account the country code). The server | 465 // the serial number doesn't take into account the country code). The server |
462 // will update us with a seed that doesn't include a country code which will | 466 // will update us with a seed that doesn't include a country code which will |
463 // enable deltas to work. | 467 // enable deltas to work. |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 // Otherwise, update the pref with the current Chrome version and country. | 755 // Otherwise, update the pref with the current Chrome version and country. |
752 base::ListValue new_list_value; | 756 base::ListValue new_list_value; |
753 new_list_value.AppendString(version.GetString()); | 757 new_list_value.AppendString(version.GetString()); |
754 new_list_value.AppendString(latest_country); | 758 new_list_value.AppendString(latest_country); |
755 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, | 759 local_state_->Set(prefs::kVariationsPermanentConsistencyCountry, |
756 new_list_value); | 760 new_list_value); |
757 return latest_country; | 761 return latest_country; |
758 } | 762 } |
759 | 763 |
760 } // namespace variations | 764 } // namespace variations |
OLD | NEW |