| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chromium/mock_crypto_client_stream_factory.h" | 5 #include "net/quic/chromium/mock_crypto_client_stream_factory.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "net/quic/chromium/quic_chromium_client_session.h" | 8 #include "net/quic/chromium/quic_chromium_client_session.h" |
| 9 #include "net/quic/core/quic_crypto_client_stream.h" | 9 #include "net/quic/core/quic_crypto_client_stream.h" |
| 10 | 10 |
| 11 using std::string; | 11 using std::string; |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 MockCryptoClientStreamFactory::~MockCryptoClientStreamFactory() {} | 15 MockCryptoClientStreamFactory::~MockCryptoClientStreamFactory() {} |
| 16 | 16 |
| 17 MockCryptoClientStreamFactory::MockCryptoClientStreamFactory() | 17 MockCryptoClientStreamFactory::MockCryptoClientStreamFactory() |
| 18 : handshake_mode_(MockCryptoClientStream::CONFIRM_HANDSHAKE), | 18 : handshake_mode_(MockCryptoClientStream::CONFIRM_HANDSHAKE), |
| 19 last_stream_(nullptr), | 19 last_stream_(nullptr), |
| 20 config_(new QuicConfig()) {} | 20 config_(new QuicConfig()), |
| 21 use_normal_crypto_stream_(false) {} |
| 21 | 22 |
| 22 void MockCryptoClientStreamFactory::SetConfig(const QuicConfig& config) { | 23 void MockCryptoClientStreamFactory::SetConfig(const QuicConfig& config) { |
| 23 config_.reset(new QuicConfig(config)); | 24 config_.reset(new QuicConfig(config)); |
| 24 } | 25 } |
| 25 | 26 |
| 26 QuicCryptoClientStream* | 27 QuicCryptoClientStream* |
| 27 MockCryptoClientStreamFactory::CreateQuicCryptoClientStream( | 28 MockCryptoClientStreamFactory::CreateQuicCryptoClientStream( |
| 28 const QuicServerId& server_id, | 29 const QuicServerId& server_id, |
| 29 QuicChromiumClientSession* session, | 30 QuicChromiumClientSession* session, |
| 30 std::unique_ptr<ProofVerifyContext> /*proof_verify_context*/, | 31 std::unique_ptr<ProofVerifyContext> /*proof_verify_context*/, |
| 31 QuicCryptoClientConfig* crypto_config) { | 32 QuicCryptoClientConfig* crypto_config) { |
| 32 const ProofVerifyDetailsChromium* proof_verify_details = nullptr; | 33 const ProofVerifyDetailsChromium* proof_verify_details = nullptr; |
| 33 if (!proof_verify_details_queue_.empty()) { | 34 if (!proof_verify_details_queue_.empty()) { |
| 34 proof_verify_details = proof_verify_details_queue_.front(); | 35 proof_verify_details = proof_verify_details_queue_.front(); |
| 35 proof_verify_details_queue_.pop(); | 36 proof_verify_details_queue_.pop(); |
| 36 } | 37 } |
| 38 |
| 39 if (use_normal_crypto_stream_) { |
| 40 return new QuicCryptoClientStream(server_id, session, nullptr, |
| 41 crypto_config, session); |
| 42 } |
| 43 |
| 37 last_stream_ = new MockCryptoClientStream( | 44 last_stream_ = new MockCryptoClientStream( |
| 38 server_id, session, nullptr, *(config_.get()), crypto_config, | 45 server_id, session, nullptr, *(config_.get()), crypto_config, |
| 39 handshake_mode_, proof_verify_details); | 46 handshake_mode_, proof_verify_details); |
| 40 return last_stream_; | 47 return last_stream_; |
| 41 } | 48 } |
| 42 | 49 |
| 43 } // namespace net | 50 } // namespace net |
| OLD | NEW |