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

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

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « net/proxy/proxy_config_unittest.cc ('k') | net/proxy/proxy_info.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_PROXY_PROXY_INFO_H_
6 #define NET_PROXY_PROXY_INFO_H_
7
8 #include <string>
9
10 #include "base/gtest_prod_util.h"
11 #include "base/time/time.h"
12 #include "net/base/net_export.h"
13 #include "net/base/net_log.h"
14 #include "net/proxy/proxy_config.h"
15 #include "net/proxy/proxy_list.h"
16 #include "net/proxy/proxy_retry_info.h"
17 #include "net/proxy/proxy_server.h"
18
19 namespace net {
20
21 // This object holds proxy information returned by ResolveProxy.
22 class NET_EXPORT ProxyInfo {
23 public:
24 ProxyInfo();
25 ~ProxyInfo();
26 // Default copy-constructor and assignment operator are OK!
27
28 // Uses the same proxy server as the given |proxy_info|.
29 void Use(const ProxyInfo& proxy_info);
30
31 // Uses a direct connection.
32 //
33 // Note that this method resets this instance unlike Fallback(), etc. which
34 // only modify |proxy_list_|. For example, since |config_id_| is cleared, the
35 // ProxyService may recognize this instance as a new config after UseDirect()
36 // call.
37 void UseDirect();
38
39 // Uses a direct connection. did_bypass_proxy() will return true to indicate
40 // that the direct connection is the result of configured proxy bypass rules.
41 //
42 // See also the note for UseDirect().
43 void UseDirectWithBypassedProxy();
44
45 // Uses a specific proxy server, of the form:
46 // proxy-uri = [<scheme> "://"] <hostname> [":" <port>]
47 // This may optionally be a semi-colon delimited list of <proxy-uri>.
48 // It is OK to have LWS between entries.
49 //
50 // See also the note for UseDirect().
51 void UseNamedProxy(const std::string& proxy_uri_list);
52
53 // Sets the proxy list to a single entry, |proxy_server|.
54 //
55 // See also the note for UseDirect().
56 void UseProxyServer(const ProxyServer& proxy_server);
57
58 // Parses from the given PAC result.
59 //
60 // See also the note for UseDirect().
61 void UsePacString(const std::string& pac_string);
62
63 // Uses the proxies from the given list.
64 //
65 // See also the note for UseDirect().
66 void UseProxyList(const ProxyList& proxy_list);
67
68 // Uses the proxies from the given list, but does not otherwise reset the
69 // proxy configuration.
70 void OverrideProxyList(const ProxyList& proxy_list);
71
72 // Returns true if this proxy info specifies a direct connection.
73 bool is_direct() const {
74 // We don't implicitly fallback to DIRECT unless it was added to the list.
75 if (is_empty())
76 return false;
77 return proxy_list_.Get().is_direct();
78 }
79
80 bool is_direct_only() const {
81 return is_direct() && proxy_list_.size() == 1 && proxy_retry_info_.empty();
82 }
83
84 // Returns true if the first valid proxy server is an https proxy.
85 bool is_https() const {
86 if (is_empty())
87 return false;
88 return proxy_server().is_https();
89 }
90
91 // Returns true if the first valid proxy server is an http proxy.
92 bool is_http() const {
93 if (is_empty())
94 return false;
95 return proxy_server().is_http();
96 }
97
98 // Returns true if the first valid proxy server is a quic proxy.
99 bool is_quic() const {
100 if (is_empty())
101 return false;
102 return proxy_server().is_quic();
103 }
104
105 // Returns true if the first valid proxy server is a socks server.
106 bool is_socks() const {
107 if (is_empty())
108 return false;
109 return proxy_server().is_socks();
110 }
111
112 // Returns true if this proxy info has no proxies left to try.
113 bool is_empty() const {
114 return proxy_list_.IsEmpty();
115 }
116
117 // Returns true if this proxy resolution is using a direct connection due to
118 // proxy bypass rules.
119 bool did_bypass_proxy() const {
120 return did_bypass_proxy_;
121 }
122
123 // Returns true if the proxy resolution was done using a PAC script.
124 bool did_use_pac_script() const {
125 return did_use_pac_script_;
126 }
127
128 // Returns the first valid proxy server. is_empty() must be false to be able
129 // to call this function.
130 const ProxyServer& proxy_server() const { return proxy_list_.Get(); }
131
132 // Returns the source for configuration settings used for proxy resolution.
133 ProxyConfigSource config_source() const { return config_source_; }
134
135 // See description in ProxyList::ToPacString().
136 std::string ToPacString() const;
137
138 // Marks the current proxy as bad. |net_error| should contain the network
139 // error encountered when this proxy was tried, if any. If this fallback
140 // is not because of a network error, then |OK| should be passed in (eg. for
141 // reasons such as local policy). Returns true if there is another proxy is
142 // available to try in proxy list_.
143 bool Fallback(int net_error, const BoundNetLog& net_log);
144
145 // De-prioritizes the proxies that we have cached as not working, by moving
146 // them to the end of the proxy list.
147 void DeprioritizeBadProxies(const ProxyRetryInfoMap& proxy_retry_info);
148
149 // Deletes any entry which doesn't have one of the specified proxy schemes.
150 void RemoveProxiesWithoutScheme(int scheme_bit_field);
151
152 ProxyConfig::ID config_id() const { return config_id_; }
153
154 // Returns the list of proxies to use.
155 const ProxyList& proxy_list() const {
156 return proxy_list_;
157 }
158
159 base::TimeTicks proxy_resolve_start_time() const {
160 return proxy_resolve_start_time_;
161 }
162
163 base::TimeTicks proxy_resolve_end_time() const {
164 return proxy_resolve_end_time_;
165 }
166
167 private:
168 friend class ProxyService;
169 FRIEND_TEST_ALL_PREFIXES(ProxyInfoTest, UseVsOverrideProxyList);
170
171 const ProxyRetryInfoMap& proxy_retry_info() const {
172 return proxy_retry_info_;
173 }
174
175 // Reset proxy and config settings.
176 void Reset();
177
178 // The ordered list of proxy servers (including DIRECT attempts) remaining to
179 // try. If proxy_list_ is empty, then there is nothing left to fall back to.
180 ProxyList proxy_list_;
181
182 // List of proxies that have been tried already.
183 ProxyRetryInfoMap proxy_retry_info_;
184
185 // This value identifies the proxy config used to initialize this object.
186 ProxyConfig::ID config_id_;
187
188 // The source of the proxy settings used,
189 ProxyConfigSource config_source_;
190
191 // Whether the proxy result represent a proxy bypass.
192 bool did_bypass_proxy_;
193
194 // Whether we used a PAC script for resolving the proxy.
195 bool did_use_pac_script_;
196
197 // How long it took to resolve the proxy. Times are both null if proxy was
198 // determined synchronously without running a PAC.
199 base::TimeTicks proxy_resolve_start_time_;
200 base::TimeTicks proxy_resolve_end_time_;
201 };
202
203 } // namespace net
204
205 #endif // NET_PROXY_PROXY_INFO_H_
OLDNEW
« no previous file with comments | « net/proxy/proxy_config_unittest.cc ('k') | net/proxy/proxy_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698