| 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/quic_session.h" | 5 #include "net/quic/quic_session.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| 11 #include "net/quic/crypto/crypto_handshake.h" | 11 #include "net/quic/crypto/crypto_handshake.h" |
| 12 #include "net/quic/quic_connection.h" | 12 #include "net/quic/quic_connection.h" |
| 13 #include "net/quic/quic_protocol.h" | 13 #include "net/quic/quic_protocol.h" |
| 14 #include "net/quic/test_tools/quic_connection_peer.h" | 14 #include "net/quic/test_tools/quic_connection_peer.h" |
| 15 #include "net/quic/test_tools/quic_data_stream_peer.h" |
| 15 #include "net/quic/test_tools/quic_test_utils.h" | 16 #include "net/quic/test_tools/quic_test_utils.h" |
| 16 #include "net/quic/test_tools/reliable_quic_stream_peer.h" | 17 #include "net/quic/test_tools/reliable_quic_stream_peer.h" |
| 17 #include "net/spdy/spdy_framer.h" | 18 #include "net/spdy/spdy_framer.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 21 |
| 21 using base::hash_map; | 22 using base::hash_map; |
| 22 using std::set; | 23 using std::set; |
| 23 using std::vector; | 24 using std::vector; |
| 24 using testing::_; | 25 using testing::_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 48 const QuicErrorCode error = session()->config()->ProcessClientHello( | 49 const QuicErrorCode error = session()->config()->ProcessClientHello( |
| 49 msg, &error_details); | 50 msg, &error_details); |
| 50 EXPECT_EQ(QUIC_NO_ERROR, error); | 51 EXPECT_EQ(QUIC_NO_ERROR, error); |
| 51 session()->OnConfigNegotiated(); | 52 session()->OnConfigNegotiated(); |
| 52 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); | 53 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); |
| 53 } | 54 } |
| 54 | 55 |
| 55 MOCK_METHOD0(OnCanWrite, void()); | 56 MOCK_METHOD0(OnCanWrite, void()); |
| 56 }; | 57 }; |
| 57 | 58 |
| 58 class TestStream : public ReliableQuicStream { | 59 class TestStream : public QuicDataStream { |
| 59 public: | 60 public: |
| 60 TestStream(QuicStreamId id, QuicSession* session) | 61 TestStream(QuicStreamId id, QuicSession* session) |
| 61 : ReliableQuicStream(id, session) { | 62 : QuicDataStream(id, session) { |
| 62 } | 63 } |
| 63 | 64 |
| 64 using ReliableQuicStream::CloseWriteSide; | 65 using ReliableQuicStream::CloseWriteSide; |
| 65 | 66 |
| 66 virtual uint32 ProcessData(const char* data, uint32 data_len) { | 67 virtual uint32 ProcessData(const char* data, uint32 data_len) { |
| 67 return data_len; | 68 return data_len; |
| 68 } | 69 } |
| 69 | 70 |
| 70 MOCK_METHOD0(OnCanWrite, void()); | 71 MOCK_METHOD0(OnCanWrite, void()); |
| 71 }; | 72 }; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 91 public: | 92 public: |
| 92 TestSession(QuicConnection* connection, bool is_server) | 93 TestSession(QuicConnection* connection, bool is_server) |
| 93 : QuicSession(connection, DefaultQuicConfig(), is_server), | 94 : QuicSession(connection, DefaultQuicConfig(), is_server), |
| 94 crypto_stream_(this) { | 95 crypto_stream_(this) { |
| 95 } | 96 } |
| 96 | 97 |
| 97 virtual TestCryptoStream* GetCryptoStream() OVERRIDE { | 98 virtual TestCryptoStream* GetCryptoStream() OVERRIDE { |
| 98 return &crypto_stream_; | 99 return &crypto_stream_; |
| 99 } | 100 } |
| 100 | 101 |
| 101 virtual TestStream* CreateOutgoingReliableStream() OVERRIDE { | 102 virtual TestStream* CreateOutgoingDataStream() OVERRIDE { |
| 102 TestStream* stream = new TestStream(GetNextStreamId(), this); | 103 TestStream* stream = new TestStream(GetNextStreamId(), this); |
| 103 ActivateStream(stream); | 104 ActivateStream(stream); |
| 104 return stream; | 105 return stream; |
| 105 } | 106 } |
| 106 | 107 |
| 107 virtual TestStream* CreateIncomingReliableStream(QuicStreamId id) OVERRIDE { | 108 virtual TestStream* CreateIncomingDataStream(QuicStreamId id) OVERRIDE { |
| 108 return new TestStream(id, this); | 109 return new TestStream(id, this); |
| 109 } | 110 } |
| 110 | 111 |
| 111 bool IsClosedStream(QuicStreamId id) { | 112 bool IsClosedStream(QuicStreamId id) { |
| 112 return QuicSession::IsClosedStream(id); | 113 return QuicSession::IsClosedStream(id); |
| 113 } | 114 } |
| 114 | 115 |
| 115 ReliableQuicStream* GetIncomingReliableStream(QuicStreamId stream_id) { | 116 QuicDataStream* GetIncomingReliableStream(QuicStreamId stream_id) { |
| 116 return QuicSession::GetIncomingReliableStream(stream_id); | 117 return QuicSession::GetIncomingReliableStream(stream_id); |
| 117 } | 118 } |
| 118 | 119 |
| 119 TestCryptoStream crypto_stream_; | 120 TestCryptoStream crypto_stream_; |
| 120 }; | 121 }; |
| 121 | 122 |
| 122 class QuicSessionTest : public ::testing::Test { | 123 class QuicSessionTest : public ::testing::Test { |
| 123 protected: | 124 protected: |
| 124 QuicSessionTest() | 125 QuicSessionTest() |
| 125 : guid_(1), | 126 : guid_(1), |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 TEST_F(QuicSessionTest, ImplicitlyCreatedStreams) { | 198 TEST_F(QuicSessionTest, ImplicitlyCreatedStreams) { |
| 198 ASSERT_TRUE(session_.GetIncomingReliableStream(7) != NULL); | 199 ASSERT_TRUE(session_.GetIncomingReliableStream(7) != NULL); |
| 199 // Both 3 and 5 should be implicitly created. | 200 // Both 3 and 5 should be implicitly created. |
| 200 EXPECT_FALSE(session_.IsClosedStream(3)); | 201 EXPECT_FALSE(session_.IsClosedStream(3)); |
| 201 EXPECT_FALSE(session_.IsClosedStream(5)); | 202 EXPECT_FALSE(session_.IsClosedStream(5)); |
| 202 ASSERT_TRUE(session_.GetIncomingReliableStream(5) != NULL); | 203 ASSERT_TRUE(session_.GetIncomingReliableStream(5) != NULL); |
| 203 ASSERT_TRUE(session_.GetIncomingReliableStream(3) != NULL); | 204 ASSERT_TRUE(session_.GetIncomingReliableStream(3) != NULL); |
| 204 } | 205 } |
| 205 | 206 |
| 206 TEST_F(QuicSessionTest, IsClosedStreamLocallyCreated) { | 207 TEST_F(QuicSessionTest, IsClosedStreamLocallyCreated) { |
| 207 TestStream* stream2 = session_.CreateOutgoingReliableStream(); | 208 TestStream* stream2 = session_.CreateOutgoingDataStream(); |
| 208 EXPECT_EQ(2u, stream2->id()); | 209 EXPECT_EQ(2u, stream2->id()); |
| 209 ReliableQuicStreamPeer::SetHeadersDecompressed(stream2, true); | 210 QuicDataStreamPeer::SetHeadersDecompressed(stream2, true); |
| 210 TestStream* stream4 = session_.CreateOutgoingReliableStream(); | 211 TestStream* stream4 = session_.CreateOutgoingDataStream(); |
| 211 EXPECT_EQ(4u, stream4->id()); | 212 EXPECT_EQ(4u, stream4->id()); |
| 212 ReliableQuicStreamPeer::SetHeadersDecompressed(stream4, true); | 213 QuicDataStreamPeer::SetHeadersDecompressed(stream4, true); |
| 213 | 214 |
| 214 CheckClosedStreams(); | 215 CheckClosedStreams(); |
| 215 CloseStream(4); | 216 CloseStream(4); |
| 216 CheckClosedStreams(); | 217 CheckClosedStreams(); |
| 217 CloseStream(2); | 218 CloseStream(2); |
| 218 CheckClosedStreams(); | 219 CheckClosedStreams(); |
| 219 } | 220 } |
| 220 | 221 |
| 221 TEST_F(QuicSessionTest, IsClosedStreamPeerCreated) { | 222 TEST_F(QuicSessionTest, IsClosedStreamPeerCreated) { |
| 222 ReliableQuicStream* stream3 = session_.GetIncomingReliableStream(3); | 223 QuicDataStream* stream3 = session_.GetIncomingReliableStream(3); |
| 223 ReliableQuicStreamPeer::SetHeadersDecompressed(stream3, true); | 224 QuicDataStreamPeer::SetHeadersDecompressed(stream3, true); |
| 224 ReliableQuicStream* stream5 = session_.GetIncomingReliableStream(5); | 225 QuicDataStream* stream5 = session_.GetIncomingReliableStream(5); |
| 225 ReliableQuicStreamPeer::SetHeadersDecompressed(stream5, true); | 226 QuicDataStreamPeer::SetHeadersDecompressed(stream5, true); |
| 226 | 227 |
| 227 CheckClosedStreams(); | 228 CheckClosedStreams(); |
| 228 CloseStream(3); | 229 CloseStream(3); |
| 229 CheckClosedStreams(); | 230 CheckClosedStreams(); |
| 230 CloseStream(5); | 231 CloseStream(5); |
| 231 // Create stream id 9, and implicitly 7 | 232 // Create stream id 9, and implicitly 7 |
| 232 ReliableQuicStream* stream9 = session_.GetIncomingReliableStream(9); | 233 QuicDataStream* stream9 = session_.GetIncomingReliableStream(9); |
| 233 ReliableQuicStreamPeer::SetHeadersDecompressed(stream9, true); | 234 QuicDataStreamPeer::SetHeadersDecompressed(stream9, true); |
| 234 CheckClosedStreams(); | 235 CheckClosedStreams(); |
| 235 // Close 9, but make sure 7 is still not closed | 236 // Close 9, but make sure 7 is still not closed |
| 236 CloseStream(9); | 237 CloseStream(9); |
| 237 CheckClosedStreams(); | 238 CheckClosedStreams(); |
| 238 } | 239 } |
| 239 | 240 |
| 240 TEST_F(QuicSessionTest, StreamIdTooLarge) { | 241 TEST_F(QuicSessionTest, StreamIdTooLarge) { |
| 241 session_.GetIncomingReliableStream(3); | 242 session_.GetIncomingReliableStream(3); |
| 242 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_INVALID_STREAM_ID)); | 243 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_INVALID_STREAM_ID)); |
| 243 session_.GetIncomingReliableStream(105); | 244 session_.GetIncomingReliableStream(105); |
| 244 } | 245 } |
| 245 | 246 |
| 246 TEST_F(QuicSessionTest, DecompressionError) { | 247 TEST_F(QuicSessionTest, DecompressionError) { |
| 247 ReliableQuicStream* stream = session_.GetIncomingReliableStream(3); | 248 ReliableQuicStream* stream = session_.GetIncomingReliableStream(3); |
| 248 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_DECOMPRESSION_FAILURE)); | 249 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_DECOMPRESSION_FAILURE)); |
| 249 const char data[] = | 250 const char data[] = |
| 250 "\1\0\0\0" // headers id | 251 "\1\0\0\0" // headers id |
| 251 "\0\0\0\4" // length | 252 "\0\0\0\4" // length |
| 252 "abcd"; // invalid compressed data | 253 "abcd"; // invalid compressed data |
| 253 stream->ProcessRawData(data, arraysize(data)); | 254 stream->ProcessRawData(data, arraysize(data)); |
| 254 } | 255 } |
| 255 | 256 |
| 256 TEST_F(QuicSessionTest, OnCanWrite) { | 257 TEST_F(QuicSessionTest, OnCanWrite) { |
| 257 TestStream* stream2 = session_.CreateOutgoingReliableStream(); | 258 TestStream* stream2 = session_.CreateOutgoingDataStream(); |
| 258 TestStream* stream4 = session_.CreateOutgoingReliableStream(); | 259 TestStream* stream4 = session_.CreateOutgoingDataStream(); |
| 259 TestStream* stream6 = session_.CreateOutgoingReliableStream(); | 260 TestStream* stream6 = session_.CreateOutgoingDataStream(); |
| 260 | 261 |
| 261 session_.MarkWriteBlocked(stream2->id(), kSomeMiddlePriority); | 262 session_.MarkWriteBlocked(stream2->id(), kSomeMiddlePriority); |
| 262 session_.MarkWriteBlocked(stream6->id(), kSomeMiddlePriority); | 263 session_.MarkWriteBlocked(stream6->id(), kSomeMiddlePriority); |
| 263 session_.MarkWriteBlocked(stream4->id(), kSomeMiddlePriority); | 264 session_.MarkWriteBlocked(stream4->id(), kSomeMiddlePriority); |
| 264 | 265 |
| 265 InSequence s; | 266 InSequence s; |
| 266 StreamBlocker stream2_blocker(&session_, stream2->id()); | 267 StreamBlocker stream2_blocker(&session_, stream2->id()); |
| 267 EXPECT_CALL(*stream2, OnCanWrite()).WillOnce( | 268 EXPECT_CALL(*stream2, OnCanWrite()).WillOnce( |
| 268 // Reregister, to test the loop limit. | 269 // Reregister, to test the loop limit. |
| 269 InvokeWithoutArgs(&stream2_blocker, &StreamBlocker::MarkWriteBlocked)); | 270 InvokeWithoutArgs(&stream2_blocker, &StreamBlocker::MarkWriteBlocked)); |
| 270 EXPECT_CALL(*stream6, OnCanWrite()); | 271 EXPECT_CALL(*stream6, OnCanWrite()); |
| 271 EXPECT_CALL(*stream4, OnCanWrite()); | 272 EXPECT_CALL(*stream4, OnCanWrite()); |
| 272 | 273 |
| 273 EXPECT_FALSE(session_.OnCanWrite()); | 274 EXPECT_FALSE(session_.OnCanWrite()); |
| 274 } | 275 } |
| 275 | 276 |
| 276 TEST_F(QuicSessionTest, BufferedHandshake) { | 277 TEST_F(QuicSessionTest, BufferedHandshake) { |
| 277 EXPECT_FALSE(session_.HasPendingHandshake()); // Default value. | 278 EXPECT_FALSE(session_.HasPendingHandshake()); // Default value. |
| 278 | 279 |
| 279 // Test that blocking other streams does not change our status. | 280 // Test that blocking other streams does not change our status. |
| 280 TestStream* stream2 = session_.CreateOutgoingReliableStream(); | 281 TestStream* stream2 = session_.CreateOutgoingDataStream(); |
| 281 StreamBlocker stream2_blocker(&session_, stream2->id()); | 282 StreamBlocker stream2_blocker(&session_, stream2->id()); |
| 282 stream2_blocker.MarkWriteBlocked(); | 283 stream2_blocker.MarkWriteBlocked(); |
| 283 EXPECT_FALSE(session_.HasPendingHandshake()); | 284 EXPECT_FALSE(session_.HasPendingHandshake()); |
| 284 | 285 |
| 285 TestStream* stream3 = session_.CreateOutgoingReliableStream(); | 286 TestStream* stream3 = session_.CreateOutgoingDataStream(); |
| 286 StreamBlocker stream3_blocker(&session_, stream3->id()); | 287 StreamBlocker stream3_blocker(&session_, stream3->id()); |
| 287 stream3_blocker.MarkWriteBlocked(); | 288 stream3_blocker.MarkWriteBlocked(); |
| 288 EXPECT_FALSE(session_.HasPendingHandshake()); | 289 EXPECT_FALSE(session_.HasPendingHandshake()); |
| 289 | 290 |
| 290 // Blocking (due to buffering of) the Crypto stream is detected. | 291 // Blocking (due to buffering of) the Crypto stream is detected. |
| 291 session_.MarkWriteBlocked(kCryptoStreamId, kSomeMiddlePriority); | 292 session_.MarkWriteBlocked(kCryptoStreamId, kSomeMiddlePriority); |
| 292 EXPECT_TRUE(session_.HasPendingHandshake()); | 293 EXPECT_TRUE(session_.HasPendingHandshake()); |
| 293 | 294 |
| 294 TestStream* stream4 = session_.CreateOutgoingReliableStream(); | 295 TestStream* stream4 = session_.CreateOutgoingDataStream(); |
| 295 StreamBlocker stream4_blocker(&session_, stream4->id()); | 296 StreamBlocker stream4_blocker(&session_, stream4->id()); |
| 296 stream4_blocker.MarkWriteBlocked(); | 297 stream4_blocker.MarkWriteBlocked(); |
| 297 EXPECT_TRUE(session_.HasPendingHandshake()); | 298 EXPECT_TRUE(session_.HasPendingHandshake()); |
| 298 | 299 |
| 299 InSequence s; | 300 InSequence s; |
| 300 // Force most streams to re-register, which is common scenario when we block | 301 // Force most streams to re-register, which is common scenario when we block |
| 301 // the Crypto stream, and only the crypto stream can "really" write. | 302 // the Crypto stream, and only the crypto stream can "really" write. |
| 302 | 303 |
| 303 // Due to prioritization, we *should* be asked to write the crypto stream | 304 // Due to prioritization, we *should* be asked to write the crypto stream |
| 304 // first. | 305 // first. |
| 305 // Don't re-register the crypto stream (which signals complete writing). | 306 // Don't re-register the crypto stream (which signals complete writing). |
| 306 TestCryptoStream* crypto_stream = session_.GetCryptoStream(); | 307 TestCryptoStream* crypto_stream = session_.GetCryptoStream(); |
| 307 EXPECT_CALL(*crypto_stream, OnCanWrite()); | 308 EXPECT_CALL(*crypto_stream, OnCanWrite()); |
| 308 | 309 |
| 309 // Re-register all other streams, to show they weren't able to proceed. | 310 // Re-register all other streams, to show they weren't able to proceed. |
| 310 EXPECT_CALL(*stream2, OnCanWrite()).WillOnce( | 311 EXPECT_CALL(*stream2, OnCanWrite()).WillOnce( |
| 311 InvokeWithoutArgs(&stream2_blocker, &StreamBlocker::MarkWriteBlocked)); | 312 InvokeWithoutArgs(&stream2_blocker, &StreamBlocker::MarkWriteBlocked)); |
| 312 | 313 |
| 313 EXPECT_CALL(*stream3, OnCanWrite()).WillOnce( | 314 EXPECT_CALL(*stream3, OnCanWrite()).WillOnce( |
| 314 InvokeWithoutArgs(&stream3_blocker, &StreamBlocker::MarkWriteBlocked)); | 315 InvokeWithoutArgs(&stream3_blocker, &StreamBlocker::MarkWriteBlocked)); |
| 315 | 316 |
| 316 EXPECT_CALL(*stream4, OnCanWrite()).WillOnce( | 317 EXPECT_CALL(*stream4, OnCanWrite()).WillOnce( |
| 317 InvokeWithoutArgs(&stream4_blocker, &StreamBlocker::MarkWriteBlocked)); | 318 InvokeWithoutArgs(&stream4_blocker, &StreamBlocker::MarkWriteBlocked)); |
| 318 | 319 |
| 319 EXPECT_FALSE(session_.OnCanWrite()); | 320 EXPECT_FALSE(session_.OnCanWrite()); |
| 320 EXPECT_FALSE(session_.HasPendingHandshake()); // Crypto stream wrote. | 321 EXPECT_FALSE(session_.HasPendingHandshake()); // Crypto stream wrote. |
| 321 } | 322 } |
| 322 | 323 |
| 323 TEST_F(QuicSessionTest, OnCanWriteWithClosedStream) { | 324 TEST_F(QuicSessionTest, OnCanWriteWithClosedStream) { |
| 324 TestStream* stream2 = session_.CreateOutgoingReliableStream(); | 325 TestStream* stream2 = session_.CreateOutgoingDataStream(); |
| 325 TestStream* stream4 = session_.CreateOutgoingReliableStream(); | 326 TestStream* stream4 = session_.CreateOutgoingDataStream(); |
| 326 TestStream* stream6 = session_.CreateOutgoingReliableStream(); | 327 TestStream* stream6 = session_.CreateOutgoingDataStream(); |
| 327 | 328 |
| 328 session_.MarkWriteBlocked(stream2->id(), kSomeMiddlePriority); | 329 session_.MarkWriteBlocked(stream2->id(), kSomeMiddlePriority); |
| 329 session_.MarkWriteBlocked(stream6->id(), kSomeMiddlePriority); | 330 session_.MarkWriteBlocked(stream6->id(), kSomeMiddlePriority); |
| 330 session_.MarkWriteBlocked(stream4->id(), kSomeMiddlePriority); | 331 session_.MarkWriteBlocked(stream4->id(), kSomeMiddlePriority); |
| 331 CloseStream(stream6->id()); | 332 CloseStream(stream6->id()); |
| 332 | 333 |
| 333 InSequence s; | 334 InSequence s; |
| 334 EXPECT_CALL(*stream2, OnCanWrite()); | 335 EXPECT_CALL(*stream2, OnCanWrite()); |
| 335 EXPECT_CALL(*stream4, OnCanWrite()); | 336 EXPECT_CALL(*stream4, OnCanWrite()); |
| 336 EXPECT_TRUE(session_.OnCanWrite()); | 337 EXPECT_TRUE(session_.OnCanWrite()); |
| 337 } | 338 } |
| 338 | 339 |
| 339 // Regression test for http://crbug.com/248737 | 340 // Regression test for http://crbug.com/248737 |
| 340 TEST_F(QuicSessionTest, OutOfOrderHeaders) { | 341 TEST_F(QuicSessionTest, OutOfOrderHeaders) { |
| 341 QuicSpdyCompressor compressor; | 342 QuicSpdyCompressor compressor; |
| 342 vector<QuicStreamFrame> frames; | 343 vector<QuicStreamFrame> frames; |
| 343 QuicPacketHeader header; | 344 QuicPacketHeader header; |
| 344 header.public_header.guid = session_.guid(); | 345 header.public_header.guid = session_.guid(); |
| 345 | 346 |
| 346 TestStream* stream2 = session_.CreateOutgoingReliableStream(); | 347 TestStream* stream2 = session_.CreateOutgoingDataStream(); |
| 347 TestStream* stream4 = session_.CreateOutgoingReliableStream(); | 348 TestStream* stream4 = session_.CreateOutgoingDataStream(); |
| 348 stream2->CloseWriteSide(); | 349 stream2->CloseWriteSide(); |
| 349 stream4->CloseWriteSide(); | 350 stream4->CloseWriteSide(); |
| 350 | 351 |
| 351 // Create frame with headers for stream2. | 352 // Create frame with headers for stream2. |
| 352 string compressed_headers1 = compressor.CompressHeaders(headers_); | 353 string compressed_headers1 = compressor.CompressHeaders(headers_); |
| 353 QuicStreamFrame frame1( | 354 QuicStreamFrame frame1( |
| 354 stream2->id(), false, 0, MakeIOVector(compressed_headers1)); | 355 stream2->id(), false, 0, MakeIOVector(compressed_headers1)); |
| 355 | 356 |
| 356 // Create frame with headers for stream4. | 357 // Create frame with headers for stream4. |
| 357 string compressed_headers2 = compressor.CompressHeaders(headers_); | 358 string compressed_headers2 = compressor.CompressHeaders(headers_); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 session_.crypto_stream_.OnHandshakeMessage(msg); | 391 session_.crypto_stream_.OnHandshakeMessage(msg); |
| 391 EXPECT_EQ(kDefaultTimeoutSecs, | 392 EXPECT_EQ(kDefaultTimeoutSecs, |
| 392 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds()); | 393 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds()); |
| 393 } | 394 } |
| 394 | 395 |
| 395 TEST_F(QuicSessionTest, ZombieStream) { | 396 TEST_F(QuicSessionTest, ZombieStream) { |
| 396 StrictMock<MockConnection>* connection = | 397 StrictMock<MockConnection>* connection = |
| 397 new StrictMock<MockConnection>(guid_, IPEndPoint(), false); | 398 new StrictMock<MockConnection>(guid_, IPEndPoint(), false); |
| 398 TestSession session(connection, /*is_server=*/ false); | 399 TestSession session(connection, /*is_server=*/ false); |
| 399 | 400 |
| 400 TestStream* stream3 = session.CreateOutgoingReliableStream(); | 401 TestStream* stream3 = session.CreateOutgoingDataStream(); |
| 401 EXPECT_EQ(3u, stream3->id()); | 402 EXPECT_EQ(3u, stream3->id()); |
| 402 TestStream* stream5 = session.CreateOutgoingReliableStream(); | 403 TestStream* stream5 = session.CreateOutgoingDataStream(); |
| 403 EXPECT_EQ(5u, stream5->id()); | 404 EXPECT_EQ(5u, stream5->id()); |
| 404 EXPECT_EQ(2u, session.GetNumOpenStreams()); | 405 EXPECT_EQ(2u, session.GetNumOpenStreams()); |
| 405 | 406 |
| 406 // Reset the stream, but since the headers have not been decompressed | 407 // Reset the stream, but since the headers have not been decompressed |
| 407 // it will become a zombie and will continue to process data | 408 // it will become a zombie and will continue to process data |
| 408 // until the headers are decompressed. | 409 // until the headers are decompressed. |
| 409 EXPECT_CALL(*connection, SendRstStream(3, QUIC_STREAM_CANCELLED)); | 410 EXPECT_CALL(*connection, SendRstStream(3, QUIC_STREAM_CANCELLED)); |
| 410 session.SendRstStream(3, QUIC_STREAM_CANCELLED); | 411 session.SendRstStream(3, QUIC_STREAM_CANCELLED); |
| 411 | 412 |
| 412 EXPECT_EQ(1u, session.GetNumOpenStreams()); | 413 EXPECT_EQ(1u, session.GetNumOpenStreams()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 430 EXPECT_EQ(1u, session.GetNumOpenStreams()); | 431 EXPECT_EQ(1u, session.GetNumOpenStreams()); |
| 431 | 432 |
| 432 EXPECT_TRUE(connection->connected()); | 433 EXPECT_TRUE(connection->connected()); |
| 433 } | 434 } |
| 434 | 435 |
| 435 TEST_F(QuicSessionTest, ZombieStreamConnectionClose) { | 436 TEST_F(QuicSessionTest, ZombieStreamConnectionClose) { |
| 436 StrictMock<MockConnection>* connection = | 437 StrictMock<MockConnection>* connection = |
| 437 new StrictMock<MockConnection>(guid_, IPEndPoint(), false); | 438 new StrictMock<MockConnection>(guid_, IPEndPoint(), false); |
| 438 TestSession session(connection, /*is_server=*/ false); | 439 TestSession session(connection, /*is_server=*/ false); |
| 439 | 440 |
| 440 TestStream* stream3 = session.CreateOutgoingReliableStream(); | 441 TestStream* stream3 = session.CreateOutgoingDataStream(); |
| 441 EXPECT_EQ(3u, stream3->id()); | 442 EXPECT_EQ(3u, stream3->id()); |
| 442 TestStream* stream5 = session.CreateOutgoingReliableStream(); | 443 TestStream* stream5 = session.CreateOutgoingDataStream(); |
| 443 EXPECT_EQ(5u, stream5->id()); | 444 EXPECT_EQ(5u, stream5->id()); |
| 444 EXPECT_EQ(2u, session.GetNumOpenStreams()); | 445 EXPECT_EQ(2u, session.GetNumOpenStreams()); |
| 445 | 446 |
| 446 stream3->CloseWriteSide(); | 447 stream3->CloseWriteSide(); |
| 447 // Reset the stream, but since the headers have not been decompressed | 448 // Reset the stream, but since the headers have not been decompressed |
| 448 // it will become a zombie and will continue to process data | 449 // it will become a zombie and will continue to process data |
| 449 // until the headers are decompressed. | 450 // until the headers are decompressed. |
| 450 EXPECT_CALL(*connection, SendRstStream(3, QUIC_STREAM_CANCELLED)); | 451 EXPECT_CALL(*connection, SendRstStream(3, QUIC_STREAM_CANCELLED)); |
| 451 session.SendRstStream(3, QUIC_STREAM_CANCELLED); | 452 session.SendRstStream(3, QUIC_STREAM_CANCELLED); |
| 452 | 453 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 471 QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED)); | 472 QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED)); |
| 472 | 473 |
| 473 QuicRstStreamFrame rst1(3, QUIC_STREAM_NO_ERROR); | 474 QuicRstStreamFrame rst1(3, QUIC_STREAM_NO_ERROR); |
| 474 session_.OnRstStream(rst1); | 475 session_.OnRstStream(rst1); |
| 475 EXPECT_EQ(0u, session_.GetNumOpenStreams()); | 476 EXPECT_EQ(0u, session_.GetNumOpenStreams()); |
| 476 } | 477 } |
| 477 | 478 |
| 478 } // namespace | 479 } // namespace |
| 479 } // namespace test | 480 } // namespace test |
| 480 } // namespace net | 481 } // namespace net |
| OLD | NEW |