| 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 <string> |
| 8 |
| 7 #include "net/quic/crypto/cached_network_parameters.h" | 9 #include "net/quic/crypto/cached_network_parameters.h" |
| 8 #include "net/quic/crypto/quic_crypto_server_config.h" | 10 #include "net/quic/crypto/quic_crypto_server_config.h" |
| 9 #include "net/quic/crypto/quic_random.h" | 11 #include "net/quic/crypto/quic_random.h" |
| 10 #include "net/quic/quic_connection.h" | 12 #include "net/quic/quic_connection.h" |
| 11 #include "net/quic/quic_crypto_server_stream.h" | 13 #include "net/quic/quic_crypto_server_stream.h" |
| 12 #include "net/quic/quic_flags.h" | 14 #include "net/quic/quic_flags.h" |
| 13 #include "net/quic/quic_utils.h" | 15 #include "net/quic/quic_utils.h" |
| 14 #include "net/quic/test_tools/quic_config_peer.h" | 16 #include "net/quic/test_tools/quic_config_peer.h" |
| 15 #include "net/quic/test_tools/quic_connection_peer.h" | 17 #include "net/quic/test_tools/quic_connection_peer.h" |
| 16 #include "net/quic/test_tools/quic_data_stream_peer.h" | 18 #include "net/quic/test_tools/quic_data_stream_peer.h" |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 if (version() <= QUIC_VERSION_21) { | 305 if (version() <= QUIC_VERSION_21) { |
| 304 return; | 306 return; |
| 305 } | 307 } |
| 306 | 308 |
| 307 // Test that bandwidth estimate updates are sent to the client, only after the | 309 // Test that bandwidth estimate updates are sent to the client, only after the |
| 308 // bandwidth estimate has changes sufficiently, and enough time has passed. | 310 // bandwidth estimate has changes sufficiently, and enough time has passed. |
| 309 | 311 |
| 310 int32 bandwidth_estimate_kbytes_per_second = 123; | 312 int32 bandwidth_estimate_kbytes_per_second = 123; |
| 311 int32 max_bandwidth_estimate_kbytes_per_second = 134; | 313 int32 max_bandwidth_estimate_kbytes_per_second = 134; |
| 312 int32 max_bandwidth_estimate_timestamp = 1122334455; | 314 int32 max_bandwidth_estimate_timestamp = 1122334455; |
| 313 const string serving_region = "not a real region"; | 315 const std::string serving_region = "not a real region"; |
| 314 session_->set_serving_region(serving_region); | 316 session_->set_serving_region(serving_region); |
| 315 | 317 |
| 316 MockQuicCryptoServerStream* crypto_stream = | 318 MockQuicCryptoServerStream* crypto_stream = |
| 317 new MockQuicCryptoServerStream(crypto_config_, session_.get()); | 319 new MockQuicCryptoServerStream(crypto_config_, session_.get()); |
| 318 QuicServerSessionPeer::SetCryptoStream(session_.get(), crypto_stream); | 320 QuicServerSessionPeer::SetCryptoStream(session_.get(), crypto_stream); |
| 319 | 321 |
| 320 // Set some initial bandwidth values. | 322 // Set some initial bandwidth values. |
| 321 QuicSentPacketManager* sent_packet_manager = | 323 QuicSentPacketManager* sent_packet_manager = |
| 322 QuicConnectionPeer::GetSentPacketManager(session_->connection()); | 324 QuicConnectionPeer::GetSentPacketManager(session_->connection()); |
| 323 QuicSustainedBandwidthRecorder& bandwidth_recorder = | 325 QuicSustainedBandwidthRecorder& bandwidth_recorder = |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 | 389 |
| 388 // Test that if a client provides a CachedNetworkParameters with the same | 390 // 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 | 391 // serving region as the current server, that this data is passed down to the |
| 390 // send algorithm. | 392 // send algorithm. |
| 391 | 393 |
| 392 // Client has sent kBWRE connection option to trigger bandwidth resumption. | 394 // Client has sent kBWRE connection option to trigger bandwidth resumption. |
| 393 QuicTagVector copt; | 395 QuicTagVector copt; |
| 394 copt.push_back(kBWRE); | 396 copt.push_back(kBWRE); |
| 395 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt); | 397 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt); |
| 396 | 398 |
| 397 const string kTestServingRegion = "a serving region"; | 399 const std::string kTestServingRegion = "a serving region"; |
| 398 session_->set_serving_region(kTestServingRegion); | 400 session_->set_serving_region(kTestServingRegion); |
| 399 | 401 |
| 400 QuicCryptoServerStream* crypto_stream = | 402 QuicCryptoServerStream* crypto_stream = |
| 401 static_cast<QuicCryptoServerStream*>( | 403 static_cast<QuicCryptoServerStream*>( |
| 402 QuicSessionPeer::GetCryptoStream(session_.get())); | 404 QuicSessionPeer::GetCryptoStream(session_.get())); |
| 403 | 405 |
| 404 // No effect if no CachedNetworkParameters provided. | 406 // No effect if no CachedNetworkParameters provided. |
| 405 EXPECT_CALL(*connection_, ResumeConnectionState(_)).Times(0); | 407 EXPECT_CALL(*connection_, ResumeConnectionState(_)).Times(0); |
| 406 session_->OnConfigNegotiated(); | 408 session_->OnConfigNegotiated(); |
| 407 | 409 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 418 cached_network_params.set_serving_region(kTestServingRegion); | 420 cached_network_params.set_serving_region(kTestServingRegion); |
| 419 crypto_stream->set_previous_cached_network_params(cached_network_params); | 421 crypto_stream->set_previous_cached_network_params(cached_network_params); |
| 420 EXPECT_CALL(*connection_, ResumeConnectionState(_)).Times(1); | 422 EXPECT_CALL(*connection_, ResumeConnectionState(_)).Times(1); |
| 421 session_->OnConfigNegotiated(); | 423 session_->OnConfigNegotiated(); |
| 422 } | 424 } |
| 423 | 425 |
| 424 } // namespace | 426 } // namespace |
| 425 } // namespace test | 427 } // namespace test |
| 426 } // namespace tools | 428 } // namespace tools |
| 427 } // namespace net | 429 } // namespace net |
| OLD | NEW |