Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1323)

Unified Diff: net/base/host_mapping_rules.cc

Issue 2906463002: Make HttpNetworkSession::host_mapping_rules no longer a pointer. (Closed)
Patch Set: Oops Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
Randy Smith (Not in Mondays) 2017/05/25 17:50:48 The movement of the exclusion check looks like a b
mmenke 2017/05/25 18:07:10 I don't think this is a behavior change. This was
Randy Smith (Not in Mondays) 2017/05/25 18:17:06 I'm sorry, I was reading too fast, and read this a
+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));

Powered by Google App Engine
This is Rietveld 408576698