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

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

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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.h" 8 #include "base/metrics/histogram.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 10
11 namespace net { 11 namespace net {
12 12
13 const char kAlternateProtocolHeader[] = "Alternate-Protocol"; 13 const char kAlternateProtocolHeader[] = "Alternate-Protocol";
14 14
15 namespace { 15 namespace {
16 16
17 // The order of these strings much match the order of the enum definition 17 // The order of these strings much match the order of the enum definition
18 // for AlternateProtocol. 18 // for AlternateProtocol.
19 const char* const kAlternateProtocolStrings[] = { 19 const char* const kAlternateProtocolStrings[] = {
20 "npn-spdy/2", 20 "npn-spdy/2",
21 "npn-spdy/3", 21 "npn-spdy/3",
22 "npn-spdy/3.1", 22 "npn-spdy/3.1",
23 "npn-h2-14", // HTTP/2 draft-14. Called SPDY4 internally.
23 "npn-h2-15", // HTTP/2 draft-15. Called SPDY4 internally. 24 "npn-h2-15", // HTTP/2 draft-15. Called SPDY4 internally.
24 "quic" 25 "quic"
25 }; 26 };
26 27
27 COMPILE_ASSERT( 28 COMPILE_ASSERT(
28 arraysize(kAlternateProtocolStrings) == NUM_VALID_ALTERNATE_PROTOCOLS, 29 arraysize(kAlternateProtocolStrings) == NUM_VALID_ALTERNATE_PROTOCOLS,
29 kAlternateProtocolStringsSize_kNumValidAlternateProtocols_not_equal); 30 kAlternateProtocolStringsSize_kNumValidAlternateProtocols_not_equal);
30 31
31 } // namespace 32 } // namespace
32 33
(...skipping 11 matching lines...) Expand all
44 bool IsAlternateProtocolValid(AlternateProtocol protocol) { 45 bool IsAlternateProtocolValid(AlternateProtocol protocol) {
45 return protocol >= ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION && 46 return protocol >= ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION &&
46 protocol <= ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION; 47 protocol <= ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION;
47 } 48 }
48 49
49 const char* AlternateProtocolToString(AlternateProtocol protocol) { 50 const char* AlternateProtocolToString(AlternateProtocol protocol) {
50 switch (protocol) { 51 switch (protocol) {
51 case DEPRECATED_NPN_SPDY_2: 52 case DEPRECATED_NPN_SPDY_2:
52 case NPN_SPDY_3: 53 case NPN_SPDY_3:
53 case NPN_SPDY_3_1: 54 case NPN_SPDY_3_1:
54 case NPN_SPDY_4: 55 case NPN_SPDY_4_14:
56 case NPN_SPDY_4_15:
55 case QUIC: 57 case QUIC:
56 DCHECK(IsAlternateProtocolValid(protocol)); 58 DCHECK(IsAlternateProtocolValid(protocol));
57 return kAlternateProtocolStrings[ 59 return kAlternateProtocolStrings[
58 protocol - ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION]; 60 protocol - ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION];
59 case UNINITIALIZED_ALTERNATE_PROTOCOL: 61 case UNINITIALIZED_ALTERNATE_PROTOCOL:
60 return "Uninitialized"; 62 return "Uninitialized";
61 } 63 }
62 NOTREACHED(); 64 NOTREACHED();
63 return ""; 65 return "";
64 } 66 }
65 67
66 AlternateProtocol AlternateProtocolFromString(const std::string& str) { 68 AlternateProtocol AlternateProtocolFromString(const std::string& str) {
67 for (int i = ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION; 69 for (int i = ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION;
68 i <= ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION; ++i) { 70 i <= ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION; ++i) {
69 AlternateProtocol protocol = static_cast<AlternateProtocol>(i); 71 AlternateProtocol protocol = static_cast<AlternateProtocol>(i);
70 if (str == AlternateProtocolToString(protocol)) 72 if (str == AlternateProtocolToString(protocol))
71 return protocol; 73 return protocol;
72 } 74 }
73 return UNINITIALIZED_ALTERNATE_PROTOCOL; 75 return UNINITIALIZED_ALTERNATE_PROTOCOL;
74 } 76 }
75 77
76 AlternateProtocol AlternateProtocolFromNextProto(NextProto next_proto) { 78 AlternateProtocol AlternateProtocolFromNextProto(NextProto next_proto) {
77 switch (next_proto) { 79 switch (next_proto) {
78 case kProtoDeprecatedSPDY2: 80 case kProtoDeprecatedSPDY2:
79 return DEPRECATED_NPN_SPDY_2; 81 return DEPRECATED_NPN_SPDY_2;
80 case kProtoSPDY3: 82 case kProtoSPDY3:
81 return NPN_SPDY_3; 83 return NPN_SPDY_3;
82 case kProtoSPDY31: 84 case kProtoSPDY31:
83 return NPN_SPDY_3_1; 85 return NPN_SPDY_3_1;
84 case kProtoSPDY4: 86 case kProtoSPDY4_14:
85 return NPN_SPDY_4; 87 return NPN_SPDY_4_14;
88 case kProtoSPDY4_15:
89 return NPN_SPDY_4_15;
86 case kProtoQUIC1SPDY3: 90 case kProtoQUIC1SPDY3:
87 return QUIC; 91 return QUIC;
88 92
89 case kProtoUnknown: 93 case kProtoUnknown:
90 case kProtoHTTP11: 94 case kProtoHTTP11:
91 break; 95 break;
92 } 96 }
93 97
94 NOTREACHED() << "Invalid NextProto: " << next_proto; 98 NOTREACHED() << "Invalid NextProto: " << next_proto;
95 return UNINITIALIZED_ALTERNATE_PROTOCOL; 99 return UNINITIALIZED_ALTERNATE_PROTOCOL;
96 } 100 }
97 101
98 std::string AlternateProtocolInfo::ToString() const { 102 std::string AlternateProtocolInfo::ToString() const {
99 return base::StringPrintf("%d:%s p=%f%s", port, 103 return base::StringPrintf("%d:%s p=%f%s", port,
100 AlternateProtocolToString(protocol), 104 AlternateProtocolToString(protocol),
101 probability, 105 probability,
102 is_broken ? " (broken)" : ""); 106 is_broken ? " (broken)" : "");
103 } 107 }
104 108
105 } // namespace net 109 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties.h ('k') | net/http/http_stream_factory_impl_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698