| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef NET_BASE_HOST_MAPPING_RULES_H_ | 5 #ifndef NET_BASE_HOST_MAPPING_RULES_H_ |
| 6 #define NET_BASE_HOST_MAPPING_RULES_H_ | 6 #define NET_BASE_HOST_MAPPING_RULES_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 | 15 |
| 16 class HostPortPair; | 16 class HostPortPair; |
| 17 | 17 |
| 18 class NET_EXPORT_PRIVATE HostMappingRules { | 18 class NET_EXPORT_PRIVATE HostMappingRules { |
| 19 public: | 19 public: |
| 20 HostMappingRules(); | 20 HostMappingRules(); |
| 21 HostMappingRules(const HostMappingRules& host_mapping_rules); |
| 21 ~HostMappingRules(); | 22 ~HostMappingRules(); |
| 22 | 23 |
| 24 HostMappingRules& operator=(const HostMappingRules& host_mapping_rules); |
| 25 |
| 23 // Modifies |*host_port| based on the current rules. Returns true if | 26 // Modifies |*host_port| based on the current rules. Returns true if |
| 24 // |*host_port| was modified, false otherwise. | 27 // |*host_port| was modified, false otherwise. |
| 25 bool RewriteHost(HostPortPair* host_port) const; | 28 bool RewriteHost(HostPortPair* host_port) const; |
| 26 | 29 |
| 27 // Adds a rule to this mapper. The format of the rule can be one of: | 30 // Adds a rule to this mapper. The format of the rule can be one of: |
| 28 // | 31 // |
| 29 // "MAP" <hostname_pattern> <replacement_host> [":" <replacement_port>] | 32 // "MAP" <hostname_pattern> <replacement_host> [":" <replacement_port>] |
| 30 // "EXCLUDE" <hostname_pattern> | 33 // "EXCLUDE" <hostname_pattern> |
| 31 // | 34 // |
| 32 // The <replacement_host> can be either a hostname, or an IP address literal. | 35 // The <replacement_host> can be either a hostname, or an IP address literal. |
| 33 // | 36 // |
| 34 // Returns true if the rule was successfully parsed and added. | 37 // Returns true if the rule was successfully parsed and added. |
| 35 bool AddRuleFromString(const std::string& rule_string); | 38 bool AddRuleFromString(const std::string& rule_string); |
| 36 | 39 |
| 37 // Sets the rules from a comma separated list of rules. | 40 // Sets the rules from a comma separated list of rules. |
| 38 void SetRulesFromString(const std::string& rules_string); | 41 void SetRulesFromString(const std::string& rules_string); |
| 39 | 42 |
| 40 private: | 43 private: |
| 41 struct MapRule; | 44 struct MapRule; |
| 42 struct ExclusionRule; | 45 struct ExclusionRule; |
| 43 | 46 |
| 44 typedef std::vector<MapRule> MapRuleList; | 47 typedef std::vector<MapRule> MapRuleList; |
| 45 typedef std::vector<ExclusionRule> ExclusionRuleList; | 48 typedef std::vector<ExclusionRule> ExclusionRuleList; |
| 46 | 49 |
| 47 MapRuleList map_rules_; | 50 MapRuleList map_rules_; |
| 48 ExclusionRuleList exclusion_rules_; | 51 ExclusionRuleList exclusion_rules_; |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(HostMappingRules); | |
| 51 }; | 52 }; |
| 52 | 53 |
| 53 } // namespace net | 54 } // namespace net |
| 54 | 55 |
| 55 #endif // NET_BASE_HOST_MAPPING_RULES_H_ | 56 #endif // NET_BASE_HOST_MAPPING_RULES_H_ |
| OLD | NEW |