| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/domain_reliability/quic_error_mapping.h" | 5 #include "components/domain_reliability/quic_error_mapping.h" |
| 6 | 6 |
| 7 namespace domain_reliability { | 7 namespace domain_reliability { |
| 8 | 8 |
| 9 namespace { | 9 namespace { |
| 10 | 10 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 "quic.stream_sequencer_invalid_state" }, | 248 "quic.stream_sequencer_invalid_state" }, |
| 249 // Connection closed because of server hits max number of sessions allowed. | 249 // Connection closed because of server hits max number of sessions allowed. |
| 250 { net::QUIC_TOO_MANY_SESSIONS_ON_SERVER, | 250 { net::QUIC_TOO_MANY_SESSIONS_ON_SERVER, |
| 251 "quic.too_many_sessions_on_server" }, | 251 "quic.too_many_sessions_on_server" }, |
| 252 | 252 |
| 253 // No error. Used as bound while iterating. | 253 // No error. Used as bound while iterating. |
| 254 { net::QUIC_LAST_ERROR, "quic.last_error"} | 254 { net::QUIC_LAST_ERROR, "quic.last_error"} |
| 255 }; | 255 }; |
| 256 | 256 |
| 257 // Must be updated any time a net::QuicErrorCode is deprecated in | 257 // Must be updated any time a net::QuicErrorCode is deprecated in |
| 258 // net/quic/core/quic_protocol.h. | 258 // net/quic/core/quic_packets.h. |
| 259 const int kDeprecatedQuicErrorCount = 4; | 259 const int kDeprecatedQuicErrorCount = 4; |
| 260 const int kActiveQuicErrorCount = | 260 const int kActiveQuicErrorCount = |
| 261 net::QUIC_LAST_ERROR - kDeprecatedQuicErrorCount; | 261 net::QUIC_LAST_ERROR - kDeprecatedQuicErrorCount; |
| 262 | 262 |
| 263 static_assert(arraysize(kQuicErrorMap) == kActiveQuicErrorCount, | 263 static_assert(arraysize(kQuicErrorMap) == kActiveQuicErrorCount, |
| 264 "quic_error_map is not in sync with quic protocol!"); | 264 "quic_error_map is not in sync with quic protocol!"); |
| 265 | 265 |
| 266 } // namespace | 266 } // namespace |
| 267 | 267 |
| 268 // static | 268 // static |
| 269 bool GetDomainReliabilityBeaconQuicError(net::QuicErrorCode quic_error, | 269 bool GetDomainReliabilityBeaconQuicError(net::QuicErrorCode quic_error, |
| 270 std::string* beacon_quic_error_out) { | 270 std::string* beacon_quic_error_out) { |
| 271 if (quic_error != net::QUIC_NO_ERROR) { | 271 if (quic_error != net::QUIC_NO_ERROR) { |
| 272 // Convert a QUIC error. | 272 // Convert a QUIC error. |
| 273 // TODO(juliatuttle): Consider sorting and using binary search? | 273 // TODO(juliatuttle): Consider sorting and using binary search? |
| 274 for (size_t i = 0; i < arraysize(kQuicErrorMap); i++) { | 274 for (size_t i = 0; i < arraysize(kQuicErrorMap); i++) { |
| 275 if (kQuicErrorMap[i].quic_error == quic_error) { | 275 if (kQuicErrorMap[i].quic_error == quic_error) { |
| 276 *beacon_quic_error_out = kQuicErrorMap[i].beacon_quic_error; | 276 *beacon_quic_error_out = kQuicErrorMap[i].beacon_quic_error; |
| 277 return true; | 277 return true; |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 } | 280 } |
| 281 beacon_quic_error_out->clear(); | 281 beacon_quic_error_out->clear(); |
| 282 return false; | 282 return false; |
| 283 } | 283 } |
| 284 | 284 |
| 285 } // namespace domain_reliability | 285 } // namespace domain_reliability |
| OLD | NEW |