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