MacViews: Get c/b/ui/views/tabs to build on Mac
[chromium-blink-merge.git] / net / quic / test_tools / quic_test_utils.h
blob99a5ae5d31b7fee9d59fee0ae73f5061a8225c7b
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
3 // found in the LICENSE file.
4 //
5 // Common utilities for Quic tests
7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_
8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_
10 #include <string>
11 #include <vector>
13 #include "base/strings/string_piece.h"
14 #include "net/quic/congestion_control/loss_detection_interface.h"
15 #include "net/quic/congestion_control/send_algorithm_interface.h"
16 #include "net/quic/quic_ack_notifier.h"
17 #include "net/quic/quic_client_session_base.h"
18 #include "net/quic/quic_connection.h"
19 #include "net/quic/quic_dispatcher.h"
20 #include "net/quic/quic_framer.h"
21 #include "net/quic/quic_per_connection_packet_writer.h"
22 #include "net/quic/quic_sent_packet_manager.h"
23 #include "net/quic/quic_session.h"
24 #include "net/quic/test_tools/mock_clock.h"
25 #include "net/quic/test_tools/mock_random.h"
26 #include "net/spdy/spdy_framer.h"
27 #include "testing/gmock/include/gmock/gmock.h"
29 namespace net {
31 namespace test {
33 static const QuicConnectionId kTestConnectionId = 42;
34 static const int kTestPort = 123;
35 static const uint32 kInitialStreamFlowControlWindowForTest =
36 32 * 1024; // 32 KB
37 static const uint32 kInitialSessionFlowControlWindowForTest =
38 64 * 1024; // 64 KB
40 // Data stream IDs start at 5: the crypto stream is 1, headers stream is 3.
41 static const QuicStreamId kClientDataStreamId1 = 5;
42 static const QuicStreamId kClientDataStreamId2 = 7;
43 static const QuicStreamId kClientDataStreamId3 = 9;
44 static const QuicStreamId kClientDataStreamId4 = 11;
46 // Returns the test peer IP address.
47 IPAddressNumber TestPeerIPAddress();
49 // Upper limit on versions we support.
50 QuicVersion QuicVersionMax();
52 // Lower limit on versions we support.
53 QuicVersion QuicVersionMin();
55 // Returns an address for 127.0.0.1.
56 IPAddressNumber Loopback4();
58 // Returns an address for ::1.
59 IPAddressNumber Loopback6();
61 void GenerateBody(std::string* body, int length);
63 // Create an encrypted packet for testing.
64 QuicEncryptedPacket* ConstructEncryptedPacket(
65 QuicConnectionId connection_id,
66 bool version_flag,
67 bool reset_flag,
68 QuicPacketSequenceNumber sequence_number,
69 const std::string& data);
71 void CompareCharArraysWithHexError(const std::string& description,
72 const char* actual,
73 const int actual_len,
74 const char* expected,
75 const int expected_len);
77 bool DecodeHexString(const base::StringPiece& hex, std::string* bytes);
79 // Returns the length of a QuicPacket that is capable of holding either a
80 // stream frame or a minimal ack frame. Sets |*payload_length| to the number
81 // of bytes of stream data that will fit in such a packet.
82 size_t GetPacketLengthForOneStream(
83 QuicVersion version,
84 bool include_version,
85 QuicSequenceNumberLength sequence_number_length,
86 InFecGroup is_in_fec_group,
87 size_t* payload_length);
89 // Returns QuicConfig set to default values.
90 QuicConfig DefaultQuicConfig();
92 // Returns a version vector consisting of |version|.
93 QuicVersionVector SupportedVersions(QuicVersion version);
95 // Testing convenience method to construct a QuicAckFrame with entropy_hash set
96 // to 0 and largest_observed from peer set to |largest_observed|.
97 QuicAckFrame MakeAckFrame(QuicPacketSequenceNumber largest_observed);
99 // Testing convenience method to construct a QuicAckFrame with |num_nack_ranges|
100 // nack ranges of width 1 packet, starting from |least_unacked|.
101 QuicAckFrame MakeAckFrameWithNackRanges(size_t num_nack_ranges,
102 QuicPacketSequenceNumber least_unacked);
104 // Returns a SerializedPacket whose |packet| member is owned by the caller, and
105 // is populated with the fields in |header| and |frames|, or is nullptr if the
106 // packet could not be created.
107 SerializedPacket BuildUnsizedDataPacket(QuicFramer* framer,
108 const QuicPacketHeader& header,
109 const QuicFrames& frames);
111 template<typename SaveType>
112 class ValueRestore {
113 public:
114 ValueRestore(SaveType* name, SaveType value)
115 : name_(name),
116 value_(*name) {
117 *name_ = value;
119 ~ValueRestore() {
120 *name_ = value_;
123 private:
124 SaveType* name_;
125 SaveType value_;
127 DISALLOW_COPY_AND_ASSIGN(ValueRestore);
130 // Simple random number generator used to compute random numbers suitable
131 // for pseudo-randomly dropping packets in tests. It works by computing
132 // the sha1 hash of the current seed, and using the first 64 bits as
133 // the next random number, and the next seed.
134 class SimpleRandom {
135 public:
136 SimpleRandom() : seed_(0) {}
138 // Returns a random number in the range [0, kuint64max].
139 uint64 RandUint64();
141 void set_seed(uint64 seed) { seed_ = seed; }
143 private:
144 uint64 seed_;
146 DISALLOW_COPY_AND_ASSIGN(SimpleRandom);
149 class MockFramerVisitor : public QuicFramerVisitorInterface {
150 public:
151 MockFramerVisitor();
152 virtual ~MockFramerVisitor();
154 MOCK_METHOD1(OnError, void(QuicFramer* framer));
155 // The constructor sets this up to return false by default.
156 MOCK_METHOD1(OnProtocolVersionMismatch, bool(QuicVersion version));
157 MOCK_METHOD0(OnPacket, void());
158 MOCK_METHOD1(OnPublicResetPacket, void(const QuicPublicResetPacket& header));
159 MOCK_METHOD1(OnVersionNegotiationPacket,
160 void(const QuicVersionNegotiationPacket& packet));
161 MOCK_METHOD0(OnRevivedPacket, void());
162 // The constructor sets this up to return true by default.
163 MOCK_METHOD1(OnUnauthenticatedHeader, bool(const QuicPacketHeader& header));
164 // The constructor sets this up to return true by default.
165 MOCK_METHOD1(OnUnauthenticatedPublicHeader, bool(
166 const QuicPacketPublicHeader& header));
167 MOCK_METHOD1(OnDecryptedPacket, void(EncryptionLevel level));
168 MOCK_METHOD1(OnPacketHeader, bool(const QuicPacketHeader& header));
169 MOCK_METHOD1(OnFecProtectedPayload, void(base::StringPiece payload));
170 MOCK_METHOD1(OnStreamFrame, bool(const QuicStreamFrame& frame));
171 MOCK_METHOD1(OnAckFrame, bool(const QuicAckFrame& frame));
172 MOCK_METHOD1(OnCongestionFeedbackFrame,
173 bool(const QuicCongestionFeedbackFrame& frame));
174 MOCK_METHOD1(OnStopWaitingFrame, bool(const QuicStopWaitingFrame& frame));
175 MOCK_METHOD1(OnPingFrame, bool(const QuicPingFrame& frame));
176 MOCK_METHOD1(OnFecData, void(const QuicFecData& fec));
177 MOCK_METHOD1(OnRstStreamFrame, bool(const QuicRstStreamFrame& frame));
178 MOCK_METHOD1(OnConnectionCloseFrame,
179 bool(const QuicConnectionCloseFrame& frame));
180 MOCK_METHOD1(OnGoAwayFrame, bool(const QuicGoAwayFrame& frame));
181 MOCK_METHOD1(OnWindowUpdateFrame, bool(const QuicWindowUpdateFrame& frame));
182 MOCK_METHOD1(OnBlockedFrame, bool(const QuicBlockedFrame& frame));
183 MOCK_METHOD0(OnPacketComplete, void());
185 private:
186 DISALLOW_COPY_AND_ASSIGN(MockFramerVisitor);
189 class NoOpFramerVisitor : public QuicFramerVisitorInterface {
190 public:
191 NoOpFramerVisitor() {}
193 void OnError(QuicFramer* framer) override {}
194 void OnPacket() override {}
195 void OnPublicResetPacket(const QuicPublicResetPacket& packet) override {}
196 void OnVersionNegotiationPacket(
197 const QuicVersionNegotiationPacket& packet) override {}
198 void OnRevivedPacket() override {}
199 bool OnProtocolVersionMismatch(QuicVersion version) override;
200 bool OnUnauthenticatedHeader(const QuicPacketHeader& header) override;
201 bool OnUnauthenticatedPublicHeader(
202 const QuicPacketPublicHeader& header) override;
203 void OnDecryptedPacket(EncryptionLevel level) override {}
204 bool OnPacketHeader(const QuicPacketHeader& header) override;
205 void OnFecProtectedPayload(base::StringPiece payload) override {}
206 bool OnStreamFrame(const QuicStreamFrame& frame) override;
207 bool OnAckFrame(const QuicAckFrame& frame) override;
208 bool OnCongestionFeedbackFrame(
209 const QuicCongestionFeedbackFrame& frame) override;
210 bool OnStopWaitingFrame(const QuicStopWaitingFrame& frame) override;
211 bool OnPingFrame(const QuicPingFrame& frame) override;
212 void OnFecData(const QuicFecData& fec) override {}
213 bool OnRstStreamFrame(const QuicRstStreamFrame& frame) override;
214 bool OnConnectionCloseFrame(const QuicConnectionCloseFrame& frame) override;
215 bool OnGoAwayFrame(const QuicGoAwayFrame& frame) override;
216 bool OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) override;
217 bool OnBlockedFrame(const QuicBlockedFrame& frame) override;
218 void OnPacketComplete() override {}
220 private:
221 DISALLOW_COPY_AND_ASSIGN(NoOpFramerVisitor);
224 class MockConnectionVisitor : public QuicConnectionVisitorInterface {
225 public:
226 MockConnectionVisitor();
227 virtual ~MockConnectionVisitor();
229 MOCK_METHOD1(OnStreamFrames, void(const std::vector<QuicStreamFrame>& frame));
230 MOCK_METHOD1(OnWindowUpdateFrames,
231 void(const std::vector<QuicWindowUpdateFrame>& frame));
232 MOCK_METHOD1(OnBlockedFrames,
233 void(const std::vector<QuicBlockedFrame>& frame));
234 MOCK_METHOD1(OnRstStream, void(const QuicRstStreamFrame& frame));
235 MOCK_METHOD1(OnGoAway, void(const QuicGoAwayFrame& frame));
236 MOCK_METHOD2(OnConnectionClosed, void(QuicErrorCode error, bool from_peer));
237 MOCK_METHOD0(OnWriteBlocked, void());
238 MOCK_METHOD0(OnCanWrite, void());
239 MOCK_METHOD1(OnCongestionWindowChange, void(QuicTime now));
240 MOCK_CONST_METHOD0(WillingAndAbleToWrite, bool());
241 MOCK_CONST_METHOD0(HasPendingHandshake, bool());
242 MOCK_CONST_METHOD0(HasOpenDataStreams, bool());
243 MOCK_METHOD1(OnSuccessfulVersionNegotiation,
244 void(const QuicVersion& version));
245 MOCK_METHOD0(OnConfigNegotiated, void());
247 private:
248 DISALLOW_COPY_AND_ASSIGN(MockConnectionVisitor);
251 class MockHelper : public QuicConnectionHelperInterface {
252 public:
253 MockHelper();
254 ~MockHelper() override;
255 const QuicClock* GetClock() const override;
256 QuicRandom* GetRandomGenerator() override;
257 QuicAlarm* CreateAlarm(QuicAlarm::Delegate* delegate) override;
258 void AdvanceTime(QuicTime::Delta delta);
260 private:
261 MockClock clock_;
262 MockRandom random_generator_;
264 DISALLOW_COPY_AND_ASSIGN(MockHelper);
267 class MockConnection : public QuicConnection {
268 public:
269 // Uses a MockHelper, ConnectionId of 42, and 127.0.0.1:123.
270 explicit MockConnection(bool is_server);
272 // Uses a MockHelper, ConnectionId of 42.
273 MockConnection(IPEndPoint address, bool is_server);
275 // Uses a MockHelper, and 127.0.0.1:123
276 MockConnection(QuicConnectionId connection_id, bool is_server);
278 // Uses a Mock helper, ConnectionId of 42, and 127.0.0.1:123.
279 MockConnection(bool is_server, const QuicVersionVector& supported_versions);
281 virtual ~MockConnection();
283 // If the constructor that uses a MockHelper has been used then this method
284 // will advance the time of the MockClock.
285 void AdvanceTime(QuicTime::Delta delta);
287 MOCK_METHOD3(ProcessUdpPacket, void(const IPEndPoint& self_address,
288 const IPEndPoint& peer_address,
289 const QuicEncryptedPacket& packet));
290 MOCK_METHOD1(SendConnectionClose, void(QuicErrorCode error));
291 MOCK_METHOD2(SendConnectionCloseWithDetails, void(QuicErrorCode error,
292 const string& details));
293 MOCK_METHOD2(SendConnectionClosePacket, void(QuicErrorCode error,
294 const string& details));
295 MOCK_METHOD3(SendRstStream, void(QuicStreamId id,
296 QuicRstStreamErrorCode error,
297 QuicStreamOffset bytes_written));
298 MOCK_METHOD3(SendGoAway, void(QuicErrorCode error,
299 QuicStreamId last_good_stream_id,
300 const string& reason));
301 MOCK_METHOD1(SendBlocked, void(QuicStreamId id));
302 MOCK_METHOD2(SendWindowUpdate, void(QuicStreamId id,
303 QuicStreamOffset byte_offset));
304 MOCK_METHOD0(OnCanWrite, void());
306 void ProcessUdpPacketInternal(const IPEndPoint& self_address,
307 const IPEndPoint& peer_address,
308 const QuicEncryptedPacket& packet) {
309 QuicConnection::ProcessUdpPacket(self_address, peer_address, packet);
312 virtual bool OnProtocolVersionMismatch(QuicVersion version) override {
313 return false;
316 private:
317 scoped_ptr<QuicConnectionHelperInterface> helper_;
319 DISALLOW_COPY_AND_ASSIGN(MockConnection);
322 class PacketSavingConnection : public MockConnection {
323 public:
324 explicit PacketSavingConnection(bool is_server);
326 PacketSavingConnection(bool is_server,
327 const QuicVersionVector& supported_versions);
329 ~PacketSavingConnection() override;
331 void SendOrQueuePacket(QueuedPacket packet) override;
333 std::vector<QuicPacket*> packets_;
334 std::vector<QuicEncryptedPacket*> encrypted_packets_;
336 private:
337 DISALLOW_COPY_AND_ASSIGN(PacketSavingConnection);
340 class MockSession : public QuicSession {
341 public:
342 explicit MockSession(QuicConnection* connection);
343 virtual ~MockSession();
344 MOCK_METHOD2(OnConnectionClosed, void(QuicErrorCode error, bool from_peer));
345 MOCK_METHOD1(CreateIncomingDataStream, QuicDataStream*(QuicStreamId id));
346 MOCK_METHOD0(GetCryptoStream, QuicCryptoStream*());
347 MOCK_METHOD0(CreateOutgoingDataStream, QuicDataStream*());
348 MOCK_METHOD6(WritevData,
349 QuicConsumedData(QuicStreamId id,
350 const IOVector& data,
351 QuicStreamOffset offset,
352 bool fin,
353 FecProtection fec_protection,
354 QuicAckNotifier::DelegateInterface*));
355 MOCK_METHOD2(OnStreamHeaders, void(QuicStreamId stream_id,
356 base::StringPiece headers_data));
357 MOCK_METHOD2(OnStreamHeadersPriority, void(QuicStreamId stream_id,
358 QuicPriority priority));
359 MOCK_METHOD3(OnStreamHeadersComplete, void(QuicStreamId stream_id,
360 bool fin,
361 size_t frame_len));
362 MOCK_METHOD3(SendRstStream, void(QuicStreamId stream_id,
363 QuicRstStreamErrorCode error,
364 QuicStreamOffset bytes_written));
365 MOCK_METHOD0(IsCryptoHandshakeConfirmed, bool());
367 using QuicSession::ActivateStream;
369 private:
370 DISALLOW_COPY_AND_ASSIGN(MockSession);
373 class TestSession : public QuicSession {
374 public:
375 TestSession(QuicConnection* connection, const QuicConfig& config);
376 virtual ~TestSession();
378 MOCK_METHOD1(CreateIncomingDataStream, QuicDataStream*(QuicStreamId id));
379 MOCK_METHOD0(CreateOutgoingDataStream, QuicDataStream*());
381 void SetCryptoStream(QuicCryptoStream* stream);
383 virtual QuicCryptoStream* GetCryptoStream() override;
385 private:
386 QuicCryptoStream* crypto_stream_;
388 DISALLOW_COPY_AND_ASSIGN(TestSession);
391 class TestClientSession : public QuicClientSessionBase {
392 public:
393 TestClientSession(QuicConnection* connection, const QuicConfig& config);
394 virtual ~TestClientSession();
396 // QuicClientSessionBase
397 MOCK_METHOD1(OnProofValid,
398 void(const QuicCryptoClientConfig::CachedState& cached));
399 MOCK_METHOD1(OnProofVerifyDetailsAvailable,
400 void(const ProofVerifyDetails& verify_details));
402 // TestClientSession
403 MOCK_METHOD1(CreateIncomingDataStream, QuicDataStream*(QuicStreamId id));
404 MOCK_METHOD0(CreateOutgoingDataStream, QuicDataStream*());
406 void SetCryptoStream(QuicCryptoStream* stream);
408 virtual QuicCryptoStream* GetCryptoStream() override;
410 private:
411 QuicCryptoStream* crypto_stream_;
413 DISALLOW_COPY_AND_ASSIGN(TestClientSession);
416 class MockPacketWriter : public QuicPacketWriter {
417 public:
418 MockPacketWriter();
419 virtual ~MockPacketWriter();
421 MOCK_METHOD4(WritePacket,
422 WriteResult(const char* buffer,
423 size_t buf_len,
424 const IPAddressNumber& self_address,
425 const IPEndPoint& peer_address));
426 MOCK_CONST_METHOD0(IsWriteBlockedDataBuffered, bool());
427 MOCK_CONST_METHOD0(IsWriteBlocked, bool());
428 MOCK_METHOD0(SetWritable, void());
430 private:
431 DISALLOW_COPY_AND_ASSIGN(MockPacketWriter);
434 class MockSendAlgorithm : public SendAlgorithmInterface {
435 public:
436 MockSendAlgorithm();
437 virtual ~MockSendAlgorithm();
439 MOCK_METHOD2(SetFromConfig, void(const QuicConfig& config, bool is_server));
440 MOCK_METHOD1(SetNumEmulatedConnections, void(int num_connections));
441 MOCK_METHOD1(SetMaxPacketSize, void(QuicByteCount max_packet_size));
442 MOCK_METHOD2(OnIncomingQuicCongestionFeedbackFrame,
443 void(const QuicCongestionFeedbackFrame&,
444 QuicTime feedback_receive_time));
445 MOCK_METHOD4(OnCongestionEvent, void(bool rtt_updated,
446 QuicByteCount bytes_in_flight,
447 const CongestionVector& acked_packets,
448 const CongestionVector& lost_packets));
449 MOCK_METHOD5(OnPacketSent,
450 bool(QuicTime, QuicByteCount, QuicPacketSequenceNumber,
451 QuicByteCount, HasRetransmittableData));
452 MOCK_METHOD1(OnRetransmissionTimeout, void(bool));
453 MOCK_METHOD0(RevertRetransmissionTimeout, void());
454 MOCK_CONST_METHOD3(TimeUntilSend,
455 QuicTime::Delta(QuicTime now,
456 QuicByteCount bytes_in_flight,
457 HasRetransmittableData));
458 MOCK_CONST_METHOD0(PacingRate, QuicBandwidth(void));
459 MOCK_CONST_METHOD0(BandwidthEstimate, QuicBandwidth(void));
460 MOCK_CONST_METHOD0(HasReliableBandwidthEstimate, bool());
461 MOCK_METHOD1(OnRttUpdated, void(QuicPacketSequenceNumber));
462 MOCK_CONST_METHOD0(RetransmissionDelay, QuicTime::Delta(void));
463 MOCK_CONST_METHOD0(GetCongestionWindow, QuicByteCount());
464 MOCK_CONST_METHOD0(InSlowStart, bool());
465 MOCK_CONST_METHOD0(InRecovery, bool());
466 MOCK_CONST_METHOD0(GetSlowStartThreshold, QuicByteCount());
467 MOCK_CONST_METHOD0(GetCongestionControlType, CongestionControlType());
469 private:
470 DISALLOW_COPY_AND_ASSIGN(MockSendAlgorithm);
473 class MockLossAlgorithm : public LossDetectionInterface {
474 public:
475 MockLossAlgorithm();
476 virtual ~MockLossAlgorithm();
478 MOCK_CONST_METHOD0(GetLossDetectionType, LossDetectionType());
479 MOCK_METHOD4(DetectLostPackets,
480 SequenceNumberSet(const QuicUnackedPacketMap& unacked_packets,
481 const QuicTime& time,
482 QuicPacketSequenceNumber largest_observed,
483 const RttStats& rtt_stats));
484 MOCK_CONST_METHOD0(GetLossTimeout, QuicTime());
486 private:
487 DISALLOW_COPY_AND_ASSIGN(MockLossAlgorithm);
490 class TestEntropyCalculator :
491 public QuicReceivedEntropyHashCalculatorInterface {
492 public:
493 TestEntropyCalculator();
494 ~TestEntropyCalculator() override;
496 QuicPacketEntropyHash EntropyHash(
497 QuicPacketSequenceNumber sequence_number) const override;
499 private:
500 DISALLOW_COPY_AND_ASSIGN(TestEntropyCalculator);
503 class MockEntropyCalculator : public TestEntropyCalculator {
504 public:
505 MockEntropyCalculator();
506 virtual ~MockEntropyCalculator();
508 MOCK_CONST_METHOD1(
509 EntropyHash,
510 QuicPacketEntropyHash(QuicPacketSequenceNumber sequence_number));
512 private:
513 DISALLOW_COPY_AND_ASSIGN(MockEntropyCalculator);
516 class MockAckNotifierDelegate : public QuicAckNotifier::DelegateInterface {
517 public:
518 MockAckNotifierDelegate();
520 MOCK_METHOD5(OnAckNotification, void(int num_original_packets,
521 int num_original_bytes,
522 int num_retransmitted_packets,
523 int num_retransmitted_bytes,
524 QuicTime::Delta delta_largest_observed));
526 protected:
527 // Object is ref counted.
528 virtual ~MockAckNotifierDelegate();
530 private:
531 DISALLOW_COPY_AND_ASSIGN(MockAckNotifierDelegate);
534 class MockNetworkChangeVisitor :
535 public QuicSentPacketManager::NetworkChangeVisitor {
536 public:
537 MockNetworkChangeVisitor();
538 virtual ~MockNetworkChangeVisitor();
540 MOCK_METHOD1(OnCongestionWindowChange, void(QuicByteCount));
542 private:
543 DISALLOW_COPY_AND_ASSIGN(MockNetworkChangeVisitor);
546 // Creates per-connection packet writers that register themselves with the
547 // TestWriterFactory on each write so that TestWriterFactory::OnPacketSent can
548 // be routed to the appropriate QuicConnection.
549 class TestWriterFactory : public QuicDispatcher::PacketWriterFactory {
550 public:
551 TestWriterFactory();
552 ~TestWriterFactory() override;
554 QuicPacketWriter* Create(QuicServerPacketWriter* writer,
555 QuicConnection* connection) override;
557 // Calls OnPacketSent on the last QuicConnection to write through one of the
558 // packet writers created by this factory.
559 void OnPacketSent(WriteResult result);
561 private:
562 class PerConnectionPacketWriter : public QuicPerConnectionPacketWriter {
563 public:
564 PerConnectionPacketWriter(TestWriterFactory* factory,
565 QuicServerPacketWriter* writer,
566 QuicConnection* connection);
567 ~PerConnectionPacketWriter() override;
569 WriteResult WritePacket(const char* buffer,
570 size_t buf_len,
571 const IPAddressNumber& self_address,
572 const IPEndPoint& peer_address) override;
574 private:
575 TestWriterFactory* factory_;
578 // If an asynchronous write is happening and |writer| gets deleted, this
579 // clears the pointer to it to prevent use-after-free.
580 void Unregister(PerConnectionPacketWriter* writer);
582 PerConnectionPacketWriter* current_writer_;
585 } // namespace test
586 } // namespace net
588 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_