OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "third_party/libaddressinput/chromium/chrome_address_validator.h" | 5 #include "third_party/libaddressinput/chromium/chrome_address_validator.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 void AddressValidator::RulesLoaded(bool success, | 156 void AddressValidator::RulesLoaded(bool success, |
157 const std::string& region_code, | 157 const std::string& region_code, |
158 int) { | 158 int) { |
159 if (load_rules_listener_) | 159 if (load_rules_listener_) |
160 load_rules_listener_->OnAddressValidationRulesLoaded(region_code, success); | 160 load_rules_listener_->OnAddressValidationRulesLoaded(region_code, success); |
161 | 161 |
162 // Count the first failed attempt to load rules as well. | 162 // Count the first failed attempt to load rules as well. |
163 if (success || attempts_number_[region_code] + 1 >= kMaxAttemptsNumber) | 163 if (success || attempts_number_[region_code] + 1 >= kMaxAttemptsNumber) |
164 return; | 164 return; |
165 | 165 |
166 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 166 // No need to retry if it's synchronous (which means that it's a test.) |
167 FROM_HERE, base::Bind(&AddressValidator::RetryLoadRules, | 167 if (base::ThreadTaskRunnerHandle::IsSet()) { |
sebsg
2017/06/23 17:26:04
I don't think we should modify the production code
Hirondelle
2017/06/23 20:30:11
Anyway, if it's synchronous, the next line would c
sebsg
2017/06/23 21:59:32
What I suggest is changing the expected status for
Parastoo
2017/06/27 18:14:31
Done.
| |
168 weak_factory_.GetWeakPtr(), region_code), | 168 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
169 GetBaseRetryPeriod() * pow(2, attempts_number_[region_code]++)); | 169 FROM_HERE, |
170 base::Bind(&AddressValidator::RetryLoadRules, | |
171 weak_factory_.GetWeakPtr(), region_code), | |
172 GetBaseRetryPeriod() * pow(2, attempts_number_[region_code]++)); | |
173 } | |
170 } | 174 } |
171 | 175 |
172 void AddressValidator::RetryLoadRules(const std::string& region_code) { | 176 void AddressValidator::RetryLoadRules(const std::string& region_code) { |
173 // Do not reset retry count. | 177 // Do not reset retry count. |
174 supplier_->LoadRules(region_code, *rules_loaded_); | 178 supplier_->LoadRules(region_code, *rules_loaded_); |
175 } | 179 } |
176 | 180 |
177 } // namespace autofill | 181 } // namespace autofill |
OLD | NEW |