Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: net/http/http_stream_factory_impl_unittest.cc

Issue 1856073002: Coalesce small buffers in net::BidirectionalStream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 740
741 // BidirectionalStreamImpl::Delegate to wait until response headers are 741 // BidirectionalStreamImpl::Delegate to wait until response headers are
742 // received. 742 // received.
743 class TestBidirectionalDelegate : public BidirectionalStreamImpl::Delegate { 743 class TestBidirectionalDelegate : public BidirectionalStreamImpl::Delegate {
744 public: 744 public:
745 void WaitUntilDone() { loop_.Run(); } 745 void WaitUntilDone() { loop_.Run(); }
746 746
747 const SpdyHeaderBlock& response_headers() const { return response_headers_; } 747 const SpdyHeaderBlock& response_headers() const { return response_headers_; }
748 748
749 private: 749 private:
750 void OnHeadersSent() override {} 750 void OnStreamReady() override {}
751 void OnHeadersReceived(const SpdyHeaderBlock& response_headers) override { 751 void OnHeadersReceived(const SpdyHeaderBlock& response_headers) override {
752 response_headers_ = response_headers; 752 response_headers_ = response_headers;
753 loop_.Quit(); 753 loop_.Quit();
754 } 754 }
755 void OnDataRead(int bytes_read) override { NOTREACHED(); } 755 void OnDataRead(int bytes_read) override { NOTREACHED(); }
756 void OnDataSent() override { NOTREACHED(); } 756 void OnDataSent() override { NOTREACHED(); }
757 void OnTrailersReceived(const SpdyHeaderBlock& trailers) override { 757 void OnTrailersReceived(const SpdyHeaderBlock& trailers) override {
758 NOTREACHED(); 758 NOTREACHED();
759 } 759 }
760 void OnFailed(int error) override { NOTREACHED(); } 760 void OnFailed(int error) override { NOTREACHED(); }
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 ASSERT_TRUE(waiter.bidirectional_stream_impl()); 1615 ASSERT_TRUE(waiter.bidirectional_stream_impl());
1616 BidirectionalStreamImpl* stream_impl = waiter.bidirectional_stream_impl(); 1616 BidirectionalStreamImpl* stream_impl = waiter.bidirectional_stream_impl();
1617 1617
1618 BidirectionalStreamRequestInfo bidi_request_info; 1618 BidirectionalStreamRequestInfo bidi_request_info;
1619 bidi_request_info.method = "GET"; 1619 bidi_request_info.method = "GET";
1620 bidi_request_info.url = GURL("https://www.example.org/"); 1620 bidi_request_info.url = GURL("https://www.example.org/");
1621 bidi_request_info.end_stream_on_headers = true; 1621 bidi_request_info.end_stream_on_headers = true;
1622 bidi_request_info.priority = LOWEST; 1622 bidi_request_info.priority = LOWEST;
1623 1623
1624 TestBidirectionalDelegate delegate; 1624 TestBidirectionalDelegate delegate;
1625 stream_impl->Start(&bidi_request_info, BoundNetLog(), &delegate, nullptr); 1625 stream_impl->Start(&bidi_request_info, BoundNetLog(), false, &delegate,
1626 nullptr);
1626 delegate.WaitUntilDone(); 1627 delegate.WaitUntilDone();
1627 1628
1628 scoped_refptr<IOBuffer> buffer = new net::IOBuffer(1); 1629 scoped_refptr<IOBuffer> buffer = new net::IOBuffer(1);
1629 EXPECT_EQ(OK, stream_impl->ReadData(buffer.get(), 1)); 1630 EXPECT_EQ(OK, stream_impl->ReadData(buffer.get(), 1));
1630 EXPECT_EQ(kProtoQUIC1SPDY3, stream_impl->GetProtocol()); 1631 EXPECT_EQ(kProtoQUIC1SPDY3, stream_impl->GetProtocol());
1631 EXPECT_EQ("200", delegate.response_headers().find(":status")->second); 1632 EXPECT_EQ("200", delegate.response_headers().find(":status")->second);
1632 EXPECT_EQ(1, GetSocketPoolGroupCount(session()->GetTransportSocketPool( 1633 EXPECT_EQ(1, GetSocketPoolGroupCount(session()->GetTransportSocketPool(
1633 HttpNetworkSession::NORMAL_SOCKET_POOL))); 1634 HttpNetworkSession::NORMAL_SOCKET_POOL)));
1634 EXPECT_EQ(1, GetSocketPoolGroupCount(session()->GetSSLSocketPool( 1635 EXPECT_EQ(1, GetSocketPoolGroupCount(session()->GetSSLSocketPool(
1635 HttpNetworkSession::NORMAL_SOCKET_POOL))); 1636 HttpNetworkSession::NORMAL_SOCKET_POOL)));
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1740 ASSERT_TRUE(waiter.bidirectional_stream_impl()); 1741 ASSERT_TRUE(waiter.bidirectional_stream_impl());
1741 BidirectionalStreamImpl* stream_impl = waiter.bidirectional_stream_impl(); 1742 BidirectionalStreamImpl* stream_impl = waiter.bidirectional_stream_impl();
1742 1743
1743 BidirectionalStreamRequestInfo bidi_request_info; 1744 BidirectionalStreamRequestInfo bidi_request_info;
1744 bidi_request_info.method = "GET"; 1745 bidi_request_info.method = "GET";
1745 bidi_request_info.url = GURL("https://www.example.org/"); 1746 bidi_request_info.url = GURL("https://www.example.org/");
1746 bidi_request_info.end_stream_on_headers = true; 1747 bidi_request_info.end_stream_on_headers = true;
1747 bidi_request_info.priority = LOWEST; 1748 bidi_request_info.priority = LOWEST;
1748 1749
1749 TestBidirectionalDelegate delegate; 1750 TestBidirectionalDelegate delegate;
1750 stream_impl->Start(&bidi_request_info, BoundNetLog(), &delegate, nullptr); 1751 stream_impl->Start(&bidi_request_info, BoundNetLog(), false, &delegate,
1752 nullptr);
1751 delegate.WaitUntilDone(); 1753 delegate.WaitUntilDone();
1752 1754
1753 // Make sure the BidirectionalStream negotiated goes through QUIC. 1755 // Make sure the BidirectionalStream negotiated goes through QUIC.
1754 scoped_refptr<IOBuffer> buffer = new net::IOBuffer(1); 1756 scoped_refptr<IOBuffer> buffer = new net::IOBuffer(1);
1755 EXPECT_EQ(OK, stream_impl->ReadData(buffer.get(), 1)); 1757 EXPECT_EQ(OK, stream_impl->ReadData(buffer.get(), 1));
1756 EXPECT_EQ(kProtoQUIC1SPDY3, stream_impl->GetProtocol()); 1758 EXPECT_EQ(kProtoQUIC1SPDY3, stream_impl->GetProtocol());
1757 EXPECT_EQ("200", delegate.response_headers().find(":status")->second); 1759 EXPECT_EQ("200", delegate.response_headers().find(":status")->second);
1758 // There is no Http2 socket pool. 1760 // There is no Http2 socket pool.
1759 EXPECT_EQ(0, GetSocketPoolGroupCount(session()->GetTransportSocketPool( 1761 EXPECT_EQ(0, GetSocketPoolGroupCount(session()->GetTransportSocketPool(
1760 HttpNetworkSession::NORMAL_SOCKET_POOL))); 1762 HttpNetworkSession::NORMAL_SOCKET_POOL)));
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 EXPECT_TRUE(waiter.used_proxy_info().is_direct()); 2001 EXPECT_TRUE(waiter.used_proxy_info().is_direct());
2000 2002
2001 // Make sure there is no orphaned job. it is already canceled. 2003 // Make sure there is no orphaned job. it is already canceled.
2002 ASSERT_EQ(0u, static_cast<HttpStreamFactoryImpl*>( 2004 ASSERT_EQ(0u, static_cast<HttpStreamFactoryImpl*>(
2003 session->http_stream_factory_for_websocket())->num_orphaned_jobs()); 2005 session->http_stream_factory_for_websocket())->num_orphaned_jobs());
2004 } 2006 }
2005 2007
2006 } // namespace 2008 } // namespace
2007 2009
2008 } // namespace net 2010 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698