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

Unified Diff: net/base/host_mapping_rules.cc

Issue 2906463002: Make HttpNetworkSession::host_mapping_rules no longer a pointer. (Closed)
Patch Set: More upstream merge conflicts! Fun! 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
« no previous file with comments | « net/base/host_mapping_rules.h ('k') | net/http/http_network_session.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « net/base/host_mapping_rules.h ('k') | net/http/http_network_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698