Andrew Top | 0d1858f | 2019-05-15 22:01:47 -0700 | [diff] [blame] | 1 | // Copyright 2018 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 | |
| 5 | #ifndef NET_QUIC_QUIC_SESSION_KEY_H_ |
| 6 | #define NET_QUIC_QUIC_SESSION_KEY_H_ |
| 7 | |
| 8 | #include "net/base/host_port_pair.h" |
| 9 | #include "net/base/privacy_mode.h" |
| 10 | #include "net/socket/socket_tag.h" |
| 11 | #include "net/third_party/quic/core/quic_server_id.h" |
| 12 | |
| 13 | namespace net { |
| 14 | |
| 15 | // The key used to identify sessions. Includes the quic::QuicServerId and socket |
| 16 | // tag. |
| 17 | class QUIC_EXPORT_PRIVATE QuicSessionKey { |
| 18 | public: |
| 19 | QuicSessionKey() = default; |
| 20 | QuicSessionKey(const HostPortPair& host_port_pair, |
| 21 | PrivacyMode privacy_mode, |
| 22 | const SocketTag& socket_tag); |
| 23 | QuicSessionKey(const std::string& host, |
| 24 | uint16_t port, |
| 25 | PrivacyMode privacy_mode, |
| 26 | const SocketTag& socket_tag); |
| 27 | QuicSessionKey(const quic::QuicServerId& server_id, |
| 28 | const SocketTag& socket_tag); |
| 29 | ~QuicSessionKey() = default; |
| 30 | |
| 31 | // Needed to be an element of std::set. |
| 32 | bool operator<(const QuicSessionKey& other) const; |
| 33 | bool operator==(const QuicSessionKey& other) const; |
| 34 | |
| 35 | const std::string& host() const { return server_id_.host(); } |
| 36 | |
| 37 | PrivacyMode privacy_mode() const { |
| 38 | return server_id_.privacy_mode_enabled() ? PRIVACY_MODE_ENABLED |
| 39 | : PRIVACY_MODE_DISABLED; |
| 40 | } |
| 41 | |
| 42 | const quic::QuicServerId& server_id() const { return server_id_; } |
| 43 | |
| 44 | SocketTag socket_tag() const { return socket_tag_; } |
| 45 | |
| 46 | size_t EstimateMemoryUsage() const; |
| 47 | |
| 48 | private: |
| 49 | quic::QuicServerId server_id_; |
| 50 | SocketTag socket_tag_; |
| 51 | }; |
| 52 | |
| 53 | } // namespace net |
| 54 | |
| 55 | #endif // NET_QUIC_QUIC_SERVER_ID_H_ |