mock_crypto_client_stream.h revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
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 3// found in the LICENSE file. 4 5#ifndef NET_QUIC_TEST_TOOLS_MOCK_CRYPTO_CLIENT_STREAM_H_ 6#define NET_QUIC_TEST_TOOLS_MOCK_CRYPTO_CLIENT_STREAM_H_ 7 8#include <string> 9 10#include "net/quic/crypto/crypto_handshake.h" 11#include "net/quic/crypto/crypto_protocol.h" 12#include "net/quic/quic_crypto_client_stream.h" 13#include "net/quic/quic_session.h" 14 15namespace net { 16 17class QuicSessionKey; 18 19class MockCryptoClientStream : public QuicCryptoClientStream { 20 public: 21 // HandshakeMode enumerates the handshake mode MockCryptoClientStream should 22 // mock in CryptoConnect. 23 enum HandshakeMode { 24 // CONFIRM_HANDSHAKE indicates that CryptoConnect will immediately confirm 25 // the handshake and establish encryption. This behavior will never happen 26 // in the field, but is convenient for higher level tests. 27 CONFIRM_HANDSHAKE, 28 29 // ZERO_RTT indicates that CryptoConnect will establish encryption but will 30 // not confirm the handshake. 31 ZERO_RTT, 32 33 // COLD_START indicates that CryptoConnect will neither establish encryption 34 // nor confirm the handshake 35 COLD_START, 36 }; 37 38 MockCryptoClientStream( 39 const QuicSessionKey& server_key, 40 QuicSession* session, 41 QuicCryptoClientConfig* crypto_config, 42 HandshakeMode handshake_mode, 43 const SSLInfo* ssl_info); 44 virtual ~MockCryptoClientStream(); 45 46 // CryptoFramerVisitorInterface implementation. 47 virtual void OnHandshakeMessage( 48 const CryptoHandshakeMessage& message) OVERRIDE; 49 50 // QuicCryptoClientStream implementation. 51 virtual bool CryptoConnect() OVERRIDE; 52 53 virtual bool GetSSLInfo(SSLInfo* ssl_info) OVERRIDE; 54 55 // Invokes the sessions's CryptoHandshakeEvent method with the specified 56 // event. 57 void SendOnCryptoHandshakeEvent(QuicSession::CryptoHandshakeEvent event); 58 59 HandshakeMode handshake_mode_; 60 61 private: 62 void SetConfigNegotiated(); 63 64 const SSLInfo* ssl_info_; 65}; 66 67} // namespace net 68 69#endif // NET_QUIC_TEST_TOOLS_MOCK_CRYPTO_CLIENT_STREAM_H_ 70