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

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 cronet/grpc 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 // static
83 AlternativeServiceInfo
84 AlternativeServiceInfo::CreateHttp2AlternativeServiceInfo(
85 const AlternativeService& alternative_service,
86 base::Time expiration) {
87 DCHECK(alternative_service.protocol != kProtoQUIC);
Bence 2017/06/16 14:43:40 DCHECK_EQ(kProtoHTTP2, alternative_service.protoco
Zhongyi Shi 2017/06/20 23:23:37 Done.
88 return AlternativeServiceInfo(alternative_service, expiration,
89 QuicVersionVector());
90 }
91
92 // static
93 AlternativeServiceInfo AlternativeServiceInfo::CreateQuicAlternativeServiceInfo(
94 const AlternativeService& alternative_service,
95 base::Time expiration,
96 const QuicVersionVector& advertised_versions) {
97 DCHECK(alternative_service.protocol == kProtoQUIC);
Bence 2017/06/16 14:43:40 DCHECK_EQ(kProtoQUIC, alternative_service.protocol
Zhongyi Shi 2017/06/20 23:23:37 Done.
98 return AlternativeServiceInfo(alternative_service, expiration,
99 advertised_versions);
100 }
101
81 AlternativeServiceInfo::AlternativeServiceInfo() : alternative_service_() {} 102 AlternativeServiceInfo::AlternativeServiceInfo() : alternative_service_() {}
82 103
104 AlternativeServiceInfo::~AlternativeServiceInfo() {}
105
83 AlternativeServiceInfo::AlternativeServiceInfo( 106 AlternativeServiceInfo::AlternativeServiceInfo(
84 const AlternativeService& alternative_service, 107 const AlternativeService& alternative_service,
85 base::Time expiration) 108 base::Time expiration,
86 : alternative_service_(alternative_service), expiration_(expiration) {} 109 const QuicVersionVector& advertised_versions)
87 110 : alternative_service_(alternative_service), expiration_(expiration) {
88 AlternativeServiceInfo::AlternativeServiceInfo(NextProto protocol, 111 if (alternative_service_.protocol == kProtoQUIC) {
89 const std::string& host, 112 advertised_versions_ = advertised_versions;
90 uint16_t port, 113 std::sort(advertised_versions_.begin(), advertised_versions_.end());
91 base::Time expiration) 114 }
92 : alternative_service_(protocol, host, port), expiration_(expiration) {} 115 }
93 116
94 AlternativeServiceInfo::AlternativeServiceInfo( 117 AlternativeServiceInfo::AlternativeServiceInfo(
95 const AlternativeServiceInfo& alternative_service_info) = default; 118 const AlternativeServiceInfo& alternative_service_info) = default;
96 119
97 AlternativeServiceInfo& AlternativeServiceInfo::operator=( 120 AlternativeServiceInfo& AlternativeServiceInfo::operator=(
98 const AlternativeServiceInfo& alternative_service_info) = default; 121 const AlternativeServiceInfo& alternative_service_info) = default;
99 122
100 std::string AlternativeService::ToString() const { 123 std::string AlternativeService::ToString() const {
101 return base::StringPrintf("%s %s:%d", NextProtoToString(protocol), 124 return base::StringPrintf("%s %s:%d", NextProtoToString(protocol),
102 host.c_str(), port); 125 host.c_str(), port);
(...skipping 14 matching lines...) Expand all
117 return os; 140 return os;
118 } 141 }
119 142
120 // static 143 // static
121 void HttpServerProperties::ForceHTTP11(SSLConfig* ssl_config) { 144 void HttpServerProperties::ForceHTTP11(SSLConfig* ssl_config) {
122 ssl_config->alpn_protos.clear(); 145 ssl_config->alpn_protos.clear();
123 ssl_config->alpn_protos.push_back(kProtoHTTP11); 146 ssl_config->alpn_protos.push_back(kProtoHTTP11);
124 } 147 }
125 148
126 } // namespace net 149 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698