Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(830)

Side by Side Diff: third_party/libaddressinput/chromium/chrome_address_validator.cc

Issue 2950353002: [Payments] Avoid a crash caused by AddressValidatorTest. (Closed)
Patch Set: Rename. Re-example. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/libaddressinput/chromium/chrome_address_validator_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | third_party/libaddressinput/chromium/chrome_address_validator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698