OLD | NEW |
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/quic_packet_creator_peer.h" | 5 #include "net/quic/test_tools/quic_packet_creator_peer.h" |
6 | 6 |
7 #include "net/quic/quic_packet_creator.h" | 7 #include "net/quic/quic_packet_creator.h" |
8 | 8 |
9 namespace net { | 9 namespace net { |
10 namespace test { | 10 namespace test { |
(...skipping 18 matching lines...) Expand all Loading... |
29 // static | 29 // static |
30 void QuicPacketCreatorPeer::SetSendPathIdInPacket(QuicPacketCreator* creator, | 30 void QuicPacketCreatorPeer::SetSendPathIdInPacket(QuicPacketCreator* creator, |
31 bool send_path_id_in_packet) { | 31 bool send_path_id_in_packet) { |
32 creator->send_path_id_in_packet_ = send_path_id_in_packet; | 32 creator->send_path_id_in_packet_ = send_path_id_in_packet; |
33 } | 33 } |
34 | 34 |
35 // static | 35 // static |
36 void QuicPacketCreatorPeer::SetPacketNumberLength( | 36 void QuicPacketCreatorPeer::SetPacketNumberLength( |
37 QuicPacketCreator* creator, | 37 QuicPacketCreator* creator, |
38 QuicPacketNumberLength packet_number_length) { | 38 QuicPacketNumberLength packet_number_length) { |
39 creator->packet_number_length_ = packet_number_length; | 39 creator->packet_.packet_number_length = packet_number_length; |
40 } | 40 } |
41 | 41 |
42 // static | 42 // static |
43 void QuicPacketCreatorPeer::SetNextPacketNumberLength( | 43 void QuicPacketCreatorPeer::SetNextPacketNumberLength( |
44 QuicPacketCreator* creator, | 44 QuicPacketCreator* creator, |
45 QuicPacketNumberLength next_packet_number_length) { | 45 QuicPacketNumberLength next_packet_number_length) { |
46 creator->next_packet_number_length_ = next_packet_number_length; | 46 creator->next_packet_number_length_ = next_packet_number_length; |
47 } | 47 } |
48 | 48 |
49 // static | 49 // static |
50 QuicPacketNumberLength QuicPacketCreatorPeer::NextPacketNumberLength( | 50 QuicPacketNumberLength QuicPacketCreatorPeer::NextPacketNumberLength( |
51 QuicPacketCreator* creator) { | 51 QuicPacketCreator* creator) { |
52 return creator->next_packet_number_length_; | 52 return creator->next_packet_number_length_; |
53 } | 53 } |
54 | 54 |
55 // static | 55 // static |
56 QuicPacketNumberLength QuicPacketCreatorPeer::GetPacketNumberLength( | 56 QuicPacketNumberLength QuicPacketCreatorPeer::GetPacketNumberLength( |
57 QuicPacketCreator* creator) { | 57 QuicPacketCreator* creator) { |
58 return creator->packet_number_length_; | 58 return creator->packet_.packet_number_length; |
59 } | 59 } |
60 | 60 |
61 void QuicPacketCreatorPeer::SetPacketNumber(QuicPacketCreator* creator, | 61 void QuicPacketCreatorPeer::SetPacketNumber(QuicPacketCreator* creator, |
62 QuicPacketNumber s) { | 62 QuicPacketNumber s) { |
63 creator->packet_number_ = s; | 63 creator->packet_.packet_number = s; |
64 } | 64 } |
65 | 65 |
66 // static | 66 // static |
67 void QuicPacketCreatorPeer::FillPacketHeader(QuicPacketCreator* creator, | 67 void QuicPacketCreatorPeer::FillPacketHeader(QuicPacketCreator* creator, |
68 QuicFecGroupNumber fec_group, | 68 QuicFecGroupNumber fec_group, |
69 bool fec_flag, | 69 bool fec_flag, |
70 QuicPacketHeader* header) { | 70 QuicPacketHeader* header) { |
71 creator->FillPacketHeader(fec_group, fec_flag, header); | 71 creator->FillPacketHeader(fec_group, fec_flag, header); |
72 } | 72 } |
73 | 73 |
(...skipping 24 matching lines...) Expand all Loading... |
98 creator->StartFecProtectingPackets(); | 98 creator->StartFecProtectingPackets(); |
99 } | 99 } |
100 | 100 |
101 // static | 101 // static |
102 void QuicPacketCreatorPeer::StopFecProtectingPackets( | 102 void QuicPacketCreatorPeer::StopFecProtectingPackets( |
103 QuicPacketCreator* creator) { | 103 QuicPacketCreator* creator) { |
104 creator->StopFecProtectingPackets(); | 104 creator->StopFecProtectingPackets(); |
105 } | 105 } |
106 | 106 |
107 // static | 107 // static |
108 SerializedPacket QuicPacketCreatorPeer::SerializeFec(QuicPacketCreator* creator, | 108 void QuicPacketCreatorPeer::SerializeFec(QuicPacketCreator* creator, |
109 char* buffer, | 109 char* buffer, |
110 size_t buffer_len) { | 110 size_t buffer_len) { |
111 return creator->SerializeFec(buffer, buffer_len); | 111 creator->SerializeFec(buffer, buffer_len); |
112 } | 112 } |
113 | 113 |
114 // static | 114 // static |
115 SerializedPacket QuicPacketCreatorPeer::SerializeAllFrames( | 115 SerializedPacket QuicPacketCreatorPeer::SerializeAllFrames( |
116 QuicPacketCreator* creator, | 116 QuicPacketCreator* creator, |
117 const QuicFrames& frames, | 117 const QuicFrames& frames, |
118 char* buffer, | 118 char* buffer, |
119 size_t buffer_len) { | 119 size_t buffer_len) { |
120 DCHECK(creator->queued_frames_.empty()); | 120 DCHECK(creator->queued_frames_.empty()); |
121 DCHECK(!frames.empty()); | 121 DCHECK(!frames.empty()); |
122 for (const QuicFrame& frame : frames) { | 122 for (const QuicFrame& frame : frames) { |
123 bool success = creator->AddFrame(frame, false); | 123 bool success = creator->AddFrame(frame, false); |
124 DCHECK(success); | 124 DCHECK(success); |
125 } | 125 } |
126 SerializedPacket packet = creator->SerializePacket(buffer, buffer_len); | 126 creator->SerializePacket(buffer, buffer_len); |
| 127 SerializedPacket packet = creator->packet_; |
| 128 // The caller takes ownership of the QuicEncryptedPacket. |
| 129 creator->packet_.packet = nullptr; |
127 DCHECK(packet.retransmittable_frames == nullptr); | 130 DCHECK(packet.retransmittable_frames == nullptr); |
128 return packet; | 131 return packet; |
129 } | 132 } |
130 | 133 |
131 // static | 134 // static |
132 void QuicPacketCreatorPeer::ResetFecGroup(QuicPacketCreator* creator) { | 135 void QuicPacketCreatorPeer::ResetFecGroup(QuicPacketCreator* creator) { |
133 creator->ResetFecGroup(); | 136 creator->ResetFecGroup(); |
134 } | 137 } |
135 | 138 |
136 // static | 139 // static |
137 QuicTime::Delta QuicPacketCreatorPeer::GetFecTimeout( | 140 QuicTime::Delta QuicPacketCreatorPeer::GetFecTimeout( |
138 QuicPacketCreator* creator) { | 141 QuicPacketCreator* creator) { |
139 return creator->fec_timeout_; | 142 return creator->fec_timeout_; |
140 } | 143 } |
141 | 144 |
142 // static | 145 // static |
143 float QuicPacketCreatorPeer::GetRttMultiplierForFecTimeout( | 146 float QuicPacketCreatorPeer::GetRttMultiplierForFecTimeout( |
144 QuicPacketCreator* creator) { | 147 QuicPacketCreator* creator) { |
145 return creator->rtt_multiplier_for_fec_timeout_; | 148 return creator->rtt_multiplier_for_fec_timeout_; |
146 } | 149 } |
147 | 150 |
148 // static | 151 // static |
149 EncryptionLevel QuicPacketCreatorPeer::GetEncryptionLevel( | 152 EncryptionLevel QuicPacketCreatorPeer::GetEncryptionLevel( |
150 QuicPacketCreator* creator) { | 153 QuicPacketCreator* creator) { |
151 return creator->encryption_level_; | 154 return creator->packet_.encryption_level; |
152 } | 155 } |
153 | 156 |
154 // static | 157 // static |
155 QuicPathId QuicPacketCreatorPeer::GetCurrentPath(QuicPacketCreator* creator) { | 158 QuicPathId QuicPacketCreatorPeer::GetCurrentPath(QuicPacketCreator* creator) { |
156 return creator->current_path_; | 159 return creator->packet_.path_id; |
157 } | 160 } |
158 | 161 |
159 } // namespace test | 162 } // namespace test |
160 } // namespace net | 163 } // namespace net |
OLD | NEW |