diff options
-rw-r--r-- | net/net.gyp | 4 | ||||
-rw-r--r-- | net/quic/crypto/proof_verifier.cc | 13 | ||||
-rw-r--r-- | net/quic/crypto/proof_verifier.h | 4 | ||||
-rw-r--r-- | net/quic/quic_client_session.cc | 4 | ||||
-rw-r--r-- | net/quic/quic_client_session.h | 8 | ||||
-rw-r--r-- | net/quic/quic_client_session_base.cc | 15 | ||||
-rw-r--r-- | net/quic/quic_client_session_base.h | 41 | ||||
-rw-r--r-- | net/quic/quic_crypto_client_stream.cc | 24 | ||||
-rw-r--r-- | net/quic/quic_crypto_client_stream.h | 30 | ||||
-rw-r--r-- | net/quic/quic_crypto_client_stream_test.cc | 12 | ||||
-rw-r--r-- | net/quic/quic_crypto_server_stream_test.cc | 17 | ||||
-rw-r--r-- | net/quic/test_tools/crypto_test_utils.cc | 4 | ||||
-rw-r--r-- | net/quic/test_tools/mock_crypto_client_stream.cc | 12 | ||||
-rw-r--r-- | net/quic/test_tools/mock_crypto_client_stream.h | 4 | ||||
-rw-r--r-- | net/quic/test_tools/mock_crypto_client_stream_factory.cc | 2 | ||||
-rw-r--r-- | net/quic/test_tools/quic_test_utils.cc | 16 | ||||
-rw-r--r-- | net/quic/test_tools/quic_test_utils.h | 28 | ||||
-rw-r--r-- | net/tools/quic/quic_client_session.cc | 12 | ||||
-rw-r--r-- | net/tools/quic/quic_client_session.h | 10 |
19 files changed, 170 insertions, 90 deletions
diff --git a/net/net.gyp b/net/net.gyp index 309127e..3dc081e 100644 --- a/net/net.gyp +++ b/net/net.gyp @@ -843,7 +843,7 @@ 'quic/crypto/proof_source.h', 'quic/crypto/proof_source_chromium.cc', 'quic/crypto/proof_source_chromium.h', - 'quic/crypto/proof_verifier.cc', + 'quic/crypto/proof_verifier.h', 'quic/crypto/proof_verifier_chromium.cc', 'quic/crypto/proof_verifier_chromium.h', 'quic/crypto/quic_crypto_client_config.cc', @@ -882,6 +882,8 @@ 'quic/quic_blocked_writer_interface.h', 'quic/quic_client_session.cc', 'quic/quic_client_session.h', + 'quic/quic_client_session_base.cc', + 'quic/quic_client_session_base.h', 'quic/quic_clock.cc', 'quic/quic_clock.h', 'quic/quic_config.cc', diff --git a/net/quic/crypto/proof_verifier.cc b/net/quic/crypto/proof_verifier.cc deleted file mode 100644 index 4132a31..0000000 --- a/net/quic/crypto/proof_verifier.cc +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "net/quic/crypto/proof_verifier.h" - -namespace net { - -ProofVerifierCallback::~ProofVerifierCallback() {} - -ProofVerifier::~ProofVerifier() {} - -} // namespace net diff --git a/net/quic/crypto/proof_verifier.h b/net/quic/crypto/proof_verifier.h index 50d1635..0cbdb6a 100644 --- a/net/quic/crypto/proof_verifier.h +++ b/net/quic/crypto/proof_verifier.h @@ -32,7 +32,7 @@ class NET_EXPORT_PRIVATE ProofVerifyContext { // call back after an asynchronous verification. class NET_EXPORT_PRIVATE ProofVerifierCallback { public: - virtual ~ProofVerifierCallback(); + virtual ~ProofVerifierCallback() {} // Run is called on the original thread to mark the completion of an // asynchonous verification. If |ok| is true then the certificate is valid @@ -58,7 +58,7 @@ class NET_EXPORT_PRIVATE ProofVerifier { PENDING = 2, }; - virtual ~ProofVerifier(); + virtual ~ProofVerifier() {} // VerifyProof checks that |signature| is a valid signature of // |server_config| by the public key in the leaf certificate of |certs|, and diff --git a/net/quic/quic_client_session.cc b/net/quic/quic_client_session.cc index 92f3cd5..171cf33 100644 --- a/net/quic/quic_client_session.cc +++ b/net/quic/quic_client_session.cc @@ -95,7 +95,7 @@ QuicClientSession::QuicClientSession( const QuicConfig& config, QuicCryptoClientConfig* crypto_config, NetLog* net_log) - : QuicSession(connection, config), + : QuicClientSessionBase(connection, config), require_confirmation_(false), stream_factory_(stream_factory), socket_(socket.Pass()), @@ -112,7 +112,7 @@ QuicClientSession::QuicClientSession( crypto_client_stream_factory ? crypto_client_stream_factory->CreateQuicCryptoClientStream( server_key, this, crypto_config) : - new QuicCryptoClientStream(server_key, this, this, + new QuicCryptoClientStream(server_key, this, new ProofVerifyContextChromium(net_log_), crypto_config)); diff --git a/net/quic/quic_client_session.h b/net/quic/quic_client_session.h index f9d3b7f..ea31dc1 100644 --- a/net/quic/quic_client_session.h +++ b/net/quic/quic_client_session.h @@ -17,11 +17,11 @@ #include "base/memory/scoped_ptr.h" #include "net/base/completion_callback.h" #include "net/proxy/proxy_server.h" +#include "net/quic/quic_client_session_base.h" #include "net/quic/quic_connection_logger.h" #include "net/quic/quic_crypto_client_stream.h" #include "net/quic/quic_protocol.h" #include "net/quic/quic_reliable_client_stream.h" -#include "net/quic/quic_session.h" namespace net { @@ -39,9 +39,7 @@ namespace test { class QuicClientSessionPeer; } // namespace test -class NET_EXPORT_PRIVATE QuicClientSession : - public QuicSession, - public QuicCryptoClientStream::Visitor { +class NET_EXPORT_PRIVATE QuicClientSession : public QuicClientSessionBase { public: // An interface for observing events on a session. class NET_EXPORT_PRIVATE Observer { @@ -136,7 +134,7 @@ class NET_EXPORT_PRIVATE QuicClientSession : const CryptoHandshakeMessage& message) OVERRIDE; virtual bool GetSSLInfo(SSLInfo* ssl_info) const OVERRIDE; - // QuicCryptoClientStream::Visitor methods: + // QuicClientSessionBase methods: virtual void OnProofValid( const QuicCryptoClientConfig::CachedState& cached) OVERRIDE; virtual void OnProofVerifyDetailsAvailable( diff --git a/net/quic/quic_client_session_base.cc b/net/quic/quic_client_session_base.cc new file mode 100644 index 0000000..b9cbaff --- /dev/null +++ b/net/quic/quic_client_session_base.cc @@ -0,0 +1,15 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "net/quic/quic_client_session_base.h" + +namespace net { + +QuicClientSessionBase::QuicClientSessionBase(QuicConnection* connection, + const QuicConfig& config) + : QuicSession(connection, config) {} + +QuicClientSessionBase::~QuicClientSessionBase() {} + +} // namespace net diff --git a/net/quic/quic_client_session_base.h b/net/quic/quic_client_session_base.h new file mode 100644 index 0000000..eab5d08 --- /dev/null +++ b/net/quic/quic_client_session_base.h @@ -0,0 +1,41 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef NET_QUIC_QUIC_CLIENT_SESSION_BASE_H_ +#define NET_QUIC_QUIC_CLIENT_SESSION_BASE_H_ + +#include "net/quic/quic_crypto_client_stream.h" +#include "net/quic/quic_session.h" + +namespace net { + +// Base class for all client-specific QuicSession subclasses. +class NET_EXPORT_PRIVATE QuicClientSessionBase : public QuicSession { + public: + QuicClientSessionBase(QuicConnection* connection, + const QuicConfig& config); + + virtual ~QuicClientSessionBase(); + + // Called when the proof in |cached| is marked valid. If this is a secure + // QUIC session, then this will happen only after the proof verifier + // completes. If this is an insecure QUIC connection, this will happen + // as soon as a valid config is discovered (either from the cache or + // from the server). + virtual void OnProofValid( + const QuicCryptoClientConfig::CachedState& cached) = 0; + + // Called when proof verification details become available, either because + // proof verification is complete, or when cached details are used. This + // will only be called for secure QUIC connections. + virtual void OnProofVerifyDetailsAvailable( + const ProofVerifyDetails& verify_details) = 0; + + private: + DISALLOW_COPY_AND_ASSIGN(QuicClientSessionBase); +}; + +} // namespace net + +#endif // NET_QUIC_QUIC_CLIENT_SESSION_BASE_H_ diff --git a/net/quic/quic_crypto_client_stream.cc b/net/quic/quic_crypto_client_stream.cc index 7c840ba..4e216e2 100644 --- a/net/quic/quic_crypto_client_stream.cc +++ b/net/quic/quic_crypto_client_stream.cc @@ -8,8 +8,8 @@ #include "net/quic/crypto/crypto_utils.h" #include "net/quic/crypto/null_encrypter.h" #include "net/quic/crypto/proof_verifier.h" +#include "net/quic/quic_client_session_base.h" #include "net/quic/quic_protocol.h" -#include "net/quic/quic_session.h" namespace net { @@ -44,12 +44,10 @@ void QuicCryptoClientStream::ProofVerifierCallbackImpl::Cancel() { QuicCryptoClientStream::QuicCryptoClientStream( const QuicSessionKey& server_key, - QuicSession* session, - Visitor* visitor, + QuicClientSessionBase* session, ProofVerifyContext* verify_context, QuicCryptoClientConfig* crypto_config) : QuicCryptoStream(session), - visitor_(visitor), next_state_(STATE_IDLE), num_client_hellos_(0), crypto_config_(crypto_config), @@ -169,8 +167,8 @@ void QuicCryptoClientStream::DoHandshakeLoop( CloseConnectionWithDetails(error, error_details); return; } - if (visitor_ && cached->proof_verify_details()) { - visitor_->OnProofVerifyDetailsAvailable( + if (cached->proof_verify_details()) { + client_session()->OnProofVerifyDetailsAvailable( *cached->proof_verify_details()); } next_state_ = STATE_RECV_SHLO; @@ -261,10 +259,8 @@ void QuicCryptoClientStream::DoHandshakeLoop( } case STATE_VERIFY_PROOF_COMPLETE: if (!verify_ok_) { - if (visitor_) { - visitor_->OnProofVerifyDetailsAvailable( - *cached->proof_verify_details()); - } + client_session()->OnProofVerifyDetailsAvailable( + *cached->proof_verify_details()); CloseConnectionWithDetails( QUIC_PROOF_INVALID, "Proof invalid: " + verify_error_details_); return; @@ -355,9 +351,11 @@ void QuicCryptoClientStream::DoHandshakeLoop( void QuicCryptoClientStream::SetCachedProofValid( QuicCryptoClientConfig::CachedState* cached) { cached->SetProofValid(); - if (visitor_) { - visitor_->OnProofValid(*cached); - } + client_session()->OnProofValid(*cached); +} + +QuicClientSessionBase* QuicCryptoClientStream::client_session() { + return reinterpret_cast<QuicClientSessionBase*>(session()); } } // namespace net diff --git a/net/quic/quic_crypto_client_stream.h b/net/quic/quic_crypto_client_stream.h index 1c8508e..aef96cc 100644 --- a/net/quic/quic_crypto_client_stream.h +++ b/net/quic/quic_crypto_client_stream.h @@ -15,7 +15,7 @@ namespace net { -class QuicSession; +class QuicClientSessionBase; namespace test { class CryptoTestUtils; @@ -23,28 +23,8 @@ class CryptoTestUtils; class NET_EXPORT_PRIVATE QuicCryptoClientStream : public QuicCryptoStream { public: - class NET_EXPORT_PRIVATE Visitor { - public: - ~Visitor() {} - - // Called when the proof in |cached| is marked valid. If this is a secure - // QUIC session, then this will happen only after the proof verifier - // completes. If this is an insecure QUIC connection, this will happen - // as soon as a valid config is discovered (either from the cache or - // from the server). - virtual void OnProofValid( - const QuicCryptoClientConfig::CachedState& cached) = 0; - - // Called when proof verification details become available, either because - // proof verification is complete, or when cached details are used. This - // will only be called for secure QUIC connections. - virtual void OnProofVerifyDetailsAvailable( - const ProofVerifyDetails& verify_details) = 0; - }; - QuicCryptoClientStream(const QuicSessionKey& server_key, - QuicSession* session, - Visitor* visitor, + QuicClientSessionBase* session, ProofVerifyContext* verify_context, QuicCryptoClientConfig* crypto_config); virtual ~QuicCryptoClientStream(); @@ -63,8 +43,6 @@ class NET_EXPORT_PRIVATE QuicCryptoClientStream : public QuicCryptoStream { // than the number of round-trips needed for the handshake. int num_sent_client_hellos() const; - Visitor* visitor() { return visitor_; } - private: // ProofVerifierCallbackImpl is passed as the callback method to VerifyProof. // The ProofVerifier calls this class with the result of proof verification @@ -104,11 +82,11 @@ class NET_EXPORT_PRIVATE QuicCryptoClientStream : public QuicCryptoStream { // |in| may be NULL if the call did not result from a received message. void DoHandshakeLoop(const CryptoHandshakeMessage* in); - // Called to set the proof of |cached| valid. Also invokes the visitor's + // Called to set the proof of |cached| valid. Also invokes the session's // OnProofValid() method. void SetCachedProofValid(QuicCryptoClientConfig::CachedState* cached); - Visitor* visitor_; + QuicClientSessionBase* client_session(); State next_state_; // num_client_hellos_ contains the number of client hello messages that this diff --git a/net/quic/quic_crypto_client_stream_test.cc b/net/quic/quic_crypto_client_stream_test.cc index 3081210..12835f3 100644 --- a/net/quic/quic_crypto_client_stream_test.cc +++ b/net/quic/quic_crypto_client_stream_test.cc @@ -27,10 +27,10 @@ class QuicCryptoClientStreamTest : public ::testing::Test { public: QuicCryptoClientStreamTest() : connection_(new PacketSavingConnection(false)), - session_(new TestSession(connection_, DefaultQuicConfig())), + session_(new TestClientSession(connection_, DefaultQuicConfig())), server_key_(kServerHostname, kServerPort, false), stream_(new QuicCryptoClientStream( - server_key_, session_.get(), NULL, NULL, &crypto_config_)) { + server_key_, session_.get(), NULL, &crypto_config_)) { session_->SetCryptoStream(stream_.get()); session_->config()->SetDefaults(); crypto_config_.SetDefaults(); @@ -47,7 +47,7 @@ class QuicCryptoClientStreamTest : public ::testing::Test { } PacketSavingConnection* connection_; - scoped_ptr<TestSession> session_; + scoped_ptr<TestClientSession> session_; QuicSessionKey server_key_; scoped_ptr<QuicCryptoClientStream> stream_; CryptoHandshakeMessage message_; @@ -108,7 +108,7 @@ TEST_F(QuicCryptoClientStreamTest, NegotiatedParameters) { TEST_F(QuicCryptoClientStreamTest, InvalidHostname) { QuicSessionKey server_key("invalid", 80, false); stream_.reset(new QuicCryptoClientStream(server_key, session_.get(), NULL, - NULL, &crypto_config_)); + &crypto_config_)); session_->SetCryptoStream(stream_.get()); CompleteCryptoHandshake(); @@ -121,9 +121,9 @@ TEST_F(QuicCryptoClientStreamTest, ExpiredServerConfig) { CompleteCryptoHandshake(); connection_ = new PacketSavingConnection(true); - session_.reset(new TestSession(connection_, DefaultQuicConfig())); + session_.reset(new TestClientSession(connection_, DefaultQuicConfig())); stream_.reset(new QuicCryptoClientStream(server_key_, session_.get(), NULL, - NULL, &crypto_config_)); + &crypto_config_)); session_->SetCryptoStream(stream_.get()); session_->config()->SetDefaults(); diff --git a/net/quic/quic_crypto_server_stream_test.cc b/net/quic/quic_crypto_server_stream_test.cc index 0c279f5..704f069 100644 --- a/net/quic/quic_crypto_server_stream_test.cc +++ b/net/quic/quic_crypto_server_stream_test.cc @@ -105,7 +105,7 @@ class QuicCryptoServerStreamTest : public ::testing::TestWithParam<bool> { protected: PacketSavingConnection* connection_; - TestSession session_; + TestClientSession session_; QuicConfig config_; QuicCryptoServerConfig crypto_config_; QuicCryptoServerStream stream_; @@ -140,14 +140,14 @@ TEST_P(QuicCryptoServerStreamTest, ZeroRTT) { QuicConfig client_config; client_config.SetDefaults(); - scoped_ptr<TestSession> client_session( - new TestSession(client_conn, client_config)); + scoped_ptr<TestClientSession> client_session( + new TestClientSession(client_conn, client_config)); QuicCryptoClientConfig client_crypto_config; client_crypto_config.SetDefaults(); QuicSessionKey server_key(kServerHostname, kServerPort, false); scoped_ptr<QuicCryptoClientStream> client(new QuicCryptoClientStream( - server_key, client_session.get(), NULL, NULL, &client_crypto_config)); + server_key, client_session.get(), NULL, &client_crypto_config)); client_session->SetCryptoStream(client.get()); // Do a first handshake in order to prime the client config with the server's @@ -155,7 +155,8 @@ TEST_P(QuicCryptoServerStreamTest, ZeroRTT) { CHECK(client->CryptoConnect()); CHECK_EQ(1u, client_conn->packets_.size()); - scoped_ptr<TestSession> server_session(new TestSession(server_conn, config_)); + scoped_ptr<TestClientSession> server_session( + new TestClientSession(server_conn, config_)); scoped_ptr<QuicCryptoServerStream> server( new QuicCryptoServerStream(crypto_config_, server_session.get())); server_session->SetCryptoStream(server.get()); @@ -177,10 +178,10 @@ TEST_P(QuicCryptoServerStreamTest, ZeroRTT) { // This causes the client's nonce to be different and thus stops the // strike-register from rejecting the repeated nonce. reinterpret_cast<MockRandom*>(client_conn->random_generator())->ChangeValue(); - client_session.reset(new TestSession(client_conn, client_config)); - server_session.reset(new TestSession(server_conn, config_)); + client_session.reset(new TestClientSession(client_conn, client_config)); + server_session.reset(new TestClientSession(server_conn, config_)); client.reset(new QuicCryptoClientStream( - server_key, client_session.get(), NULL, NULL, &client_crypto_config)); + server_key, client_session.get(), NULL, &client_crypto_config)); client_session->SetCryptoStream(client.get()); server.reset(new QuicCryptoServerStream(crypto_config_, diff --git a/net/quic/test_tools/crypto_test_utils.cc b/net/quic/test_tools/crypto_test_utils.cc index f8d65b9..6dc60ca 100644 --- a/net/quic/test_tools/crypto_test_utils.cc +++ b/net/quic/test_tools/crypto_test_utils.cc @@ -167,7 +167,7 @@ int CryptoTestUtils::HandshakeWithFakeClient( QuicCryptoServerStream* server, const FakeClientOptions& options) { PacketSavingConnection* client_conn = new PacketSavingConnection(false); - TestSession client_session(client_conn, DefaultQuicConfig()); + TestClientSession client_session(client_conn, DefaultQuicConfig()); QuicCryptoClientConfig crypto_config; client_session.config()->SetDefaults(); @@ -180,7 +180,7 @@ int CryptoTestUtils::HandshakeWithFakeClient( crypto_config.SetChannelIDSigner(ChannelIDSignerForTesting()); } QuicSessionKey server_key(kServerHostname, kServerPort, false); - QuicCryptoClientStream client(server_key, &client_session, NULL, NULL, + QuicCryptoClientStream client(server_key, &client_session, NULL, &crypto_config); client_session.SetCryptoStream(&client); diff --git a/net/quic/test_tools/mock_crypto_client_stream.cc b/net/quic/test_tools/mock_crypto_client_stream.cc index d829fb2..a5ff173 100644 --- a/net/quic/test_tools/mock_crypto_client_stream.cc +++ b/net/quic/test_tools/mock_crypto_client_stream.cc @@ -4,6 +4,7 @@ #include "net/quic/test_tools/mock_crypto_client_stream.h" +#include "net/quic/quic_client_session_base.h" #include "net/quic/quic_session_key.h" #include "testing/gtest/include/gtest/gtest.h" @@ -11,13 +12,12 @@ namespace net { MockCryptoClientStream::MockCryptoClientStream( const QuicSessionKey& server_key, - QuicSession* session, - QuicCryptoClientStream::Visitor* visitor, + QuicClientSessionBase* session, ProofVerifyContext* verify_context, QuicCryptoClientConfig* crypto_config, HandshakeMode handshake_mode, const ProofVerifyDetails* proof_verify_details) - : QuicCryptoClientStream(server_key, session, visitor, verify_context, + : QuicCryptoClientStream(server_key, session, verify_context, crypto_config), handshake_mode_(handshake_mode), proof_verify_details_(proof_verify_details) { @@ -45,7 +45,7 @@ bool MockCryptoClientStream::CryptoConnect() { encryption_established_ = true; handshake_confirmed_ = true; if (proof_verify_details_) { - visitor()->OnProofVerifyDetailsAvailable(*proof_verify_details_); + client_session()->OnProofVerifyDetailsAvailable(*proof_verify_details_); } SetConfigNegotiated(); session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); @@ -92,4 +92,8 @@ void MockCryptoClientStream::SetConfigNegotiated() { ASSERT_TRUE(session()->config()->negotiated()); } +QuicClientSessionBase* MockCryptoClientStream::client_session() { + return reinterpret_cast<QuicClientSessionBase*>(session()); +} + } // namespace net diff --git a/net/quic/test_tools/mock_crypto_client_stream.h b/net/quic/test_tools/mock_crypto_client_stream.h index 1bec098..8567945 100644 --- a/net/quic/test_tools/mock_crypto_client_stream.h +++ b/net/quic/test_tools/mock_crypto_client_stream.h @@ -37,8 +37,7 @@ class MockCryptoClientStream : public QuicCryptoClientStream { MockCryptoClientStream( const QuicSessionKey& server_key, - QuicSession* session, - QuicCryptoClientStream::Visitor* visitor, + QuicClientSessionBase* session, ProofVerifyContext* verify_context, QuicCryptoClientConfig* crypto_config, HandshakeMode handshake_mode, @@ -60,6 +59,7 @@ class MockCryptoClientStream : public QuicCryptoClientStream { private: void SetConfigNegotiated(); + QuicClientSessionBase* client_session(); const ProofVerifyDetails* proof_verify_details_; }; diff --git a/net/quic/test_tools/mock_crypto_client_stream_factory.cc b/net/quic/test_tools/mock_crypto_client_stream_factory.cc index d9ebcaf..83dac36 100644 --- a/net/quic/test_tools/mock_crypto_client_stream_factory.cc +++ b/net/quic/test_tools/mock_crypto_client_stream_factory.cc @@ -25,7 +25,7 @@ MockCryptoClientStreamFactory::CreateQuicCryptoClientStream( QuicClientSession* session, QuicCryptoClientConfig* crypto_config) { last_stream_ = new MockCryptoClientStream( - server_key, session, session, NULL, crypto_config, handshake_mode_, + server_key, session, NULL, crypto_config, handshake_mode_, proof_verify_details_); return last_stream_; } diff --git a/net/quic/test_tools/quic_test_utils.cc b/net/quic/test_tools/quic_test_utils.cc index c3e20ae..e6beb98 100644 --- a/net/quic/test_tools/quic_test_utils.cc +++ b/net/quic/test_tools/quic_test_utils.cc @@ -364,6 +364,22 @@ QuicCryptoStream* TestSession::GetCryptoStream() { return crypto_stream_; } +TestClientSession::TestClientSession(QuicConnection* connection, + const QuicConfig& config) + : QuicClientSessionBase(connection, config), + crypto_stream_(NULL) { +} + +TestClientSession::~TestClientSession() {} + +void TestClientSession::SetCryptoStream(QuicCryptoStream* stream) { + crypto_stream_ = stream; +} + +QuicCryptoStream* TestClientSession::GetCryptoStream() { + return crypto_stream_; +} + MockPacketWriter::MockPacketWriter() { } diff --git a/net/quic/test_tools/quic_test_utils.h b/net/quic/test_tools/quic_test_utils.h index f6e188a..1cca4e8 100644 --- a/net/quic/test_tools/quic_test_utils.h +++ b/net/quic/test_tools/quic_test_utils.h @@ -13,7 +13,9 @@ #include "base/strings/string_piece.h" #include "net/quic/congestion_control/loss_detection_interface.h" #include "net/quic/congestion_control/send_algorithm_interface.h" +#include "net/quic/crypto/quic_crypto_client_config.h" #include "net/quic/quic_ack_notifier.h" +#include "net/quic/quic_client_session_base.h" #include "net/quic/quic_connection.h" #include "net/quic/quic_framer.h" #include "net/quic/quic_session.h" @@ -396,13 +398,37 @@ class TestSession : public QuicSession { void SetCryptoStream(QuicCryptoStream* stream); - virtual QuicCryptoStream* GetCryptoStream(); + virtual QuicCryptoStream* GetCryptoStream() OVERRIDE; private: QuicCryptoStream* crypto_stream_; DISALLOW_COPY_AND_ASSIGN(TestSession); }; +class TestClientSession : public QuicClientSessionBase { + public: + TestClientSession(QuicConnection* connection, const QuicConfig& config); + virtual ~TestClientSession(); + + // QuicClientSessionBase + MOCK_METHOD1(OnProofValid, + void(const QuicCryptoClientConfig::CachedState& cached)); + MOCK_METHOD1(OnProofVerifyDetailsAvailable, + void(const ProofVerifyDetails& verify_details)); + + // TestClientSession + MOCK_METHOD1(CreateIncomingDataStream, QuicDataStream*(QuicStreamId id)); + MOCK_METHOD0(CreateOutgoingDataStream, QuicDataStream*()); + + void SetCryptoStream(QuicCryptoStream* stream); + + virtual QuicCryptoStream* GetCryptoStream() OVERRIDE; + + private: + QuicCryptoStream* crypto_stream_; + DISALLOW_COPY_AND_ASSIGN(TestClientSession); +}; + class MockPacketWriter : public QuicPacketWriter { public: MockPacketWriter(); diff --git a/net/tools/quic/quic_client_session.cc b/net/tools/quic/quic_client_session.cc index 03c9cae..29b178a 100644 --- a/net/tools/quic/quic_client_session.cc +++ b/net/tools/quic/quic_client_session.cc @@ -19,13 +19,21 @@ QuicClientSession::QuicClientSession( const QuicConfig& config, QuicConnection* connection, QuicCryptoClientConfig* crypto_config) - : QuicSession(connection, config), - crypto_stream_(server_key, this, NULL, NULL, crypto_config) { + : QuicClientSessionBase(connection, config), + crypto_stream_(server_key, this, NULL, crypto_config) { } QuicClientSession::~QuicClientSession() { } +void QuicClientSession::OnProofValid( + const QuicCryptoClientConfig::CachedState& /*cached*/) { +} + +void QuicClientSession::OnProofVerifyDetailsAvailable( + const ProofVerifyDetails& /*verify_details*/) { +} + QuicSpdyClientStream* QuicClientSession::CreateOutgoingDataStream() { if (!crypto_stream_.encryption_established()) { DVLOG(1) << "Encryption not active so no outgoing stream created."; diff --git a/net/tools/quic/quic_client_session.h b/net/tools/quic/quic_client_session.h index f3bce29..6f7a1ba 100644 --- a/net/tools/quic/quic_client_session.h +++ b/net/tools/quic/quic_client_session.h @@ -10,9 +10,9 @@ #include <string> #include "base/basictypes.h" +#include "net/quic/quic_client_session_base.h" #include "net/quic/quic_crypto_client_stream.h" #include "net/quic/quic_protocol.h" -#include "net/quic/quic_session.h" #include "net/tools/quic/quic_spdy_client_stream.h" namespace net { @@ -23,7 +23,7 @@ class ReliableQuicStream; namespace tools { -class QuicClientSession : public QuicSession { +class QuicClientSession : public QuicClientSessionBase { public: QuicClientSession(const QuicSessionKey& server_key, const QuicConfig& config, @@ -31,6 +31,12 @@ class QuicClientSession : public QuicSession { QuicCryptoClientConfig* crypto_config); virtual ~QuicClientSession(); + // QuicClientSessionBase methods: + virtual void OnProofValid( + const QuicCryptoClientConfig::CachedState& cached) OVERRIDE; + virtual void OnProofVerifyDetailsAvailable( + const ProofVerifyDetails& verify_details) OVERRIDE; + // QuicSession methods: virtual QuicSpdyClientStream* CreateOutgoingDataStream() OVERRIDE; virtual QuicCryptoClientStream* GetCryptoStream() OVERRIDE; |