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

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

Issue 2375663002: Replace MessageLoop::current()->task_runner() with ThreadTaskRunnerHandle::Get(). (Closed)
Patch Set: rebase Created 4 years, 2 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
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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/threading/thread_task_runner_handle.h"
14 #include "third_party/libaddressinput/chromium/addressinput_util.h" 14 #include "third_party/libaddressinput/chromium/addressinput_util.h"
15 #include "third_party/libaddressinput/chromium/input_suggester.h" 15 #include "third_party/libaddressinput/chromium/input_suggester.h"
16 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da ta.h" 16 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da ta.h"
17 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_no rmalizer.h" 17 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_no rmalizer.h"
18 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/source.h" 18 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/source.h"
19 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/storage.h" 19 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/storage.h"
20 20
21 namespace autofill { 21 namespace autofill {
22 namespace { 22 namespace {
23 23
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 void AddressValidator::RulesLoaded(bool success, 141 void AddressValidator::RulesLoaded(bool success,
142 const std::string& region_code, 142 const std::string& region_code,
143 int) { 143 int) {
144 if (load_rules_listener_) 144 if (load_rules_listener_)
145 load_rules_listener_->OnAddressValidationRulesLoaded(region_code, success); 145 load_rules_listener_->OnAddressValidationRulesLoaded(region_code, success);
146 146
147 // Count the first failed attempt to load rules as well. 147 // Count the first failed attempt to load rules as well.
148 if (success || attempts_number_[region_code] + 1 >= kMaxAttemptsNumber) 148 if (success || attempts_number_[region_code] + 1 >= kMaxAttemptsNumber)
149 return; 149 return;
150 150
151 base::MessageLoop::current()->task_runner()->PostDelayedTask( 151 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
152 FROM_HERE, base::Bind(&AddressValidator::RetryLoadRules, 152 FROM_HERE, base::Bind(&AddressValidator::RetryLoadRules,
153 weak_factory_.GetWeakPtr(), region_code), 153 weak_factory_.GetWeakPtr(), region_code),
154 GetBaseRetryPeriod() * pow(2, attempts_number_[region_code]++)); 154 GetBaseRetryPeriod() * pow(2, attempts_number_[region_code]++));
155 } 155 }
156 156
157 void AddressValidator::RetryLoadRules(const std::string& region_code) { 157 void AddressValidator::RetryLoadRules(const std::string& region_code) {
158 // Do not reset retry count. 158 // Do not reset retry count.
159 supplier_->LoadRules(region_code, *rules_loaded_); 159 supplier_->LoadRules(region_code, *rules_loaded_);
160 } 160 }
161 161
162 } // namespace autofill 162 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698