| 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/http/http_stream_factory_impl.h" | 5 #include "net/http/http_stream_factory_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 | 736 |
| 737 // BidirectionalStreamImpl::Delegate to wait until response headers are | 737 // BidirectionalStreamImpl::Delegate to wait until response headers are |
| 738 // received. | 738 // received. |
| 739 class TestBidirectionalDelegate : public BidirectionalStreamImpl::Delegate { | 739 class TestBidirectionalDelegate : public BidirectionalStreamImpl::Delegate { |
| 740 public: | 740 public: |
| 741 void WaitUntilDone() { loop_.Run(); } | 741 void WaitUntilDone() { loop_.Run(); } |
| 742 | 742 |
| 743 const SpdyHeaderBlock& response_headers() const { return response_headers_; } | 743 const SpdyHeaderBlock& response_headers() const { return response_headers_; } |
| 744 | 744 |
| 745 private: | 745 private: |
| 746 void OnStreamReady() override {} | 746 void OnStreamReady(bool request_headers_sent) override {} |
| 747 void OnHeadersReceived(const SpdyHeaderBlock& response_headers) override { | 747 void OnHeadersReceived(const SpdyHeaderBlock& response_headers) override { |
| 748 response_headers_ = response_headers; | 748 response_headers_ = response_headers; |
| 749 loop_.Quit(); | 749 loop_.Quit(); |
| 750 } | 750 } |
| 751 void OnDataRead(int bytes_read) override { NOTREACHED(); } | 751 void OnDataRead(int bytes_read) override { NOTREACHED(); } |
| 752 void OnDataSent() override { NOTREACHED(); } | 752 void OnDataSent() override { NOTREACHED(); } |
| 753 void OnTrailersReceived(const SpdyHeaderBlock& trailers) override { | 753 void OnTrailersReceived(const SpdyHeaderBlock& trailers) override { |
| 754 NOTREACHED(); | 754 NOTREACHED(); |
| 755 } | 755 } |
| 756 void OnFailed(int error) override { NOTREACHED(); } | 756 void OnFailed(int error) override { NOTREACHED(); } |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1626 ASSERT_TRUE(waiter.bidirectional_stream_impl()); | 1626 ASSERT_TRUE(waiter.bidirectional_stream_impl()); |
| 1627 BidirectionalStreamImpl* stream_impl = waiter.bidirectional_stream_impl(); | 1627 BidirectionalStreamImpl* stream_impl = waiter.bidirectional_stream_impl(); |
| 1628 | 1628 |
| 1629 BidirectionalStreamRequestInfo bidi_request_info; | 1629 BidirectionalStreamRequestInfo bidi_request_info; |
| 1630 bidi_request_info.method = "GET"; | 1630 bidi_request_info.method = "GET"; |
| 1631 bidi_request_info.url = GURL("https://www.example.org/"); | 1631 bidi_request_info.url = GURL("https://www.example.org/"); |
| 1632 bidi_request_info.end_stream_on_headers = true; | 1632 bidi_request_info.end_stream_on_headers = true; |
| 1633 bidi_request_info.priority = LOWEST; | 1633 bidi_request_info.priority = LOWEST; |
| 1634 | 1634 |
| 1635 TestBidirectionalDelegate delegate; | 1635 TestBidirectionalDelegate delegate; |
| 1636 stream_impl->Start(&bidi_request_info, BoundNetLog(), false, &delegate, | 1636 stream_impl->Start(&bidi_request_info, BoundNetLog(), |
| 1637 /*send_request_headers_automatically=*/true, &delegate, |
| 1637 nullptr); | 1638 nullptr); |
| 1638 delegate.WaitUntilDone(); | 1639 delegate.WaitUntilDone(); |
| 1639 | 1640 |
| 1640 scoped_refptr<IOBuffer> buffer = new net::IOBuffer(1); | 1641 scoped_refptr<IOBuffer> buffer = new net::IOBuffer(1); |
| 1641 EXPECT_EQ(OK, stream_impl->ReadData(buffer.get(), 1)); | 1642 EXPECT_EQ(OK, stream_impl->ReadData(buffer.get(), 1)); |
| 1642 EXPECT_EQ(kProtoQUIC1SPDY3, stream_impl->GetProtocol()); | 1643 EXPECT_EQ(kProtoQUIC1SPDY3, stream_impl->GetProtocol()); |
| 1643 EXPECT_EQ("200", delegate.response_headers().find(":status")->second); | 1644 EXPECT_EQ("200", delegate.response_headers().find(":status")->second); |
| 1644 EXPECT_EQ(0, GetSocketPoolGroupCount(session()->GetTransportSocketPool( | 1645 EXPECT_EQ(0, GetSocketPoolGroupCount(session()->GetTransportSocketPool( |
| 1645 HttpNetworkSession::NORMAL_SOCKET_POOL))); | 1646 HttpNetworkSession::NORMAL_SOCKET_POOL))); |
| 1646 EXPECT_EQ(0, GetSocketPoolGroupCount(session()->GetSSLSocketPool( | 1647 EXPECT_EQ(0, GetSocketPoolGroupCount(session()->GetSSLSocketPool( |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1752 ASSERT_TRUE(waiter.bidirectional_stream_impl()); | 1753 ASSERT_TRUE(waiter.bidirectional_stream_impl()); |
| 1753 BidirectionalStreamImpl* stream_impl = waiter.bidirectional_stream_impl(); | 1754 BidirectionalStreamImpl* stream_impl = waiter.bidirectional_stream_impl(); |
| 1754 | 1755 |
| 1755 BidirectionalStreamRequestInfo bidi_request_info; | 1756 BidirectionalStreamRequestInfo bidi_request_info; |
| 1756 bidi_request_info.method = "GET"; | 1757 bidi_request_info.method = "GET"; |
| 1757 bidi_request_info.url = GURL("https://www.example.org/"); | 1758 bidi_request_info.url = GURL("https://www.example.org/"); |
| 1758 bidi_request_info.end_stream_on_headers = true; | 1759 bidi_request_info.end_stream_on_headers = true; |
| 1759 bidi_request_info.priority = LOWEST; | 1760 bidi_request_info.priority = LOWEST; |
| 1760 | 1761 |
| 1761 TestBidirectionalDelegate delegate; | 1762 TestBidirectionalDelegate delegate; |
| 1762 stream_impl->Start(&bidi_request_info, BoundNetLog(), false, &delegate, | 1763 stream_impl->Start(&bidi_request_info, BoundNetLog(), |
| 1764 /*send_request_headers_automatically=*/true, &delegate, |
| 1763 nullptr); | 1765 nullptr); |
| 1764 delegate.WaitUntilDone(); | 1766 delegate.WaitUntilDone(); |
| 1765 | 1767 |
| 1766 // Make sure the BidirectionalStream negotiated goes through QUIC. | 1768 // Make sure the BidirectionalStream negotiated goes through QUIC. |
| 1767 scoped_refptr<IOBuffer> buffer = new net::IOBuffer(1); | 1769 scoped_refptr<IOBuffer> buffer = new net::IOBuffer(1); |
| 1768 EXPECT_EQ(OK, stream_impl->ReadData(buffer.get(), 1)); | 1770 EXPECT_EQ(OK, stream_impl->ReadData(buffer.get(), 1)); |
| 1769 EXPECT_EQ(kProtoQUIC1SPDY3, stream_impl->GetProtocol()); | 1771 EXPECT_EQ(kProtoQUIC1SPDY3, stream_impl->GetProtocol()); |
| 1770 EXPECT_EQ("200", delegate.response_headers().find(":status")->second); | 1772 EXPECT_EQ("200", delegate.response_headers().find(":status")->second); |
| 1771 // There is no Http2 socket pool. | 1773 // There is no Http2 socket pool. |
| 1772 EXPECT_EQ(0, GetSocketPoolGroupCount(session()->GetTransportSocketPool( | 1774 EXPECT_EQ(0, GetSocketPoolGroupCount(session()->GetTransportSocketPool( |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2015 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); | 2017 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); |
| 2016 | 2018 |
| 2017 // Make sure there is no orphaned job. it is already canceled. | 2019 // Make sure there is no orphaned job. it is already canceled. |
| 2018 ASSERT_EQ(0u, static_cast<HttpStreamFactoryImpl*>( | 2020 ASSERT_EQ(0u, static_cast<HttpStreamFactoryImpl*>( |
| 2019 session->http_stream_factory_for_websocket())->num_orphaned_jobs()); | 2021 session->http_stream_factory_for_websocket())->num_orphaned_jobs()); |
| 2020 } | 2022 } |
| 2021 | 2023 |
| 2022 } // namespace | 2024 } // namespace |
| 2023 | 2025 |
| 2024 } // namespace net | 2026 } // namespace net |
| OLD | NEW |