1 // 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/quic/quic_server_id.h"
6
7 using std::string;
8
9 namespace net {
10
QuicServerId()11 QuicServerId::QuicServerId() {}
12
QuicServerId(const HostPortPair & host_port_pair,bool is_https,PrivacyMode privacy_mode)13 QuicServerId::QuicServerId(const HostPortPair& host_port_pair,
14 bool is_https,
15 PrivacyMode privacy_mode)
16 : host_port_pair_(host_port_pair),
17 is_https_(is_https),
18 privacy_mode_(privacy_mode) {}
19
QuicServerId(const string & host,uint16 port,bool is_https)20 QuicServerId::QuicServerId(const string& host,
21 uint16 port,
22 bool is_https)
23 : host_port_pair_(host, port),
24 is_https_(is_https),
25 privacy_mode_(PRIVACY_MODE_DISABLED) {}
26
QuicServerId(const string & host,uint16 port,bool is_https,PrivacyMode privacy_mode)27 QuicServerId::QuicServerId(const string& host,
28 uint16 port,
29 bool is_https,
30 PrivacyMode privacy_mode)
31 : host_port_pair_(host, port),
32 is_https_(is_https),
33 privacy_mode_(privacy_mode) {}
34
~QuicServerId()35 QuicServerId::~QuicServerId() {}
36
operator <(const QuicServerId & other) const37 bool QuicServerId::operator<(const QuicServerId& other) const {
38 if (!host_port_pair_.Equals(other.host_port_pair_)) {
39 return host_port_pair_ < other.host_port_pair_;
40 }
41 if (is_https_ != other.is_https_) {
42 return is_https_ < other.is_https_;
43 }
44 return privacy_mode_ < other.privacy_mode_;
45 }
46
operator ==(const QuicServerId & other) const47 bool QuicServerId::operator==(const QuicServerId& other) const {
48 return is_https_ == other.is_https_ &&
49 privacy_mode_ == other.privacy_mode_ &&
50 host_port_pair_.Equals(other.host_port_pair_);
51 }
52
ToString() const53 string QuicServerId::ToString() const {
54 return (is_https_ ? "https://" : "http://") + host_port_pair_.ToString() +
55 (privacy_mode_ == PRIVACY_MODE_ENABLED ? "/private" : "");
56 }
57
58 } // namespace net
59