• 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/spdy/spdy_session_key.h"
6 
7 #include <tuple>
8 
9 #include "base/feature_list.h"
10 #include "base/logging.h"
11 #include "base/trace_event/memory_usage_estimator.h"
12 #include "net/base/features.h"
13 #include "net/base/host_port_pair.h"
14 #include "net/base/proxy_chain.h"
15 #include "net/base/proxy_string_util.h"
16 #include "net/dns/public/secure_dns_policy.h"
17 #include "third_party/abseil-cpp/absl/types/optional.h"
18 
19 namespace net {
20 
21 SpdySessionKey::SpdySessionKey() = default;
22 
SpdySessionKey(const HostPortPair & host_port_pair,const ProxyChain & proxy_chain,PrivacyMode privacy_mode,IsProxySession is_proxy_session,const SocketTag & socket_tag,const NetworkAnonymizationKey & network_anonymization_key,SecureDnsPolicy secure_dns_policy)23 SpdySessionKey::SpdySessionKey(
24     const HostPortPair& host_port_pair,
25     const ProxyChain& proxy_chain,
26     PrivacyMode privacy_mode,
27     IsProxySession is_proxy_session,
28     const SocketTag& socket_tag,
29     const NetworkAnonymizationKey& network_anonymization_key,
30     SecureDnsPolicy secure_dns_policy)
31     : host_port_proxy_pair_(host_port_pair, proxy_chain),
32       privacy_mode_(privacy_mode),
33       is_proxy_session_(is_proxy_session),
34       socket_tag_(socket_tag),
35       network_anonymization_key_(
36           NetworkAnonymizationKey::IsPartitioningEnabled()
37               ? network_anonymization_key
38               : NetworkAnonymizationKey()),
39       secure_dns_policy_(secure_dns_policy) {
40   DVLOG(1) << "SpdySessionKey(host=" << host_port_pair.ToString()
41            << ", proxy_chain=" << proxy_chain << ", privacy=" << privacy_mode;
42 }
43 
44 SpdySessionKey::SpdySessionKey(const SpdySessionKey& other) = default;
45 
46 SpdySessionKey::~SpdySessionKey() = default;
47 
operator <(const SpdySessionKey & other) const48 bool SpdySessionKey::operator<(const SpdySessionKey& other) const {
49   return std::tie(privacy_mode_, host_port_proxy_pair_.first,
50                   host_port_proxy_pair_.second, is_proxy_session_,
51                   network_anonymization_key_, secure_dns_policy_, socket_tag_) <
52          std::tie(other.privacy_mode_, other.host_port_proxy_pair_.first,
53                   other.host_port_proxy_pair_.second, other.is_proxy_session_,
54                   other.network_anonymization_key_, other.secure_dns_policy_,
55                   other.socket_tag_);
56 }
57 
operator ==(const SpdySessionKey & other) const58 bool SpdySessionKey::operator==(const SpdySessionKey& other) const {
59   return privacy_mode_ == other.privacy_mode_ &&
60          host_port_proxy_pair_.first.Equals(
61              other.host_port_proxy_pair_.first) &&
62          host_port_proxy_pair_.second == other.host_port_proxy_pair_.second &&
63          is_proxy_session_ == other.is_proxy_session_ &&
64          network_anonymization_key_ == other.network_anonymization_key_ &&
65          secure_dns_policy_ == other.secure_dns_policy_ &&
66          socket_tag_ == other.socket_tag_;
67 }
68 
operator !=(const SpdySessionKey & other) const69 bool SpdySessionKey::operator!=(const SpdySessionKey& other) const {
70   return !(*this == other);
71 }
72 
CompareForAliasing(const SpdySessionKey & other) const73 SpdySessionKey::CompareForAliasingResult SpdySessionKey::CompareForAliasing(
74     const SpdySessionKey& other) const {
75   CompareForAliasingResult result;
76   result.is_potentially_aliasable =
77       (privacy_mode_ == other.privacy_mode_ &&
78        host_port_proxy_pair_.second == other.host_port_proxy_pair_.second &&
79        is_proxy_session_ == other.is_proxy_session_ &&
80        network_anonymization_key_ == other.network_anonymization_key_ &&
81        secure_dns_policy_ == other.secure_dns_policy_);
82   result.is_socket_tag_match = (socket_tag_ == other.socket_tag_);
83   return result;
84 }
85 
86 }  // namespace net
87