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

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

Issue 1898793003: Make QuicDispatcher's helper and alarm factory arguments unique_ptrs to make ownership clear. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@119871679
Patch Set: fixing rebase Created 4 years, 8 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/crypto_test_utils.h ('k') | net/quic/test_tools/mock_quic_dispatcher.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/crypto_test_utils.h" 5 #include "net/quic/test_tools/crypto_test_utils.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "net/quic/crypto/channel_id.h" 8 #include "net/quic/crypto/channel_id.h"
9 #include "net/quic/crypto/common_cert_set.h" 9 #include "net/quic/crypto/common_cert_set.h"
10 #include "net/quic/crypto/crypto_handshake.h" 10 #include "net/quic/crypto/crypto_handshake.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 : token_binding_enabled(false) {} 121 : token_binding_enabled(false) {}
122 122
123 CryptoTestUtils::FakeClientOptions::FakeClientOptions() 123 CryptoTestUtils::FakeClientOptions::FakeClientOptions()
124 : channel_id_enabled(false), 124 : channel_id_enabled(false),
125 channel_id_source_async(false), 125 channel_id_source_async(false),
126 token_binding_enabled(false) {} 126 token_binding_enabled(false) {}
127 127
128 // static 128 // static
129 int CryptoTestUtils::HandshakeWithFakeServer( 129 int CryptoTestUtils::HandshakeWithFakeServer(
130 MockConnectionHelper* helper, 130 MockConnectionHelper* helper,
131 MockAlarmFactory* alarm_factory,
131 PacketSavingConnection* client_conn, 132 PacketSavingConnection* client_conn,
132 QuicCryptoClientStream* client, 133 QuicCryptoClientStream* client,
133 const FakeServerOptions& options) { 134 const FakeServerOptions& options) {
134 PacketSavingConnection* server_conn = new PacketSavingConnection( 135 PacketSavingConnection* server_conn =
135 helper, Perspective::IS_SERVER, client_conn->supported_versions()); 136 new PacketSavingConnection(helper, alarm_factory, Perspective::IS_SERVER,
137 client_conn->supported_versions());
136 138
137 QuicConfig config = DefaultQuicConfig(); 139 QuicConfig config = DefaultQuicConfig();
138 QuicCryptoServerConfig crypto_config(QuicCryptoServerConfig::TESTING, 140 QuicCryptoServerConfig crypto_config(QuicCryptoServerConfig::TESTING,
139 QuicRandom::GetInstance(), 141 QuicRandom::GetInstance(),
140 ProofSourceForTesting()); 142 ProofSourceForTesting());
141 QuicCompressedCertsCache compressed_certs_cache( 143 QuicCompressedCertsCache compressed_certs_cache(
142 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize); 144 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize);
143 SetupCryptoServerConfigForTest(server_conn->clock(), 145 SetupCryptoServerConfigForTest(server_conn->clock(),
144 server_conn->random_generator(), &config, 146 server_conn->random_generator(), &config,
145 &crypto_config, options); 147 &crypto_config, options);
146 148
147 TestQuicSpdyServerSession server_session(server_conn, config, &crypto_config, 149 TestQuicSpdyServerSession server_session(server_conn, config, &crypto_config,
148 &compressed_certs_cache); 150 &compressed_certs_cache);
149 151
150 // The client's handshake must have been started already. 152 // The client's handshake must have been started already.
151 CHECK_NE(0u, client_conn->encrypted_packets_.size()); 153 CHECK_NE(0u, client_conn->encrypted_packets_.size());
152 154
153 CommunicateHandshakeMessages(client_conn, client, server_conn, 155 CommunicateHandshakeMessages(client_conn, client, server_conn,
154 server_session.GetCryptoStream()); 156 server_session.GetCryptoStream());
155 CompareClientAndServerKeys(client, server_session.GetCryptoStream()); 157 CompareClientAndServerKeys(client, server_session.GetCryptoStream());
156 158
157 return client->num_sent_client_hellos(); 159 return client->num_sent_client_hellos();
158 } 160 }
159 161
160 // static 162 // static
161 int CryptoTestUtils::HandshakeWithFakeClient( 163 int CryptoTestUtils::HandshakeWithFakeClient(
162 MockConnectionHelper* helper, 164 MockConnectionHelper* helper,
165 MockAlarmFactory* alarm_factory,
163 PacketSavingConnection* server_conn, 166 PacketSavingConnection* server_conn,
164 QuicCryptoServerStream* server, 167 QuicCryptoServerStream* server,
165 const QuicServerId& server_id, 168 const QuicServerId& server_id,
166 const FakeClientOptions& options) { 169 const FakeClientOptions& options) {
167 PacketSavingConnection* client_conn = 170 PacketSavingConnection* client_conn =
168 new PacketSavingConnection(helper, Perspective::IS_CLIENT); 171 new PacketSavingConnection(helper, alarm_factory, Perspective::IS_CLIENT);
169 // Advance the time, because timers do not like uninitialized times. 172 // Advance the time, because timers do not like uninitialized times.
170 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(1)); 173 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(1));
171 174
172 QuicCryptoClientConfig crypto_config(ProofVerifierForTesting()); 175 QuicCryptoClientConfig crypto_config(ProofVerifierForTesting());
173 AsyncTestChannelIDSource* async_channel_id_source = nullptr; 176 AsyncTestChannelIDSource* async_channel_id_source = nullptr;
174 if (options.channel_id_enabled) { 177 if (options.channel_id_enabled) {
175 ChannelIDSource* source = ChannelIDSourceForTesting(); 178 ChannelIDSource* source = ChannelIDSourceForTesting();
176 if (options.channel_id_source_async) { 179 if (options.channel_id_source_async) {
177 async_channel_id_source = new AsyncTestChannelIDSource(source); 180 async_channel_id_source = new AsyncTestChannelIDSource(source);
178 source = async_channel_id_source; 181 source = async_channel_id_source;
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 645
643 ASSERT_EQ(0u, crypto_framer.InputBytesRemaining()); 646 ASSERT_EQ(0u, crypto_framer.InputBytesRemaining());
644 647
645 for (const CryptoHandshakeMessage& message : crypto_visitor.messages()) { 648 for (const CryptoHandshakeMessage& message : crypto_visitor.messages()) {
646 dest_stream->OnHandshakeMessage(message); 649 dest_stream->OnHandshakeMessage(message);
647 } 650 }
648 } 651 }
649 652
650 } // namespace test 653 } // namespace test
651 } // namespace net 654 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/crypto_test_utils.h ('k') | net/quic/test_tools/mock_quic_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698