| 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 "base/macros.h" | 7 #include "base/macros.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/proto/cached_network_parameters.pb.h" | 10 #include "net/quic/proto/cached_network_parameters.pb.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 } | 99 } |
| 100 | 100 |
| 101 QuicSpdyStream* stream = | 101 QuicSpdyStream* stream = |
| 102 new QuicSimpleServerStream(GetNextOutgoingStreamId(), this); | 102 new QuicSimpleServerStream(GetNextOutgoingStreamId(), this); |
| 103 stream->SetPriority(priority); | 103 stream->SetPriority(priority); |
| 104 ActivateStream(stream); | 104 ActivateStream(stream); |
| 105 return stream; | 105 return stream; |
| 106 } | 106 } |
| 107 | 107 |
| 108 QuicCryptoServerStreamBase* CreateQuicCryptoServerStream( | 108 QuicCryptoServerStreamBase* CreateQuicCryptoServerStream( |
| 109 const QuicCryptoServerConfig* crypto_config) override { | 109 const QuicCryptoServerConfig* crypto_config, |
| 110 QuicCompressedCertsCache* compressed_certs_cache) override { |
| 110 return new QuicCryptoServerStream( | 111 return new QuicCryptoServerStream( |
| 111 crypto_config, FLAGS_enable_quic_stateless_reject_support, this); | 112 crypto_config, compressed_certs_cache, |
| 113 FLAGS_enable_quic_stateless_reject_support, this); |
| 112 } | 114 } |
| 113 }; | 115 }; |
| 114 | 116 |
| 115 const size_t kMaxStreamsForTest = 10; | 117 const size_t kMaxStreamsForTest = 10; |
| 116 | 118 |
| 117 class QuicServerSessionBaseTest : public ::testing::TestWithParam<QuicVersion> { | 119 class QuicServerSessionBaseTest : public ::testing::TestWithParam<QuicVersion> { |
| 118 protected: | 120 protected: |
| 119 QuicServerSessionBaseTest() | 121 QuicServerSessionBaseTest() |
| 120 : crypto_config_(QuicCryptoServerConfig::TESTING, | 122 : crypto_config_(QuicCryptoServerConfig::TESTING, |
| 121 QuicRandom::GetInstance(), | 123 QuicRandom::GetInstance(), |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 QuicConnectionPeer::CloseConnection(connection_); | 337 QuicConnectionPeer::CloseConnection(connection_); |
| 336 EXPECT_DFATAL( | 338 EXPECT_DFATAL( |
| 337 QuicServerSessionBasePeer::GetOrCreateDynamicStream(session_.get(), 5), | 339 QuicServerSessionBasePeer::GetOrCreateDynamicStream(session_.get(), 5), |
| 338 "ShouldCreateIncomingDynamicStream called when disconnected"); | 340 "ShouldCreateIncomingDynamicStream called when disconnected"); |
| 339 } | 341 } |
| 340 | 342 |
| 341 class MockQuicCryptoServerStream : public QuicCryptoServerStream { | 343 class MockQuicCryptoServerStream : public QuicCryptoServerStream { |
| 342 public: | 344 public: |
| 343 explicit MockQuicCryptoServerStream( | 345 explicit MockQuicCryptoServerStream( |
| 344 const QuicCryptoServerConfig* crypto_config, | 346 const QuicCryptoServerConfig* crypto_config, |
| 347 QuicCompressedCertsCache* compressed_certs_cache, |
| 345 QuicSession* session) | 348 QuicSession* session) |
| 346 : QuicCryptoServerStream(crypto_config, | 349 : QuicCryptoServerStream(crypto_config, |
| 350 compressed_certs_cache, |
| 347 FLAGS_enable_quic_stateless_reject_support, | 351 FLAGS_enable_quic_stateless_reject_support, |
| 348 session) {} | 352 session) {} |
| 349 ~MockQuicCryptoServerStream() override {} | 353 ~MockQuicCryptoServerStream() override {} |
| 350 | 354 |
| 351 MOCK_METHOD1(SendServerConfigUpdate, | 355 MOCK_METHOD1(SendServerConfigUpdate, |
| 352 void(const CachedNetworkParameters* cached_network_parameters)); | 356 void(const CachedNetworkParameters* cached_network_parameters)); |
| 353 | 357 |
| 354 void set_encryption_established(bool has_established) { | 358 void set_encryption_established(bool has_established) { |
| 355 encryption_established_ = has_established; | 359 encryption_established_ = has_established; |
| 356 } | 360 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 372 session_->OnConfigNegotiated(); | 376 session_->OnConfigNegotiated(); |
| 373 EXPECT_TRUE( | 377 EXPECT_TRUE( |
| 374 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); | 378 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); |
| 375 | 379 |
| 376 int32_t bandwidth_estimate_kbytes_per_second = 123; | 380 int32_t bandwidth_estimate_kbytes_per_second = 123; |
| 377 int32_t max_bandwidth_estimate_kbytes_per_second = 134; | 381 int32_t max_bandwidth_estimate_kbytes_per_second = 134; |
| 378 int32_t max_bandwidth_estimate_timestamp = 1122334455; | 382 int32_t max_bandwidth_estimate_timestamp = 1122334455; |
| 379 const string serving_region = "not a real region"; | 383 const string serving_region = "not a real region"; |
| 380 session_->set_serving_region(serving_region); | 384 session_->set_serving_region(serving_region); |
| 381 | 385 |
| 382 MockQuicCryptoServerStream* crypto_stream = | 386 MockQuicCryptoServerStream* crypto_stream = new MockQuicCryptoServerStream( |
| 383 new MockQuicCryptoServerStream(&crypto_config_, session_.get()); | 387 &crypto_config_, &compressed_certs_cache_, session_.get()); |
| 384 QuicServerSessionBasePeer::SetCryptoStream(session_.get(), crypto_stream); | 388 QuicServerSessionBasePeer::SetCryptoStream(session_.get(), crypto_stream); |
| 385 | 389 |
| 386 // Set some initial bandwidth values. | 390 // Set some initial bandwidth values. |
| 387 QuicSentPacketManager* sent_packet_manager = | 391 QuicSentPacketManager* sent_packet_manager = |
| 388 QuicConnectionPeer::GetSentPacketManager(session_->connection()); | 392 QuicConnectionPeer::GetSentPacketManager(session_->connection()); |
| 389 QuicSustainedBandwidthRecorder& bandwidth_recorder = | 393 QuicSustainedBandwidthRecorder& bandwidth_recorder = |
| 390 QuicSentPacketManagerPeer::GetBandwidthRecorder(sent_packet_manager); | 394 QuicSentPacketManagerPeer::GetBandwidthRecorder(sent_packet_manager); |
| 391 // Seed an rtt measurement equal to the initial default rtt. | 395 // Seed an rtt measurement equal to the initial default rtt. |
| 392 RttStats* rtt_stats = | 396 RttStats* rtt_stats = |
| 393 QuicSentPacketManagerPeer::GetRttStats(sent_packet_manager); | 397 QuicSentPacketManagerPeer::GetRttStats(sent_packet_manager); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 EXPECT_FALSE( | 526 EXPECT_FALSE( |
| 523 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); | 527 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); |
| 524 session_->OnConfigNegotiated(); | 528 session_->OnConfigNegotiated(); |
| 525 EXPECT_FALSE( | 529 EXPECT_FALSE( |
| 526 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); | 530 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); |
| 527 } | 531 } |
| 528 | 532 |
| 529 } // namespace | 533 } // namespace |
| 530 } // namespace test | 534 } // namespace test |
| 531 } // namespace net | 535 } // namespace net |
| OLD | NEW |