• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
15 namespace net {
16 
17 class MockCryptoClientStream : public QuicCryptoClientStream {
18  public:
19   // HandshakeMode enumerates the handshake mode MockCryptoClientStream should
20   // mock in CryptoConnect.
21   enum HandshakeMode {
22     // CONFIRM_HANDSHAKE indicates that CryptoConnect will immediately confirm
23     // the handshake and establish encryption.  This behavior will never happen
24     // in the field, but is convenient for higher level tests.
25     CONFIRM_HANDSHAKE,
26 
27     // ZERO_RTT indicates that CryptoConnect will establish encryption but will
28     // not confirm the handshake.
29     ZERO_RTT,
30 
31     // COLD_START indicates that CryptoConnect will neither establish encryption
32     // nor confirm the handshake
33     COLD_START,
34   };
35 
36   MockCryptoClientStream(
37       const string& server_hostname,
38       QuicSession* session,
39       QuicCryptoClientConfig* crypto_config,
40       HandshakeMode handshake_mode);
41   virtual ~MockCryptoClientStream();
42 
43   // CryptoFramerVisitorInterface implementation.
44   virtual void OnHandshakeMessage(
45       const CryptoHandshakeMessage& message) OVERRIDE;
46 
47   // QuicCryptoClientStream implementation.
48   virtual bool CryptoConnect() OVERRIDE;
49 
50   // Invokes the sessions's CryptoHandshakeEvent method with the specified
51   // event.
52   void SendOnCryptoHandshakeEvent(QuicSession::CryptoHandshakeEvent event);
53 
54   HandshakeMode handshake_mode_;
55 
56  private:
57   void SetConfigNegotiated();
58 };
59 
60 }  // namespace net
61 
62 #endif  // NET_QUIC_TEST_TOOLS_MOCK_CRYPTO_CLIENT_STREAM_H_
63