Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Side by Side Diff: net/quic/test_tools/mock_crypto_client_stream.cc

Issue 1665743003: Refactor QuicCryptoClientStream to use QuicSession directly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@113297234
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/test_tools/mock_crypto_client_stream.h ('k') | net/quic/test_tools/quic_test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/test_tools/mock_crypto_client_stream.h" 5 #include "net/quic/test_tools/mock_crypto_client_stream.h"
6 6
7 #include "net/quic/crypto/quic_decrypter.h" 7 #include "net/quic/crypto/quic_decrypter.h"
8 #include "net/quic/crypto/quic_encrypter.h" 8 #include "net/quic/crypto/quic_encrypter.h"
9 #include "net/quic/quic_client_session_base.h" 9 #include "net/quic/quic_client_session_base.h"
10 #include "net/quic/quic_server_id.h" 10 #include "net/quic/quic_server_id.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 using std::string; 13 using std::string;
14 14
15 namespace net { 15 namespace net {
16 16
17 MockCryptoClientStream::MockCryptoClientStream( 17 MockCryptoClientStream::MockCryptoClientStream(
18 const QuicServerId& server_id, 18 const QuicServerId& server_id,
19 QuicClientSessionBase* session, 19 QuicClientSessionBase* session,
20 ProofVerifyContext* verify_context, 20 ProofVerifyContext* verify_context,
21 QuicCryptoClientConfig* crypto_config, 21 QuicCryptoClientConfig* crypto_config,
22 HandshakeMode handshake_mode, 22 HandshakeMode handshake_mode,
23 const ProofVerifyDetails* proof_verify_details) 23 const ProofVerifyDetails* proof_verify_details)
24 : QuicCryptoClientStream(server_id, session, verify_context, crypto_config), 24 : QuicCryptoClientStream(server_id,
25 session,
26 verify_context,
27 crypto_config,
28 session),
25 handshake_mode_(handshake_mode), 29 handshake_mode_(handshake_mode),
26 proof_verify_details_(proof_verify_details) {} 30 proof_verify_details_(proof_verify_details) {}
27 31
28 MockCryptoClientStream::~MockCryptoClientStream() {} 32 MockCryptoClientStream::~MockCryptoClientStream() {}
29 33
30 void MockCryptoClientStream::OnHandshakeMessage( 34 void MockCryptoClientStream::OnHandshakeMessage(
31 const CryptoHandshakeMessage& message) { 35 const CryptoHandshakeMessage& message) {
32 CloseConnectionWithDetails(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE, 36 CloseConnectionWithDetails(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE,
33 "Forced mock failure"); 37 "Forced mock failure");
34 } 38 }
35 39
36 void MockCryptoClientStream::CryptoConnect() { 40 void MockCryptoClientStream::CryptoConnect() {
37 switch (handshake_mode_) { 41 switch (handshake_mode_) {
38 case ZERO_RTT: { 42 case ZERO_RTT: {
39 encryption_established_ = true; 43 encryption_established_ = true;
40 handshake_confirmed_ = false; 44 handshake_confirmed_ = false;
41 crypto_negotiated_params_.key_exchange = kC255; 45 crypto_negotiated_params_.key_exchange = kC255;
42 crypto_negotiated_params_.aead = kAESG; 46 crypto_negotiated_params_.aead = kAESG;
43 if (proof_verify_details_) { 47 if (proof_verify_details_) {
44 client_session()->OnProofVerifyDetailsAvailable(*proof_verify_details_); 48 reinterpret_cast<QuicClientSessionBase*>(session())
49 ->OnProofVerifyDetailsAvailable(*proof_verify_details_);
45 } 50 }
46 session()->connection()->SetDecrypter(ENCRYPTION_INITIAL, 51 session()->connection()->SetDecrypter(ENCRYPTION_INITIAL,
47 QuicDecrypter::Create(kNULL)); 52 QuicDecrypter::Create(kNULL));
48 session()->connection()->SetEncrypter(ENCRYPTION_INITIAL, 53 session()->connection()->SetEncrypter(ENCRYPTION_INITIAL,
49 QuicEncrypter::Create(kNULL)); 54 QuicEncrypter::Create(kNULL));
50 session()->connection()->SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); 55 session()->connection()->SetDefaultEncryptionLevel(ENCRYPTION_INITIAL);
51 session()->OnCryptoHandshakeEvent( 56 session()->OnCryptoHandshakeEvent(
52 QuicSession::ENCRYPTION_FIRST_ESTABLISHED); 57 QuicSession::ENCRYPTION_FIRST_ESTABLISHED);
53 break; 58 break;
54 } 59 }
55 60
56 case CONFIRM_HANDSHAKE: { 61 case CONFIRM_HANDSHAKE: {
57 encryption_established_ = true; 62 encryption_established_ = true;
58 handshake_confirmed_ = true; 63 handshake_confirmed_ = true;
59 crypto_negotiated_params_.key_exchange = kC255; 64 crypto_negotiated_params_.key_exchange = kC255;
60 crypto_negotiated_params_.aead = kAESG; 65 crypto_negotiated_params_.aead = kAESG;
61 if (proof_verify_details_) { 66 if (proof_verify_details_) {
62 client_session()->OnProofVerifyDetailsAvailable(*proof_verify_details_); 67 reinterpret_cast<QuicClientSessionBase*>(session())
68 ->OnProofVerifyDetailsAvailable(*proof_verify_details_);
63 } 69 }
64 SetConfigNegotiated(); 70 SetConfigNegotiated();
65 session()->connection()->SetDecrypter(ENCRYPTION_FORWARD_SECURE, 71 session()->connection()->SetDecrypter(ENCRYPTION_FORWARD_SECURE,
66 QuicDecrypter::Create(kNULL)); 72 QuicDecrypter::Create(kNULL));
67 session()->connection()->SetEncrypter(ENCRYPTION_FORWARD_SECURE, 73 session()->connection()->SetEncrypter(ENCRYPTION_FORWARD_SECURE,
68 QuicEncrypter::Create(kNULL)); 74 QuicEncrypter::Create(kNULL));
69 session()->connection()->SetDefaultEncryptionLevel( 75 session()->connection()->SetDefaultEncryptionLevel(
70 ENCRYPTION_FORWARD_SECURE); 76 ENCRYPTION_FORWARD_SECURE);
71 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); 77 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED);
72 break; 78 break;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 CryptoHandshakeMessage msg; 115 CryptoHandshakeMessage msg;
110 config.ToHandshakeMessage(&msg); 116 config.ToHandshakeMessage(&msg);
111 string error_details; 117 string error_details;
112 const QuicErrorCode error = 118 const QuicErrorCode error =
113 session()->config()->ProcessPeerHello(msg, CLIENT, &error_details); 119 session()->config()->ProcessPeerHello(msg, CLIENT, &error_details);
114 ASSERT_EQ(QUIC_NO_ERROR, error); 120 ASSERT_EQ(QUIC_NO_ERROR, error);
115 ASSERT_TRUE(session()->config()->negotiated()); 121 ASSERT_TRUE(session()->config()->negotiated());
116 session()->OnConfigNegotiated(); 122 session()->OnConfigNegotiated();
117 } 123 }
118 124
119 QuicClientSessionBase* MockCryptoClientStream::client_session() {
120 return reinterpret_cast<QuicClientSessionBase*>(session());
121 }
122
123 } // namespace net 125 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/mock_crypto_client_stream.h ('k') | net/quic/test_tools/quic_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698