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

Side by Side Diff: net/tools/quic/quic_dispatcher_test.cc

Issue 1716453002: relnote: Make QUIC version negotiation stateless. The QUIC dispatcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « net/tools/quic/quic_dispatcher.cc ('k') | net/tools/quic/quic_time_wait_list_manager.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 (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 #include "net/tools/quic/quic_dispatcher.h" 5 #include "net/tools/quic/quic_dispatcher.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 188
189 void ProcessPacket(IPEndPoint client_address, 189 void ProcessPacket(IPEndPoint client_address,
190 QuicConnectionId connection_id, 190 QuicConnectionId connection_id,
191 bool has_version_flag, 191 bool has_version_flag,
192 bool has_multipath_flag, 192 bool has_multipath_flag,
193 const string& data, 193 const string& data,
194 QuicConnectionIdLength connection_id_length, 194 QuicConnectionIdLength connection_id_length,
195 QuicPacketNumberLength packet_number_length, 195 QuicPacketNumberLength packet_number_length,
196 QuicPathId path_id, 196 QuicPathId path_id,
197 QuicPacketNumber packet_number) { 197 QuicPacketNumber packet_number) {
198 ProcessPacket(client_address, connection_id, has_version_flag,
199 QuicSupportedVersions().front(), data, connection_id_length,
200 packet_number_length, packet_number);
201 }
202
203 void ProcessPacket(IPEndPoint client_address,
204 QuicConnectionId connection_id,
205 bool has_version_flag,
206 QuicVersion version,
207 const string& data,
208 QuicConnectionIdLength connection_id_length,
209 QuicPacketNumberLength packet_number_length,
210 QuicPacketNumber packet_number) {
211 QuicVersionVector versions(SupportedVersions(version));
198 scoped_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket( 212 scoped_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket(
199 connection_id, has_version_flag, has_multipath_flag, false, path_id, 213 connection_id, has_version_flag, false, false, 0, packet_number, data,
200 packet_number, data, connection_id_length, packet_number_length)); 214 connection_id_length, packet_number_length, &versions));
215
201 data_ = string(packet->data(), packet->length()); 216 data_ = string(packet->data(), packet->length());
202 dispatcher_.ProcessPacket(server_address_, client_address, *packet); 217 dispatcher_.ProcessPacket(server_address_, client_address, *packet);
203 } 218 }
204 219
205 void ValidatePacket(const QuicEncryptedPacket& packet) { 220 void ValidatePacket(const QuicEncryptedPacket& packet) {
206 EXPECT_EQ(data_.length(), packet.AsStringPiece().length()); 221 EXPECT_EQ(data_.length(), packet.AsStringPiece().length());
207 EXPECT_EQ(data_, packet.AsStringPiece()); 222 EXPECT_EQ(data_, packet.AsStringPiece());
208 } 223 }
209 224
210 void CreateTimeWaitListManager() { 225 void CreateTimeWaitListManager() {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 ProcessPacket(client_address, 2, true, false, "bar"); 262 ProcessPacket(client_address, 2, true, false, "bar");
248 263
249 EXPECT_CALL(*reinterpret_cast<MockConnection*>(session1_->connection()), 264 EXPECT_CALL(*reinterpret_cast<MockConnection*>(session1_->connection()),
250 ProcessUdpPacket(_, _, _)) 265 ProcessUdpPacket(_, _, _))
251 .Times(1) 266 .Times(1)
252 .WillOnce(testing::WithArgs<2>( 267 .WillOnce(testing::WithArgs<2>(
253 Invoke(this, &QuicDispatcherTest::ValidatePacket))); 268 Invoke(this, &QuicDispatcherTest::ValidatePacket)));
254 ProcessPacket(client_address, 1, false, false, "eep"); 269 ProcessPacket(client_address, 1, false, false, "eep");
255 } 270 }
256 271
272 TEST_F(QuicDispatcherTest, StatelessVersionNegotiation) {
273 ValueRestore<bool> old_flag(&FLAGS_quic_stateless_version_negotiation, true);
274 IPEndPoint client_address(net::test::Loopback4(), 1);
275 server_address_ = IPEndPoint(net::test::Any4(), 5);
276
277 EXPECT_CALL(dispatcher_, CreateQuicSession(1, client_address)).Times(0);
278 QuicVersion version = static_cast<QuicVersion>(QuicVersionMin() - 1);
279 ProcessPacket(client_address, 1, true, version, "foo",
280 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER, 1);
281 }
282
283 TEST_F(QuicDispatcherTest, StatefulVersionNegotiation) {
284 ValueRestore<bool> old_flag(&FLAGS_quic_stateless_version_negotiation, false);
285 IPEndPoint client_address(net::test::Loopback4(), 1);
286 server_address_ = IPEndPoint(net::test::Any4(), 5);
287
288 EXPECT_CALL(dispatcher_, CreateQuicSession(1, client_address))
289 .WillOnce(testing::Return(CreateSession(&dispatcher_, config_, 1,
290 client_address, &mock_helper_,
291 &crypto_config_, &session1_)));
292 QuicVersion version = static_cast<QuicVersion>(QuicVersionMin() - 1);
293 ProcessPacket(client_address, 1, true, version, "foo",
294 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER, 1);
295 }
296
257 TEST_F(QuicDispatcherTest, Shutdown) { 297 TEST_F(QuicDispatcherTest, Shutdown) {
258 IPEndPoint client_address(net::test::Loopback4(), 1); 298 IPEndPoint client_address(net::test::Loopback4(), 1);
259 299
260 EXPECT_CALL(dispatcher_, CreateQuicSession(_, client_address)) 300 EXPECT_CALL(dispatcher_, CreateQuicSession(_, client_address))
261 .WillOnce(testing::Return(CreateSession(&dispatcher_, config_, 1, 301 .WillOnce(testing::Return(CreateSession(&dispatcher_, config_, 1,
262 client_address, &mock_helper_, 302 client_address, &mock_helper_,
263 &crypto_config_, &session1_))); 303 &crypto_config_, &session1_)));
264 304
265 ProcessPacket(client_address, 1, true, false, "foo"); 305 ProcessPacket(client_address, 1, true, false, "foo");
266 306
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 805
766 // And we'll resume where we left off when we get another call. 806 // And we'll resume where we left off when we get another call.
767 EXPECT_CALL(*connection2(), OnCanWrite()); 807 EXPECT_CALL(*connection2(), OnCanWrite());
768 dispatcher_.OnCanWrite(); 808 dispatcher_.OnCanWrite();
769 EXPECT_FALSE(dispatcher_.HasPendingWrites()); 809 EXPECT_FALSE(dispatcher_.HasPendingWrites());
770 } 810 }
771 811
772 } // namespace 812 } // namespace
773 } // namespace test 813 } // namespace test
774 } // namespace net 814 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_dispatcher.cc ('k') | net/tools/quic/quic_time_wait_list_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698