• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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)17 void 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()25 void ProxyInfo::UseDirect() {
26   Reset();
27   proxy_list_.SetSingleProxyServer(ProxyServer::Direct());
28 }
29 
UseDirectWithBypassedProxy()30 void ProxyInfo::UseDirectWithBypassedProxy() {
31   UseDirect();
32   did_bypass_proxy_ = true;
33 }
34 
UseNamedProxy(const std::string & proxy_uri_list)35 void ProxyInfo::UseNamedProxy(const std::string& proxy_uri_list) {
36   Reset();
37   proxy_list_.Set(proxy_uri_list);
38 }
39 
UseProxyServer(const ProxyServer & proxy_server)40 void ProxyInfo::UseProxyServer(const ProxyServer& proxy_server) {
41   Reset();
42   proxy_list_.SetSingleProxyServer(proxy_server);
43 }
44 
UsePacString(const std::string & pac_string)45 void ProxyInfo::UsePacString(const std::string& pac_string) {
46   Reset();
47   proxy_list_.SetFromPacString(pac_string);
48 }
49 
UseProxyList(const ProxyList & proxy_list)50 void ProxyInfo::UseProxyList(const ProxyList& proxy_list) {
51   Reset();
52   proxy_list_ = proxy_list;
53 }
54 
OverrideProxyList(const ProxyList & proxy_list)55 void ProxyInfo::OverrideProxyList(const ProxyList& proxy_list) {
56   proxy_list_ = proxy_list;
57 }
58 
ToPacString() const59 std::string ProxyInfo::ToPacString() const {
60   return proxy_list_.ToPacString();
61 }
62 
Fallback(int net_error,const NetLogWithSource & net_log)63 bool 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)67 void ProxyInfo::DeprioritizeBadProxies(
68     const ProxyRetryInfoMap& proxy_retry_info) {
69   proxy_list_.DeprioritizeBadProxies(proxy_retry_info);
70 }
71 
RemoveProxiesWithoutScheme(int scheme_bit_field)72 void ProxyInfo::RemoveProxiesWithoutScheme(int scheme_bit_field) {
73   proxy_list_.RemoveProxiesWithoutScheme(scheme_bit_field);
74 }
75 
Reset()76 void 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