| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/http/bidirectional_stream.h" | 5 #include "net/http/bidirectional_stream.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 HttpNetworkSession::Params params = | 347 HttpNetworkSession::Params params = |
| 348 SpdySessionDependencies::CreateSessionParams(&session_deps_); | 348 SpdySessionDependencies::CreateSessionParams(&session_deps_); |
| 349 scoped_ptr<HttpNetworkSession> session(new HttpNetworkSession(params)); | 349 scoped_ptr<HttpNetworkSession> session(new HttpNetworkSession(params)); |
| 350 delegate.SetRunUntilCompletion(true); | 350 delegate.SetRunUntilCompletion(true); |
| 351 delegate.Start(std::move(request_info), session.get()); | 351 delegate.Start(std::move(request_info), session.get()); |
| 352 | 352 |
| 353 EXPECT_EQ(ERR_DISALLOWED_URL_SCHEME, delegate.error()); | 353 EXPECT_EQ(ERR_DISALLOWED_URL_SCHEME, delegate.error()); |
| 354 } | 354 } |
| 355 | 355 |
| 356 // Simulates user calling ReadData after END_STREAM has been received in | 356 // Simulates user calling ReadData after END_STREAM has been received in |
| 357 // BidirectionalStreamSpdyJob. | 357 // BidirectionalStreamSpdyImpl. |
| 358 TEST_F(BidirectionalStreamTest, TestReadDataAfterClose) { | 358 TEST_F(BidirectionalStreamTest, TestReadDataAfterClose) { |
| 359 scoped_ptr<SpdyFrame> req( | 359 scoped_ptr<SpdyFrame> req( |
| 360 spdy_util_.ConstructSpdyGet("https://www.example.org", 1, LOWEST)); | 360 spdy_util_.ConstructSpdyGet("https://www.example.org", 1, LOWEST)); |
| 361 // Empty DATA frame with an END_STREAM flag. | 361 // Empty DATA frame with an END_STREAM flag. |
| 362 scoped_ptr<SpdyFrame> end_stream( | 362 scoped_ptr<SpdyFrame> end_stream( |
| 363 spdy_util_.ConstructSpdyBodyFrame(1, nullptr, 0, true)); | 363 spdy_util_.ConstructSpdyBodyFrame(1, nullptr, 0, true)); |
| 364 MockWrite writes[] = { | 364 MockWrite writes[] = { |
| 365 CreateMockWrite(*req.get(), 0), | 365 CreateMockWrite(*req.get(), 0), |
| 366 }; | 366 }; |
| 367 | 367 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 392 | 392 |
| 393 scoped_ptr<BidirectionalStreamRequestInfo> request_info( | 393 scoped_ptr<BidirectionalStreamRequestInfo> request_info( |
| 394 new BidirectionalStreamRequestInfo); | 394 new BidirectionalStreamRequestInfo); |
| 395 request_info->method = "GET"; | 395 request_info->method = "GET"; |
| 396 request_info->url = GURL("https://www.example.org/"); | 396 request_info->url = GURL("https://www.example.org/"); |
| 397 request_info->end_stream_on_headers = true; | 397 request_info->end_stream_on_headers = true; |
| 398 request_info->priority = LOWEST; | 398 request_info->priority = LOWEST; |
| 399 | 399 |
| 400 scoped_refptr<IOBuffer> read_buffer(new IOBuffer(kReadBufferSize)); | 400 scoped_refptr<IOBuffer> read_buffer(new IOBuffer(kReadBufferSize)); |
| 401 // Create a MockTimer. Retain a raw pointer since the underlying | 401 // Create a MockTimer. Retain a raw pointer since the underlying |
| 402 // BidirectionalStreamJob owns it. | 402 // BidirectionalStreamImpl owns it. |
| 403 MockTimer* timer = new MockTimer(); | 403 MockTimer* timer = new MockTimer(); |
| 404 scoped_ptr<TestDelegateBase> delegate(new TestDelegateBase( | 404 scoped_ptr<TestDelegateBase> delegate(new TestDelegateBase( |
| 405 read_buffer.get(), kReadBufferSize, make_scoped_ptr(timer))); | 405 read_buffer.get(), kReadBufferSize, make_scoped_ptr(timer))); |
| 406 delegate->set_do_not_start_read(true); | 406 delegate->set_do_not_start_read(true); |
| 407 | 407 |
| 408 delegate->Start(std::move(request_info), http_session_.get()); | 408 delegate->Start(std::move(request_info), http_session_.get()); |
| 409 | 409 |
| 410 // Write request, and deliver response headers. | 410 // Write request, and deliver response headers. |
| 411 sequenced_data_->RunUntilPaused(); | 411 sequenced_data_->RunUntilPaused(); |
| 412 EXPECT_FALSE(timer->IsRunning()); | 412 EXPECT_FALSE(timer->IsRunning()); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 EXPECT_EQ("200", delegate->response_headers().find(":status")->second); | 543 EXPECT_EQ("200", delegate->response_headers().find(":status")->second); |
| 544 EXPECT_EQ(2, delegate->on_data_read_count()); | 544 EXPECT_EQ(2, delegate->on_data_read_count()); |
| 545 EXPECT_EQ(3, delegate->on_data_sent_count()); | 545 EXPECT_EQ(3, delegate->on_data_sent_count()); |
| 546 EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol()); | 546 EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol()); |
| 547 EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), | 547 EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), |
| 548 delegate->GetTotalSentBytes()); | 548 delegate->GetTotalSentBytes()); |
| 549 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)), | 549 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)), |
| 550 delegate->GetTotalReceivedBytes()); | 550 delegate->GetTotalReceivedBytes()); |
| 551 } | 551 } |
| 552 | 552 |
| 553 // Tests that BidirectionalStreamSpdyJob::OnClose will complete any remaining | 553 // Tests that BidirectionalStreamSpdyImpl::OnClose will complete any remaining |
| 554 // read even if the read queue is empty. | 554 // read even if the read queue is empty. |
| 555 TEST_F(BidirectionalStreamTest, TestCompleteAsyncRead) { | 555 TEST_F(BidirectionalStreamTest, TestCompleteAsyncRead) { |
| 556 scoped_ptr<SpdyFrame> req( | 556 scoped_ptr<SpdyFrame> req( |
| 557 spdy_util_.ConstructSpdyGet("https://www.example.org", 1, LOWEST)); | 557 spdy_util_.ConstructSpdyGet("https://www.example.org", 1, LOWEST)); |
| 558 // Empty DATA frame with an END_STREAM flag. | 558 // Empty DATA frame with an END_STREAM flag. |
| 559 scoped_ptr<SpdyFrame> end_stream( | 559 scoped_ptr<SpdyFrame> end_stream( |
| 560 spdy_util_.ConstructSpdyBodyFrame(1, nullptr, 0, true)); | 560 spdy_util_.ConstructSpdyBodyFrame(1, nullptr, 0, true)); |
| 561 | 561 |
| 562 MockWrite writes[] = {CreateMockWrite(*req.get(), 0)}; | 562 MockWrite writes[] = {CreateMockWrite(*req.get(), 0)}; |
| 563 | 563 |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 http_session_->http_server_properties()->GetAlternativeServices( | 1257 http_session_->http_server_properties()->GetAlternativeServices( |
| 1258 host_port_pair); | 1258 host_port_pair); |
| 1259 ASSERT_EQ(1u, alternative_service_vector.size()); | 1259 ASSERT_EQ(1u, alternative_service_vector.size()); |
| 1260 EXPECT_EQ(AlternateProtocolFromNextProto(kProtoQUIC1SPDY3), | 1260 EXPECT_EQ(AlternateProtocolFromNextProto(kProtoQUIC1SPDY3), |
| 1261 alternative_service_vector[0].protocol); | 1261 alternative_service_vector[0].protocol); |
| 1262 EXPECT_EQ("www.example.org", alternative_service_vector[0].host); | 1262 EXPECT_EQ("www.example.org", alternative_service_vector[0].host); |
| 1263 EXPECT_EQ(443, alternative_service_vector[0].port); | 1263 EXPECT_EQ(443, alternative_service_vector[0].port); |
| 1264 } | 1264 } |
| 1265 | 1265 |
| 1266 } // namespace net | 1266 } // namespace net |
| OLD | NEW |