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