| OLD | NEW |
| 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_service.h" | 5 #include "net/proxy/proxy_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1199 | 1199 |
| 1200 bool re_resolve = result->config_id_ != config_.id(); | 1200 bool re_resolve = result->config_id_ != config_.id(); |
| 1201 | 1201 |
| 1202 if (re_resolve) { | 1202 if (re_resolve) { |
| 1203 // If we have a new config or the config was never tried, we delete the | 1203 // If we have a new config or the config was never tried, we delete the |
| 1204 // list of bad proxies and we try again. | 1204 // list of bad proxies and we try again. |
| 1205 proxy_retry_info_.clear(); | 1205 proxy_retry_info_.clear(); |
| 1206 return ResolveProxy(url, load_flags, result, callback, pac_request, | 1206 return ResolveProxy(url, load_flags, result, callback, pac_request, |
| 1207 network_delegate, net_log); | 1207 network_delegate, net_log); |
| 1208 } | 1208 } |
| 1209 | 1209 // TODO(kundaji): Make this a callback to remove dependency on data reduction |
| 1210 #if defined(SPDY_PROXY_AUTH_ORIGIN) | 1210 // proxy related classes. |
| 1211 if (result->proxy_server().isDataReductionProxy()) { | 1211 const net::ProxyServer& proxy_server = result->proxy_server(); |
| 1212 RecordDataReductionProxyBypassInfo( | 1212 if (proxy_server.is_valid() && !proxy_server.is_direct()) { |
| 1213 true, false, result->proxy_server(), NETWORK_ERROR); | 1213 if (proxy_server.host_port_pair().Equals( |
| 1214 RecordDataReductionProxyBypassOnNetworkError( | 1214 data_reduction_default_origin_)) { |
| 1215 true, result->proxy_server(), net_error); | 1215 RecordDataReductionProxyBypassInfo( |
| 1216 } else if (result->proxy_server().isDataReductionProxyFallback()) { | 1216 true, false, proxy_server, NETWORK_ERROR); |
| 1217 RecordDataReductionProxyBypassInfo( | 1217 RecordDataReductionProxyBypassOnNetworkError( |
| 1218 false, false, result->proxy_server(), NETWORK_ERROR); | 1218 true, proxy_server, net_error); |
| 1219 RecordDataReductionProxyBypassOnNetworkError( | 1219 } else if (proxy_server.host_port_pair().Equals( |
| 1220 false, result->proxy_server(), net_error); | 1220 data_reduction_default_fallback_origin_)) { |
| 1221 RecordDataReductionProxyBypassInfo( |
| 1222 false, false, proxy_server, NETWORK_ERROR); |
| 1223 RecordDataReductionProxyBypassOnNetworkError( |
| 1224 false, proxy_server, net_error); |
| 1225 } |
| 1221 } | 1226 } |
| 1222 #endif | |
| 1223 | 1227 |
| 1224 // We don't have new proxy settings to try, try to fallback to the next proxy | 1228 // We don't have new proxy settings to try, try to fallback to the next proxy |
| 1225 // in the list. | 1229 // in the list. |
| 1226 bool did_fallback = result->Fallback(net_log); | 1230 bool did_fallback = result->Fallback(net_log); |
| 1227 | 1231 |
| 1228 // Return synchronous failure if there is nothing left to fall-back to. | 1232 // Return synchronous failure if there is nothing left to fall-back to. |
| 1229 // TODO(eroman): This is a yucky API, clean it up. | 1233 // TODO(eroman): This is a yucky API, clean it up. |
| 1230 return did_fallback ? OK : ERR_FAILED; | 1234 return did_fallback ? OK : ERR_FAILED; |
| 1231 } | 1235 } |
| 1232 | 1236 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1391 if (previous_state != STATE_NONE) | 1395 if (previous_state != STATE_NONE) |
| 1392 ApplyProxyConfigIfAvailable(); | 1396 ApplyProxyConfigIfAvailable(); |
| 1393 } | 1397 } |
| 1394 | 1398 |
| 1395 void ProxyService::ForceReloadProxyConfig() { | 1399 void ProxyService::ForceReloadProxyConfig() { |
| 1396 DCHECK(CalledOnValidThread()); | 1400 DCHECK(CalledOnValidThread()); |
| 1397 ResetProxyConfig(false); | 1401 ResetProxyConfig(false); |
| 1398 ApplyProxyConfigIfAvailable(); | 1402 ApplyProxyConfigIfAvailable(); |
| 1399 } | 1403 } |
| 1400 | 1404 |
| 1405 void ProxyService::SetDataReductionProxyOrigins( |
| 1406 const std::string& data_reduction_default_origin, |
| 1407 const std::string& data_reduction_default_fallback_origin) { |
| 1408 DCHECK(CalledOnValidThread()); |
| 1409 data_reduction_default_origin_ = |
| 1410 net::HostPortPair::FromURL(GURL(data_reduction_default_origin)); |
| 1411 data_reduction_default_fallback_origin_ = |
| 1412 net::HostPortPair::FromURL(GURL(data_reduction_default_fallback_origin)); |
| 1413 } |
| 1414 |
| 1401 // static | 1415 // static |
| 1402 ProxyConfigService* ProxyService::CreateSystemProxyConfigService( | 1416 ProxyConfigService* ProxyService::CreateSystemProxyConfigService( |
| 1403 base::SingleThreadTaskRunner* io_thread_task_runner, | 1417 base::SingleThreadTaskRunner* io_thread_task_runner, |
| 1404 base::MessageLoop* file_loop) { | 1418 base::MessageLoop* file_loop) { |
| 1405 #if defined(OS_WIN) | 1419 #if defined(OS_WIN) |
| 1406 return new ProxyConfigServiceWin(); | 1420 return new ProxyConfigServiceWin(); |
| 1407 #elif defined(OS_IOS) | 1421 #elif defined(OS_IOS) |
| 1408 return new ProxyConfigServiceIOS(); | 1422 return new ProxyConfigServiceIOS(); |
| 1409 #elif defined(OS_MACOSX) | 1423 #elif defined(OS_MACOSX) |
| 1410 return new ProxyConfigServiceMac(io_thread_task_runner); | 1424 return new ProxyConfigServiceMac(io_thread_task_runner); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1610 State previous_state = ResetProxyConfig(false); | 1624 State previous_state = ResetProxyConfig(false); |
| 1611 if (previous_state != STATE_NONE) | 1625 if (previous_state != STATE_NONE) |
| 1612 ApplyProxyConfigIfAvailable(); | 1626 ApplyProxyConfigIfAvailable(); |
| 1613 } | 1627 } |
| 1614 | 1628 |
| 1615 void ProxyService::OnDNSChanged() { | 1629 void ProxyService::OnDNSChanged() { |
| 1616 OnIPAddressChanged(); | 1630 OnIPAddressChanged(); |
| 1617 } | 1631 } |
| 1618 | 1632 |
| 1619 } // namespace net | 1633 } // namespace net |
| OLD | NEW |