OLD | NEW |
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/tools/quic/quic_server_session.h" | 5 #include "net/tools/quic/quic_server_session.h" |
6 | 6 |
7 #include "net/quic/crypto/cached_network_parameters.h" | 7 #include "net/quic/crypto/cached_network_parameters.h" |
8 #include "net/quic/crypto/quic_crypto_server_config.h" | 8 #include "net/quic/crypto/quic_crypto_server_config.h" |
9 #include "net/quic/crypto/quic_random.h" | 9 #include "net/quic/crypto/quic_random.h" |
10 #include "net/quic/quic_connection.h" | 10 #include "net/quic/quic_connection.h" |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 expected_network_params.set_serving_region(serving_region); | 375 expected_network_params.set_serving_region(serving_region); |
376 | 376 |
377 EXPECT_CALL(*crypto_stream, | 377 EXPECT_CALL(*crypto_stream, |
378 SendServerConfigUpdate(EqualsProto(expected_network_params))) | 378 SendServerConfigUpdate(EqualsProto(expected_network_params))) |
379 .Times(1); | 379 .Times(1); |
380 EXPECT_CALL(*connection_, OnSendConnectionState(_)).Times(1); | 380 EXPECT_CALL(*connection_, OnSendConnectionState(_)).Times(1); |
381 session_->OnCongestionWindowChange(now); | 381 session_->OnCongestionWindowChange(now); |
382 } | 382 } |
383 | 383 |
384 TEST_P(QuicServerSessionTest, BandwidthResumptionExperiment) { | 384 TEST_P(QuicServerSessionTest, BandwidthResumptionExperiment) { |
385 ValueRestore<bool> old_flag( | |
386 &FLAGS_quic_enable_bandwidth_resumption_experiment, true); | |
387 | |
388 // Test that if a client provides a CachedNetworkParameters with the same | 385 // Test that if a client provides a CachedNetworkParameters with the same |
389 // serving region as the current server, that this data is passed down to the | 386 // serving region as the current server, that this data is passed down to the |
390 // send algorithm. | 387 // send algorithm. |
391 | 388 |
392 // Client has sent kBWRE connection option to trigger bandwidth resumption. | 389 // Client has sent kBWRE connection option to trigger bandwidth resumption. |
393 QuicTagVector copt; | 390 QuicTagVector copt; |
394 copt.push_back(kBWRE); | 391 copt.push_back(kBWRE); |
395 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt); | 392 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt); |
396 | 393 |
397 const string kTestServingRegion = "a serving region"; | 394 const string kTestServingRegion = "a serving region"; |
398 session_->set_serving_region(kTestServingRegion); | 395 session_->set_serving_region(kTestServingRegion); |
399 | 396 |
400 QuicCryptoServerStream* crypto_stream = | 397 QuicCryptoServerStream* crypto_stream = |
401 static_cast<QuicCryptoServerStream*>( | 398 static_cast<QuicCryptoServerStream*>( |
402 QuicSessionPeer::GetCryptoStream(session_.get())); | 399 QuicSessionPeer::GetCryptoStream(session_.get())); |
403 | 400 |
404 // No effect if no CachedNetworkParameters provided. | 401 // No effect if no CachedNetworkParameters provided. |
405 EXPECT_CALL(*connection_, ResumeConnectionState(_)).Times(0); | 402 EXPECT_CALL(*connection_, ResumeConnectionState(_, _)).Times(0); |
406 session_->OnConfigNegotiated(); | 403 session_->OnConfigNegotiated(); |
407 | 404 |
408 // No effect if CachedNetworkParameters provided, but different serving | 405 // No effect if CachedNetworkParameters provided, but different serving |
409 // regions. | 406 // regions. |
410 CachedNetworkParameters cached_network_params; | 407 CachedNetworkParameters cached_network_params; |
411 cached_network_params.set_bandwidth_estimate_bytes_per_second(1); | 408 cached_network_params.set_bandwidth_estimate_bytes_per_second(1); |
412 cached_network_params.set_serving_region("different serving region"); | 409 cached_network_params.set_serving_region("different serving region"); |
413 crypto_stream->set_previous_cached_network_params(cached_network_params); | 410 crypto_stream->set_previous_cached_network_params(cached_network_params); |
414 EXPECT_CALL(*connection_, ResumeConnectionState(_)).Times(0); | 411 EXPECT_CALL(*connection_, ResumeConnectionState(_, _)).Times(0); |
415 session_->OnConfigNegotiated(); | 412 session_->OnConfigNegotiated(); |
416 | 413 |
417 // Same serving region results in CachedNetworkParameters being stored. | 414 // Same serving region results in CachedNetworkParameters being stored. |
418 cached_network_params.set_serving_region(kTestServingRegion); | 415 cached_network_params.set_serving_region(kTestServingRegion); |
419 crypto_stream->set_previous_cached_network_params(cached_network_params); | 416 crypto_stream->set_previous_cached_network_params(cached_network_params); |
420 EXPECT_CALL(*connection_, ResumeConnectionState(_)).Times(1); | 417 EXPECT_CALL(*connection_, ResumeConnectionState(_, _)).Times(1); |
421 session_->OnConfigNegotiated(); | 418 session_->OnConfigNegotiated(); |
422 } | 419 } |
423 | 420 |
424 } // namespace | 421 } // namespace |
425 } // namespace test | 422 } // namespace test |
426 } // namespace tools | 423 } // namespace tools |
427 } // namespace net | 424 } // namespace net |
OLD | NEW |