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

Unified Diff: net/proxy/proxy_config.cc

Issue 10310179: Track sources of proxy settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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/proxy/proxy_config.cc
diff --git a/net/proxy/proxy_config.cc b/net/proxy/proxy_config.cc
index d160fa4e1571c7ba6ced2d4d658ded3d5296165f..3eae29bc1f20c268a555a0c42feebad15d4c788c 100644
--- a/net/proxy/proxy_config.cc
+++ b/net/proxy/proxy_config.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -32,10 +32,10 @@ ProxyConfig::ProxyRules::ProxyRules()
ProxyConfig::ProxyRules::~ProxyRules() {
}
-void ProxyConfig::ProxyRules::Apply(const GURL& url, ProxyInfo* result) {
+bool ProxyConfig::ProxyRules::Apply(const GURL& url, ProxyInfo* result) const {
if (empty()) {
result->UseDirect();
- return;
+ return false;
}
bool bypass_proxy = bypass_rules.Matches(url);
@@ -43,29 +43,30 @@ void ProxyConfig::ProxyRules::Apply(const GURL& url, ProxyInfo* result) {
bypass_proxy = !bypass_proxy;
if (bypass_proxy) {
result->UseDirect();
- return;
+ return true;
}
switch (type) {
case ProxyRules::TYPE_SINGLE_PROXY: {
result->UseProxyServer(single_proxy);
- return;
+ return true;
}
case ProxyRules::TYPE_PROXY_PER_SCHEME: {
const ProxyServer* entry = MapUrlSchemeToProxy(url.scheme());
if (entry) {
result->UseProxyServer(*entry);
+ return true;
} else {
// We failed to find a matching proxy server for the current URL
// scheme. Default to direct.
result->UseDirect();
+ return false;
}
- return;
}
default: {
result->UseDirect();
NOTREACHED();
- return;
+ return false;
}
}
}
@@ -159,7 +160,8 @@ ProxyServer* ProxyConfig::ProxyRules::MapUrlSchemeToProxyNoFallback(
}
ProxyConfig::ProxyConfig()
- : auto_detect_(false), pac_mandatory_(false), id_(kInvalidConfigID) {
+ : auto_detect_(false), pac_mandatory_(false),
+ source_(PROXY_CONFIG_SOURCE_UNKNOWN), id_(kInvalidConfigID) {
}
ProxyConfig::ProxyConfig(const ProxyConfig& config)
@@ -167,6 +169,7 @@ ProxyConfig::ProxyConfig(const ProxyConfig& config)
pac_url_(config.pac_url_),
pac_mandatory_(config.pac_mandatory_),
proxy_rules_(config.proxy_rules_),
+ source_(config.source_),
id_(config.id_) {
}
@@ -178,13 +181,14 @@ ProxyConfig& ProxyConfig::operator=(const ProxyConfig& config) {
pac_url_ = config.pac_url_;
pac_mandatory_ = config.pac_mandatory_;
proxy_rules_ = config.proxy_rules_;
+ source_ = config.source_;
id_ = config.id_;
return *this;
}
bool ProxyConfig::Equals(const ProxyConfig& other) const {
- // The two configs can have different IDs. We are just interested in if they
- // have the same settings.
+ // The two configs can have different IDs and sources. We are just interested
+ // in if they have the same settings.
return auto_detect_ == other.auto_detect_ &&
pac_url_ == other.pac_url_ &&
pac_mandatory_ == other.pac_mandatory_ &&
@@ -249,6 +253,9 @@ Value* ProxyConfig::ToValue() const {
}
}
+ // Output the source.
+ dict->SetString("source", ProxyConfigSourceToString(source_));
+
return dict;
}

Powered by Google App Engine
This is Rietveld 408576698