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), | |
14 did_bypass_proxy_(false), | |
15 did_use_pac_script_(false) { | |
12 } | 16 } |
13 | 17 |
14 ProxyInfo::~ProxyInfo() { | 18 ProxyInfo::~ProxyInfo() { |
15 } | 19 } |
16 | 20 |
17 void ProxyInfo::Use(const ProxyInfo& other) { | 21 void ProxyInfo::Use(const ProxyInfo& other) { |
18 proxy_list_ = other.proxy_list_; | 22 proxy_list_ = other.proxy_list_; |
19 proxy_retry_info_ = other.proxy_retry_info_; | 23 proxy_retry_info_ = other.proxy_retry_info_; |
24 config_id_ = other.config_id_; | |
25 config_source_ = other.config_source_; | |
26 did_bypass_proxy_ = other.did_bypass_proxy_; | |
27 did_use_pac_script_ = other.did_use_pac_script_; | |
20 } | 28 } |
21 | 29 |
22 void ProxyInfo::UseDirect() { | 30 void ProxyInfo::UseDirect() { |
31 Reset(); | |
eroman
2012/10/30 00:38:25
FYI: interestingly, there was fragile code relying
| |
23 proxy_list_.SetSingleProxyServer(ProxyServer::Direct()); | 32 proxy_list_.SetSingleProxyServer(ProxyServer::Direct()); |
24 proxy_retry_info_.clear(); | 33 } |
34 | |
35 void ProxyInfo::UseDirectWithBypassedProxy() { | |
36 UseDirect(); | |
37 did_bypass_proxy_ = true; | |
25 } | 38 } |
26 | 39 |
27 void ProxyInfo::UseNamedProxy(const std::string& proxy_uri_list) { | 40 void ProxyInfo::UseNamedProxy(const std::string& proxy_uri_list) { |
41 Reset(); | |
28 proxy_list_.Set(proxy_uri_list); | 42 proxy_list_.Set(proxy_uri_list); |
29 proxy_retry_info_.clear(); | |
30 } | 43 } |
31 | 44 |
32 void ProxyInfo::UseProxyServer(const ProxyServer& proxy_server) { | 45 void ProxyInfo::UseProxyServer(const ProxyServer& proxy_server) { |
46 Reset(); | |
33 proxy_list_.SetSingleProxyServer(proxy_server); | 47 proxy_list_.SetSingleProxyServer(proxy_server); |
34 proxy_retry_info_.clear(); | |
35 } | 48 } |
36 | 49 |
37 std::string ProxyInfo::ToPacString() const { | 50 std::string ProxyInfo::ToPacString() const { |
38 return proxy_list_.ToPacString(); | 51 return proxy_list_.ToPacString(); |
39 } | 52 } |
40 | 53 |
41 bool ProxyInfo::Fallback(const BoundNetLog& net_log) { | 54 bool ProxyInfo::Fallback(const BoundNetLog& net_log) { |
42 return proxy_list_.Fallback(&proxy_retry_info_, net_log); | 55 return proxy_list_.Fallback(&proxy_retry_info_, net_log); |
43 } | 56 } |
44 | 57 |
45 void ProxyInfo::DeprioritizeBadProxies( | 58 void ProxyInfo::DeprioritizeBadProxies( |
46 const ProxyRetryInfoMap& proxy_retry_info) { | 59 const ProxyRetryInfoMap& proxy_retry_info) { |
47 proxy_list_.DeprioritizeBadProxies(proxy_retry_info); | 60 proxy_list_.DeprioritizeBadProxies(proxy_retry_info); |
48 } | 61 } |
49 | 62 |
50 void ProxyInfo::RemoveProxiesWithoutScheme(int scheme_bit_field) { | 63 void ProxyInfo::RemoveProxiesWithoutScheme(int scheme_bit_field) { |
51 proxy_list_.RemoveProxiesWithoutScheme(scheme_bit_field); | 64 proxy_list_.RemoveProxiesWithoutScheme(scheme_bit_field); |
52 } | 65 } |
53 | 66 |
67 void ProxyInfo::Reset() { | |
68 proxy_list_.Clear(); | |
69 proxy_retry_info_.clear(); | |
70 config_id_ = ProxyConfig::kInvalidConfigID; | |
71 config_source_ = PROXY_CONFIG_SOURCE_UNKNOWN; | |
72 did_bypass_proxy_ = false; | |
73 did_use_pac_script_ = false; | |
74 } | |
75 | |
54 } // namespace net | 76 } // namespace net |
OLD | NEW |