| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/spdy/spdy_stream.h" | 5 #include "net/spdy/spdy_stream.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <cstddef> | 9 #include <cstddef> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "net/log/test_net_log.h" | 22 #include "net/log/test_net_log.h" |
| 23 #include "net/log/test_net_log_entry.h" | 23 #include "net/log/test_net_log_entry.h" |
| 24 #include "net/log/test_net_log_util.h" | 24 #include "net/log/test_net_log_util.h" |
| 25 #include "net/socket/socket_test_util.h" | 25 #include "net/socket/socket_test_util.h" |
| 26 #include "net/spdy/buffered_spdy_framer.h" | 26 #include "net/spdy/buffered_spdy_framer.h" |
| 27 #include "net/spdy/spdy_http_utils.h" | 27 #include "net/spdy/spdy_http_utils.h" |
| 28 #include "net/spdy/spdy_protocol.h" | 28 #include "net/spdy/spdy_protocol.h" |
| 29 #include "net/spdy/spdy_session.h" | 29 #include "net/spdy/spdy_session.h" |
| 30 #include "net/spdy/spdy_stream_test_util.h" | 30 #include "net/spdy/spdy_stream_test_util.h" |
| 31 #include "net/spdy/spdy_test_util_common.h" | 31 #include "net/spdy/spdy_test_util_common.h" |
| 32 #include "net/test/cert_test_util.h" |
| 32 #include "net/test/gtest_util.h" | 33 #include "net/test/gtest_util.h" |
| 34 #include "net/test/test_data_directory.h" |
| 33 #include "testing/gmock/include/gmock/gmock.h" | 35 #include "testing/gmock/include/gmock/gmock.h" |
| 34 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
| 35 | 37 |
| 36 using net::test::IsError; | 38 using net::test::IsError; |
| 37 using net::test::IsOk; | 39 using net::test::IsOk; |
| 38 | 40 |
| 39 // TODO(ukai): factor out common part with spdy_http_stream_unittest.cc | 41 // TODO(ukai): factor out common part with spdy_http_stream_unittest.cc |
| 40 // | 42 // |
| 41 namespace net { | 43 namespace net { |
| 42 | 44 |
| 43 namespace test { | 45 namespace test { |
| 44 | 46 |
| 45 namespace { | 47 namespace { |
| 46 | 48 |
| 47 const char kStreamUrl[] = "http://www.example.org/"; | 49 const char kStreamUrl[] = "http://www.example.org/"; |
| 48 const char kPostBody[] = "\0hello!\xff"; | 50 const char kPostBody[] = "\0hello!\xff"; |
| 49 const size_t kPostBodyLength = arraysize(kPostBody); | 51 const size_t kPostBodyLength = arraysize(kPostBody); |
| 50 const base::StringPiece kPostBodyStringPiece(kPostBody, kPostBodyLength); | 52 const base::StringPiece kPostBodyStringPiece(kPostBody, kPostBodyLength); |
| 51 | 53 |
| 52 } // namespace | 54 } // namespace |
| 53 | 55 |
| 54 class SpdyStreamTest : public ::testing::Test { | 56 class SpdyStreamTest : public ::testing::Test { |
| 55 protected: | 57 protected: |
| 56 // A function that takes a SpdyStream and the number of bytes which | 58 // A function that takes a SpdyStream and the number of bytes which |
| 57 // will unstall the next frame completely. | 59 // will unstall the next frame completely. |
| 58 typedef base::Callback<void(const base::WeakPtr<SpdyStream>&, int32_t)> | 60 typedef base::Callback<void(const base::WeakPtr<SpdyStream>&, int32_t)> |
| 59 UnstallFunction; | 61 UnstallFunction; |
| 60 | 62 |
| 61 SpdyStreamTest() : offset_(0) { | 63 SpdyStreamTest() : offset_(0), ssl_(SYNCHRONOUS, OK) { |
| 62 spdy_util_.set_default_url(GURL(kStreamUrl)); | 64 spdy_util_.set_default_url(GURL(kStreamUrl)); |
| 63 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); | 65 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); |
| 64 } | 66 } |
| 65 | 67 |
| 66 ~SpdyStreamTest() override {} | 68 ~SpdyStreamTest() override {} |
| 67 | 69 |
| 68 base::WeakPtr<SpdySession> CreateDefaultSpdySession() { | 70 base::WeakPtr<SpdySession> CreateDefaultSpdySession() { |
| 69 SpdySessionKey key(HostPortPair("www.example.org", 80), | 71 SpdySessionKey key(HostPortPair("www.example.org", 80), |
| 70 ProxyServer::Direct(), PRIVACY_MODE_DISABLED); | 72 ProxyServer::Direct(), PRIVACY_MODE_DISABLED); |
| 71 return CreateInsecureSpdySession(session_.get(), key, NetLogWithSource()); | 73 return CreateSecureSpdySession(session_.get(), key, NetLogWithSource()); |
| 72 } | 74 } |
| 73 | 75 |
| 74 void TearDown() override { base::RunLoop().RunUntilIdle(); } | 76 void TearDown() override { base::RunLoop().RunUntilIdle(); } |
| 75 | 77 |
| 76 void RunResumeAfterUnstallRequestResponseTest( | 78 void RunResumeAfterUnstallRequestResponseTest( |
| 77 const UnstallFunction& unstall_function); | 79 const UnstallFunction& unstall_function); |
| 78 | 80 |
| 79 void RunResumeAfterUnstallBidirectionalTest( | 81 void RunResumeAfterUnstallBidirectionalTest( |
| 80 const UnstallFunction& unstall_function); | 82 const UnstallFunction& unstall_function); |
| 81 | 83 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 return writes_.size(); | 116 return writes_.size(); |
| 115 } | 117 } |
| 116 | 118 |
| 117 void ActivatePushStream(SpdySession* session, SpdyStream* stream) { | 119 void ActivatePushStream(SpdySession* session, SpdyStream* stream) { |
| 118 std::unique_ptr<SpdyStream> activated = | 120 std::unique_ptr<SpdyStream> activated = |
| 119 session->ActivateCreatedStream(stream); | 121 session->ActivateCreatedStream(stream); |
| 120 activated->set_stream_id(2); | 122 activated->set_stream_id(2); |
| 121 session->InsertActivatedStream(std::move(activated)); | 123 session->InsertActivatedStream(std::move(activated)); |
| 122 } | 124 } |
| 123 | 125 |
| 126 void AddSSLSocketData() { |
| 127 // Load a cert that is valid for |
| 128 // www.example.org, mail.example.org, and mail.example.com. |
| 129 ssl_.cert = ImportCertFromFile(GetTestCertsDirectory(), "spdy_pooling.pem"); |
| 130 ASSERT_TRUE(ssl_.cert); |
| 131 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_); |
| 132 } |
| 133 |
| 124 SpdyTestUtil spdy_util_; | 134 SpdyTestUtil spdy_util_; |
| 125 SpdySessionDependencies session_deps_; | 135 SpdySessionDependencies session_deps_; |
| 126 std::unique_ptr<HttpNetworkSession> session_; | 136 std::unique_ptr<HttpNetworkSession> session_; |
| 127 | 137 |
| 128 private: | 138 private: |
| 129 // Used by Add{Read,Write}() above. | 139 // Used by Add{Read,Write}() above. |
| 130 std::vector<MockWrite> writes_; | 140 std::vector<MockWrite> writes_; |
| 131 std::vector<MockRead> reads_; | 141 std::vector<MockRead> reads_; |
| 132 int offset_; | 142 int offset_; |
| 143 SSLSocketDataProvider ssl_; |
| 133 }; | 144 }; |
| 134 | 145 |
| 135 TEST_F(SpdyStreamTest, SendDataAfterOpen) { | 146 TEST_F(SpdyStreamTest, SendDataAfterOpen) { |
| 136 GURL url(kStreamUrl); | 147 GURL url(kStreamUrl); |
| 137 | 148 |
| 138 SpdySerializedFrame req(spdy_util_.ConstructSpdyPost( | 149 SpdySerializedFrame req(spdy_util_.ConstructSpdyPost( |
| 139 kStreamUrl, 1, kPostBodyLength, LOWEST, NULL, 0)); | 150 kStreamUrl, 1, kPostBodyLength, LOWEST, NULL, 0)); |
| 140 AddWrite(req); | 151 AddWrite(req); |
| 141 | 152 |
| 142 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); | 153 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); |
| 143 AddRead(resp); | 154 AddRead(resp); |
| 144 | 155 |
| 145 SpdySerializedFrame msg( | 156 SpdySerializedFrame msg( |
| 146 spdy_util_.ConstructSpdyDataFrame(1, kPostBody, kPostBodyLength, false)); | 157 spdy_util_.ConstructSpdyDataFrame(1, kPostBody, kPostBodyLength, false)); |
| 147 AddWrite(msg); | 158 AddWrite(msg); |
| 148 | 159 |
| 149 SpdySerializedFrame echo( | 160 SpdySerializedFrame echo( |
| 150 spdy_util_.ConstructSpdyDataFrame(1, kPostBody, kPostBodyLength, false)); | 161 spdy_util_.ConstructSpdyDataFrame(1, kPostBody, kPostBodyLength, false)); |
| 151 AddRead(echo); | 162 AddRead(echo); |
| 152 | 163 |
| 153 AddReadEOF(); | 164 AddReadEOF(); |
| 154 | 165 |
| 155 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), | 166 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), |
| 156 GetNumWrites()); | 167 GetNumWrites()); |
| 157 MockConnect connect_data(SYNCHRONOUS, OK); | 168 MockConnect connect_data(SYNCHRONOUS, OK); |
| 158 data.set_connect_data(connect_data); | 169 data.set_connect_data(connect_data); |
| 170 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 159 | 171 |
| 160 session_deps_.socket_factory->AddSocketDataProvider(&data); | 172 AddSSLSocketData(); |
| 161 | 173 |
| 162 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); | 174 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); |
| 163 | 175 |
| 164 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( | 176 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( |
| 165 SPDY_BIDIRECTIONAL_STREAM, session, url, LOWEST, NetLogWithSource()); | 177 SPDY_BIDIRECTIONAL_STREAM, session, url, LOWEST, NetLogWithSource()); |
| 166 ASSERT_TRUE(stream); | 178 ASSERT_TRUE(stream); |
| 167 | 179 |
| 168 StreamDelegateSendImmediate delegate(stream, kPostBodyStringPiece); | 180 StreamDelegateSendImmediate delegate(stream, kPostBodyStringPiece); |
| 169 stream->SetDelegate(&delegate); | 181 stream->SetDelegate(&delegate); |
| 170 | 182 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 SpdySerializedFrame trailers(spdy_util_.ConstructSpdyResponseHeaders( | 240 SpdySerializedFrame trailers(spdy_util_.ConstructSpdyResponseHeaders( |
| 229 1, std::move(late_headers), false)); | 241 1, std::move(late_headers), false)); |
| 230 AddRead(trailers); | 242 AddRead(trailers); |
| 231 | 243 |
| 232 AddReadEOF(); | 244 AddReadEOF(); |
| 233 | 245 |
| 234 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), | 246 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), |
| 235 GetNumWrites()); | 247 GetNumWrites()); |
| 236 MockConnect connect_data(SYNCHRONOUS, OK); | 248 MockConnect connect_data(SYNCHRONOUS, OK); |
| 237 data.set_connect_data(connect_data); | 249 data.set_connect_data(connect_data); |
| 250 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 238 | 251 |
| 239 session_deps_.socket_factory->AddSocketDataProvider(&data); | 252 AddSSLSocketData(); |
| 240 | 253 |
| 241 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); | 254 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); |
| 242 | 255 |
| 243 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( | 256 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( |
| 244 SPDY_REQUEST_RESPONSE_STREAM, session, url, LOWEST, NetLogWithSource()); | 257 SPDY_REQUEST_RESPONSE_STREAM, session, url, LOWEST, NetLogWithSource()); |
| 245 ASSERT_TRUE(stream); | 258 ASSERT_TRUE(stream); |
| 246 | 259 |
| 247 StreamDelegateWithTrailers delegate(stream, kPostBodyStringPiece); | 260 StreamDelegateWithTrailers delegate(stream, kPostBodyStringPiece); |
| 248 stream->SetDelegate(&delegate); | 261 stream->SetDelegate(&delegate); |
| 249 | 262 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 267 EXPECT_TRUE(data.AllWriteDataConsumed()); | 280 EXPECT_TRUE(data.AllWriteDataConsumed()); |
| 268 } | 281 } |
| 269 | 282 |
| 270 TEST_F(SpdyStreamTest, PushedStream) { | 283 TEST_F(SpdyStreamTest, PushedStream) { |
| 271 AddReadEOF(); | 284 AddReadEOF(); |
| 272 | 285 |
| 273 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), | 286 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), |
| 274 GetNumWrites()); | 287 GetNumWrites()); |
| 275 MockConnect connect_data(SYNCHRONOUS, OK); | 288 MockConnect connect_data(SYNCHRONOUS, OK); |
| 276 data.set_connect_data(connect_data); | 289 data.set_connect_data(connect_data); |
| 290 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 277 | 291 |
| 278 session_deps_.socket_factory->AddSocketDataProvider(&data); | 292 AddSSLSocketData(); |
| 279 | 293 |
| 280 base::WeakPtr<SpdySession> spdy_session(CreateDefaultSpdySession()); | 294 base::WeakPtr<SpdySession> spdy_session(CreateDefaultSpdySession()); |
| 281 | 295 |
| 282 // Conjure up a stream. | 296 // Conjure up a stream. |
| 283 SpdyStreamRequest stream_request; | 297 SpdyStreamRequest stream_request; |
| 284 int result = stream_request.StartRequest( | 298 int result = stream_request.StartRequest( |
| 285 SPDY_PUSH_STREAM, spdy_session, GURL(), DEFAULT_PRIORITY, | 299 SPDY_PUSH_STREAM, spdy_session, GURL(), DEFAULT_PRIORITY, |
| 286 NetLogWithSource(), CompletionCallback()); | 300 NetLogWithSource(), CompletionCallback()); |
| 287 ASSERT_THAT(result, IsOk()); | 301 ASSERT_THAT(result, IsOk()); |
| 288 base::WeakPtr<SpdyStream> stream = stream_request.ReleaseStream(); | 302 base::WeakPtr<SpdyStream> stream = stream_request.ReleaseStream(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 AddRead(echo); | 365 AddRead(echo); |
| 352 | 366 |
| 353 AddReadEOF(); | 367 AddReadEOF(); |
| 354 | 368 |
| 355 BoundTestNetLog log; | 369 BoundTestNetLog log; |
| 356 | 370 |
| 357 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), | 371 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), |
| 358 GetNumWrites()); | 372 GetNumWrites()); |
| 359 MockConnect connect_data(SYNCHRONOUS, OK); | 373 MockConnect connect_data(SYNCHRONOUS, OK); |
| 360 data.set_connect_data(connect_data); | 374 data.set_connect_data(connect_data); |
| 375 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 361 | 376 |
| 362 session_deps_.socket_factory->AddSocketDataProvider(&data); | 377 AddSSLSocketData(); |
| 363 | 378 |
| 364 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); | 379 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); |
| 365 | 380 |
| 366 base::WeakPtr<SpdyStream> stream = | 381 base::WeakPtr<SpdyStream> stream = |
| 367 CreateStreamSynchronously( | 382 CreateStreamSynchronously( |
| 368 SPDY_BIDIRECTIONAL_STREAM, session, url, LOWEST, log.bound()); | 383 SPDY_BIDIRECTIONAL_STREAM, session, url, LOWEST, log.bound()); |
| 369 ASSERT_TRUE(stream); | 384 ASSERT_TRUE(stream); |
| 370 | 385 |
| 371 StreamDelegateSendImmediate delegate(stream, kPostBodyStringPiece); | 386 StreamDelegateSendImmediate delegate(stream, kPostBodyStringPiece); |
| 372 stream->SetDelegate(&delegate); | 387 stream->SetDelegate(&delegate); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 | 440 |
| 426 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); | 441 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(NULL, 0)); |
| 427 AddRead(resp); | 442 AddRead(resp); |
| 428 | 443 |
| 429 AddReadEOF(); | 444 AddReadEOF(); |
| 430 | 445 |
| 431 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), | 446 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), |
| 432 GetNumWrites()); | 447 GetNumWrites()); |
| 433 MockConnect connect_data(SYNCHRONOUS, OK); | 448 MockConnect connect_data(SYNCHRONOUS, OK); |
| 434 data.set_connect_data(connect_data); | 449 data.set_connect_data(connect_data); |
| 450 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 435 | 451 |
| 436 session_deps_.socket_factory->AddSocketDataProvider(&data); | 452 AddSSLSocketData(); |
| 437 | 453 |
| 438 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); | 454 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); |
| 439 | 455 |
| 440 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( | 456 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( |
| 441 SPDY_REQUEST_RESPONSE_STREAM, session, url, LOWEST, NetLogWithSource()); | 457 SPDY_REQUEST_RESPONSE_STREAM, session, url, LOWEST, NetLogWithSource()); |
| 442 ASSERT_TRUE(stream); | 458 ASSERT_TRUE(stream); |
| 443 | 459 |
| 444 std::string body_data(3 * kMaxSpdyFrameChunkSize, 'x'); | 460 std::string body_data(3 * kMaxSpdyFrameChunkSize, 'x'); |
| 445 StreamDelegateWithBody delegate(stream, body_data); | 461 StreamDelegateWithBody delegate(stream, body_data); |
| 446 stream->SetDelegate(&delegate); | 462 stream->SetDelegate(&delegate); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 AddWrite(chunk); | 496 AddWrite(chunk); |
| 481 AddWrite(chunk); | 497 AddWrite(chunk); |
| 482 AddWrite(chunk); | 498 AddWrite(chunk); |
| 483 | 499 |
| 484 AddReadEOF(); | 500 AddReadEOF(); |
| 485 | 501 |
| 486 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), | 502 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), |
| 487 GetNumWrites()); | 503 GetNumWrites()); |
| 488 MockConnect connect_data(SYNCHRONOUS, OK); | 504 MockConnect connect_data(SYNCHRONOUS, OK); |
| 489 data.set_connect_data(connect_data); | 505 data.set_connect_data(connect_data); |
| 506 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 490 | 507 |
| 491 session_deps_.socket_factory->AddSocketDataProvider(&data); | 508 AddSSLSocketData(); |
| 492 | 509 |
| 493 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); | 510 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); |
| 494 | 511 |
| 495 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( | 512 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( |
| 496 SPDY_BIDIRECTIONAL_STREAM, session, url, LOWEST, NetLogWithSource()); | 513 SPDY_BIDIRECTIONAL_STREAM, session, url, LOWEST, NetLogWithSource()); |
| 497 ASSERT_TRUE(stream); | 514 ASSERT_TRUE(stream); |
| 498 | 515 |
| 499 std::string body_data(3 * kMaxSpdyFrameChunkSize, 'x'); | 516 std::string body_data(3 * kMaxSpdyFrameChunkSize, 'x'); |
| 500 StreamDelegateSendImmediate delegate(stream, body_data); | 517 StreamDelegateSendImmediate delegate(stream, body_data); |
| 501 stream->SetDelegate(&delegate); | 518 stream->SetDelegate(&delegate); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 SpdySerializedFrame rst( | 550 SpdySerializedFrame rst( |
| 534 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); | 551 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_PROTOCOL_ERROR)); |
| 535 AddWrite(rst); | 552 AddWrite(rst); |
| 536 | 553 |
| 537 AddReadEOF(); | 554 AddReadEOF(); |
| 538 | 555 |
| 539 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), | 556 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), |
| 540 GetNumWrites()); | 557 GetNumWrites()); |
| 541 MockConnect connect_data(SYNCHRONOUS, OK); | 558 MockConnect connect_data(SYNCHRONOUS, OK); |
| 542 data.set_connect_data(connect_data); | 559 data.set_connect_data(connect_data); |
| 560 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 543 | 561 |
| 544 session_deps_.socket_factory->AddSocketDataProvider(&data); | 562 AddSSLSocketData(); |
| 545 | 563 |
| 546 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); | 564 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); |
| 547 | 565 |
| 548 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( | 566 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( |
| 549 SPDY_REQUEST_RESPONSE_STREAM, session, url, LOWEST, NetLogWithSource()); | 567 SPDY_REQUEST_RESPONSE_STREAM, session, url, LOWEST, NetLogWithSource()); |
| 550 ASSERT_TRUE(stream); | 568 ASSERT_TRUE(stream); |
| 551 | 569 |
| 552 StreamDelegateDoNothing delegate(stream); | 570 StreamDelegateDoNothing delegate(stream); |
| 553 stream->SetDelegate(&delegate); | 571 stream->SetDelegate(&delegate); |
| 554 | 572 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 584 AddWrite(rst); | 602 AddWrite(rst); |
| 585 | 603 |
| 586 AddReadPause(); | 604 AddReadPause(); |
| 587 | 605 |
| 588 AddReadEOF(); | 606 AddReadEOF(); |
| 589 | 607 |
| 590 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), | 608 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), |
| 591 GetNumWrites()); | 609 GetNumWrites()); |
| 592 MockConnect connect_data(SYNCHRONOUS, OK); | 610 MockConnect connect_data(SYNCHRONOUS, OK); |
| 593 data.set_connect_data(connect_data); | 611 data.set_connect_data(connect_data); |
| 612 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 594 | 613 |
| 595 session_deps_.socket_factory->AddSocketDataProvider(&data); | 614 AddSSLSocketData(); |
| 596 | 615 |
| 597 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); | 616 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); |
| 598 | 617 |
| 599 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( | 618 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( |
| 600 SPDY_REQUEST_RESPONSE_STREAM, session, url, LOWEST, NetLogWithSource()); | 619 SPDY_REQUEST_RESPONSE_STREAM, session, url, LOWEST, NetLogWithSource()); |
| 601 ASSERT_TRUE(stream); | 620 ASSERT_TRUE(stream); |
| 602 | 621 |
| 603 StreamDelegateDoNothing delegate(stream); | 622 StreamDelegateDoNothing delegate(stream); |
| 604 stream->SetDelegate(&delegate); | 623 stream->SetDelegate(&delegate); |
| 605 | 624 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 SpdySerializedFrame rst( | 670 SpdySerializedFrame rst( |
| 652 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR)); | 671 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR)); |
| 653 AddWrite(rst); | 672 AddWrite(rst); |
| 654 | 673 |
| 655 AddReadEOF(); | 674 AddReadEOF(); |
| 656 | 675 |
| 657 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), | 676 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), |
| 658 GetNumWrites()); | 677 GetNumWrites()); |
| 659 MockConnect connect_data(SYNCHRONOUS, OK); | 678 MockConnect connect_data(SYNCHRONOUS, OK); |
| 660 data.set_connect_data(connect_data); | 679 data.set_connect_data(connect_data); |
| 680 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 661 | 681 |
| 662 session_deps_.socket_factory->AddSocketDataProvider(&data); | 682 AddSSLSocketData(); |
| 663 | 683 |
| 664 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); | 684 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); |
| 665 | 685 |
| 666 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( | 686 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( |
| 667 SPDY_REQUEST_RESPONSE_STREAM, session, url, LOWEST, NetLogWithSource()); | 687 SPDY_REQUEST_RESPONSE_STREAM, session, url, LOWEST, NetLogWithSource()); |
| 668 ASSERT_TRUE(stream); | 688 ASSERT_TRUE(stream); |
| 669 | 689 |
| 670 StreamDelegateDoNothing delegate(stream); | 690 StreamDelegateDoNothing delegate(stream); |
| 671 stream->SetDelegate(&delegate); | 691 stream->SetDelegate(&delegate); |
| 672 | 692 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 SpdySerializedFrame rst( | 745 SpdySerializedFrame rst( |
| 726 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR)); | 746 spdy_util_.ConstructSpdyRstStream(2, RST_STREAM_PROTOCOL_ERROR)); |
| 727 AddWrite(rst); | 747 AddWrite(rst); |
| 728 | 748 |
| 729 AddReadEOF(); | 749 AddReadEOF(); |
| 730 | 750 |
| 731 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), | 751 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), |
| 732 GetNumWrites()); | 752 GetNumWrites()); |
| 733 MockConnect connect_data(SYNCHRONOUS, OK); | 753 MockConnect connect_data(SYNCHRONOUS, OK); |
| 734 data.set_connect_data(connect_data); | 754 data.set_connect_data(connect_data); |
| 755 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 735 | 756 |
| 736 session_deps_.socket_factory->AddSocketDataProvider(&data); | 757 AddSSLSocketData(); |
| 737 | 758 |
| 738 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); | 759 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); |
| 739 | 760 |
| 740 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( | 761 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( |
| 741 SPDY_REQUEST_RESPONSE_STREAM, session, url, LOWEST, NetLogWithSource()); | 762 SPDY_REQUEST_RESPONSE_STREAM, session, url, LOWEST, NetLogWithSource()); |
| 742 ASSERT_TRUE(stream); | 763 ASSERT_TRUE(stream); |
| 743 | 764 |
| 744 StreamDelegateDoNothing delegate(stream); | 765 StreamDelegateDoNothing delegate(stream); |
| 745 stream->SetDelegate(&delegate); | 766 stream->SetDelegate(&delegate); |
| 746 | 767 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 AddWrite(rst); | 808 AddWrite(rst); |
| 788 | 809 |
| 789 AddReadEOF(); | 810 AddReadEOF(); |
| 790 | 811 |
| 791 BoundTestNetLog log; | 812 BoundTestNetLog log; |
| 792 | 813 |
| 793 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), | 814 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), |
| 794 GetNumWrites()); | 815 GetNumWrites()); |
| 795 MockConnect connect_data(SYNCHRONOUS, OK); | 816 MockConnect connect_data(SYNCHRONOUS, OK); |
| 796 data.set_connect_data(connect_data); | 817 data.set_connect_data(connect_data); |
| 818 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 797 | 819 |
| 798 session_deps_.socket_factory->AddSocketDataProvider(&data); | 820 AddSSLSocketData(); |
| 799 | 821 |
| 800 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); | 822 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); |
| 801 GURL url(kStreamUrl); | 823 GURL url(kStreamUrl); |
| 802 | 824 |
| 803 base::WeakPtr<SpdyStream> stream = | 825 base::WeakPtr<SpdyStream> stream = |
| 804 CreateStreamSynchronously( | 826 CreateStreamSynchronously( |
| 805 SPDY_BIDIRECTIONAL_STREAM, session, url, LOWEST, log.bound()); | 827 SPDY_BIDIRECTIONAL_STREAM, session, url, LOWEST, log.bound()); |
| 806 ASSERT_TRUE(stream); | 828 ASSERT_TRUE(stream); |
| 807 StreamDelegateSendImmediate delegate(stream, kPostBodyStringPiece); | 829 StreamDelegateSendImmediate delegate(stream, kPostBodyStringPiece); |
| 808 stream->SetDelegate(&delegate); | 830 stream->SetDelegate(&delegate); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 | 897 |
| 876 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); | 898 SpdySerializedFrame resp(spdy_util_.ConstructSpdyGetReply(NULL, 0, 1)); |
| 877 AddRead(resp); | 899 AddRead(resp); |
| 878 | 900 |
| 879 AddReadEOF(); | 901 AddReadEOF(); |
| 880 | 902 |
| 881 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), | 903 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), |
| 882 GetNumWrites()); | 904 GetNumWrites()); |
| 883 MockConnect connect_data(SYNCHRONOUS, OK); | 905 MockConnect connect_data(SYNCHRONOUS, OK); |
| 884 data.set_connect_data(connect_data); | 906 data.set_connect_data(connect_data); |
| 907 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 885 | 908 |
| 886 session_deps_.socket_factory->AddSocketDataProvider(&data); | 909 AddSSLSocketData(); |
| 887 | 910 |
| 888 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); | 911 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); |
| 889 | 912 |
| 890 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( | 913 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( |
| 891 SPDY_REQUEST_RESPONSE_STREAM, session, url, LOWEST, NetLogWithSource()); | 914 SPDY_REQUEST_RESPONSE_STREAM, session, url, LOWEST, NetLogWithSource()); |
| 892 ASSERT_TRUE(stream); | 915 ASSERT_TRUE(stream); |
| 893 | 916 |
| 894 StreamDelegateWithBody delegate(stream, kPostBodyStringPiece); | 917 StreamDelegateWithBody delegate(stream, kPostBodyStringPiece); |
| 895 stream->SetDelegate(&delegate); | 918 stream->SetDelegate(&delegate); |
| 896 | 919 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 SpdySerializedFrame echo( | 977 SpdySerializedFrame echo( |
| 955 spdy_util_.ConstructSpdyDataFrame(1, kPostBody, kPostBodyLength, false)); | 978 spdy_util_.ConstructSpdyDataFrame(1, kPostBody, kPostBodyLength, false)); |
| 956 AddRead(echo); | 979 AddRead(echo); |
| 957 | 980 |
| 958 AddReadEOF(); | 981 AddReadEOF(); |
| 959 | 982 |
| 960 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), | 983 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), |
| 961 GetNumWrites()); | 984 GetNumWrites()); |
| 962 MockConnect connect_data(SYNCHRONOUS, OK); | 985 MockConnect connect_data(SYNCHRONOUS, OK); |
| 963 data.set_connect_data(connect_data); | 986 data.set_connect_data(connect_data); |
| 987 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 964 | 988 |
| 965 session_deps_.socket_factory->AddSocketDataProvider(&data); | 989 AddSSLSocketData(); |
| 966 | 990 |
| 967 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); | 991 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); |
| 968 | 992 |
| 969 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( | 993 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( |
| 970 SPDY_BIDIRECTIONAL_STREAM, session, url, LOWEST, NetLogWithSource()); | 994 SPDY_BIDIRECTIONAL_STREAM, session, url, LOWEST, NetLogWithSource()); |
| 971 ASSERT_TRUE(stream); | 995 ASSERT_TRUE(stream); |
| 972 | 996 |
| 973 StreamDelegateSendImmediate delegate(stream, kPostBodyStringPiece); | 997 StreamDelegateSendImmediate delegate(stream, kPostBodyStringPiece); |
| 974 stream->SetDelegate(&delegate); | 998 stream->SetDelegate(&delegate); |
| 975 | 999 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 AddRead(msg); | 1059 AddRead(msg); |
| 1036 | 1060 |
| 1037 AddReadPause(); | 1061 AddReadPause(); |
| 1038 | 1062 |
| 1039 AddReadEOF(); | 1063 AddReadEOF(); |
| 1040 | 1064 |
| 1041 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), | 1065 SequencedSocketData data(GetReads(), GetNumReads(), GetWrites(), |
| 1042 GetNumWrites()); | 1066 GetNumWrites()); |
| 1043 MockConnect connect_data(SYNCHRONOUS, OK); | 1067 MockConnect connect_data(SYNCHRONOUS, OK); |
| 1044 data.set_connect_data(connect_data); | 1068 data.set_connect_data(connect_data); |
| 1069 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 1045 | 1070 |
| 1046 session_deps_.socket_factory->AddSocketDataProvider(&data); | 1071 AddSSLSocketData(); |
| 1047 | 1072 |
| 1048 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); | 1073 base::WeakPtr<SpdySession> session(CreateDefaultSpdySession()); |
| 1049 | 1074 |
| 1050 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( | 1075 base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously( |
| 1051 SPDY_REQUEST_RESPONSE_STREAM, session, url, LOWEST, NetLogWithSource()); | 1076 SPDY_REQUEST_RESPONSE_STREAM, session, url, LOWEST, NetLogWithSource()); |
| 1052 ASSERT_TRUE(stream); | 1077 ASSERT_TRUE(stream); |
| 1053 | 1078 |
| 1054 StreamDelegateDoNothing delegate(stream); | 1079 StreamDelegateDoNothing delegate(stream); |
| 1055 stream->SetDelegate(&delegate); | 1080 stream->SetDelegate(&delegate); |
| 1056 | 1081 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1083 EXPECT_EQ(response_len, stream->raw_received_bytes()); | 1108 EXPECT_EQ(response_len, stream->raw_received_bytes()); |
| 1084 | 1109 |
| 1085 // FIN | 1110 // FIN |
| 1086 data.Resume(); | 1111 data.Resume(); |
| 1087 EXPECT_THAT(delegate.WaitForClose(), IsError(ERR_CONNECTION_CLOSED)); | 1112 EXPECT_THAT(delegate.WaitForClose(), IsError(ERR_CONNECTION_CLOSED)); |
| 1088 } | 1113 } |
| 1089 | 1114 |
| 1090 } // namespace test | 1115 } // namespace test |
| 1091 | 1116 |
| 1092 } // namespace net | 1117 } // namespace net |
| OLD | NEW |