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

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

Issue 12315019: Change ProxyRules to handle ProxyLists rather than just single ProxyServer instances. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: (Removed blank lines). Created 7 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 | « no previous file | net/proxy/proxy_config.cc » ('j') | net/proxy/proxy_config.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 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_CONFIG_H_ 5 #ifndef NET_PROXY_PROXY_CONFIG_H_
6 #define NET_PROXY_PROXY_CONFIG_H_ 6 #define NET_PROXY_PROXY_CONFIG_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
11 #include "net/base/net_export.h" 11 #include "net/base/net_export.h"
12 #include "net/proxy/proxy_bypass_rules.h" 12 #include "net/proxy/proxy_bypass_rules.h"
13 #include "net/proxy/proxy_config_source.h" 13 #include "net/proxy/proxy_config_source.h"
14 #include "net/proxy/proxy_list.h"
14 #include "net/proxy/proxy_server.h" 15 #include "net/proxy/proxy_server.h"
15 16
16 namespace base { 17 namespace base {
17 class Value; 18 class Value;
18 } 19 }
19 20
20 namespace net { 21 namespace net {
21 22
22 class ProxyInfo; 23 class ProxyInfo;
23 24
24 // ProxyConfig describes a user's proxy settings. 25 // ProxyConfig describes a user's proxy settings.
25 // 26 //
26 // There are two categories of proxy settings: 27 // There are two categories of proxy settings:
27 // (1) Automatic (indicates the methods to obtain a PAC script) 28 // (1) Automatic (indicates the methods to obtain a PAC script)
28 // (2) Manual (simple set of proxy servers per scheme, and bypass patterns) 29 // (2) Manual (simple set of proxy servers per scheme, and bypass patterns)
29 // 30 //
30 // When both automatic and manual settings are specified, the Automatic ones 31 // When both automatic and manual settings are specified, the Automatic ones
31 // take precedence over the manual ones. 32 // take precedence over the manual ones.
32 // 33 //
33 // For more details see: 34 // For more details see:
34 // http://www.chromium.org/developers/design-documents/proxy-settings-fallback 35 // http://www.chromium.org/developers/design-documents/proxy-settings-fallback
35 class NET_EXPORT ProxyConfig { 36 class NET_EXPORT ProxyConfig {
36 public: 37 public:
37 // ProxyRules describes the "manual" proxy settings. 38 // ProxyRules describes the "manual" proxy settings.
38 // TODO(eroman): Turn this into a class. 39 // TODO(eroman): Turn this into a class.
40 // TODO(marq): Update the enum names; "TYPE_SINGLE_PROXY" really means
41 // the same set of proxies are used for all requests.
39 struct NET_EXPORT ProxyRules { 42 struct NET_EXPORT ProxyRules {
40 enum Type { 43 enum Type {
41 TYPE_NO_RULES, 44 TYPE_NO_RULES,
42 TYPE_SINGLE_PROXY, 45 TYPE_SINGLE_PROXY,
43 TYPE_PROXY_PER_SCHEME, 46 TYPE_PROXY_PER_SCHEME,
44 }; 47 };
45 48
46 // Note that the default of TYPE_NO_RULES results in direct connections 49 // Note that the default of TYPE_NO_RULES results in direct connections
47 // being made when using this ProxyConfig. 50 // being made when using this ProxyConfig.
48 ProxyRules(); 51 ProxyRules();
49 ~ProxyRules(); 52 ~ProxyRules();
50 53
51 bool empty() const { 54 bool empty() const {
52 return type == TYPE_NO_RULES; 55 return type == TYPE_NO_RULES;
53 } 56 }
54 57
55 // Sets |result| with the proxy to use for |url| based on the current rules. 58 // Sets |result| with the proxies to use for |url| based on the current
59 // rules.
56 void Apply(const GURL& url, ProxyInfo* result) const; 60 void Apply(const GURL& url, ProxyInfo* result) const;
57 61
58 // Parses the rules from a string, indicating which proxies to use. 62 // Parses the rules from a string, indicating which proxies to use.
59 // 63 //
60 // proxy-uri = [<proxy-scheme>"://"]<proxy-host>[":"<proxy-port>] 64 // proxy-uri = [<proxy-scheme>"://"]<proxy-host>[":"<proxy-port>]
61 // 65 //
62 // If the proxy to use depends on the scheme of the URL, can instead specify 66 // proxy-uri-list = <proxy-uri>[","<proxy-uri-list>]
63 // a semicolon separated list of:
64 // 67 //
65 // <url-scheme>"="<proxy-uri> 68 // If all URLs should use the same proxies, |proxy_rules| should be a
eroman 2013/03/05 01:55:55 [optional] Your current wording is fine. Another w
marq_use_my_chromium_address 2013/03/05 22:52:40 Done.
69 // <proxy-uri-list>.
70 //
71 // If the proxy to use depends on the scheme of the URL, |proxy_rules| can
72 // instead be a a semicolon separated list of:
73 //
74 // <url-scheme>"="<proxy-uri-list>
75 //
76 // If 'socks' is specified as a scheme, any schemes left without proxies
77 // specified will have that 'socks' server added.
eroman 2013/03/05 01:55:55 This is best understood in terms of fallback-proxy
marq_use_my_chromium_address 2013/03/05 22:52:40 Done.
66 // 78 //
67 // For example: 79 // For example:
68 // "http=foopy:80;ftp=foopy2" -- use HTTP proxy "foopy:80" for http:// 80 // "http=foopy:80;ftp=foopy2" -- use HTTP proxy "foopy:80" for http://
69 // URLs, and HTTP proxy "foopy2:80" for 81 // URLs, and HTTP proxy "foopy2:80" for
70 // ftp:// URLs. 82 // ftp:// URLs.
71 // "foopy:80" -- use HTTP proxy "foopy:80" for all URLs. 83 // "foopy:80" -- use HTTP proxy "foopy:80" for all URLs.
84 // "foopy:80,bar,direct://" -- use HTTP proxy "foopy:80" for all URLs,
85 // failing over to "bar" if "foopy:80" is
86 // unavailable, and after that using no
87 // proxy.
72 // "socks4://foopy" -- use SOCKS v4 proxy "foopy:1080" for all 88 // "socks4://foopy" -- use SOCKS v4 proxy "foopy:1080" for all
73 // URLs. 89 // URLs.
90 // "http=foopy,bar.com -- use HTTP proxy "foopy" for http URLs,
eroman 2013/03/05 01:55:55 To make this example more interesting, I suggest c
marq_use_my_chromium_address 2013/03/05 22:52:40 Done.
91 // and fail over to "bar.com" if "foopy"
92 // is unavailable.
93 // "http=foopy,direct:// -- use HTTP proxy "foopy" for http URLs,
94 // and use no proxy if "foopy" is
95 // unavailable.
96 // "http=foopy;socks=foopy2 -- use HTTP proxy "foopy" for http URLs,
97 // and use socks4://foopy2 for all other
98 // URLs.
74 void ParseFromString(const std::string& proxy_rules); 99 void ParseFromString(const std::string& proxy_rules);
75 100
76 // Returns one of {&proxy_for_http, &proxy_for_https, &proxy_for_ftp, 101 // Returns one of {&proxies_for_http, &proxies_for_https, &proxies_for_ftp,
77 // &fallback_proxy}, or NULL if there is no proxy to use. 102 // &fallback_proxies}, or NULL if there is no proxy to use.
78 // Should only call this if the type is TYPE_PROXY_PER_SCHEME. 103 // Should only call this if the type is TYPE_PROXY_PER_SCHEME.
79 const ProxyServer* MapUrlSchemeToProxy(const std::string& url_scheme) const; 104 const ProxyList* MapUrlSchemeToProxyList(
105 const std::string& url_scheme) const;
80 106
81 // Returns true if |*this| describes the same configuration as |other|. 107 // Returns true if |*this| describes the same configuration as |other|.
82 bool Equals(const ProxyRules& other) const; 108 bool Equals(const ProxyRules& other) const;
83 109
84 // Exceptions for when not to use a proxy. 110 // Exceptions for when not to use a proxy.
85 ProxyBypassRules bypass_rules; 111 ProxyBypassRules bypass_rules;
86 112
87 // Reverse the meaning of |bypass_rules|. 113 // Reverse the meaning of |bypass_rules|.
88 bool reverse_bypass; 114 bool reverse_bypass;
89 115
90 Type type; 116 Type type;
91 117
92 // Set if |type| is TYPE_SINGLE_PROXY. 118 // Set if |type| is TYPE_SINGLE_PROXY.
93 ProxyServer single_proxy; 119 ProxyList single_proxies;
94 120
95 // Set if |type| is TYPE_PROXY_PER_SCHEME. 121 // Set if |type| is TYPE_PROXY_PER_SCHEME.
96 ProxyServer proxy_for_http; 122 ProxyList proxies_for_http;
97 ProxyServer proxy_for_https; 123 ProxyList proxies_for_https;
98 ProxyServer proxy_for_ftp; 124 ProxyList proxies_for_ftp;
99 125
100 // Used when there isn't a more specific per-scheme proxy server. 126 // Used when a fallback has been defined and the url to be proxied doesn't
101 ProxyServer fallback_proxy; 127 // match any of the standard schemes.
128 ProxyList fallback_proxies;
102 129
103 private: 130 private:
104 // Returns one of {&proxy_for_http, &proxy_for_https, &proxy_for_ftp} 131 // Returns one of {&proxies_for_http, &proxies_for_https, &proxies_for_ftp}
105 // or NULL if it is a scheme that we don't have a mapping 132 // or NULL if it is a scheme that we don't have a mapping
106 // for. Should only call this if the type is TYPE_PROXY_PER_SCHEME. 133 // for. Should only call this if the type is TYPE_PROXY_PER_SCHEME.
107 ProxyServer* MapUrlSchemeToProxyNoFallback(const std::string& scheme); 134 ProxyList* MapUrlSchemeToProxyListNoFallback(const std::string& scheme);
108 }; 135 };
109 136
110 typedef int ID; 137 typedef int ID;
111 138
112 // Indicates an invalid proxy config. 139 // Indicates an invalid proxy config.
113 static const ID kInvalidConfigID = 0; 140 static const ID kInvalidConfigID = 0;
114 141
115 ProxyConfig(); 142 ProxyConfig();
116 ProxyConfig(const ProxyConfig& config); 143 ProxyConfig(const ProxyConfig& config);
117 ~ProxyConfig(); 144 ~ProxyConfig();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 ProxyConfigSource source_; 245 ProxyConfigSource source_;
219 246
220 ID id_; 247 ID id_;
221 }; 248 };
222 249
223 } // namespace net 250 } // namespace net
224 251
225 252
226 253
227 #endif // NET_PROXY_PROXY_CONFIG_H_ 254 #endif // NET_PROXY_PROXY_CONFIG_H_
OLDNEW
« no previous file with comments | « no previous file | net/proxy/proxy_config.cc » ('j') | net/proxy/proxy_config.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698