| 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_base.h" | 5 #include "net/tools/quic/quic_server_session_base.h" |
| 6 | 6 |
| 7 #include <cstdint> | 7 #include <cstdint> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 DISALLOW_COPY_AND_ASSIGN(MockQuicCryptoServerStream); | 386 DISALLOW_COPY_AND_ASSIGN(MockQuicCryptoServerStream); |
| 387 }; | 387 }; |
| 388 | 388 |
| 389 TEST_P(QuicServerSessionBaseTest, BandwidthEstimates) { | 389 TEST_P(QuicServerSessionBaseTest, BandwidthEstimates) { |
| 390 // Test that bandwidth estimate updates are sent to the client, only when | 390 // Test that bandwidth estimate updates are sent to the client, only when |
| 391 // bandwidth resumption is enabled, the bandwidth estimate has changed | 391 // bandwidth resumption is enabled, the bandwidth estimate has changed |
| 392 // sufficiently, enough time has passed, | 392 // sufficiently, enough time has passed, |
| 393 // and we don't have any other data to write. | 393 // and we don't have any other data to write. |
| 394 | 394 |
| 395 // Client has sent kBWRE connection option to trigger bandwidth resumption. | 395 // Client has sent kBWRE connection option to trigger bandwidth resumption. |
| 396 // Disable this flag because if connection uses multipath sent packet manager, |
| 397 // static_cast here does not work. |
| 398 FLAGS_quic_enable_multipath = false; |
| 396 QuicTagVector copt; | 399 QuicTagVector copt; |
| 397 copt.push_back(kBWRE); | 400 copt.push_back(kBWRE); |
| 398 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt); | 401 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt); |
| 399 session_->OnConfigNegotiated(); | 402 session_->OnConfigNegotiated(); |
| 400 EXPECT_TRUE( | 403 EXPECT_TRUE( |
| 401 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); | 404 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); |
| 402 | 405 |
| 403 int32_t bandwidth_estimate_kbytes_per_second = 123; | 406 int32_t bandwidth_estimate_kbytes_per_second = 123; |
| 404 int32_t max_bandwidth_estimate_kbytes_per_second = 134; | 407 int32_t max_bandwidth_estimate_kbytes_per_second = 134; |
| 405 int32_t max_bandwidth_estimate_timestamp = 1122334455; | 408 int32_t max_bandwidth_estimate_timestamp = 1122334455; |
| 406 const string serving_region = "not a real region"; | 409 const string serving_region = "not a real region"; |
| 407 session_->set_serving_region(serving_region); | 410 session_->set_serving_region(serving_region); |
| 408 | 411 |
| 409 MockQuicCryptoServerStream* crypto_stream = new MockQuicCryptoServerStream( | 412 MockQuicCryptoServerStream* crypto_stream = new MockQuicCryptoServerStream( |
| 410 &crypto_config_, &compressed_certs_cache_, session_.get()); | 413 &crypto_config_, &compressed_certs_cache_, session_.get()); |
| 411 QuicServerSessionBasePeer::SetCryptoStream(session_.get(), crypto_stream); | 414 QuicServerSessionBasePeer::SetCryptoStream(session_.get(), crypto_stream); |
| 412 | 415 |
| 413 // Set some initial bandwidth values. | 416 // Set some initial bandwidth values. |
| 414 QuicSentPacketManager* sent_packet_manager = | 417 QuicSentPacketManager* sent_packet_manager = |
| 415 QuicConnectionPeer::GetSentPacketManager(session_->connection()); | 418 static_cast<QuicSentPacketManager*>( |
| 419 QuicConnectionPeer::GetSentPacketManager(session_->connection())); |
| 416 QuicSustainedBandwidthRecorder& bandwidth_recorder = | 420 QuicSustainedBandwidthRecorder& bandwidth_recorder = |
| 417 QuicSentPacketManagerPeer::GetBandwidthRecorder(sent_packet_manager); | 421 QuicSentPacketManagerPeer::GetBandwidthRecorder(sent_packet_manager); |
| 418 // Seed an rtt measurement equal to the initial default rtt. | 422 // Seed an rtt measurement equal to the initial default rtt. |
| 419 RttStats* rtt_stats = | 423 RttStats* rtt_stats = |
| 420 const_cast<RttStats*>(sent_packet_manager->GetRttStats()); | 424 const_cast<RttStats*>(sent_packet_manager->GetRttStats()); |
| 421 rtt_stats->UpdateRtt( | 425 rtt_stats->UpdateRtt( |
| 422 QuicTime::Delta::FromMicroseconds(rtt_stats->initial_rtt_us()), | 426 QuicTime::Delta::FromMicroseconds(rtt_stats->initial_rtt_us()), |
| 423 QuicTime::Delta::Zero(), QuicTime::Zero()); | 427 QuicTime::Delta::Zero(), QuicTime::Zero()); |
| 424 QuicSustainedBandwidthRecorderPeer::SetBandwidthEstimate( | 428 QuicSustainedBandwidthRecorderPeer::SetBandwidthEstimate( |
| 425 &bandwidth_recorder, bandwidth_estimate_kbytes_per_second); | 429 &bandwidth_recorder, bandwidth_estimate_kbytes_per_second); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 EXPECT_FALSE( | 553 EXPECT_FALSE( |
| 550 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); | 554 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); |
| 551 session_->OnConfigNegotiated(); | 555 session_->OnConfigNegotiated(); |
| 552 EXPECT_FALSE( | 556 EXPECT_FALSE( |
| 553 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); | 557 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); |
| 554 } | 558 } |
| 555 | 559 |
| 556 } // namespace | 560 } // namespace |
| 557 } // namespace test | 561 } // namespace test |
| 558 } // namespace net | 562 } // namespace net |
| OLD | NEW |