OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" | 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h " | 9 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h " |
10 #include "net/proxy/proxy_info.h" | 10 #include "net/proxy/proxy_info.h" |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 return std::string(); | 322 return std::string(); |
323 if (command_line.HasSwitch(switches::kEnableDataReductionProxyDev) || | 323 if (command_line.HasSwitch(switches::kEnableDataReductionProxyDev) || |
324 (FieldTrialList::FindFullName("DataCompressionProxyDevRollout") == | 324 (FieldTrialList::FindFullName("DataCompressionProxyDevRollout") == |
325 kEnabled)) { | 325 kEnabled)) { |
326 return DATA_REDUCTION_DEV_HOST; | 326 return DATA_REDUCTION_DEV_HOST; |
327 } | 327 } |
328 #endif | 328 #endif |
329 return std::string(); | 329 return std::string(); |
330 } | 330 } |
331 | 331 |
332 bool DataReductionProxyParams::WereDataReductionProxiesBypassed( | |
333 const net::URLRequest* request) const { | |
334 DataReductionProxyParams::DataReductionProxyList proxies = | |
335 GetAllowedProxies(); | |
336 if (proxies.size() == 0) | |
337 return false; | |
338 | |
339 if (request == NULL || request->context() == NULL || | |
bengr
2014/07/16 01:40:09
Are any of these NULL in practice? I'd prefer:
DCH
| |
340 request->context()->proxy_service() == NULL) { | |
341 return false; | |
342 } | |
343 | |
344 const net::ProxyRetryInfoMap& retry_map = | |
345 request->context()->proxy_service()->proxy_retry_info(); | |
346 if (retry_map.size() == 0) | |
347 return false; | |
348 | |
349 // The request is bypassed if all configured proxies are in the retry map. | |
350 for (size_t i = 0; i < proxies.size(); ++i) { | |
bengr
2014/07/16 01:40:10
This isn't right if alt proxies are involved. If t
megjablon
2014/07/16 23:07:14
This is based on:
https://code.google.com/p/chro
bengr
2014/07/16 23:28:14
Yes
| |
351 std::string proxy = net::HostPortPair::FromURL(proxies[i]).ToString(); | |
352 // The retry list has the scheme prefix for https but not for http. | |
353 if (proxies[i].SchemeIs("https")) | |
354 proxy = std::string("https://") + proxy; | |
355 | |
356 net::ProxyRetryInfoMap::const_iterator found = retry_map.find(proxy); | |
357 if (found == retry_map.end()) | |
358 return false; | |
359 | |
360 } | |
361 return true; | |
362 } | |
363 | |
332 std::string DataReductionProxyParams::GetDefaultOrigin() const { | 364 std::string DataReductionProxyParams::GetDefaultOrigin() const { |
333 #if defined(SPDY_PROXY_AUTH_ORIGIN) | 365 #if defined(SPDY_PROXY_AUTH_ORIGIN) |
334 return SPDY_PROXY_AUTH_ORIGIN; | 366 return SPDY_PROXY_AUTH_ORIGIN; |
335 #endif | 367 #endif |
336 return std::string(); | 368 return std::string(); |
337 } | 369 } |
338 | 370 |
339 std::string DataReductionProxyParams::GetDefaultFallbackOrigin() const { | 371 std::string DataReductionProxyParams::GetDefaultFallbackOrigin() const { |
340 #if defined(DATA_REDUCTION_FALLBACK_HOST) | 372 #if defined(DATA_REDUCTION_FALLBACK_HOST) |
341 return DATA_REDUCTION_FALLBACK_HOST; | 373 return DATA_REDUCTION_FALLBACK_HOST; |
(...skipping 30 matching lines...) Expand all Loading... | |
372 } | 404 } |
373 | 405 |
374 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { | 406 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { |
375 #if defined(DATA_REDUCTION_PROXY_WARMUP_URL) | 407 #if defined(DATA_REDUCTION_PROXY_WARMUP_URL) |
376 return DATA_REDUCTION_PROXY_WARMUP_URL; | 408 return DATA_REDUCTION_PROXY_WARMUP_URL; |
377 #endif | 409 #endif |
378 return std::string(); | 410 return std::string(); |
379 } | 411 } |
380 | 412 |
381 } // namespace data_reduction_proxy | 413 } // namespace data_reduction_proxy |
OLD | NEW |