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.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-14", // HTTP/2 draft-14. Called SPDY4 internally. |
24 "npn-h2-15", // HTTP/2 draft-15. Called SPDY4 internally. | 24 "npn-h2-15", // HTTP/2 draft-15. Called SPDY4 internally. |
25 "quic" | 25 "quic" |
26 }; | 26 }; |
27 | 27 |
28 COMPILE_ASSERT( | 28 static_assert(arraysize(kAlternateProtocolStrings) == |
29 arraysize(kAlternateProtocolStrings) == NUM_VALID_ALTERNATE_PROTOCOLS, | 29 NUM_VALID_ALTERNATE_PROTOCOLS, |
30 kAlternateProtocolStringsSize_kNumValidAlternateProtocols_not_equal); | 30 "kAlternateProtocolStrings has incorrect size"); |
31 | 31 |
32 } // namespace | 32 } // namespace |
33 | 33 |
34 void HistogramAlternateProtocolUsage(AlternateProtocolUsage usage) { | 34 void HistogramAlternateProtocolUsage(AlternateProtocolUsage usage) { |
35 UMA_HISTOGRAM_ENUMERATION("Net.AlternateProtocolUsage", usage, | 35 UMA_HISTOGRAM_ENUMERATION("Net.AlternateProtocolUsage", usage, |
36 ALTERNATE_PROTOCOL_USAGE_MAX); | 36 ALTERNATE_PROTOCOL_USAGE_MAX); |
37 } | 37 } |
38 | 38 |
39 void HistogramBrokenAlternateProtocolLocation( | 39 void HistogramBrokenAlternateProtocolLocation( |
40 BrokenAlternateProtocolLocation location){ | 40 BrokenAlternateProtocolLocation location){ |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 100 } |
101 | 101 |
102 std::string AlternateProtocolInfo::ToString() const { | 102 std::string AlternateProtocolInfo::ToString() const { |
103 return base::StringPrintf("%d:%s p=%f%s", port, | 103 return base::StringPrintf("%d:%s p=%f%s", port, |
104 AlternateProtocolToString(protocol), | 104 AlternateProtocolToString(protocol), |
105 probability, | 105 probability, |
106 is_broken ? " (broken)" : ""); | 106 is_broken ? " (broken)" : ""); |
107 } | 107 } |
108 | 108 |
109 } // namespace net | 109 } // namespace net |
OLD | NEW |