Index: net/base/host_mapping_rules.cc |
diff --git a/net/base/host_mapping_rules.cc b/net/base/host_mapping_rules.cc |
index 3c24b245942319b069d18f7b5f791fc04e8baa09..b8fef178e7a7f8f9c2751b2fa8b63917fed823eb 100644 |
--- a/net/base/host_mapping_rules.cc |
+++ b/net/base/host_mapping_rules.cc |
@@ -28,22 +28,17 @@ struct HostMappingRules::ExclusionRule { |
HostMappingRules::HostMappingRules() {} |
+HostMappingRules::HostMappingRules(const HostMappingRules& host_mapping_rules) = |
+ default; |
+ |
HostMappingRules::~HostMappingRules() {} |
-bool HostMappingRules::RewriteHost(HostPortPair* host_port) const { |
- // Check if the hostname was excluded. |
- for (ExclusionRuleList::const_iterator it = exclusion_rules_.begin(); |
- it != exclusion_rules_.end(); ++it) { |
- const ExclusionRule& rule = *it; |
- if (base::MatchPattern(host_port->host(), rule.hostname_pattern)) |
- return false; |
- } |
+HostMappingRules& HostMappingRules::operator=( |
+ const HostMappingRules& host_mapping_rules) = default; |
+bool HostMappingRules::RewriteHost(HostPortPair* host_port) const { |
// Check if the hostname was remapped. |
- for (MapRuleList::const_iterator it = map_rules_.begin(); |
- it != map_rules_.end(); ++it) { |
- const MapRule& rule = *it; |
- |
+ for (const auto& rule : map_rules_) { |
// The rule's hostname_pattern will be something like: |
// www.foo.com |
// *.foo.com |
@@ -57,6 +52,12 @@ bool HostMappingRules::RewriteHost(HostPortPair* host_port) const { |
continue; // This rule doesn't apply. |
} |
+ // Check if the hostname was excluded. |
+ for (const auto& rule : exclusion_rules_) { |
+ if (base::MatchPattern(host_port->host(), rule.hostname_pattern)) |
+ return false; |
+ } |
+ |
host_port->set_host(rule.replacement_hostname); |
if (rule.replacement_port != -1) |
host_port->set_port(static_cast<uint16_t>(rule.replacement_port)); |