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

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

Issue 380543003: Add an async ChannelIDSource for testing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
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 #ifndef NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ 5 #ifndef NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_
6 #define NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ 6 #define NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_
7 7
8 #include <stdarg.h> 8 #include <stdarg.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 20 matching lines...) Expand all
31 class QuicCryptoServerStream; 31 class QuicCryptoServerStream;
32 class QuicCryptoStream; 32 class QuicCryptoStream;
33 class QuicRandom; 33 class QuicRandom;
34 34
35 namespace test { 35 namespace test {
36 36
37 class PacketSavingConnection; 37 class PacketSavingConnection;
38 38
39 class CryptoTestUtils { 39 class CryptoTestUtils {
40 public: 40 public:
41 // An interface for a source of tasks to run.
42 class TaskSource {
wtc 2014/07/09 01:03:53 I'd appreciate suggestion for a better name. If t
43 public:
44 virtual ~TaskSource() {}
45
46 // Runs all pending tasks in this source.
47 virtual void RunPending() = 0;
48 };
49
41 // FakeClientOptions bundles together a number of options for configuring 50 // FakeClientOptions bundles together a number of options for configuring
42 // HandshakeWithFakeClient. 51 // HandshakeWithFakeClient.
43 struct FakeClientOptions { 52 struct FakeClientOptions {
44 FakeClientOptions(); 53 FakeClientOptions();
45 54
46 // If dont_verify_certs is true then no ProofVerifier is set on the client. 55 // If dont_verify_certs is true then no ProofVerifier is set on the client.
47 // Thus no certificates will be requested or checked. 56 // Thus no certificates will be requested or checked.
48 bool dont_verify_certs; 57 bool dont_verify_certs;
49 58
50 // If channel_id_enabled is true then the client will attempt to send a 59 // If channel_id_enabled is true then the client will attempt to send a
51 // ChannelID. 60 // ChannelID.
52 bool channel_id_enabled; 61 bool channel_id_enabled;
62
63 // If channel_id_source_async is true then the client will use an async
64 // ChannelIDSource for testing. Ignored if channel_id_enabled is false.
65 bool channel_id_source_async;
53 }; 66 };
54 67
55 // returns: the number of client hellos that the client sent. 68 // returns: the number of client hellos that the client sent.
56 static int HandshakeWithFakeServer(PacketSavingConnection* client_conn, 69 static int HandshakeWithFakeServer(PacketSavingConnection* client_conn,
57 QuicCryptoClientStream* client); 70 QuicCryptoClientStream* client);
58 71
59 // returns: the number of client hellos that the client sent. 72 // returns: the number of client hellos that the client sent.
60 static int HandshakeWithFakeClient(PacketSavingConnection* server_conn, 73 static int HandshakeWithFakeClient(PacketSavingConnection* server_conn,
61 QuicCryptoServerStream* server, 74 QuicCryptoServerStream* server,
62 const FakeClientOptions& options); 75 const FakeClientOptions& options);
63 76
64 // SetupCryptoServerConfigForTest configures |config| and |crypto_config| 77 // SetupCryptoServerConfigForTest configures |config| and |crypto_config|
65 // with sensible defaults for testing. 78 // with sensible defaults for testing.
66 static void SetupCryptoServerConfigForTest( 79 static void SetupCryptoServerConfigForTest(
67 const QuicClock* clock, 80 const QuicClock* clock,
68 QuicRandom* rand, 81 QuicRandom* rand,
69 QuicConfig* config, 82 QuicConfig* config,
70 QuicCryptoServerConfig* crypto_config); 83 QuicCryptoServerConfig* crypto_config);
71 84
72 // CommunicateHandshakeMessages moves messages from |a| to |b| and back until 85 // CommunicateHandshakeMessages moves messages from |a| to |b| and back and
73 // |a|'s handshake has completed. 86 // runs pending tasks in |task_source| until |a|'s handshake has completed.
74 static void CommunicateHandshakeMessages(PacketSavingConnection* a_conn, 87 static void CommunicateHandshakeMessages(PacketSavingConnection* a_conn,
75 QuicCryptoStream* a, 88 QuicCryptoStream* a,
76 PacketSavingConnection* b_conn, 89 PacketSavingConnection* b_conn,
77 QuicCryptoStream* b); 90 QuicCryptoStream* b,
91 TaskSource* task_source = NULL);
wtc 2014/07/09 01:03:52 It seems that the Style Guide allows this use of d
Ryan Hamilton 2014/07/09 16:54:39 The way I read the style guide, it's not just that
wtc 2014/07/09 19:44:42 Done. Added a CommunicateHandshakeMessagesAndDoWor
78 92
79 // AdvanceHandshake attempts to moves messages from |a| to |b| and |b| to |a|. 93 // AdvanceHandshake attempts to moves messages from |a| to |b| and |b| to |a|.
80 // Returns the number of messages moved. 94 // Returns the number of messages moved.
81 static std::pair<size_t, size_t> AdvanceHandshake( 95 static std::pair<size_t, size_t> AdvanceHandshake(
82 PacketSavingConnection* a_conn, 96 PacketSavingConnection* a_conn,
83 QuicCryptoStream* a, 97 QuicCryptoStream* a,
84 size_t a_i, 98 size_t a_i,
85 PacketSavingConnection* b_conn, 99 PacketSavingConnection* b_conn,
86 QuicCryptoStream* b, 100 QuicCryptoStream* b,
87 size_t b_i); 101 size_t b_i);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 QuicCryptoServerStream* server); 166 QuicCryptoServerStream* server);
153 167
154 DISALLOW_COPY_AND_ASSIGN(CryptoTestUtils); 168 DISALLOW_COPY_AND_ASSIGN(CryptoTestUtils);
155 }; 169 };
156 170
157 } // namespace test 171 } // namespace test
158 172
159 } // namespace net 173 } // namespace net
160 174
161 #endif // NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ 175 #endif // NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698