| 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 <cstdint> | 7 #include <cstdint> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 MOCK_METHOD0(OnCanWrite, void()); | 87 MOCK_METHOD0(OnCanWrite, void()); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 class TestStream : public QuicSpdyStream { | 90 class TestStream : public QuicSpdyStream { |
| 91 public: | 91 public: |
| 92 TestStream(QuicStreamId id, QuicSpdySession* session) | 92 TestStream(QuicStreamId id, QuicSpdySession* session) |
| 93 : QuicSpdyStream(id, session) {} | 93 : QuicSpdyStream(id, session) {} |
| 94 | 94 |
| 95 using QuicStream::CloseWriteSide; | 95 using QuicStream::CloseWriteSide; |
| 96 using QuicStream::SetIsDeletable; |
| 96 | 97 |
| 97 void OnDataAvailable() override {} | 98 void OnDataAvailable() override {} |
| 98 | 99 |
| 99 MOCK_METHOD0(OnCanWrite, void()); | 100 MOCK_METHOD0(OnCanWrite, void()); |
| 100 }; | 101 }; |
| 101 | 102 |
| 102 // Poor man's functor for use as callback in a mock. | 103 // Poor man's functor for use as callback in a mock. |
| 103 class StreamBlocker { | 104 class StreamBlocker { |
| 104 public: | 105 public: |
| 105 StreamBlocker(QuicSession* session, QuicStreamId stream_id) | 106 StreamBlocker(QuicSession* session, QuicStreamId stream_id) |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 QuicConsumedData SendLargeFakeData(QuicStream* stream, int bytes) { | 222 QuicConsumedData SendLargeFakeData(QuicStream* stream, int bytes) { |
| 222 DCHECK(writev_consumes_all_data_); | 223 DCHECK(writev_consumes_all_data_); |
| 223 struct iovec iov; | 224 struct iovec iov; |
| 224 iov.iov_base = nullptr; // should not be read. | 225 iov.iov_base = nullptr; // should not be read. |
| 225 iov.iov_len = static_cast<size_t>(bytes); | 226 iov.iov_len = static_cast<size_t>(bytes); |
| 226 return WritevData(stream, stream->id(), QuicIOVector(&iov, 1, bytes), 0, | 227 return WritevData(stream, stream->id(), QuicIOVector(&iov, 1, bytes), 0, |
| 227 FIN, nullptr); | 228 FIN, nullptr); |
| 228 } | 229 } |
| 229 | 230 |
| 230 using QuicSession::PostProcessAfterData; | 231 using QuicSession::PostProcessAfterData; |
| 232 using QuicSession::closed_streams; |
| 233 using QuicSession::zombie_streams; |
| 231 | 234 |
| 232 private: | 235 private: |
| 233 StrictMock<TestCryptoStream> crypto_stream_; | 236 StrictMock<TestCryptoStream> crypto_stream_; |
| 234 | 237 |
| 235 bool writev_consumes_all_data_; | 238 bool writev_consumes_all_data_; |
| 236 }; | 239 }; |
| 237 | 240 |
| 238 class QuicSessionTestBase : public QuicTestWithParam<QuicVersion> { | 241 class QuicSessionTestBase : public QuicTestWithParam<QuicVersion> { |
| 239 protected: | 242 protected: |
| 240 explicit QuicSessionTestBase(Perspective perspective) | 243 explicit QuicSessionTestBase(Perspective perspective) |
| (...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1339 TEST_P(QuicSessionTestClient, EnableFHOLThroughConfigOption) { | 1342 TEST_P(QuicSessionTestClient, EnableFHOLThroughConfigOption) { |
| 1340 session_.config()->SetForceHolBlocking(); | 1343 session_.config()->SetForceHolBlocking(); |
| 1341 session_.OnConfigNegotiated(); | 1344 session_.OnConfigNegotiated(); |
| 1342 if (version() != QUIC_VERSION_36) { | 1345 if (version() != QUIC_VERSION_36) { |
| 1343 EXPECT_FALSE(session_.force_hol_blocking()); | 1346 EXPECT_FALSE(session_.force_hol_blocking()); |
| 1344 } else { | 1347 } else { |
| 1345 EXPECT_TRUE(session_.force_hol_blocking()); | 1348 EXPECT_TRUE(session_.force_hol_blocking()); |
| 1346 } | 1349 } |
| 1347 } | 1350 } |
| 1348 | 1351 |
| 1352 TEST_P(QuicSessionTestServer, ZombieStreams) { |
| 1353 if (!session_.use_stream_notifier()) { |
| 1354 return; |
| 1355 } |
| 1356 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority); |
| 1357 stream2->SetIsDeletable(false); |
| 1358 |
| 1359 EXPECT_CALL(*connection_, SendRstStream(2, _, _)); |
| 1360 session_.CloseStream(2); |
| 1361 EXPECT_TRUE(ContainsKey(session_.zombie_streams(), 2)); |
| 1362 EXPECT_TRUE(session_.closed_streams()->empty()); |
| 1363 stream2->SetIsDeletable(true); |
| 1364 EXPECT_FALSE(ContainsKey(session_.zombie_streams(), 2)); |
| 1365 EXPECT_EQ(1u, session_.closed_streams()->size()); |
| 1366 EXPECT_EQ(2u, session_.closed_streams()->front()->id()); |
| 1367 } |
| 1368 |
| 1349 } // namespace | 1369 } // namespace |
| 1350 } // namespace test | 1370 } // namespace test |
| 1351 } // namespace net | 1371 } // namespace net |
| OLD | NEW |