| 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/quic/quic_protocol.h" | 5 #include "net/quic/quic_protocol.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "net/quic/quic_utils.h" | 8 #include "net/quic/quic_utils.h" |
| 9 | 9 |
| 10 using base::StringPiece; | 10 using base::StringPiece; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 122 } |
| 123 | 123 |
| 124 QuicVersion QuicVersionMax() { return kSupportedQuicVersions[0]; } | 124 QuicVersion QuicVersionMax() { return kSupportedQuicVersions[0]; } |
| 125 | 125 |
| 126 QuicTag QuicVersionToQuicTag(const QuicVersion version) { | 126 QuicTag QuicVersionToQuicTag(const QuicVersion version) { |
| 127 switch (version) { | 127 switch (version) { |
| 128 case QUIC_VERSION_6: | 128 case QUIC_VERSION_6: |
| 129 return MakeQuicTag('Q', '0', '0', '6'); | 129 return MakeQuicTag('Q', '0', '0', '6'); |
| 130 case QUIC_VERSION_7: | 130 case QUIC_VERSION_7: |
| 131 return MakeQuicTag('Q', '0', '0', '7'); | 131 return MakeQuicTag('Q', '0', '0', '7'); |
| 132 case QUIC_VERSION_8: |
| 133 return MakeQuicTag('Q', '0', '0', '8'); |
| 132 default: | 134 default: |
| 133 // This shold be an ERROR because we should never attempt to convert an | 135 // This shold be an ERROR because we should never attempt to convert an |
| 134 // invalid QuicVersion to be written to the wire. | 136 // invalid QuicVersion to be written to the wire. |
| 135 LOG(ERROR) << "Unsupported QuicVersion: " << version; | 137 LOG(ERROR) << "Unsupported QuicVersion: " << version; |
| 136 return 0; | 138 return 0; |
| 137 } | 139 } |
| 138 } | 140 } |
| 139 | 141 |
| 140 QuicVersion QuicTagToQuicVersion(const QuicTag version_tag) { | 142 QuicVersion QuicTagToQuicVersion(const QuicTag version_tag) { |
| 141 const QuicTag quic_tag_v6 = MakeQuicTag('Q', '0', '0', '6'); | 143 const QuicTag quic_tag_v6 = MakeQuicTag('Q', '0', '0', '6'); |
| 142 const QuicTag quic_tag_v7 = MakeQuicTag('Q', '0', '0', '7'); | 144 const QuicTag quic_tag_v7 = MakeQuicTag('Q', '0', '0', '7'); |
| 145 const QuicTag quic_tag_v8 = MakeQuicTag('Q', '0', '0', '8'); |
| 143 | 146 |
| 144 if (version_tag == quic_tag_v6) { | 147 if (version_tag == quic_tag_v6) { |
| 145 return QUIC_VERSION_6; | 148 return QUIC_VERSION_6; |
| 146 } else if (version_tag == quic_tag_v7) { | 149 } else if (version_tag == quic_tag_v7) { |
| 147 return QUIC_VERSION_7; | 150 return QUIC_VERSION_7; |
| 151 } else if (version_tag == quic_tag_v8) { |
| 152 return QUIC_VERSION_8; |
| 148 } else { | 153 } else { |
| 149 // Reading from the client so this should not be considered an ERROR. | 154 // Reading from the client so this should not be considered an ERROR. |
| 150 DLOG(INFO) << "Unsupported QuicTag version: " | 155 DLOG(INFO) << "Unsupported QuicTag version: " |
| 151 << QuicUtils::TagToString(version_tag); | 156 << QuicUtils::TagToString(version_tag); |
| 152 return QUIC_VERSION_UNSUPPORTED; | 157 return QUIC_VERSION_UNSUPPORTED; |
| 153 } | 158 } |
| 154 } | 159 } |
| 155 | 160 |
| 161 #define RETURN_STRING_LITERAL(x) \ |
| 162 case x: \ |
| 163 return #x |
| 164 |
| 156 string QuicVersionToString(const QuicVersion version) { | 165 string QuicVersionToString(const QuicVersion version) { |
| 157 // TODO(rjshade): Possibly start using RETURN_STRING_LITERAL here when we | |
| 158 // start supporting a lot of versions. | |
| 159 switch (version) { | 166 switch (version) { |
| 160 case QUIC_VERSION_6: | 167 RETURN_STRING_LITERAL(QUIC_VERSION_6); |
| 161 return "QUIC_VERSION_6"; | 168 RETURN_STRING_LITERAL(QUIC_VERSION_7); |
| 162 case QUIC_VERSION_7: | 169 RETURN_STRING_LITERAL(QUIC_VERSION_8); |
| 163 return "QUIC_VERSION_7"; | |
| 164 default: | 170 default: |
| 165 return "QUIC_VERSION_UNSUPPORTED"; | 171 return "QUIC_VERSION_UNSUPPORTED"; |
| 166 } | 172 } |
| 167 } | 173 } |
| 168 | 174 |
| 169 string QuicVersionArrayToString(const QuicVersion versions[], | 175 string QuicVersionArrayToString(const QuicVersion versions[], |
| 170 int num_versions) { | 176 int num_versions) { |
| 171 string result = ""; | 177 string result = ""; |
| 172 for (int i = 0; i < num_versions; ++i) { | 178 for (int i = 0; i < num_versions; ++i) { |
| 173 const QuicVersion& version = versions[i]; | 179 const QuicVersion& version = versions[i]; |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 return os; | 422 return os; |
| 417 } | 423 } |
| 418 | 424 |
| 419 ostream& operator<<(ostream& os, const QuicConsumedData& s) { | 425 ostream& operator<<(ostream& os, const QuicConsumedData& s) { |
| 420 os << "bytes_consumed: " << s.bytes_consumed | 426 os << "bytes_consumed: " << s.bytes_consumed |
| 421 << " fin_consumed: " << s.fin_consumed; | 427 << " fin_consumed: " << s.fin_consumed; |
| 422 return os; | 428 return os; |
| 423 } | 429 } |
| 424 | 430 |
| 425 } // namespace net | 431 } // namespace net |
| OLD | NEW |