| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/tools/quic/quic_client_base.h" | 5 #include "net/tools/quic/quic_client_base.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "net/quic/core/crypto/quic_random.h" | 8 #include "net/quic/core/crypto/quic_random.h" |
| 9 #include "net/quic/core/quic_server_id.h" | 9 #include "net/quic/core/quic_server_id.h" |
| 10 #include "net/quic/core/spdy_utils.h" | 10 #include "net/quic/core/spdy_utils.h" |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 QuicConnectionId server_designated_id = GetNextServerDesignatedConnectionId(); | 371 QuicConnectionId server_designated_id = GetNextServerDesignatedConnectionId(); |
| 372 return server_designated_id ? server_designated_id | 372 return server_designated_id ? server_designated_id |
| 373 : GenerateNewConnectionId(); | 373 : GenerateNewConnectionId(); |
| 374 } | 374 } |
| 375 | 375 |
| 376 QuicConnectionId QuicClientBase::GetNextServerDesignatedConnectionId() { | 376 QuicConnectionId QuicClientBase::GetNextServerDesignatedConnectionId() { |
| 377 QuicCryptoClientConfig::CachedState* cached = | 377 QuicCryptoClientConfig::CachedState* cached = |
| 378 crypto_config_.LookupOrCreate(server_id_); | 378 crypto_config_.LookupOrCreate(server_id_); |
| 379 // If the cached state indicates that we should use a server-designated | 379 // If the cached state indicates that we should use a server-designated |
| 380 // connection ID, then return that connection ID. | 380 // connection ID, then return that connection ID. |
| 381 CHECK(cached != nullptr) << "QuicClientCryptoConfig::LookupOrCreate returned " | 381 // QuicClientCryptoConfig::LookupOrCreate returned unexpected nullptr. |
| 382 << "unexpected nullptr."; | 382 CHECK(cached != nullptr); |
| 383 return cached->has_server_designated_connection_id() | 383 return cached->has_server_designated_connection_id() |
| 384 ? cached->GetNextServerDesignatedConnectionId() | 384 ? cached->GetNextServerDesignatedConnectionId() |
| 385 : 0; | 385 : 0; |
| 386 } | 386 } |
| 387 | 387 |
| 388 QuicConnectionId QuicClientBase::GenerateNewConnectionId() { | 388 QuicConnectionId QuicClientBase::GenerateNewConnectionId() { |
| 389 return QuicRandom::GetInstance()->RandUint64(); | 389 return QuicRandom::GetInstance()->RandUint64(); |
| 390 } | 390 } |
| 391 | 391 |
| 392 void QuicClientBase::MaybeAddDataToResend(const SpdyHeaderBlock& headers, | 392 void QuicClientBase::MaybeAddDataToResend(const SpdyHeaderBlock& headers, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 QUIC_BUG_IF(!store_response_) << "Response not stored!"; | 476 QUIC_BUG_IF(!store_response_) << "Response not stored!"; |
| 477 return latest_response_body_; | 477 return latest_response_body_; |
| 478 } | 478 } |
| 479 | 479 |
| 480 const string& QuicClientBase::latest_response_trailers() const { | 480 const string& QuicClientBase::latest_response_trailers() const { |
| 481 QUIC_BUG_IF(!store_response_) << "Response not stored!"; | 481 QUIC_BUG_IF(!store_response_) << "Response not stored!"; |
| 482 return latest_response_trailers_; | 482 return latest_response_trailers_; |
| 483 } | 483 } |
| 484 | 484 |
| 485 } // namespace net | 485 } // namespace net |
| OLD | NEW |