proxy_info.cc 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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
  3. // found in the LICENSE file.
  4. #include "net/proxy_resolution/proxy_info.h"
  5. #include "net/proxy_resolution/proxy_retry_info.h"
  6. namespace net {
  7. ProxyInfo::ProxyInfo() = default;
  8. ProxyInfo::ProxyInfo(const ProxyInfo& other) = default;
  9. ProxyInfo::~ProxyInfo() = default;
  10. void ProxyInfo::Use(const ProxyInfo& other) {
  11. proxy_resolve_start_time_ = other.proxy_resolve_start_time_;
  12. proxy_resolve_end_time_ = other.proxy_resolve_end_time_;
  13. proxy_list_ = other.proxy_list_;
  14. proxy_retry_info_ = other.proxy_retry_info_;
  15. did_bypass_proxy_ = other.did_bypass_proxy_;
  16. }
  17. void ProxyInfo::UseDirect() {
  18. Reset();
  19. proxy_list_.SetSingleProxyServer(ProxyServer::Direct());
  20. }
  21. void ProxyInfo::UseDirectWithBypassedProxy() {
  22. UseDirect();
  23. did_bypass_proxy_ = true;
  24. }
  25. void ProxyInfo::UseNamedProxy(const std::string& proxy_uri_list) {
  26. Reset();
  27. proxy_list_.Set(proxy_uri_list);
  28. }
  29. void ProxyInfo::UseProxyServer(const ProxyServer& proxy_server) {
  30. Reset();
  31. proxy_list_.SetSingleProxyServer(proxy_server);
  32. }
  33. void ProxyInfo::UsePacString(const std::string& pac_string) {
  34. Reset();
  35. proxy_list_.SetFromPacString(pac_string);
  36. }
  37. void ProxyInfo::UseProxyList(const ProxyList& proxy_list) {
  38. Reset();
  39. proxy_list_ = proxy_list;
  40. }
  41. void ProxyInfo::OverrideProxyList(const ProxyList& proxy_list) {
  42. proxy_list_ = proxy_list;
  43. }
  44. std::string ProxyInfo::ToPacString() const {
  45. return proxy_list_.ToPacString();
  46. }
  47. bool ProxyInfo::Fallback(int net_error, const NetLogWithSource& net_log) {
  48. return proxy_list_.Fallback(&proxy_retry_info_, net_error, net_log);
  49. }
  50. void ProxyInfo::DeprioritizeBadProxies(
  51. const ProxyRetryInfoMap& proxy_retry_info) {
  52. proxy_list_.DeprioritizeBadProxies(proxy_retry_info);
  53. }
  54. void ProxyInfo::RemoveProxiesWithoutScheme(int scheme_bit_field) {
  55. proxy_list_.RemoveProxiesWithoutScheme(scheme_bit_field);
  56. }
  57. void ProxyInfo::Reset() {
  58. proxy_resolve_start_time_ = base::TimeTicks();
  59. proxy_resolve_end_time_ = base::TimeTicks();
  60. proxy_list_.Clear();
  61. proxy_retry_info_.clear();
  62. did_bypass_proxy_ = false;
  63. }
  64. } // namespace net