| 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/quic_crypto_server_config.h" | 7 #include "net/quic/crypto/quic_crypto_server_config.h" |
| 8 #include "net/quic/crypto/quic_random.h" | 8 #include "net/quic/crypto/quic_random.h" |
| 9 #include "net/quic/proto/cached_network_parameters.pb.h" | 9 #include "net/quic/proto/cached_network_parameters.pb.h" |
| 10 #include "net/quic/quic_connection.h" | 10 #include "net/quic/quic_connection.h" |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 | 448 |
| 449 // No effect if no CachedNetworkParameters provided. | 449 // No effect if no CachedNetworkParameters provided. |
| 450 EXPECT_CALL(*connection_, ResumeConnectionState(_, _)).Times(0); | 450 EXPECT_CALL(*connection_, ResumeConnectionState(_, _)).Times(0); |
| 451 session_->OnConfigNegotiated(); | 451 session_->OnConfigNegotiated(); |
| 452 | 452 |
| 453 // No effect if CachedNetworkParameters provided, but different serving | 453 // No effect if CachedNetworkParameters provided, but different serving |
| 454 // regions. | 454 // regions. |
| 455 CachedNetworkParameters cached_network_params; | 455 CachedNetworkParameters cached_network_params; |
| 456 cached_network_params.set_bandwidth_estimate_bytes_per_second(1); | 456 cached_network_params.set_bandwidth_estimate_bytes_per_second(1); |
| 457 cached_network_params.set_serving_region("different serving region"); | 457 cached_network_params.set_serving_region("different serving region"); |
| 458 crypto_stream->set_previous_cached_network_params(cached_network_params); | 458 crypto_stream->SetPreviousCachedNetworkParams(cached_network_params); |
| 459 EXPECT_CALL(*connection_, ResumeConnectionState(_, _)).Times(0); | 459 EXPECT_CALL(*connection_, ResumeConnectionState(_, _)).Times(0); |
| 460 session_->OnConfigNegotiated(); | 460 session_->OnConfigNegotiated(); |
| 461 | 461 |
| 462 // Same serving region, but timestamp is too old, should have no effect. | 462 // Same serving region, but timestamp is too old, should have no effect. |
| 463 cached_network_params.set_serving_region(kTestServingRegion); | 463 cached_network_params.set_serving_region(kTestServingRegion); |
| 464 cached_network_params.set_timestamp(0); | 464 cached_network_params.set_timestamp(0); |
| 465 crypto_stream->set_previous_cached_network_params(cached_network_params); | 465 crypto_stream->SetPreviousCachedNetworkParams(cached_network_params); |
| 466 EXPECT_CALL(*connection_, ResumeConnectionState(_, _)).Times(0); | 466 EXPECT_CALL(*connection_, ResumeConnectionState(_, _)).Times(0); |
| 467 session_->OnConfigNegotiated(); | 467 session_->OnConfigNegotiated(); |
| 468 | 468 |
| 469 // Same serving region, and timestamp is recent: estimate is stored. | 469 // Same serving region, and timestamp is recent: estimate is stored. |
| 470 cached_network_params.set_timestamp( | 470 cached_network_params.set_timestamp( |
| 471 connection_->clock()->WallNow().ToUNIXSeconds()); | 471 connection_->clock()->WallNow().ToUNIXSeconds()); |
| 472 crypto_stream->set_previous_cached_network_params(cached_network_params); | 472 crypto_stream->SetPreviousCachedNetworkParams(cached_network_params); |
| 473 EXPECT_CALL(*connection_, ResumeConnectionState(_, _)).Times(1); | 473 EXPECT_CALL(*connection_, ResumeConnectionState(_, _)).Times(1); |
| 474 session_->OnConfigNegotiated(); | 474 session_->OnConfigNegotiated(); |
| 475 } | 475 } |
| 476 | 476 |
| 477 TEST_P(QuicServerSessionTest, BandwidthMaxEnablesResumption) { | 477 TEST_P(QuicServerSessionTest, BandwidthMaxEnablesResumption) { |
| 478 EXPECT_FALSE( | 478 EXPECT_FALSE( |
| 479 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get())); | 479 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get())); |
| 480 | 480 |
| 481 // Client has sent kBWMX connection option to trigger bandwidth resumption. | 481 // Client has sent kBWMX connection option to trigger bandwidth resumption. |
| 482 QuicTagVector copt; | 482 QuicTagVector copt; |
| 483 copt.push_back(kBWMX); | 483 copt.push_back(kBWMX); |
| 484 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt); | 484 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt); |
| 485 session_->OnConfigNegotiated(); | 485 session_->OnConfigNegotiated(); |
| 486 EXPECT_TRUE( | 486 EXPECT_TRUE( |
| 487 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get())); | 487 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get())); |
| 488 } | 488 } |
| 489 | 489 |
| 490 TEST_P(QuicServerSessionTest, NoBandwidthResumptionByDefault) { | 490 TEST_P(QuicServerSessionTest, NoBandwidthResumptionByDefault) { |
| 491 EXPECT_FALSE( | 491 EXPECT_FALSE( |
| 492 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get())); | 492 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get())); |
| 493 session_->OnConfigNegotiated(); | 493 session_->OnConfigNegotiated(); |
| 494 EXPECT_FALSE( | 494 EXPECT_FALSE( |
| 495 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get())); | 495 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get())); |
| 496 } | 496 } |
| 497 | 497 |
| 498 } // namespace | 498 } // namespace |
| 499 } // namespace test | 499 } // namespace test |
| 500 } // namespace tools | 500 } // namespace tools |
| 501 } // namespace net | 501 } // namespace net |
| OLD | NEW |