blob: 6a4e56f88b93ce7b74429938db0d83152715b193 [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// Copyright 2014 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#include "net/third_party/quiche/src/quic/core/quic_server_id.h"
6
vasilvv872e7a32019-03-12 16:42:44 -07007#include <string>
QUICHE teama6ef0a62019-03-07 20:34:33 -05008#include <tuple>
9
10#include "net/third_party/quiche/src/quic/platform/api/quic_estimate_memory_usage.h"
11#include "net/third_party/quiche/src/quic/platform/api/quic_str_cat.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050012
13namespace quic {
14
15QuicServerId::QuicServerId() : QuicServerId("", 0, false) {}
16
vasilvvc48c8712019-03-11 13:38:16 -070017QuicServerId::QuicServerId(const std::string& host, uint16_t port)
QUICHE teama6ef0a62019-03-07 20:34:33 -050018 : QuicServerId(host, port, false) {}
19
vasilvvc48c8712019-03-11 13:38:16 -070020QuicServerId::QuicServerId(const std::string& host,
QUICHE teama6ef0a62019-03-07 20:34:33 -050021 uint16_t port,
22 bool privacy_mode_enabled)
23 : host_(host), port_(port), privacy_mode_enabled_(privacy_mode_enabled) {}
24
25QuicServerId::~QuicServerId() {}
26
27bool QuicServerId::operator<(const QuicServerId& other) const {
28 return std::tie(port_, host_, privacy_mode_enabled_) <
29 std::tie(other.port_, other.host_, other.privacy_mode_enabled_);
30}
31
32bool QuicServerId::operator==(const QuicServerId& other) const {
33 return privacy_mode_enabled_ == other.privacy_mode_enabled_ &&
34 host_ == other.host_ && port_ == other.port_;
35}
36
37size_t QuicServerId::EstimateMemoryUsage() const {
38 return QuicEstimateMemoryUsage(host_);
39}
40
41} // namespace quic