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

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

Issue 1421853006: Landing Recent QUIC changes until: Fri Oct 30 22:23:58 2015 +0000 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comments Created 5 years, 1 month 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/quic_session_peer.cc ('k') | net/quic/test_tools/quic_test_utils.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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_test_packet_maker.h" 5 #include "net/quic/test_tools/quic_test_packet_maker.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "net/quic/quic_framer.h" 9 #include "net/quic/quic_framer.h"
10 #include "net/quic/quic_http_utils.h" 10 #include "net/quic/quic_http_utils.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 frames.push_back(QuicFrame(&stop_waiting)); 85 frames.push_back(QuicFrame(&stop_waiting));
86 86
87 QuicRstStreamFrame rst(stream_id, error_code, 0); 87 QuicRstStreamFrame rst(stream_id, error_code, 0);
88 frames.push_back(QuicFrame(&rst)); 88 frames.push_back(QuicFrame(&rst));
89 89
90 QuicFramer framer(SupportedVersions(version_), clock_->Now(), 90 QuicFramer framer(SupportedVersions(version_), clock_->Now(),
91 Perspective::IS_CLIENT); 91 Perspective::IS_CLIENT);
92 scoped_ptr<QuicPacket> packet( 92 scoped_ptr<QuicPacket> packet(
93 BuildUnsizedDataPacket(&framer, header, frames)); 93 BuildUnsizedDataPacket(&framer, header, frames));
94 char buffer[kMaxPacketSize]; 94 char buffer[kMaxPacketSize];
95 scoped_ptr<QuicEncryptedPacket> encrypted(framer.EncryptPayload( 95 size_t encrypted_size = framer.EncryptPayload(
96 ENCRYPTION_NONE, header.packet_number, *packet, buffer, kMaxPacketSize)); 96 ENCRYPTION_NONE, header.packet_number, *packet, buffer, kMaxPacketSize);
97 EXPECT_TRUE(encrypted != nullptr); 97 EXPECT_NE(0u, encrypted_size);
98 return scoped_ptr<QuicEncryptedPacket>(encrypted->Clone()); 98 QuicEncryptedPacket encrypted(buffer, encrypted_size, false);
99 return scoped_ptr<QuicEncryptedPacket>(encrypted.Clone());
99 } 100 }
100 101
101 scoped_ptr<QuicEncryptedPacket> QuicTestPacketMaker::MakeConnectionClosePacket( 102 scoped_ptr<QuicEncryptedPacket> QuicTestPacketMaker::MakeConnectionClosePacket(
102 QuicPacketNumber num) { 103 QuicPacketNumber num) {
103 QuicPacketHeader header; 104 QuicPacketHeader header;
104 header.public_header.connection_id = connection_id_; 105 header.public_header.connection_id = connection_id_;
105 header.public_header.reset_flag = false; 106 header.public_header.reset_flag = false;
106 header.public_header.version_flag = false; 107 header.public_header.version_flag = false;
107 header.public_header.packet_number_length = PACKET_1BYTE_PACKET_NUMBER; 108 header.public_header.packet_number_length = PACKET_1BYTE_PACKET_NUMBER;
108 header.packet_number = num; 109 header.packet_number = num;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 QuicFrames frames; 143 QuicFrames frames;
143 frames.push_back(QuicFrame(&ack)); 144 frames.push_back(QuicFrame(&ack));
144 145
145 QuicStopWaitingFrame stop_waiting; 146 QuicStopWaitingFrame stop_waiting;
146 stop_waiting.least_unacked = least_unacked; 147 stop_waiting.least_unacked = least_unacked;
147 frames.push_back(QuicFrame(&stop_waiting)); 148 frames.push_back(QuicFrame(&stop_waiting));
148 149
149 scoped_ptr<QuicPacket> packet( 150 scoped_ptr<QuicPacket> packet(
150 BuildUnsizedDataPacket(&framer, header, frames)); 151 BuildUnsizedDataPacket(&framer, header, frames));
151 char buffer[kMaxPacketSize]; 152 char buffer[kMaxPacketSize];
152 scoped_ptr<QuicEncryptedPacket> encrypted(framer.EncryptPayload( 153 size_t encrypted_size = framer.EncryptPayload(
153 ENCRYPTION_NONE, header.packet_number, *packet, buffer, kMaxPacketSize)); 154 ENCRYPTION_NONE, header.packet_number, *packet, buffer, kMaxPacketSize);
154 EXPECT_TRUE(encrypted != nullptr); 155 EXPECT_NE(0u, encrypted_size);
155 return scoped_ptr<QuicEncryptedPacket>(encrypted->Clone()); 156 QuicEncryptedPacket encrypted(buffer, encrypted_size, false);
157 return scoped_ptr<QuicEncryptedPacket>(encrypted.Clone());
156 } 158 }
157 159
158 // Returns a newly created packet to send kData on stream 1. 160 // Returns a newly created packet to send kData on stream 1.
159 scoped_ptr<QuicEncryptedPacket> QuicTestPacketMaker::MakeDataPacket( 161 scoped_ptr<QuicEncryptedPacket> QuicTestPacketMaker::MakeDataPacket(
160 QuicPacketNumber packet_number, 162 QuicPacketNumber packet_number,
161 QuicStreamId stream_id, 163 QuicStreamId stream_id,
162 bool should_include_version, 164 bool should_include_version,
163 bool fin, 165 bool fin,
164 QuicStreamOffset offset, 166 QuicStreamOffset offset,
165 base::StringPiece data) { 167 base::StringPiece data) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 scoped_ptr<QuicEncryptedPacket> QuicTestPacketMaker::MakePacket( 277 scoped_ptr<QuicEncryptedPacket> QuicTestPacketMaker::MakePacket(
276 const QuicPacketHeader& header, 278 const QuicPacketHeader& header,
277 const QuicFrame& frame) { 279 const QuicFrame& frame) {
278 QuicFramer framer(SupportedVersions(version_), QuicTime::Zero(), 280 QuicFramer framer(SupportedVersions(version_), QuicTime::Zero(),
279 Perspective::IS_CLIENT); 281 Perspective::IS_CLIENT);
280 QuicFrames frames; 282 QuicFrames frames;
281 frames.push_back(frame); 283 frames.push_back(frame);
282 scoped_ptr<QuicPacket> packet( 284 scoped_ptr<QuicPacket> packet(
283 BuildUnsizedDataPacket(&framer, header, frames)); 285 BuildUnsizedDataPacket(&framer, header, frames));
284 char buffer[kMaxPacketSize]; 286 char buffer[kMaxPacketSize];
285 scoped_ptr<QuicEncryptedPacket> encrypted(framer.EncryptPayload( 287 size_t encrypted_size = framer.EncryptPayload(
286 ENCRYPTION_NONE, header.packet_number, *packet, buffer, kMaxPacketSize)); 288 ENCRYPTION_NONE, header.packet_number, *packet, buffer, kMaxPacketSize);
287 EXPECT_TRUE(encrypted != nullptr); 289 EXPECT_NE(0u, encrypted_size);
288 return scoped_ptr<QuicEncryptedPacket>(encrypted->Clone()); 290 QuicEncryptedPacket encrypted(buffer, encrypted_size, false);
291 return scoped_ptr<QuicEncryptedPacket>(encrypted.Clone());
289 } 292 }
290 293
291 void QuicTestPacketMaker::InitializeHeader(QuicPacketNumber packet_number, 294 void QuicTestPacketMaker::InitializeHeader(QuicPacketNumber packet_number,
292 bool should_include_version) { 295 bool should_include_version) {
293 header_.public_header.connection_id = connection_id_; 296 header_.public_header.connection_id = connection_id_;
294 header_.public_header.reset_flag = false; 297 header_.public_header.reset_flag = false;
295 header_.public_header.version_flag = should_include_version; 298 header_.public_header.version_flag = should_include_version;
296 header_.public_header.packet_number_length = PACKET_1BYTE_PACKET_NUMBER; 299 header_.public_header.packet_number_length = PACKET_1BYTE_PACKET_NUMBER;
297 header_.packet_number = packet_number; 300 header_.packet_number = packet_number;
298 header_.fec_group = 0; 301 header_.fec_group = 0;
299 header_.entropy_flag = false; 302 header_.entropy_flag = false;
300 header_.fec_flag = false; 303 header_.fec_flag = false;
301 } 304 }
302 305
303 } // namespace test 306 } // namespace test
304 } // namespace net 307 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_session_peer.cc ('k') | net/quic/test_tools/quic_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698