OLD | NEW |
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 // Common utilities for Quic tests | 5 // Common utilities for Quic tests |
6 | 6 |
7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 // Testing convenience method to construct a QuicAckFrame with entropy_hash set | 97 // Testing convenience method to construct a QuicAckFrame with entropy_hash set |
98 // to 0 and largest_observed from peer set to |largest_observed|. | 98 // to 0 and largest_observed from peer set to |largest_observed|. |
99 QuicAckFrame MakeAckFrame(QuicPacketSequenceNumber largest_observed); | 99 QuicAckFrame MakeAckFrame(QuicPacketSequenceNumber largest_observed); |
100 | 100 |
101 // Testing convenience method to construct a QuicAckFrame with |num_nack_ranges| | 101 // Testing convenience method to construct a QuicAckFrame with |num_nack_ranges| |
102 // nack ranges of width 1 packet, starting from |least_unacked|. | 102 // nack ranges of width 1 packet, starting from |least_unacked|. |
103 QuicAckFrame MakeAckFrameWithNackRanges(size_t num_nack_ranges, | 103 QuicAckFrame MakeAckFrameWithNackRanges(size_t num_nack_ranges, |
104 QuicPacketSequenceNumber least_unacked); | 104 QuicPacketSequenceNumber least_unacked); |
105 | 105 |
106 // Returns a QuicPacket whose that is owned by the caller, and | 106 // Returns a QuicPacket that is owned by the caller, and |
107 // is populated with the fields in |header| and |frames|, or is nullptr if the | 107 // is populated with the fields in |header| and |frames|, or is nullptr if the |
108 // packet could not be created. | 108 // packet could not be created. |
109 QuicPacket* BuildUnsizedDataPacket(QuicFramer* framer, | 109 QuicPacket* BuildUnsizedDataPacket(QuicFramer* framer, |
110 const QuicPacketHeader& header, | 110 const QuicPacketHeader& header, |
111 const QuicFrames& frames); | 111 const QuicFrames& frames); |
| 112 // Returns a QuicPacket that is owned by the caller, and of size |packet_size|. |
| 113 QuicPacket* BuildUnsizedDataPacket(QuicFramer* framer, |
| 114 const QuicPacketHeader& header, |
| 115 const QuicFrames& frames, |
| 116 size_t packet_size); |
112 | 117 |
113 template<typename SaveType> | 118 template<typename SaveType> |
114 class ValueRestore { | 119 class ValueRestore { |
115 public: | 120 public: |
116 ValueRestore(SaveType* name, SaveType value) | 121 ValueRestore(SaveType* name, SaveType value) |
117 : name_(name), | 122 : name_(name), |
118 value_(*name) { | 123 value_(*name) { |
119 *name_ = value; | 124 *name_ = value; |
120 } | 125 } |
121 ~ValueRestore() { | 126 ~ValueRestore() { |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 // clears the pointer to it to prevent use-after-free. | 598 // clears the pointer to it to prevent use-after-free. |
594 void Unregister(PerConnectionPacketWriter* writer); | 599 void Unregister(PerConnectionPacketWriter* writer); |
595 | 600 |
596 PerConnectionPacketWriter* current_writer_; | 601 PerConnectionPacketWriter* current_writer_; |
597 }; | 602 }; |
598 | 603 |
599 } // namespace test | 604 } // namespace test |
600 } // namespace net | 605 } // namespace net |
601 | 606 |
602 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 607 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
OLD | NEW |