OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/payments/core/address_normalizer.h" | 5 #include "components/payments/core/address_normalizer.h" |
6 | 6 |
| 7 #include <map> |
| 8 #include <memory> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
7 #include <stddef.h> | 12 #include <stddef.h> |
8 #include <utility> | 13 #include <utility> |
9 | 14 |
10 #include "base/bind.h" | 15 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 16 #include "base/bind_helpers.h" |
12 #include "base/cancelable_callback.h" | 17 #include "base/cancelable_callback.h" |
13 #include "base/location.h" | 18 #include "base/location.h" |
14 #include "base/logging.h" | 19 #include "base/logging.h" |
15 #include "base/memory/ptr_util.h" | 20 #include "base/memory/ptr_util.h" |
16 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 151 } |
147 | 152 |
148 it->second.push_back(std::move(request)); | 153 it->second.push_back(std::move(request)); |
149 | 154 |
150 // Start loading the rules for that region. If the rules were already in the | 155 // Start loading the rules for that region. If the rules were already in the |
151 // process of being loaded, this call will do nothing. | 156 // process of being loaded, this call will do nothing. |
152 LoadRulesForRegion(region_code); | 157 LoadRulesForRegion(region_code); |
153 } | 158 } |
154 } | 159 } |
155 | 160 |
156 void AddressNormalizer::OnAddressValidationRulesLoaded( | 161 void AddressNormalizer::OnAddressRulesLoaded(const std::string& region_code, |
157 const std::string& region_code, | 162 bool success) { |
158 bool success) { | |
159 // Check if an address normalization is pending. | 163 // Check if an address normalization is pending. |
160 auto it = pending_normalization_.find(region_code); | 164 auto it = pending_normalization_.find(region_code); |
161 if (it != pending_normalization_.end()) { | 165 if (it != pending_normalization_.end()) { |
162 for (size_t i = 0; i < it->second.size(); ++i) { | 166 for (size_t i = 0; i < it->second.size(); ++i) { |
163 it->second[i]->OnRulesLoaded(success); | 167 it->second[i]->OnRulesLoaded(success); |
164 } | 168 } |
165 pending_normalization_.erase(it); | 169 pending_normalization_.erase(it); |
166 } | 170 } |
167 } | 171 } |
168 | 172 |
169 } // namespace payments | 173 } // namespace payments |
OLD | NEW |