OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <sys/epoll.h> | 6 #include <sys/epoll.h> |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 2594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2605 AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody, | 2605 AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody, |
2606 push_urls, kNumResources, 0); | 2606 push_urls, kNumResources, 0); |
2607 | 2607 |
2608 client_->client()->set_response_listener( | 2608 client_->client()->set_response_listener( |
2609 std::unique_ptr<QuicClientBase::ResponseListener>( | 2609 std::unique_ptr<QuicClientBase::ResponseListener>( |
2610 new TestResponseListener)); | 2610 new TestResponseListener)); |
2611 | 2611 |
2612 DVLOG(1) << "send request for /push_example"; | 2612 DVLOG(1) << "send request for /push_example"; |
2613 EXPECT_EQ(kBody, client_->SendSynchronousRequest( | 2613 EXPECT_EQ(kBody, client_->SendSynchronousRequest( |
2614 "https://example.com/push_example")); | 2614 "https://example.com/push_example")); |
| 2615 QuicHeadersStream* headers_stream = |
| 2616 QuicSpdySessionPeer::GetHeadersStream(client_->client()->session()); |
| 2617 QuicStreamSequencer* sequencer = |
| 2618 ReliableQuicStreamPeer::sequencer(headers_stream); |
| 2619 // Headers stream's sequencer buffer shouldn't be released because server push |
| 2620 // hasn't finished yet. |
| 2621 EXPECT_TRUE(QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer)); |
| 2622 |
2615 for (const string& url : push_urls) { | 2623 for (const string& url : push_urls) { |
2616 DVLOG(1) << "send request for pushed stream on url " << url; | 2624 DVLOG(1) << "send request for pushed stream on url " << url; |
2617 string expected_body = "This is server push response body for " + url; | 2625 string expected_body = "This is server push response body for " + url; |
2618 string response_body = client_->SendSynchronousRequest(url); | 2626 string response_body = client_->SendSynchronousRequest(url); |
2619 DVLOG(1) << "response body " << response_body; | 2627 DVLOG(1) << "response body " << response_body; |
2620 EXPECT_EQ(expected_body, response_body); | 2628 EXPECT_EQ(expected_body, response_body); |
2621 } | 2629 } |
| 2630 EXPECT_NE(FLAGS_quic_headers_stream_release_sequencer_buffer && |
| 2631 FLAGS_quic_reduce_sequencer_buffer_memory_life_time, |
| 2632 QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer)); |
2622 } | 2633 } |
2623 | 2634 |
2624 TEST_P(EndToEndTestServerPush, ServerPushUnderLimit) { | 2635 TEST_P(EndToEndTestServerPush, ServerPushUnderLimit) { |
2625 // Tests that sending a request which has 4 push resources will trigger server | 2636 // Tests that sending a request which has 4 push resources will trigger server |
2626 // to push those 4 resources and client can handle pushed resources and match | 2637 // to push those 4 resources and client can handle pushed resources and match |
2627 // them with requests later. | 2638 // them with requests later. |
2628 ASSERT_TRUE(Initialize()); | 2639 ASSERT_TRUE(Initialize()); |
2629 | 2640 |
2630 client_->client()->WaitForCryptoHandshakeConfirmed(); | 2641 client_->client()->WaitForCryptoHandshakeConfirmed(); |
2631 | 2642 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2901 client_->client()->WaitForCryptoHandshakeConfirmed(); | 2912 client_->client()->WaitForCryptoHandshakeConfirmed(); |
2902 SetPacketLossPercentage(1); | 2913 SetPacketLossPercentage(1); |
2903 client_->SendRequest("/huge_response"); | 2914 client_->SendRequest("/huge_response"); |
2904 client_->WaitForResponse(); | 2915 client_->WaitForResponse(); |
2905 // TODO(fayang): Fix this test to work with stateless rejects. | 2916 // TODO(fayang): Fix this test to work with stateless rejects. |
2906 if (!BothSidesSupportStatelessRejects()) { | 2917 if (!BothSidesSupportStatelessRejects()) { |
2907 VerifyCleanConnection(true); | 2918 VerifyCleanConnection(true); |
2908 } | 2919 } |
2909 } | 2920 } |
2910 | 2921 |
| 2922 TEST_P(EndToEndTest, ReleaseHeadersStreamBufferWhenIdle) { |
| 2923 // Tests that when client side has no active request and no waiting |
| 2924 // PUSH_PROMISE, its headers stream's sequencer buffer should be released. |
| 2925 ASSERT_TRUE(Initialize()); |
| 2926 client_->SendSynchronousRequest("/foo"); |
| 2927 QuicHeadersStream* headers_stream = |
| 2928 QuicSpdySessionPeer::GetHeadersStream(client_->client()->session()); |
| 2929 QuicStreamSequencer* sequencer = |
| 2930 ReliableQuicStreamPeer::sequencer(headers_stream); |
| 2931 EXPECT_NE(FLAGS_quic_headers_stream_release_sequencer_buffer && |
| 2932 FLAGS_quic_reduce_sequencer_buffer_memory_life_time, |
| 2933 QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer)); |
| 2934 } |
| 2935 |
2911 class EndToEndBufferedPacketsTest : public EndToEndTest { | 2936 class EndToEndBufferedPacketsTest : public EndToEndTest { |
2912 public: | 2937 public: |
2913 EndToEndBufferedPacketsTest() : EndToEndTest() { | 2938 EndToEndBufferedPacketsTest() : EndToEndTest() { |
2914 FLAGS_quic_buffer_packet_till_chlo = true; | 2939 FLAGS_quic_buffer_packet_till_chlo = true; |
2915 } | 2940 } |
2916 | 2941 |
2917 void CreateClientWithWriter() override { | 2942 void CreateClientWithWriter() override { |
2918 LOG(ERROR) << "create client with reorder_writer_ "; | 2943 LOG(ERROR) << "create client with reorder_writer_ "; |
2919 reorder_writer_ = new PacketReorderingWriter(); | 2944 reorder_writer_ = new PacketReorderingWriter(); |
2920 client_.reset(EndToEndTest::CreateQuicClient(reorder_writer_)); | 2945 client_.reset(EndToEndTest::CreateQuicClient(reorder_writer_)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2958 client_->WaitForResponse(); | 2983 client_->WaitForResponse(); |
2959 EXPECT_EQ(kBarResponseBody, client_->response_body()); | 2984 EXPECT_EQ(kBarResponseBody, client_->response_body()); |
2960 QuicConnectionStats client_stats = | 2985 QuicConnectionStats client_stats = |
2961 client_->client()->session()->connection()->GetStats(); | 2986 client_->client()->session()->connection()->GetStats(); |
2962 EXPECT_EQ(0u, client_stats.packets_lost); | 2987 EXPECT_EQ(0u, client_stats.packets_lost); |
2963 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); | 2988 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); |
2964 } | 2989 } |
2965 } // namespace | 2990 } // namespace |
2966 } // namespace test | 2991 } // namespace test |
2967 } // namespace net | 2992 } // namespace net |
OLD | NEW |