| 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/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| 11 | 11 |
| 12 const char kAlternateProtocolHeader[] = "Alternate-Protocol"; | 12 const char kAlternateProtocolHeader[] = "Alternate-Protocol"; |
| 13 // The order of these strings much match the order of the enum definition | 13 // The order of these strings much match the order of the enum definition |
| 14 // for AlternateProtocol. | 14 // for AlternateProtocol. |
| 15 const char* const kAlternateProtocolStrings[] = { | 15 const char* const kAlternateProtocolStrings[] = { |
| 16 "npn-spdy/1", | 16 "npn-spdy/1", |
| 17 "npn-spdy/2", | 17 "npn-spdy/2", |
| 18 "npn-spdy/3", | 18 "npn-spdy/3", |
| 19 "npn-spdy/3.1", | 19 "npn-spdy/3.1", |
| 20 "npn-spdy/4a2", | 20 "npn-spdy/4a2", |
| 21 "quic" | 21 "quic" |
| 22 }; | 22 }; |
| 23 const char kBrokenAlternateProtocol[] = "Broken"; | 23 const char kBrokenAlternateProtocol[] = "Broken"; |
| 24 | 24 |
| 25 const char* AlternateProtocolToString(AlternateProtocol protocol) { | 25 const char* AlternateProtocolToString(AlternateProtocol protocol) { |
| 26 switch (protocol) { | 26 switch (protocol) { |
| 27 case NPN_SPDY_1: | 27 case NPN_SPDY_1: |
| 28 case NPN_SPDY_2: | 28 case NPN_SPDY_2: |
| 29 case NPN_SPDY_3: | 29 case NPN_SPDY_3: |
| 30 case NPN_SPDY_3_1: |
| 31 case NPN_SPDY_4A2: |
| 30 case QUIC: | 32 case QUIC: |
| 31 DCHECK_LT(static_cast<size_t>(protocol), | 33 DCHECK_LT(static_cast<size_t>(protocol), |
| 32 arraysize(kAlternateProtocolStrings)); | 34 arraysize(kAlternateProtocolStrings)); |
| 33 return kAlternateProtocolStrings[protocol]; | 35 return kAlternateProtocolStrings[protocol]; |
| 34 case ALTERNATE_PROTOCOL_BROKEN: | 36 case ALTERNATE_PROTOCOL_BROKEN: |
| 35 return kBrokenAlternateProtocol; | 37 return kBrokenAlternateProtocol; |
| 36 case UNINITIALIZED_ALTERNATE_PROTOCOL: | 38 case UNINITIALIZED_ALTERNATE_PROTOCOL: |
| 37 return "Uninitialized"; | 39 return "Uninitialized"; |
| 38 default: | 40 default: |
| 39 NOTREACHED(); | 41 NOTREACHED(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 50 return UNINITIALIZED_ALTERNATE_PROTOCOL; | 52 return UNINITIALIZED_ALTERNATE_PROTOCOL; |
| 51 } | 53 } |
| 52 | 54 |
| 53 | 55 |
| 54 std::string PortAlternateProtocolPair::ToString() const { | 56 std::string PortAlternateProtocolPair::ToString() const { |
| 55 return base::StringPrintf("%d:%s", port, | 57 return base::StringPrintf("%d:%s", port, |
| 56 AlternateProtocolToString(protocol)); | 58 AlternateProtocolToString(protocol)); |
| 57 } | 59 } |
| 58 | 60 |
| 59 } // namespace net | 61 } // namespace net |
| OLD | NEW |