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