| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 PrefService* local_state) { | 514 PrefService* local_state) { |
| 515 return base::WrapUnique(new VariationsService( | 515 return base::WrapUnique(new VariationsService( |
| 516 std::move(client), | 516 std::move(client), |
| 517 base::MakeUnique<web_resource::ResourceRequestAllowedNotifier>( | 517 base::MakeUnique<web_resource::ResourceRequestAllowedNotifier>( |
| 518 local_state, nullptr), | 518 local_state, nullptr), |
| 519 local_state, nullptr, UIStringOverrider())); | 519 local_state, nullptr, UIStringOverrider())); |
| 520 } | 520 } |
| 521 | 521 |
| 522 void VariationsService::DoActualFetch() { | 522 void VariationsService::DoActualFetch() { |
| 523 DCHECK(thread_checker_.CalledOnValidThread()); | 523 DCHECK(thread_checker_.CalledOnValidThread()); |
| 524 DCHECK(!pending_seed_request_); | 524 |
| 525 // Normally, there shouldn't be a |pending_request_| when this fires. However |
| 526 // it's not impossible - for example if Chrome was paused (e.g. in a debugger |
| 527 // or if the machine was suspended) and OnURLFetchComplete() hasn't had a |
| 528 // chance to run yet from the previous request. In this case, don't start a |
| 529 // new request and just let the previous one finish. |
| 530 if (pending_seed_request_) |
| 531 return; |
| 525 | 532 |
| 526 pending_seed_request_ = net::URLFetcher::Create(0, variations_server_url_, | 533 pending_seed_request_ = net::URLFetcher::Create(0, variations_server_url_, |
| 527 net::URLFetcher::GET, this); | 534 net::URLFetcher::GET, this); |
| 528 data_use_measurement::DataUseUserData::AttachToFetcher( | 535 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 529 pending_seed_request_.get(), | 536 pending_seed_request_.get(), |
| 530 data_use_measurement::DataUseUserData::VARIATIONS); | 537 data_use_measurement::DataUseUserData::VARIATIONS); |
| 531 pending_seed_request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 538 pending_seed_request_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 539 net::LOAD_DO_NOT_SEND_AUTH_DATA | |
| 532 net::LOAD_DO_NOT_SAVE_COOKIES); | 540 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 533 pending_seed_request_->SetRequestContext(client_->GetURLRequestContext()); | 541 pending_seed_request_->SetRequestContext(client_->GetURLRequestContext()); |
| 534 bool enable_deltas = false; | 542 bool enable_deltas = false; |
| 535 if (!seed_store_.variations_serial_number().empty() && | 543 if (!seed_store_.variations_serial_number().empty() && |
| 536 !disable_deltas_for_next_request_) { | 544 !disable_deltas_for_next_request_) { |
| 537 // If the current seed includes a country code, deltas are not supported (as | 545 // If the current seed includes a country code, deltas are not supported (as |
| 538 // the serial number doesn't take into account the country code). The server | 546 // the serial number doesn't take into account the country code). The server |
| 539 // will update us with a seed that doesn't include a country code which will | 547 // will update us with a seed that doesn't include a country code which will |
| 540 // enable deltas to work. | 548 // enable deltas to work. |
| 541 // TODO(asvitkine): Remove the check in M50+ when the percentage of clients | 549 // TODO(asvitkine): Remove the check in M50+ when the percentage of clients |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 | 902 |
| 895 if (got_stored_country && stored_country == country_override) | 903 if (got_stored_country && stored_country == country_override) |
| 896 return false; | 904 return false; |
| 897 | 905 |
| 898 base::Version version(version_info::GetVersionNumber()); | 906 base::Version version(version_info::GetVersionNumber()); |
| 899 StorePermanentCountry(version, country_override); | 907 StorePermanentCountry(version, country_override); |
| 900 return true; | 908 return true; |
| 901 } | 909 } |
| 902 | 910 |
| 903 } // namespace variations | 911 } // namespace variations |
| OLD | NEW |