| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "net/tools/tld_cleanup/tld_cleanup_util.h" | 5 #include "net/tools/tld_cleanup/tld_cleanup_util.h" |
| 6 | 6 |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 Rule rule; | 170 Rule rule; |
| 171 rule.wildcard = false; | 171 rule.wildcard = false; |
| 172 rule.exception = false; | 172 rule.exception = false; |
| 173 rule.is_private = is_private; | 173 rule.is_private = is_private; |
| 174 NormalizeResult new_result = NormalizeRule(&domain, &rule); | 174 NormalizeResult new_result = NormalizeRule(&domain, &rule); |
| 175 if (new_result != kError) { | 175 if (new_result != kError) { |
| 176 // Check the existing rules to make sure we don't have an exception and | 176 // Check the existing rules to make sure we don't have an exception and |
| 177 // wildcard for the same rule, or that the same domain is listed as both | 177 // wildcard for the same rule, or that the same domain is listed as both |
| 178 // private and not private. If we did, we'd have to update our | 178 // private and not private. If we did, we'd have to update our |
| 179 // parsing code to handle this case. | 179 // parsing code to handle this case. |
| 180 CHECK(rules->find(domain) == rules->end()) | 180 // Duplicate rule found for |domain|. |
| 181 << "Duplicate rule found for " << domain; | 181 CHECK(rules->find(domain) == rules->end()); |
| 182 | 182 |
| 183 (*rules)[domain] = rule; | 183 (*rules)[domain] = rule; |
| 184 // Add true TLD for multi-level rules. We don't add them right now, in | 184 // Add true TLD for multi-level rules. We don't add them right now, in |
| 185 // case there's an exception or wild card that either exists or might be | 185 // case there's an exception or wild card that either exists or might be |
| 186 // added in a later iteration. In those cases, there's no need to add | 186 // added in a later iteration. In those cases, there's no need to add |
| 187 // it and it would just slow down parsing the data. | 187 // it and it would just slow down parsing the data. |
| 188 size_t tld_start = domain.find_last_of('.'); | 188 size_t tld_start = domain.find_last_of('.'); |
| 189 if (tld_start != std::string::npos && tld_start + 1 < domain.size()) { | 189 if (tld_start != std::string::npos && tld_start + 1 < domain.size()) { |
| 190 std::string extra_rule_domain = domain.substr(tld_start + 1); | 190 std::string extra_rule_domain = domain.substr(tld_start + 1); |
| 191 RuleMap::const_iterator iter = extra_rules.find(extra_rule_domain); | 191 RuleMap::const_iterator iter = extra_rules.find(extra_rule_domain); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 LOG(ERROR) << "Error(s) writing output file"; | 246 LOG(ERROR) << "Error(s) writing output file"; |
| 247 result = kError; | 247 result = kError; |
| 248 } | 248 } |
| 249 | 249 |
| 250 return result; | 250 return result; |
| 251 } | 251 } |
| 252 | 252 |
| 253 | 253 |
| 254 } // namespace tld_cleanup | 254 } // namespace tld_cleanup |
| 255 } // namespace net | 255 } // namespace net |
| OLD | NEW |