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.
5 #include "net/quic/quic_server_id.h"
11 QuicServerId::QuicServerId()
12 : is_https_(false), privacy_mode_(PRIVACY_MODE_DISABLED
) {
15 QuicServerId::QuicServerId(const HostPortPair
& host_port_pair
,
17 PrivacyMode privacy_mode
)
18 : host_port_pair_(host_port_pair
),
20 privacy_mode_(privacy_mode
) {}
22 QuicServerId::QuicServerId(const string
& host
,
25 : host_port_pair_(host
, port
),
27 privacy_mode_(PRIVACY_MODE_DISABLED
) {}
29 QuicServerId::QuicServerId(const string
& host
,
32 PrivacyMode privacy_mode
)
33 : host_port_pair_(host
, port
),
35 privacy_mode_(privacy_mode
) {}
37 QuicServerId::~QuicServerId() {}
39 bool QuicServerId::operator<(const QuicServerId
& other
) const {
40 if (!host_port_pair_
.Equals(other
.host_port_pair_
)) {
41 return host_port_pair_
< other
.host_port_pair_
;
43 if (is_https_
!= other
.is_https_
) {
44 return is_https_
< other
.is_https_
;
46 return privacy_mode_
< other
.privacy_mode_
;
49 bool QuicServerId::operator==(const QuicServerId
& other
) const {
50 return is_https_
== other
.is_https_
&&
51 privacy_mode_
== other
.privacy_mode_
&&
52 host_port_pair_
.Equals(other
.host_port_pair_
);
55 string
QuicServerId::ToString() const {
56 return (is_https_
? "https://" : "http://") + host_port_pair_
.ToString() +
57 (privacy_mode_
== PRIVACY_MODE_ENABLED
? "/private" : "");