| 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 "net/base/ip_mapping_rules.h" | 5 #include "net/base/ip_mapping_rules.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 addresses->insert(addresses->begin(), | 59 addresses->insert(addresses->begin(), |
| 60 IPEndPoint((*rule_it)->replacement_address(), port)); | 60 IPEndPoint((*rule_it)->replacement_address(), port)); |
| 61 return true; | 61 return true; |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 return false; | 64 return false; |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool IPMappingRules::AddRuleFromString(const std::string& rule_string) { | 67 bool IPMappingRules::AddRuleFromString(const std::string& rule_string) { |
| 68 std::string trimmed; | 68 std::string trimmed; |
| 69 TrimWhitespaceASCII(rule_string, TRIM_ALL, &trimmed); | 69 base::TrimWhitespaceASCII(rule_string, base::TRIM_ALL, &trimmed); |
| 70 if (trimmed.empty()) | 70 if (trimmed.empty()) |
| 71 return true; // Allow empty rules. | 71 return true; // Allow empty rules. |
| 72 | 72 |
| 73 std::vector<std::string> parts; | 73 std::vector<std::string> parts; |
| 74 base::SplitString(trimmed, ' ', &parts); | 74 base::SplitString(trimmed, ' ', &parts); |
| 75 | 75 |
| 76 if (parts.size() != 3) { | 76 if (parts.size() != 3) { |
| 77 DVLOG(1) << "Rule has wrong number of parts: " << rule_string; | 77 DVLOG(1) << "Rule has wrong number of parts: " << rule_string; |
| 78 return false; | 78 return false; |
| 79 } | 79 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 if (!AddRuleFromString(rules.token())) { | 111 if (!AddRuleFromString(rules.token())) { |
| 112 DVLOG(1) << "Failed parsing rule: " << rules.token(); | 112 DVLOG(1) << "Failed parsing rule: " << rules.token(); |
| 113 STLDeleteElements(&rules_); | 113 STLDeleteElements(&rules_); |
| 114 return false; | 114 return false; |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 return true; | 117 return true; |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace net | 120 } // namespace net |
| OLD | NEW |