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 20 matching lines...) Expand all Loading... |
31 | 31 |
32 using ::i18n::addressinput::ADMIN_AREA; | 32 using ::i18n::addressinput::ADMIN_AREA; |
33 using ::i18n::addressinput::DEPENDENT_LOCALITY; | 33 using ::i18n::addressinput::DEPENDENT_LOCALITY; |
34 using ::i18n::addressinput::POSTAL_CODE; | 34 using ::i18n::addressinput::POSTAL_CODE; |
35 | 35 |
36 // The maximum number attempts to load rules. | 36 // The maximum number attempts to load rules. |
37 static const int kMaxAttemptsNumber = 8; | 37 static const int kMaxAttemptsNumber = 8; |
38 | 38 |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 AddressValidator::AddressValidator(scoped_ptr<Source> source, | 41 AddressValidator::AddressValidator(std::unique_ptr<Source> source, |
42 scoped_ptr<Storage> storage, | 42 std::unique_ptr<Storage> storage, |
43 LoadRulesListener* load_rules_listener) | 43 LoadRulesListener* load_rules_listener) |
44 : supplier_(new PreloadSupplier(source.release(), | 44 : supplier_(new PreloadSupplier(source.release(), storage.release())), |
45 storage.release())), | |
46 input_suggester_(new InputSuggester(supplier_.get())), | 45 input_suggester_(new InputSuggester(supplier_.get())), |
47 normalizer_(new AddressNormalizer(supplier_.get())), | 46 normalizer_(new AddressNormalizer(supplier_.get())), |
48 validator_(new ::i18n::addressinput::AddressValidator(supplier_.get())), | 47 validator_(new ::i18n::addressinput::AddressValidator(supplier_.get())), |
49 validated_(BuildCallback(this, &AddressValidator::Validated)), | 48 validated_(BuildCallback(this, &AddressValidator::Validated)), |
50 rules_loaded_(BuildCallback(this, &AddressValidator::RulesLoaded)), | 49 rules_loaded_(BuildCallback(this, &AddressValidator::RulesLoaded)), |
51 load_rules_listener_(load_rules_listener), | 50 load_rules_listener_(load_rules_listener), |
52 weak_factory_(this) {} | 51 weak_factory_(this) {} |
53 | 52 |
54 AddressValidator::~AddressValidator() {} | 53 AddressValidator::~AddressValidator() {} |
55 | 54 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 region_code), | 154 region_code), |
156 GetBaseRetryPeriod() * pow(2, attempts_number_[region_code]++)); | 155 GetBaseRetryPeriod() * pow(2, attempts_number_[region_code]++)); |
157 } | 156 } |
158 | 157 |
159 void AddressValidator::RetryLoadRules(const std::string& region_code) { | 158 void AddressValidator::RetryLoadRules(const std::string& region_code) { |
160 // Do not reset retry count. | 159 // Do not reset retry count. |
161 supplier_->LoadRules(region_code, *rules_loaded_); | 160 supplier_->LoadRules(region_code, *rules_loaded_); |
162 } | 161 } |
163 | 162 |
164 } // namespace autofill | 163 } // namespace autofill |
OLD | NEW |