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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } | 66 } |
67 | 67 |
68 json_ = Json::Build().Pass(); | 68 json_ = Json::Build().Pass(); |
69 if (!success || !json_->ParseObject(data)) { | 69 if (!success || !json_->ParseObject(data)) { |
70 (*rules_ready_)(false, country_code_, scoped_ptr<Ruleset>()); | 70 (*rules_ready_)(false, country_code_, scoped_ptr<Ruleset>()); |
71 Reset(); | 71 Reset(); |
72 return; | 72 return; |
73 } | 73 } |
74 | 74 |
75 scoped_ptr<Ruleset> ruleset = Build(key_, COUNTRY); | 75 scoped_ptr<Ruleset> ruleset = Build(key_, COUNTRY); |
76 (*rules_ready_)(ruleset != NULL, country_code_, ruleset.Pass()); | 76 const bool parse_success = ruleset != NULL; |
| 77 (*rules_ready_)(parse_success, country_code_, ruleset.Pass()); |
77 Reset(); | 78 Reset(); |
78 } | 79 } |
79 | 80 |
80 scoped_ptr<Ruleset> CountryRulesAggregator::Build(const std::string& key, | 81 scoped_ptr<Ruleset> CountryRulesAggregator::Build(const std::string& key, |
81 AddressField field) { | 82 AddressField field) { |
82 scoped_ptr<Rule> rule = ParseRule(key, field); | 83 scoped_ptr<Rule> rule = ParseRule(key, field); |
83 if (rule == NULL) { | 84 if (rule == NULL) { |
84 return scoped_ptr<Ruleset>(); | 85 return scoped_ptr<Ruleset>(); |
85 } | 86 } |
86 | 87 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 void CountryRulesAggregator::Reset() { | 146 void CountryRulesAggregator::Reset() { |
146 country_code_.clear(); | 147 country_code_.clear(); |
147 key_.clear(); | 148 key_.clear(); |
148 rules_ready_.reset(); | 149 rules_ready_.reset(); |
149 json_.reset(); | 150 json_.reset(); |
150 non_default_languages_.clear(); | 151 non_default_languages_.clear(); |
151 } | 152 } |
152 | 153 |
153 } // namespace addressinput | 154 } // namespace addressinput |
154 } // namespace i18n | 155 } // namespace i18n |
OLD | NEW |