| OLD | NEW |
| 1 // Copyright (C) 2014 Google Inc. | 1 // Copyright (C) 2014 Google Inc. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 non_default_languages_() { | 41 non_default_languages_() { |
| 42 assert(retriever_ != NULL); | 42 assert(retriever_ != NULL); |
| 43 } | 43 } |
| 44 | 44 |
| 45 CountryRulesAggregator::~CountryRulesAggregator() {} | 45 CountryRulesAggregator::~CountryRulesAggregator() {} |
| 46 | 46 |
| 47 void CountryRulesAggregator::AggregateRules(const std::string& country_code, | 47 void CountryRulesAggregator::AggregateRules(const std::string& country_code, |
| 48 scoped_ptr<Callback> rules_ready) { | 48 scoped_ptr<Callback> rules_ready) { |
| 49 Reset(); | 49 Reset(); |
| 50 country_code_ = country_code; | 50 country_code_ = country_code; |
| 51 rules_ready_.reset(rules_ready.release()); | 51 rules_ready_ = rules_ready.Pass(); |
| 52 | 52 |
| 53 // Key construction: | 53 // Key construction: |
| 54 // https://code.google.com/p/libaddressinput/wiki/AddressValidationMetadata | 54 // https://code.google.com/p/libaddressinput/wiki/AddressValidationMetadata |
| 55 // Example of a country-level key: "data/CA". | 55 // Example of a country-level key: "data/CA". |
| 56 key_ = "data/" + country_code_; | 56 key_ = "data/" + country_code_; |
| 57 retriever_->Retrieve( | 57 retriever_->Retrieve( |
| 58 key_, BuildCallback(this, &CountryRulesAggregator::OnDataReady)); | 58 key_, BuildCallback(this, &CountryRulesAggregator::OnDataReady)); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void CountryRulesAggregator::OnDataReady(bool success, | 61 void CountryRulesAggregator::OnDataReady(bool success, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 void CountryRulesAggregator::Reset() { | 145 void CountryRulesAggregator::Reset() { |
| 146 country_code_.clear(); | 146 country_code_.clear(); |
| 147 key_.clear(); | 147 key_.clear(); |
| 148 rules_ready_.reset(); | 148 rules_ready_.reset(); |
| 149 json_.reset(); | 149 json_.reset(); |
| 150 non_default_languages_.clear(); | 150 non_default_languages_.clear(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 } // namespace addressinput | 153 } // namespace addressinput |
| 154 } // namespace i18n | 154 } // namespace i18n |
| OLD | NEW |