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

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

Issue 710623002: Merge to M39: Correct manual proxy selection for WebSockets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2171
Patch Set: Created 6 years, 1 month 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.h ('k') | net/proxy/proxy_config_unittest.cc » ('j') | no next file with comments »
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 #include "net/proxy/proxy_config.h" 5 #include "net/proxy/proxy_config.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/string_tokenizer.h" 9 #include "base/strings/string_tokenizer.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 138 }
139 } 139 }
140 } 140 }
141 141
142 const ProxyList* ProxyConfig::ProxyRules::MapUrlSchemeToProxyList( 142 const ProxyList* ProxyConfig::ProxyRules::MapUrlSchemeToProxyList(
143 const std::string& url_scheme) const { 143 const std::string& url_scheme) const {
144 const ProxyList* proxy_server_list = const_cast<ProxyRules*>(this)-> 144 const ProxyList* proxy_server_list = const_cast<ProxyRules*>(this)->
145 MapUrlSchemeToProxyListNoFallback(url_scheme); 145 MapUrlSchemeToProxyListNoFallback(url_scheme);
146 if (proxy_server_list && !proxy_server_list->IsEmpty()) 146 if (proxy_server_list && !proxy_server_list->IsEmpty())
147 return proxy_server_list; 147 return proxy_server_list;
148 if (url_scheme == "ws" || url_scheme == "wss")
149 return GetProxyListForWebSocketScheme();
148 if (!fallback_proxies.IsEmpty()) 150 if (!fallback_proxies.IsEmpty())
149 return &fallback_proxies; 151 return &fallback_proxies;
150 return NULL; // No mapping for this scheme. Use direct. 152 return NULL; // No mapping for this scheme. Use direct.
151 } 153 }
152 154
153 bool ProxyConfig::ProxyRules::Equals(const ProxyRules& other) const { 155 bool ProxyConfig::ProxyRules::Equals(const ProxyRules& other) const {
154 return type == other.type && 156 return type == other.type &&
155 single_proxies.Equals(other.single_proxies) && 157 single_proxies.Equals(other.single_proxies) &&
156 proxies_for_http.Equals(other.proxies_for_http) && 158 proxies_for_http.Equals(other.proxies_for_http) &&
157 proxies_for_https.Equals(other.proxies_for_https) && 159 proxies_for_https.Equals(other.proxies_for_https) &&
158 proxies_for_ftp.Equals(other.proxies_for_ftp) && 160 proxies_for_ftp.Equals(other.proxies_for_ftp) &&
159 fallback_proxies.Equals(other.fallback_proxies) && 161 fallback_proxies.Equals(other.fallback_proxies) &&
160 bypass_rules.Equals(other.bypass_rules) && 162 bypass_rules.Equals(other.bypass_rules) &&
161 reverse_bypass == other.reverse_bypass; 163 reverse_bypass == other.reverse_bypass;
162 } 164 }
163 165
164 ProxyList* ProxyConfig::ProxyRules::MapUrlSchemeToProxyListNoFallback( 166 ProxyList* ProxyConfig::ProxyRules::MapUrlSchemeToProxyListNoFallback(
165 const std::string& scheme) { 167 const std::string& scheme) {
166 DCHECK_EQ(TYPE_PROXY_PER_SCHEME, type); 168 DCHECK_EQ(TYPE_PROXY_PER_SCHEME, type);
167 if (scheme == "http") 169 if (scheme == "http")
168 return &proxies_for_http; 170 return &proxies_for_http;
169 if (scheme == "https") 171 if (scheme == "https")
170 return &proxies_for_https; 172 return &proxies_for_https;
171 if (scheme == "ftp") 173 if (scheme == "ftp")
172 return &proxies_for_ftp; 174 return &proxies_for_ftp;
173 return NULL; // No mapping for this scheme. 175 return NULL; // No mapping for this scheme.
174 } 176 }
175 177
178 const ProxyList* ProxyConfig::ProxyRules::GetProxyListForWebSocketScheme()
179 const {
180 if (!fallback_proxies.IsEmpty())
181 return &fallback_proxies;
182 if (!proxies_for_https.IsEmpty())
183 return &proxies_for_https;
184 if (!proxies_for_http.IsEmpty())
185 return &proxies_for_http;
186 return NULL;
187 }
188
176 ProxyConfig::ProxyConfig() 189 ProxyConfig::ProxyConfig()
177 : auto_detect_(false), pac_mandatory_(false), 190 : auto_detect_(false), pac_mandatory_(false),
178 source_(PROXY_CONFIG_SOURCE_UNKNOWN), id_(kInvalidConfigID) { 191 source_(PROXY_CONFIG_SOURCE_UNKNOWN), id_(kInvalidConfigID) {
179 } 192 }
180 193
181 ProxyConfig::ProxyConfig(const ProxyConfig& config) 194 ProxyConfig::ProxyConfig(const ProxyConfig& config)
182 : auto_detect_(config.auto_detect_), 195 : auto_detect_(config.auto_detect_),
183 pac_url_(config.pac_url_), 196 pac_url_(config.pac_url_),
184 pac_mandatory_(config.pac_mandatory_), 197 pac_mandatory_(config.pac_mandatory_),
185 proxy_rules_(config.proxy_rules_), 198 proxy_rules_(config.proxy_rules_),
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 281 }
269 } 282 }
270 283
271 // Output the source. 284 // Output the source.
272 dict->SetString("source", ProxyConfigSourceToString(source_)); 285 dict->SetString("source", ProxyConfigSourceToString(source_));
273 286
274 return dict; 287 return dict;
275 } 288 }
276 289
277 } // namespace net 290 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_config.h ('k') | net/proxy/proxy_config_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698