| 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 "base/macros.h" |
| 7 #include "net/quic/crypto/quic_crypto_server_config.h" | 8 #include "net/quic/crypto/quic_crypto_server_config.h" |
| 8 #include "net/quic/crypto/quic_random.h" | 9 #include "net/quic/crypto/quic_random.h" |
| 9 #include "net/quic/proto/cached_network_parameters.pb.h" | 10 #include "net/quic/proto/cached_network_parameters.pb.h" |
| 10 #include "net/quic/quic_connection.h" | 11 #include "net/quic/quic_connection.h" |
| 11 #include "net/quic/quic_crypto_server_stream.h" | 12 #include "net/quic/quic_crypto_server_stream.h" |
| 12 #include "net/quic/quic_utils.h" | 13 #include "net/quic/quic_utils.h" |
| 13 #include "net/quic/test_tools/crypto_test_utils.h" | 14 #include "net/quic/test_tools/crypto_test_utils.h" |
| 14 #include "net/quic/test_tools/quic_config_peer.h" | 15 #include "net/quic/test_tools/quic_config_peer.h" |
| 15 #include "net/quic/test_tools/quic_connection_peer.h" | 16 #include "net/quic/test_tools/quic_connection_peer.h" |
| 16 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" | 17 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 // and we don't have any other data to write. | 339 // and we don't have any other data to write. |
| 339 | 340 |
| 340 // Client has sent kBWRE connection option to trigger bandwidth resumption. | 341 // Client has sent kBWRE connection option to trigger bandwidth resumption. |
| 341 QuicTagVector copt; | 342 QuicTagVector copt; |
| 342 copt.push_back(kBWRE); | 343 copt.push_back(kBWRE); |
| 343 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt); | 344 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt); |
| 344 session_->OnConfigNegotiated(); | 345 session_->OnConfigNegotiated(); |
| 345 EXPECT_TRUE( | 346 EXPECT_TRUE( |
| 346 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get())); | 347 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get())); |
| 347 | 348 |
| 348 int32 bandwidth_estimate_kbytes_per_second = 123; | 349 int32_t bandwidth_estimate_kbytes_per_second = 123; |
| 349 int32 max_bandwidth_estimate_kbytes_per_second = 134; | 350 int32_t max_bandwidth_estimate_kbytes_per_second = 134; |
| 350 int32 max_bandwidth_estimate_timestamp = 1122334455; | 351 int32_t max_bandwidth_estimate_timestamp = 1122334455; |
| 351 const string serving_region = "not a real region"; | 352 const string serving_region = "not a real region"; |
| 352 session_->set_serving_region(serving_region); | 353 session_->set_serving_region(serving_region); |
| 353 | 354 |
| 354 MockQuicCryptoServerStream* crypto_stream = | 355 MockQuicCryptoServerStream* crypto_stream = |
| 355 new MockQuicCryptoServerStream(&crypto_config_, session_.get()); | 356 new MockQuicCryptoServerStream(&crypto_config_, session_.get()); |
| 356 QuicServerSessionPeer::SetCryptoStream(session_.get(), crypto_stream); | 357 QuicServerSessionPeer::SetCryptoStream(session_.get(), crypto_stream); |
| 357 | 358 |
| 358 // Set some initial bandwidth values. | 359 // Set some initial bandwidth values. |
| 359 QuicSentPacketManager* sent_packet_manager = | 360 QuicSentPacketManager* sent_packet_manager = |
| 360 QuicConnectionPeer::GetSentPacketManager(session_->connection()); | 361 QuicConnectionPeer::GetSentPacketManager(session_->connection()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 381 session_->OnCongestionWindowChange(now); | 382 session_->OnCongestionWindowChange(now); |
| 382 | 383 |
| 383 // Bandwidth estimate has now changed sufficiently but not enough time has | 384 // Bandwidth estimate has now changed sufficiently but not enough time has |
| 384 // passed to send a Server Config Update. | 385 // passed to send a Server Config Update. |
| 385 bandwidth_estimate_kbytes_per_second = | 386 bandwidth_estimate_kbytes_per_second = |
| 386 bandwidth_estimate_kbytes_per_second * 1.6; | 387 bandwidth_estimate_kbytes_per_second * 1.6; |
| 387 session_->OnCongestionWindowChange(now); | 388 session_->OnCongestionWindowChange(now); |
| 388 | 389 |
| 389 // Bandwidth estimate has now changed sufficiently and enough time has passed, | 390 // Bandwidth estimate has now changed sufficiently and enough time has passed, |
| 390 // but not enough packets have been sent. | 391 // but not enough packets have been sent. |
| 391 int64 srtt_ms = | 392 int64_t srtt_ms = |
| 392 sent_packet_manager->GetRttStats()->smoothed_rtt().ToMilliseconds(); | 393 sent_packet_manager->GetRttStats()->smoothed_rtt().ToMilliseconds(); |
| 393 now = now.Add(QuicTime::Delta::FromMilliseconds( | 394 now = now.Add(QuicTime::Delta::FromMilliseconds( |
| 394 kMinIntervalBetweenServerConfigUpdatesRTTs * srtt_ms)); | 395 kMinIntervalBetweenServerConfigUpdatesRTTs * srtt_ms)); |
| 395 session_->OnCongestionWindowChange(now); | 396 session_->OnCongestionWindowChange(now); |
| 396 | 397 |
| 397 // The connection no longer has pending data to be written. | 398 // The connection no longer has pending data to be written. |
| 398 session_->OnCanWrite(); | 399 session_->OnCanWrite(); |
| 399 EXPECT_FALSE(session_->HasDataToWrite()); | 400 EXPECT_FALSE(session_->HasDataToWrite()); |
| 400 session_->OnCongestionWindowChange(now); | 401 session_->OnCongestionWindowChange(now); |
| 401 | 402 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 // Create peer initiated stream should have no problem. | 555 // Create peer initiated stream should have no problem. |
| 555 QuicStreamFrame data2(kClientDataStreamId2, false, 0, StringPiece("HT")); | 556 QuicStreamFrame data2(kClientDataStreamId2, false, 0, StringPiece("HT")); |
| 556 session_->OnStreamFrame(data2); | 557 session_->OnStreamFrame(data2); |
| 557 EXPECT_EQ(2u, session_->GetNumOpenIncomingStreams()); | 558 EXPECT_EQ(2u, session_->GetNumOpenIncomingStreams()); |
| 558 } | 559 } |
| 559 | 560 |
| 560 } // namespace | 561 } // namespace |
| 561 } // namespace test | 562 } // namespace test |
| 562 } // namespace tools | 563 } // namespace tools |
| 563 } // namespace net | 564 } // namespace net |
| OLD | NEW |