| OLD | NEW |
| 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/socket/ssl_client_socket.h" | 10 #include "net/socket/ssl_client_socket.h" |
| 11 #include "net/ssl/ssl_config.h" | 11 #include "net/ssl/ssl_config.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 const char kAlternativeServiceHeader[] = "Alt-Svc"; | 15 const char kAlternativeServiceHeader[] = "Alt-Svc"; |
| 16 | 16 |
| 17 void HistogramAlternateProtocolUsage(AlternateProtocolUsage usage) { | 17 void HistogramAlternateProtocolUsage(AlternateProtocolUsage usage) { |
| 18 UMA_HISTOGRAM_ENUMERATION("Net.AlternateProtocolUsage", usage, | 18 UMA_HISTOGRAM_ENUMERATION("Net.AlternateProtocolUsage", usage, |
| 19 ALTERNATE_PROTOCOL_USAGE_MAX); | 19 ALTERNATE_PROTOCOL_USAGE_MAX); |
| 20 } | 20 } |
| 21 | 21 |
| 22 void HistogramBrokenAlternateProtocolLocation( | 22 void HistogramBrokenAlternateProtocolLocation( |
| 23 BrokenAlternateProtocolLocation location){ | 23 BrokenAlternateProtocolLocation location){ |
| 24 UMA_HISTOGRAM_ENUMERATION("Net.AlternateProtocolBrokenLocation", location, | 24 UMA_HISTOGRAM_ENUMERATION("Net.AlternateProtocolBrokenLocation", location, |
| 25 BROKEN_ALTERNATE_PROTOCOL_LOCATION_MAX); | 25 BROKEN_ALTERNATE_PROTOCOL_LOCATION_MAX); |
| 26 } | 26 } |
| 27 | 27 |
| 28 bool IsAlternateProtocolValid(AlternateProtocol protocol) { | 28 bool IsAlternateProtocolValid(AlternateProtocol protocol) { |
| 29 return protocol >= ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION && | 29 switch (protocol) { |
| 30 protocol <= ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION; | 30 case NPN_HTTP_2: |
| 31 return true; |
| 32 case QUIC: |
| 33 return true; |
| 34 case UNINITIALIZED_ALTERNATE_PROTOCOL: |
| 35 return false; |
| 36 } |
| 37 NOTREACHED(); |
| 38 return false; |
| 31 } | 39 } |
| 32 | 40 |
| 33 const char* AlternateProtocolToString(AlternateProtocol protocol) { | 41 const char* AlternateProtocolToString(AlternateProtocol protocol) { |
| 34 switch (protocol) { | 42 switch (protocol) { |
| 35 case QUIC: | 43 case QUIC: |
| 36 return "quic"; | 44 return "quic"; |
| 37 case NPN_HTTP_2: | 45 case NPN_HTTP_2: |
| 38 return "h2"; | 46 return "h2"; |
| 39 case UNINITIALIZED_ALTERNATE_PROTOCOL: | 47 case UNINITIALIZED_ALTERNATE_PROTOCOL: |
| 40 return "Uninitialized"; | 48 return "Uninitialized"; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second); | 97 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second); |
| 90 } | 98 } |
| 91 | 99 |
| 92 // static | 100 // static |
| 93 void HttpServerProperties::ForceHTTP11(SSLConfig* ssl_config) { | 101 void HttpServerProperties::ForceHTTP11(SSLConfig* ssl_config) { |
| 94 ssl_config->alpn_protos.clear(); | 102 ssl_config->alpn_protos.clear(); |
| 95 ssl_config->alpn_protos.push_back(kProtoHTTP11); | 103 ssl_config->alpn_protos.push_back(kProtoHTTP11); |
| 96 } | 104 } |
| 97 | 105 |
| 98 } // namespace net | 106 } // namespace net |
| OLD | NEW |