Commit 9e1ecbb6 authored by Eric Roman's avatar Eric Roman Committed by Commit Bot

Remove ProxyBypassRules::Equals() and ProxyBypassRules::AssignFrom().

Instead use operator== and operator=.

Change-Id: Ia2f694e75f3a5f22338d97ec7c4ce61e1a500996
Reviewed-on: https://chromium-review.googlesource.com/c/1324133
Commit-Queue: Eric Roman <eroman@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarEric Roman <eroman@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606583}
parent 4c212d9a
......@@ -1101,10 +1101,8 @@ base::Value ConvertOncProxySettingsToProxyConfig(
net::ProxyBypassRules bypass_rules;
const base::Value* exclude_domains = onc_proxy_settings.FindKeyOfType(
::onc::proxy::kExcludeDomains, base::Value::Type::LIST);
if (exclude_domains) {
bypass_rules.AssignFrom(
ConvertOncExcludeDomainsToBypassRules(*exclude_domains));
}
if (exclude_domains)
bypass_rules = ConvertOncExcludeDomainsToBypassRules(*exclude_domains);
return ProxyConfigDictionary::CreateFixedServers(manual_spec,
bypass_rules.ToString());
}
......
......@@ -290,7 +290,7 @@ TEST_F(DataReductionProxyConfiguratorTest, TestBypassList) {
expected.AddRuleFromString("http://www.google.com");
expected.AddRuleFromString("fefe:13::abc/33");
EXPECT_TRUE(expected.Equals(config_->bypass_rules_));
EXPECT_EQ(expected, config_->bypass_rules_);
}
TEST_F(DataReductionProxyConfiguratorTest,
......
......@@ -208,13 +208,22 @@ bool ProxyBypassRules::Rule::Equals(const Rule& rule) const {
ProxyBypassRules::ProxyBypassRules() = default;
ProxyBypassRules::ProxyBypassRules(const ProxyBypassRules& rhs) {
AssignFrom(rhs);
*this = rhs;
}
ProxyBypassRules::ProxyBypassRules(ProxyBypassRules&& rhs) {
*this = std::move(rhs);
}
ProxyBypassRules::~ProxyBypassRules() = default;
ProxyBypassRules& ProxyBypassRules::operator=(const ProxyBypassRules& rhs) {
AssignFrom(rhs);
ParseFromString(rhs.ToString());
return *this;
}
ProxyBypassRules& ProxyBypassRules::operator=(ProxyBypassRules&& rhs) {
rules_ = std::move(rhs.rules_);
return *this;
}
......@@ -259,7 +268,7 @@ bool ProxyBypassRules::Matches(const GURL& url, bool reverse) const {
return reverse;
}
bool ProxyBypassRules::Equals(const ProxyBypassRules& other) const {
bool ProxyBypassRules::operator==(const ProxyBypassRules& other) const {
if (rules_.size() != other.rules_.size())
return false;
......@@ -320,10 +329,6 @@ void ProxyBypassRules::Clear() {
rules_.clear();
}
void ProxyBypassRules::AssignFrom(const ProxyBypassRules& other) {
ParseFromString(other.ToString());
}
void ProxyBypassRules::ParseFromString(const std::string& raw,
ParseFormat format) {
Clear();
......
......@@ -83,8 +83,10 @@ class NET_EXPORT ProxyBypassRules {
// Note: This class supports copy constructor and assignment.
ProxyBypassRules();
ProxyBypassRules(const ProxyBypassRules& rhs);
ProxyBypassRules(ProxyBypassRules&& rhs);
~ProxyBypassRules();
ProxyBypassRules& operator=(const ProxyBypassRules& rhs);
ProxyBypassRules& operator=(ProxyBypassRules&& rhs);
// Returns the current list of rules. The rules list contains pointers
// which are owned by this class, callers should NOT keep references
......@@ -100,9 +102,8 @@ class NET_EXPORT ProxyBypassRules {
// Matches(), except for implicit matches).
bool Matches(const GURL& url, bool reverse = false) const;
// Returns true if |*this| is equal to |other|; in other words, whether they
// describe the same set of rules.
bool Equals(const ProxyBypassRules& other) const;
// Returns true if |*this| has the same serialized list of rules as |other|.
bool operator==(const ProxyBypassRules& other) const;
// Initializes the list of rules by parsing the string |raw|. |raw| is a
// comma separated or semi-colon separated list of rules. See
......@@ -209,9 +210,6 @@ class NET_EXPORT ProxyBypassRules {
// Removes all the rules.
void Clear();
// Sets |*this| to |other|.
void AssignFrom(const ProxyBypassRules& other);
// Returns true if |url| matches one of the implicit proxy bypass rules
// (localhost or link local).
static bool MatchesImplicitRules(const GURL& url);
......
......@@ -310,14 +310,14 @@ TEST(ProxyBypassRulesTest, Equals) {
rules1.ParseFromString("foo1.com, .foo2.com");
rules2.ParseFromString("foo1.com,.FOo2.com");
EXPECT_TRUE(rules1.Equals(rules2));
EXPECT_TRUE(rules2.Equals(rules1));
EXPECT_EQ(rules1, rules2);
EXPECT_EQ(rules2, rules1);
rules1.ParseFromString(".foo2.com");
rules2.ParseFromString("foo1.com,.FOo2.com");
EXPECT_FALSE(rules1.Equals(rules2));
EXPECT_FALSE(rules2.Equals(rules1));
EXPECT_FALSE(rules1 == rules2);
EXPECT_FALSE(rules2 == rules1);
}
TEST(ProxyBypassRulesTest, BypassLocalNames) {
......
......@@ -154,13 +154,12 @@ const ProxyList* ProxyConfig::ProxyRules::MapUrlSchemeToProxyList(
}
bool ProxyConfig::ProxyRules::Equals(const ProxyRules& other) const {
return type == other.type &&
single_proxies.Equals(other.single_proxies) &&
return type == other.type && single_proxies.Equals(other.single_proxies) &&
proxies_for_http.Equals(other.proxies_for_http) &&
proxies_for_https.Equals(other.proxies_for_https) &&
proxies_for_ftp.Equals(other.proxies_for_ftp) &&
fallback_proxies.Equals(other.fallback_proxies) &&
bypass_rules.Equals(other.bypass_rules) &&
bypass_rules == other.bypass_rules &&
reverse_bypass == other.reverse_bypass;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment