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

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: self review Created 3 years, 7 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 if (alternative_service.protocol == kProtoQUIC)
91 advertised_versions = HttpNetworkSession::Params().quic_supported_versions;
Ryan Hamilton 2017/05/25 22:01:45 I don't think this is the right thing to do. This
92 }
93
94 AlternativeServiceInfo::AlternativeServiceInfo(
95 const AlternativeServiceInfo& alternative_service_info) = default;
96
97 AlternativeServiceInfo& AlternativeServiceInfo::operator=(
98 const AlternativeServiceInfo& alternative_service_info) = default;
99
81 std::string AlternativeService::ToString() const { 100 std::string AlternativeService::ToString() const {
82 return base::StringPrintf("%s %s:%d", NextProtoToString(protocol), 101 return base::StringPrintf("%s %s:%d", NextProtoToString(protocol),
83 host.c_str(), port); 102 host.c_str(), port);
84 } 103 }
85 104
86 std::string AlternativeServiceInfo::ToString() const { 105 std::string AlternativeServiceInfo::ToString() const {
87 base::Time::Exploded exploded; 106 base::Time::Exploded exploded;
88 expiration.LocalExplode(&exploded); 107 expiration.LocalExplode(&exploded);
89 return base::StringPrintf( 108 return base::StringPrintf(
90 "%s, expires %04d-%02d-%02d %02d:%02d:%02d", 109 "%s, expires %04d-%02d-%02d %02d:%02d:%02d",
91 alternative_service.ToString().c_str(), exploded.year, exploded.month, 110 alternative_service.ToString().c_str(), exploded.year, exploded.month,
92 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second); 111 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second);
93 } 112 }
94 113
95 std::ostream& operator<<(std::ostream& os, 114 std::ostream& operator<<(std::ostream& os,
96 const AlternativeService& alternative_service) { 115 const AlternativeService& alternative_service) {
97 os << alternative_service.ToString(); 116 os << alternative_service.ToString();
98 return os; 117 return os;
99 } 118 }
100 119
101 // static 120 // static
102 void HttpServerProperties::ForceHTTP11(SSLConfig* ssl_config) { 121 void HttpServerProperties::ForceHTTP11(SSLConfig* ssl_config) {
103 ssl_config->alpn_protos.clear(); 122 ssl_config->alpn_protos.clear();
104 ssl_config->alpn_protos.push_back(kProtoHTTP11); 123 ssl_config->alpn_protos.push_back(kProtoHTTP11);
105 } 124 }
106 125
107 } // namespace net 126 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698