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

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

Issue 1579213006: Remove unused SPDY/3 enum values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove trivial comparisons; change non-trivial ones. Created 4 years, 11 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
« no previous file with comments | « net/http/http_server_properties.h ('k') | net/socket/next_proto.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 kAlternateProtocolHeader[] = "Alternate-Protocol"; 15 const char kAlternateProtocolHeader[] = "Alternate-Protocol";
16 const char kAlternativeServiceHeader[] = "Alt-Svc"; 16 const char kAlternativeServiceHeader[] = "Alt-Svc";
17 17
18 namespace { 18 namespace {
19 19
20 // The order of these strings much match the order of the enum definition 20 // The order of these strings much match the order of the enum definition
21 // for AlternateProtocol. 21 // for AlternateProtocol.
22 const char* const kAlternateProtocolStrings[] = { 22 const char* const kAlternateProtocolStrings[] = {
23 "npn-spdy/3",
24 "npn-spdy/3.1", 23 "npn-spdy/3.1",
25 "npn-h2", 24 "npn-h2",
26 "quic"}; 25 "quic"};
27 26
28 static_assert(arraysize(kAlternateProtocolStrings) == 27 static_assert(arraysize(kAlternateProtocolStrings) ==
29 NUM_VALID_ALTERNATE_PROTOCOLS, 28 NUM_VALID_ALTERNATE_PROTOCOLS,
30 "kAlternateProtocolStrings has incorrect size"); 29 "kAlternateProtocolStrings has incorrect size");
31 30
32 } // namespace 31 } // namespace
33 32
34 void HistogramAlternateProtocolUsage(AlternateProtocolUsage usage) { 33 void HistogramAlternateProtocolUsage(AlternateProtocolUsage usage) {
35 UMA_HISTOGRAM_ENUMERATION("Net.AlternateProtocolUsage", usage, 34 UMA_HISTOGRAM_ENUMERATION("Net.AlternateProtocolUsage", usage,
36 ALTERNATE_PROTOCOL_USAGE_MAX); 35 ALTERNATE_PROTOCOL_USAGE_MAX);
37 } 36 }
38 37
39 void HistogramBrokenAlternateProtocolLocation( 38 void HistogramBrokenAlternateProtocolLocation(
40 BrokenAlternateProtocolLocation location){ 39 BrokenAlternateProtocolLocation location){
41 UMA_HISTOGRAM_ENUMERATION("Net.AlternateProtocolBrokenLocation", location, 40 UMA_HISTOGRAM_ENUMERATION("Net.AlternateProtocolBrokenLocation", location,
42 BROKEN_ALTERNATE_PROTOCOL_LOCATION_MAX); 41 BROKEN_ALTERNATE_PROTOCOL_LOCATION_MAX);
43 } 42 }
44 43
45 bool IsAlternateProtocolValid(AlternateProtocol protocol) { 44 bool IsAlternateProtocolValid(AlternateProtocol protocol) {
46 return protocol >= ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION && 45 return protocol >= ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION &&
47 protocol <= ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION; 46 protocol <= ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION;
48 } 47 }
49 48
50 const char* AlternateProtocolToString(AlternateProtocol protocol) { 49 const char* AlternateProtocolToString(AlternateProtocol protocol) {
51 switch (protocol) { 50 switch (protocol) {
52 case NPN_SPDY_3:
53 case NPN_SPDY_3_1: 51 case NPN_SPDY_3_1:
54 case NPN_HTTP_2: 52 case NPN_HTTP_2:
55 case QUIC: 53 case QUIC:
56 DCHECK(IsAlternateProtocolValid(protocol)); 54 DCHECK(IsAlternateProtocolValid(protocol));
57 return kAlternateProtocolStrings[ 55 return kAlternateProtocolStrings[
58 protocol - ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION]; 56 protocol - ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION];
59 case UNINITIALIZED_ALTERNATE_PROTOCOL: 57 case UNINITIALIZED_ALTERNATE_PROTOCOL:
60 return "Uninitialized"; 58 return "Uninitialized";
61 } 59 }
62 NOTREACHED(); 60 NOTREACHED();
63 return ""; 61 return "";
64 } 62 }
65 63
66 AlternateProtocol AlternateProtocolFromString(const std::string& str) { 64 AlternateProtocol AlternateProtocolFromString(const std::string& str) {
67 for (int i = ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION; 65 for (int i = ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION;
68 i <= ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION; ++i) { 66 i <= ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION; ++i) {
69 AlternateProtocol protocol = static_cast<AlternateProtocol>(i); 67 AlternateProtocol protocol = static_cast<AlternateProtocol>(i);
70 if (str == AlternateProtocolToString(protocol)) 68 if (str == AlternateProtocolToString(protocol))
71 return protocol; 69 return protocol;
72 } 70 }
73 return UNINITIALIZED_ALTERNATE_PROTOCOL; 71 return UNINITIALIZED_ALTERNATE_PROTOCOL;
74 } 72 }
75 73
76 AlternateProtocol AlternateProtocolFromNextProto(NextProto next_proto) { 74 AlternateProtocol AlternateProtocolFromNextProto(NextProto next_proto) {
77 switch (next_proto) { 75 switch (next_proto) {
78 case kProtoSPDY3:
79 return NPN_SPDY_3;
80 case kProtoSPDY31: 76 case kProtoSPDY31:
81 return NPN_SPDY_3_1; 77 return NPN_SPDY_3_1;
82 case kProtoHTTP2: 78 case kProtoHTTP2:
83 return NPN_HTTP_2; 79 return NPN_HTTP_2;
84 case kProtoQUIC1SPDY3: 80 case kProtoQUIC1SPDY3:
85 return QUIC; 81 return QUIC;
86 82
87 case kProtoUnknown: 83 case kProtoUnknown:
88 case kProtoHTTP11: 84 case kProtoHTTP11:
89 break; 85 break;
(...skipping 20 matching lines...) Expand all
110 106
111 // static 107 // static
112 void HttpServerProperties::ForceHTTP11(SSLConfig* ssl_config) { 108 void HttpServerProperties::ForceHTTP11(SSLConfig* ssl_config) {
113 ssl_config->alpn_protos.clear(); 109 ssl_config->alpn_protos.clear();
114 ssl_config->alpn_protos.push_back(kProtoHTTP11); 110 ssl_config->alpn_protos.push_back(kProtoHTTP11);
115 ssl_config->npn_protos.clear(); 111 ssl_config->npn_protos.clear();
116 ssl_config->npn_protos.push_back(kProtoHTTP11); 112 ssl_config->npn_protos.push_back(kProtoHTTP11);
117 } 113 }
118 114
119 } // namespace net 115 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties.h ('k') | net/socket/next_proto.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698