| OLD | NEW |
| 1 // Copyright (c) 2011 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_info.h" | 5 #include "net/proxy/proxy_info.h" |
| 6 | 6 |
| 7 #include "net/proxy/proxy_retry_info.h" | 7 #include "net/proxy/proxy_retry_info.h" |
| 8 | 8 |
| 9 namespace net { | 9 namespace net { |
| 10 | 10 |
| 11 ProxyInfo::ProxyInfo() : config_id_(ProxyConfig::kInvalidConfigID) { | 11 ProxyInfo::ProxyInfo() |
| 12 : config_id_(ProxyConfig::kInvalidConfigID), |
| 13 config_source_(PROXY_CONFIG_SOURCE_UNKNOWN) { |
| 12 } | 14 } |
| 13 | 15 |
| 14 ProxyInfo::~ProxyInfo() { | 16 ProxyInfo::~ProxyInfo() { |
| 15 } | 17 } |
| 16 | 18 |
| 17 void ProxyInfo::Use(const ProxyInfo& other) { | 19 void ProxyInfo::Use(const ProxyInfo& other) { |
| 18 proxy_list_ = other.proxy_list_; | 20 proxy_list_ = other.proxy_list_; |
| 19 proxy_retry_info_ = other.proxy_retry_info_; | 21 proxy_retry_info_ = other.proxy_retry_info_; |
| 22 config_id_ = other.config_id_; |
| 23 config_source_ = other.config_source_; |
| 20 } | 24 } |
| 21 | 25 |
| 22 void ProxyInfo::UseDirect() { | 26 void ProxyInfo::UseDirect() { |
| 27 Reset(); |
| 23 proxy_list_.SetSingleProxyServer(ProxyServer::Direct()); | 28 proxy_list_.SetSingleProxyServer(ProxyServer::Direct()); |
| 24 proxy_retry_info_.clear(); | |
| 25 } | 29 } |
| 26 | 30 |
| 27 void ProxyInfo::UseNamedProxy(const std::string& proxy_uri_list) { | 31 void ProxyInfo::UseNamedProxy(const std::string& proxy_uri_list) { |
| 32 Reset(); |
| 28 proxy_list_.Set(proxy_uri_list); | 33 proxy_list_.Set(proxy_uri_list); |
| 29 proxy_retry_info_.clear(); | |
| 30 } | 34 } |
| 31 | 35 |
| 32 void ProxyInfo::UseProxyServer(const ProxyServer& proxy_server) { | 36 void ProxyInfo::UseProxyServer(const ProxyServer& proxy_server) { |
| 37 Reset(); |
| 33 proxy_list_.SetSingleProxyServer(proxy_server); | 38 proxy_list_.SetSingleProxyServer(proxy_server); |
| 34 proxy_retry_info_.clear(); | |
| 35 } | 39 } |
| 36 | 40 |
| 37 std::string ProxyInfo::ToPacString() const { | 41 std::string ProxyInfo::ToPacString() const { |
| 38 return proxy_list_.ToPacString(); | 42 return proxy_list_.ToPacString(); |
| 39 } | 43 } |
| 40 | 44 |
| 41 bool ProxyInfo::Fallback(const BoundNetLog& net_log) { | 45 bool ProxyInfo::Fallback(const BoundNetLog& net_log) { |
| 42 return proxy_list_.Fallback(&proxy_retry_info_, net_log); | 46 return proxy_list_.Fallback(&proxy_retry_info_, net_log); |
| 43 } | 47 } |
| 44 | 48 |
| 45 void ProxyInfo::DeprioritizeBadProxies( | 49 void ProxyInfo::DeprioritizeBadProxies( |
| 46 const ProxyRetryInfoMap& proxy_retry_info) { | 50 const ProxyRetryInfoMap& proxy_retry_info) { |
| 47 proxy_list_.DeprioritizeBadProxies(proxy_retry_info); | 51 proxy_list_.DeprioritizeBadProxies(proxy_retry_info); |
| 48 } | 52 } |
| 49 | 53 |
| 50 void ProxyInfo::RemoveProxiesWithoutScheme(int scheme_bit_field) { | 54 void ProxyInfo::RemoveProxiesWithoutScheme(int scheme_bit_field) { |
| 51 proxy_list_.RemoveProxiesWithoutScheme(scheme_bit_field); | 55 proxy_list_.RemoveProxiesWithoutScheme(scheme_bit_field); |
| 52 } | 56 } |
| 53 | 57 |
| 58 void ProxyInfo::Reset() { |
| 59 proxy_list_.Clear(); |
| 60 proxy_retry_info_.clear(); |
| 61 config_id_ = ProxyConfig::kInvalidConfigID; |
| 62 config_source_ = PROXY_CONFIG_SOURCE_UNKNOWN; |
| 63 } |
| 64 |
| 54 } // namespace net | 65 } // namespace net |
| OLD | NEW |