1 // Copyright 2012 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "net/proxy_resolution/proxy_info.h" 6 7 #include "net/proxy_resolution/proxy_retry_info.h" 8 9 namespace net { 10 11 ProxyInfo::ProxyInfo() = default; 12 13 ProxyInfo::ProxyInfo(const ProxyInfo& other) = default; 14 15 ProxyInfo::~ProxyInfo() = default; 16 Use(const ProxyInfo & other)17void ProxyInfo::Use(const ProxyInfo& other) { 18 proxy_resolve_start_time_ = other.proxy_resolve_start_time_; 19 proxy_resolve_end_time_ = other.proxy_resolve_end_time_; 20 proxy_list_ = other.proxy_list_; 21 proxy_retry_info_ = other.proxy_retry_info_; 22 did_bypass_proxy_ = other.did_bypass_proxy_; 23 } 24 UseDirect()25void ProxyInfo::UseDirect() { 26 Reset(); 27 proxy_list_.SetSingleProxyServer(ProxyServer::Direct()); 28 } 29 UseDirectWithBypassedProxy()30void ProxyInfo::UseDirectWithBypassedProxy() { 31 UseDirect(); 32 did_bypass_proxy_ = true; 33 } 34 UseNamedProxy(const std::string & proxy_uri_list)35void ProxyInfo::UseNamedProxy(const std::string& proxy_uri_list) { 36 Reset(); 37 proxy_list_.Set(proxy_uri_list); 38 } 39 UseProxyServer(const ProxyServer & proxy_server)40void ProxyInfo::UseProxyServer(const ProxyServer& proxy_server) { 41 Reset(); 42 proxy_list_.SetSingleProxyServer(proxy_server); 43 } 44 UsePacString(const std::string & pac_string)45void ProxyInfo::UsePacString(const std::string& pac_string) { 46 Reset(); 47 proxy_list_.SetFromPacString(pac_string); 48 } 49 UseProxyList(const ProxyList & proxy_list)50void ProxyInfo::UseProxyList(const ProxyList& proxy_list) { 51 Reset(); 52 proxy_list_ = proxy_list; 53 } 54 OverrideProxyList(const ProxyList & proxy_list)55void ProxyInfo::OverrideProxyList(const ProxyList& proxy_list) { 56 proxy_list_ = proxy_list; 57 } 58 ToPacString() const59std::string ProxyInfo::ToPacString() const { 60 return proxy_list_.ToPacString(); 61 } 62 Fallback(int net_error,const NetLogWithSource & net_log)63bool ProxyInfo::Fallback(int net_error, const NetLogWithSource& net_log) { 64 return proxy_list_.Fallback(&proxy_retry_info_, net_error, net_log); 65 } 66 DeprioritizeBadProxies(const ProxyRetryInfoMap & proxy_retry_info)67void ProxyInfo::DeprioritizeBadProxies( 68 const ProxyRetryInfoMap& proxy_retry_info) { 69 proxy_list_.DeprioritizeBadProxies(proxy_retry_info); 70 } 71 RemoveProxiesWithoutScheme(int scheme_bit_field)72void ProxyInfo::RemoveProxiesWithoutScheme(int scheme_bit_field) { 73 proxy_list_.RemoveProxiesWithoutScheme(scheme_bit_field); 74 } 75 Reset()76void ProxyInfo::Reset() { 77 proxy_resolve_start_time_ = base::TimeTicks(); 78 proxy_resolve_end_time_ = base::TimeTicks(); 79 proxy_list_.Clear(); 80 proxy_retry_info_.clear(); 81 did_bypass_proxy_ = false; 82 } 83 84 } // namespace net 85