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

Side by Side Diff: net/proxy/proxy_info.h

Issue 10310179: Track sources of proxy settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update copyright Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_PROXY_PROXY_INFO_H_ 5 #ifndef NET_PROXY_PROXY_INFO_H_
6 #define NET_PROXY_PROXY_INFO_H_ 6 #define NET_PROXY_PROXY_INFO_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "net/base/net_export.h" 11 #include "net/base/net_export.h"
(...skipping 11 matching lines...) Expand all
23 ProxyInfo(); 23 ProxyInfo();
24 ~ProxyInfo(); 24 ~ProxyInfo();
25 // Default copy-constructor and assignment operator are OK! 25 // Default copy-constructor and assignment operator are OK!
26 26
27 // Uses the same proxy server as the given |proxy_info|. 27 // Uses the same proxy server as the given |proxy_info|.
28 void Use(const ProxyInfo& proxy_info); 28 void Use(const ProxyInfo& proxy_info);
29 29
30 // Uses a direct connection. 30 // Uses a direct connection.
31 void UseDirect(); 31 void UseDirect();
32 32
33 // Uses a direct connection. did_bypass_proxy() will return true to indicate
34 // that the direct connection is the result of configured proxy bypass rules.
35 void UseDirectWithBypassedProxy();
36
33 // Uses a specific proxy server, of the form: 37 // Uses a specific proxy server, of the form:
34 // proxy-uri = [<scheme> "://"] <hostname> [":" <port>] 38 // proxy-uri = [<scheme> "://"] <hostname> [":" <port>]
35 // This may optionally be a semi-colon delimited list of <proxy-uri>. 39 // This may optionally be a semi-colon delimited list of <proxy-uri>.
36 // It is OK to have LWS between entries. 40 // It is OK to have LWS between entries.
37 void UseNamedProxy(const std::string& proxy_uri_list); 41 void UseNamedProxy(const std::string& proxy_uri_list);
38 42
39 // Sets the proxy list to a single entry, |proxy_server|. 43 // Sets the proxy list to a single entry, |proxy_server|.
40 void UseProxyServer(const ProxyServer& proxy_server); 44 void UseProxyServer(const ProxyServer& proxy_server);
41 45
42 // Parses from the given PAC result. 46 // Parses from the given PAC result.
43 void UsePacString(const std::string& pac_string) { 47 void UsePacString(const std::string& pac_string) {
44 proxy_list_.SetFromPacString(pac_string); 48 proxy_list_.SetFromPacString(pac_string);
45 } 49 }
46 50
47 // Returns true if this proxy info specifies a direct connection. 51 // Returns true if this proxy info specifies a direct connection.
48 bool is_direct() const { 52 bool is_direct() const {
49 // We don't implicitly fallback to DIRECT unless it was added to the list. 53 // We don't implicitly fallback to DIRECT unless it was added to the list.
50 if (is_empty()) 54 if (is_empty())
51 return false; 55 return false;
52 return proxy_list_.Get().is_direct(); 56 return proxy_list_.Get().is_direct();
53 } 57 }
54 58
59 bool is_direct_only() const {
60 return is_direct() && proxy_list_.size() == 1 && proxy_retry_info_.empty();
61 }
62
55 // Returns true if the first valid proxy server is an https proxy. 63 // Returns true if the first valid proxy server is an https proxy.
56 bool is_https() const { 64 bool is_https() const {
57 if (is_empty()) 65 if (is_empty())
58 return false; 66 return false;
59 return proxy_server().is_https(); 67 return proxy_server().is_https();
60 } 68 }
61 69
62 // Returns true if the first valid proxy server is an http proxy. 70 // Returns true if the first valid proxy server is an http proxy.
63 bool is_http() const { 71 bool is_http() const {
64 if (is_empty()) 72 if (is_empty())
65 return false; 73 return false;
66 return proxy_server().is_http(); 74 return proxy_server().is_http();
67 } 75 }
68 76
69 // Returns true if the first valid proxy server is a socks server. 77 // Returns true if the first valid proxy server is a socks server.
70 bool is_socks() const { 78 bool is_socks() const {
71 if (is_empty()) 79 if (is_empty())
72 return false; 80 return false;
73 return proxy_server().is_socks(); 81 return proxy_server().is_socks();
74 } 82 }
75 83
76 // Returns true if this proxy info has no proxies left to try. 84 // Returns true if this proxy info has no proxies left to try.
77 bool is_empty() const { 85 bool is_empty() const {
78 return proxy_list_.IsEmpty(); 86 return proxy_list_.IsEmpty();
79 } 87 }
80 88
89 // Returns true if this proxy resolution is using a direct connection due to
90 // proxy bypass rules.
91 bool did_bypass_proxy() const {
92 return did_bypass_proxy_;
93 }
94
95 // Returns true if the proxy resolution was done using a PAC script.
96 bool did_use_pac_script() const {
97 return did_use_pac_script_;
98 }
99
81 // Returns the first valid proxy server. is_empty() must be false to be able 100 // Returns the first valid proxy server. is_empty() must be false to be able
82 // to call this function. 101 // to call this function.
83 const ProxyServer& proxy_server() const { return proxy_list_.Get(); } 102 const ProxyServer& proxy_server() const { return proxy_list_.Get(); }
84 103
104 // Returns the source for configuration settings used for proxy resolution.
105 ProxyConfigSource config_source() const { return config_source_; }
106
85 // See description in ProxyList::ToPacString(). 107 // See description in ProxyList::ToPacString().
86 std::string ToPacString() const; 108 std::string ToPacString() const;
87 109
88 // Marks the current proxy as bad. Returns true if there is another proxy 110 // Marks the current proxy as bad. Returns true if there is another proxy
89 // available to try in proxy list_. 111 // available to try in proxy list_.
90 bool Fallback(const BoundNetLog& net_log); 112 bool Fallback(const BoundNetLog& net_log);
91 113
92 // De-prioritizes the proxies that we have cached as not working, by moving 114 // De-prioritizes the proxies that we have cached as not working, by moving
93 // them to the end of the proxy list. 115 // them to the end of the proxy list.
94 void DeprioritizeBadProxies(const ProxyRetryInfoMap& proxy_retry_info); 116 void DeprioritizeBadProxies(const ProxyRetryInfoMap& proxy_retry_info);
95 117
96 // Deletes any entry which doesn't have one of the specified proxy schemes. 118 // Deletes any entry which doesn't have one of the specified proxy schemes.
97 void RemoveProxiesWithoutScheme(int scheme_bit_field); 119 void RemoveProxiesWithoutScheme(int scheme_bit_field);
98 120
99 private: 121 private:
100 friend class ProxyService; 122 friend class ProxyService;
101 123
102 const ProxyRetryInfoMap& proxy_retry_info() const { 124 const ProxyRetryInfoMap& proxy_retry_info() const {
103 return proxy_retry_info_; 125 return proxy_retry_info_;
104 } 126 }
105 127
128 // Reset proxy and config settings.
129 void Reset();
130
106 // The ordered list of proxy servers (including DIRECT attempts) remaining to 131 // The ordered list of proxy servers (including DIRECT attempts) remaining to
107 // try. If proxy_list_ is empty, then there is nothing left to fall back to. 132 // try. If proxy_list_ is empty, then there is nothing left to fall back to.
108 ProxyList proxy_list_; 133 ProxyList proxy_list_;
109 134
110 // List of proxies that have been tried already. 135 // List of proxies that have been tried already.
111 ProxyRetryInfoMap proxy_retry_info_; 136 ProxyRetryInfoMap proxy_retry_info_;
112 137
113 // This value identifies the proxy config used to initialize this object. 138 // This value identifies the proxy config used to initialize this object.
114 ProxyConfig::ID config_id_; 139 ProxyConfig::ID config_id_;
140
141 // The source of the proxy settings used,
142 ProxyConfigSource config_source_;
143
144 // Whether the proxy result represent a proxy bypass.
145 bool did_bypass_proxy_;
146
147 // Whether we used a PAC script for resolving the proxy.
148 bool did_use_pac_script_;
115 }; 149 };
116 150
117 } // namespace net 151 } // namespace net
118 152
119 #endif // NET_PROXY_PROXY_INFO_H_ 153 #endif // NET_PROXY_PROXY_INFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698