Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: net/http/http_server_properties.cc

Issue 2901093004: Add and persist a new field in AlternativeServiceInfo to list QUIC verisons advertised (Closed)
Patch Set: fix compile in components Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_server_properties.h" 5 #include "net/http/http_server_properties.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "net/http/http_network_session.h"
10 #include "net/socket/ssl_client_socket.h" 11 #include "net/socket/ssl_client_socket.h"
11 #include "net/ssl/ssl_config.h" 12 #include "net/ssl/ssl_config.h"
12 13
13 namespace net { 14 namespace net {
14 15
15 namespace { 16 namespace {
16 17
17 enum AlternativeProxyUsage { 18 enum AlternativeProxyUsage {
18 // Alternative Proxy was used without racing a normal connection. 19 // Alternative Proxy was used without racing a normal connection.
19 ALTERNATIVE_PROXY_USAGE_NO_RACE = 0, 20 ALTERNATIVE_PROXY_USAGE_NO_RACE = 0,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 return false; 72 return false;
72 case kProtoHTTP2: 73 case kProtoHTTP2:
73 return true; 74 return true;
74 case kProtoQUIC: 75 case kProtoQUIC:
75 return true; 76 return true;
76 } 77 }
77 NOTREACHED(); 78 NOTREACHED();
78 return false; 79 return false;
79 } 80 }
80 81
82 AlternativeServiceInfo::AlternativeServiceInfo() : alternative_service() {}
83
84 AlternativeServiceInfo::~AlternativeServiceInfo() {}
85
86 AlternativeServiceInfo::AlternativeServiceInfo(
87 const AlternativeService& alternative_service,
88 base::Time expiration)
89 : alternative_service(alternative_service), expiration(expiration) {}
90
91 AlternativeServiceInfo::AlternativeServiceInfo(
92 const AlternativeService& alternative_service,
93 base::Time expiration,
94 const QuicVersionVector& advertised_versions)
95 : alternative_service(alternative_service), expiration(expiration) {
96 if (alternative_service.protocol == kProtoQUIC) {
97 advertised_versions_ = advertised_versions;
98 std::sort(advertised_versions_.begin(), advertised_versions_.end());
99 }
100 }
101
102 AlternativeServiceInfo::AlternativeServiceInfo(
103 const AlternativeServiceInfo& alternative_service_info) = default;
104
105 AlternativeServiceInfo& AlternativeServiceInfo::operator=(
106 const AlternativeServiceInfo& alternative_service_info) = default;
107
108 bool AlternativeServiceInfo::EqualAdvertisedVersions(
109 const AlternativeServiceInfo& other) const {
110 if (alternative_service.protocol != kProtoQUIC)
111 return true;
112
113 // Check equality of advertised versions for QUIC.
114 if (advertised_versions_.size() != other.advertised_versions().size())
115 return false;
Ryan Hamilton 2017/06/07 20:52:23 Is this expression necessary? I suspect == will ju
Zhongyi Shi 2017/06/08 23:11:16 Acknowledged. This method is removed in the new pa
116
117 return advertised_versions_ == other.advertised_versions();
118 }
119
81 std::string AlternativeService::ToString() const { 120 std::string AlternativeService::ToString() const {
82 return base::StringPrintf("%s %s:%d", NextProtoToString(protocol), 121 return base::StringPrintf("%s %s:%d", NextProtoToString(protocol),
83 host.c_str(), port); 122 host.c_str(), port);
84 } 123 }
85 124
86 std::string AlternativeServiceInfo::ToString() const { 125 std::string AlternativeServiceInfo::ToString() const {
87 base::Time::Exploded exploded; 126 base::Time::Exploded exploded;
88 expiration.LocalExplode(&exploded); 127 expiration.LocalExplode(&exploded);
89 return base::StringPrintf( 128 return base::StringPrintf(
90 "%s, expires %04d-%02d-%02d %02d:%02d:%02d", 129 "%s, expires %04d-%02d-%02d %02d:%02d:%02d",
91 alternative_service.ToString().c_str(), exploded.year, exploded.month, 130 alternative_service.ToString().c_str(), exploded.year, exploded.month,
92 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second); 131 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second);
93 } 132 }
94 133
95 std::ostream& operator<<(std::ostream& os, 134 std::ostream& operator<<(std::ostream& os,
96 const AlternativeService& alternative_service) { 135 const AlternativeService& alternative_service) {
97 os << alternative_service.ToString(); 136 os << alternative_service.ToString();
98 return os; 137 return os;
99 } 138 }
100 139
101 // static 140 // static
102 void HttpServerProperties::ForceHTTP11(SSLConfig* ssl_config) { 141 void HttpServerProperties::ForceHTTP11(SSLConfig* ssl_config) {
103 ssl_config->alpn_protos.clear(); 142 ssl_config->alpn_protos.clear();
104 ssl_config->alpn_protos.push_back(kProtoHTTP11); 143 ssl_config->alpn_protos.push_back(kProtoHTTP11);
105 } 144 }
106 145
107 } // namespace net 146 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698