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 "net/quic/core/quic_session.h" | 5 #include "net/quic/core/quic_session.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "net/quic/core/crypto/crypto_protocol.h" | 14 #include "net/quic/core/crypto/crypto_protocol.h" |
15 #include "net/quic/core/crypto/null_encrypter.h" | 15 #include "net/quic/core/crypto/null_encrypter.h" |
16 #include "net/quic/core/quic_crypto_stream.h" | 16 #include "net/quic/core/quic_crypto_stream.h" |
17 #include "net/quic/core/quic_flags.h" | 17 #include "net/quic/core/quic_flags.h" |
18 #include "net/quic/core/quic_packets.h" | 18 #include "net/quic/core/quic_packets.h" |
19 #include "net/quic/core/quic_stream.h" | 19 #include "net/quic/core/quic_stream.h" |
20 #include "net/quic/core/quic_utils.h" | 20 #include "net/quic/core/quic_utils.h" |
21 #include "net/quic/platform/api/quic_str_cat.h" | 21 #include "net/quic/platform/api/quic_str_cat.h" |
22 #include "net/quic/test_tools/quic_config_peer.h" | 22 #include "net/quic/test_tools/quic_config_peer.h" |
23 #include "net/quic/test_tools/quic_connection_peer.h" | 23 #include "net/quic/test_tools/quic_connection_peer.h" |
24 #include "net/quic/test_tools/quic_flow_controller_peer.h" | 24 #include "net/quic/test_tools/quic_flow_controller_peer.h" |
25 #include "net/quic/test_tools/quic_headers_stream_peer.h" | |
26 #include "net/quic/test_tools/quic_session_peer.h" | 25 #include "net/quic/test_tools/quic_session_peer.h" |
27 #include "net/quic/test_tools/quic_spdy_session_peer.h" | 26 #include "net/quic/test_tools/quic_spdy_session_peer.h" |
28 #include "net/quic/test_tools/quic_spdy_stream_peer.h" | 27 #include "net/quic/test_tools/quic_spdy_stream_peer.h" |
29 #include "net/quic/test_tools/quic_stream_peer.h" | 28 #include "net/quic/test_tools/quic_stream_peer.h" |
30 #include "net/quic/test_tools/quic_test_utils.h" | 29 #include "net/quic/test_tools/quic_test_utils.h" |
31 #include "net/spdy/spdy_framer.h" | 30 #include "net/spdy/spdy_framer.h" |
32 #include "net/test/gtest_util.h" | 31 #include "net/test/gtest_util.h" |
33 #include "testing/gmock/include/gmock/gmock.h" | 32 #include "testing/gmock/include/gmock/gmock.h" |
34 #include "testing/gmock_mutant.h" | 33 #include "testing/gmock_mutant.h" |
35 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 EXPECT_FALSE(session_.IsStreamFlowControlBlocked()); | 915 EXPECT_FALSE(session_.IsStreamFlowControlBlocked()); |
917 QuicStreamId stream_id = 5; | 916 QuicStreamId stream_id = 5; |
918 // Write until the header stream is flow control blocked. | 917 // Write until the header stream is flow control blocked. |
919 EXPECT_CALL(*connection_, SendBlocked(kHeadersStreamId)); | 918 EXPECT_CALL(*connection_, SendBlocked(kHeadersStreamId)); |
920 SpdyHeaderBlock headers; | 919 SpdyHeaderBlock headers; |
921 while (!headers_stream->flow_controller()->IsBlocked() && stream_id < 2000) { | 920 while (!headers_stream->flow_controller()->IsBlocked() && stream_id < 2000) { |
922 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); | 921 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); |
923 EXPECT_FALSE(session_.IsStreamFlowControlBlocked()); | 922 EXPECT_FALSE(session_.IsStreamFlowControlBlocked()); |
924 headers["header"] = QuicStrCat("", base::RandUint64(), base::RandUint64(), | 923 headers["header"] = QuicStrCat("", base::RandUint64(), base::RandUint64(), |
925 base::RandUint64()); | 924 base::RandUint64()); |
926 headers_stream->WriteHeaders(stream_id, headers.Clone(), true, 0, nullptr); | 925 session_.WriteHeaders(stream_id, headers.Clone(), true, 0, nullptr); |
927 stream_id += 2; | 926 stream_id += 2; |
928 } | 927 } |
929 // Write once more to ensure that the headers stream has buffered data. The | 928 // Write once more to ensure that the headers stream has buffered data. The |
930 // random headers may have exactly filled the flow control window. | 929 // random headers may have exactly filled the flow control window. |
931 headers_stream->WriteHeaders(stream_id, std::move(headers), true, 0, nullptr); | 930 session_.WriteHeaders(stream_id, std::move(headers), true, 0, nullptr); |
932 EXPECT_TRUE(headers_stream->HasBufferedData()); | 931 EXPECT_TRUE(headers_stream->HasBufferedData()); |
933 | 932 |
934 EXPECT_TRUE(headers_stream->flow_controller()->IsBlocked()); | 933 EXPECT_TRUE(headers_stream->flow_controller()->IsBlocked()); |
935 EXPECT_FALSE(crypto_stream->flow_controller()->IsBlocked()); | 934 EXPECT_FALSE(crypto_stream->flow_controller()->IsBlocked()); |
936 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); | 935 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); |
937 EXPECT_TRUE(session_.IsStreamFlowControlBlocked()); | 936 EXPECT_TRUE(session_.IsStreamFlowControlBlocked()); |
938 EXPECT_FALSE(session_.HasDataToWrite()); | 937 EXPECT_FALSE(session_.HasDataToWrite()); |
939 | 938 |
940 // Now complete the crypto handshake, resulting in an increased flow control | 939 // Now complete the crypto handshake, resulting in an increased flow control |
941 // send window. | 940 // send window. |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 session_.max_open_incoming_streams()); | 1295 session_.max_open_incoming_streams()); |
1297 EXPECT_EQ(session_.max_open_outgoing_streams(), | 1296 EXPECT_EQ(session_.max_open_outgoing_streams(), |
1298 kDefaultMaxStreamsPerConnection); | 1297 kDefaultMaxStreamsPerConnection); |
1299 } | 1298 } |
1300 | 1299 |
1301 TEST_P(QuicSessionTestClient, EnableDHDTThroughConnectionOption) { | 1300 TEST_P(QuicSessionTestClient, EnableDHDTThroughConnectionOption) { |
1302 QuicTagVector copt; | 1301 QuicTagVector copt; |
1303 copt.push_back(kDHDT); | 1302 copt.push_back(kDHDT); |
1304 QuicConfigPeer::SetConnectionOptionsToSend(session_.config(), copt); | 1303 QuicConfigPeer::SetConnectionOptionsToSend(session_.config(), copt); |
1305 session_.OnConfigNegotiated(); | 1304 session_.OnConfigNegotiated(); |
1306 EXPECT_EQ(QuicHeadersStreamPeer::GetSpdyFramer(session_.headers_stream()) | 1305 EXPECT_EQ( |
1307 .header_encoder_table_size(), | 1306 QuicSpdySessionPeer::GetSpdyFramer(&session_).header_encoder_table_size(), |
1308 0UL); | 1307 0UL); |
1309 } | 1308 } |
1310 | 1309 |
1311 TEST_P(QuicSessionTestClient, EnableFHOLThroughConfigOption) { | 1310 TEST_P(QuicSessionTestClient, EnableFHOLThroughConfigOption) { |
1312 session_.config()->SetForceHolBlocking(); | 1311 session_.config()->SetForceHolBlocking(); |
1313 session_.OnConfigNegotiated(); | 1312 session_.OnConfigNegotiated(); |
1314 if (version() <= QUIC_VERSION_35) { | 1313 if (version() <= QUIC_VERSION_35) { |
1315 EXPECT_FALSE(session_.force_hol_blocking()); | 1314 EXPECT_FALSE(session_.force_hol_blocking()); |
1316 } else { | 1315 } else { |
1317 EXPECT_TRUE(session_.force_hol_blocking()); | 1316 EXPECT_TRUE(session_.force_hol_blocking()); |
1318 } | 1317 } |
1319 } | 1318 } |
1320 | 1319 |
1321 } // namespace | 1320 } // namespace |
1322 } // namespace test | 1321 } // namespace test |
1323 } // namespace net | 1322 } // namespace net |
OLD | NEW |