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

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

Issue 1856073002: Coalesce small buffers in net::BidirectionalStream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Andrei's comments 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 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/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/thread_task_runner_handle.h" 11 #include "base/thread_task_runner_handle.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
14 #include "net/base/load_flags.h" 14 #include "net/base/load_flags.h"
15 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
16 #include "net/http/bidirectional_stream_request_info.h" 16 #include "net/http/bidirectional_stream_request_info.h"
17 #include "net/http/http_network_session.h" 17 #include "net/http/http_network_session.h"
18 #include "net/http/http_response_headers.h" 18 #include "net/http/http_response_headers.h"
19 #include "net/http/http_stream.h" 19 #include "net/http/http_stream.h"
20 #include "net/spdy/spdy_http_utils.h" 20 #include "net/spdy/spdy_http_utils.h"
21 #include "net/ssl/ssl_cert_request_info.h" 21 #include "net/ssl/ssl_cert_request_info.h"
22 #include "net/ssl/ssl_config.h" 22 #include "net/ssl/ssl_config.h"
23 #include "url/gurl.h" 23 #include "url/gurl.h"
24 24
25 namespace net { 25 namespace net {
26 26
27 BidirectionalStream::Delegate::Delegate() {} 27 BidirectionalStream::Delegate::Delegate() {}
28 28
29 void BidirectionalStream::Delegate::OnStreamReady() {}
30
29 BidirectionalStream::Delegate::~Delegate() {} 31 BidirectionalStream::Delegate::~Delegate() {}
30 32
31 BidirectionalStream::BidirectionalStream( 33 BidirectionalStream::BidirectionalStream(
32 scoped_ptr<BidirectionalStreamRequestInfo> request_info, 34 scoped_ptr<BidirectionalStreamRequestInfo> request_info,
33 HttpNetworkSession* session, 35 HttpNetworkSession* session,
36 bool disable_auto_flush,
34 Delegate* delegate) 37 Delegate* delegate)
35 : BidirectionalStream(std::move(request_info), 38 : BidirectionalStream(std::move(request_info),
36 session, 39 session,
40 disable_auto_flush,
37 delegate, 41 delegate,
38 make_scoped_ptr(new base::Timer(false, false))) {} 42 make_scoped_ptr(new base::Timer(false, false))) {}
39 43
40 BidirectionalStream::BidirectionalStream( 44 BidirectionalStream::BidirectionalStream(
41 scoped_ptr<BidirectionalStreamRequestInfo> request_info, 45 scoped_ptr<BidirectionalStreamRequestInfo> request_info,
42 HttpNetworkSession* session, 46 HttpNetworkSession* session,
47 bool disable_auto_flush,
43 Delegate* delegate, 48 Delegate* delegate,
44 scoped_ptr<base::Timer> timer) 49 scoped_ptr<base::Timer> timer)
45 : request_info_(std::move(request_info)), 50 : request_info_(std::move(request_info)),
46 net_log_(BoundNetLog::Make(session->net_log(), 51 net_log_(BoundNetLog::Make(session->net_log(),
47 NetLog::SOURCE_BIDIRECTIONAL_STREAM)), 52 NetLog::SOURCE_BIDIRECTIONAL_STREAM)),
48 session_(session), 53 session_(session),
54 disable_auto_flush_(disable_auto_flush),
49 delegate_(delegate), 55 delegate_(delegate),
50 timer_(std::move(timer)) { 56 timer_(std::move(timer)) {
51 DCHECK(delegate_); 57 DCHECK(delegate_);
52 DCHECK(request_info_); 58 DCHECK(request_info_);
53 59
54 SSLConfig server_ssl_config; 60 SSLConfig server_ssl_config;
55 session->ssl_config_service()->GetSSLConfig(&server_ssl_config); 61 session->ssl_config_service()->GetSSLConfig(&server_ssl_config);
56 session->GetAlpnProtos(&server_ssl_config.alpn_protos); 62 session->GetAlpnProtos(&server_ssl_config.alpn_protos);
57 session->GetNpnProtos(&server_ssl_config.npn_protos); 63 session->GetNpnProtos(&server_ssl_config.npn_protos);
58 64
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 96 }
91 97
92 void BidirectionalStream::SendData(IOBuffer* data, 98 void BidirectionalStream::SendData(IOBuffer* data,
93 int length, 99 int length,
94 bool end_stream) { 100 bool end_stream) {
95 DCHECK(stream_impl_); 101 DCHECK(stream_impl_);
96 102
97 stream_impl_->SendData(data, length, end_stream); 103 stream_impl_->SendData(data, length, end_stream);
98 } 104 }
99 105
106 void BidirectionalStream::SendvData(const std::vector<IOBuffer*>& buffers,
107 const std::vector<int>& lengths,
108 bool end_stream) {
109 DCHECK(stream_impl_);
110
111 stream_impl_->SendvData(buffers, lengths, end_stream);
112 }
113
100 void BidirectionalStream::Cancel() { 114 void BidirectionalStream::Cancel() {
101 stream_request_.reset(); 115 stream_request_.reset();
102 if (stream_impl_) { 116 if (stream_impl_) {
103 stream_impl_->Cancel(); 117 stream_impl_->Cancel();
104 stream_impl_.reset(); 118 stream_impl_.reset();
105 } 119 }
106 } 120 }
107 121
108 NextProto BidirectionalStream::GetProtocol() const { 122 NextProto BidirectionalStream::GetProtocol() const {
109 if (!stream_impl_) 123 if (!stream_impl_)
110 return kProtoUnknown; 124 return kProtoUnknown;
111 125
112 return stream_impl_->GetProtocol(); 126 return stream_impl_->GetProtocol();
113 } 127 }
114 128
115 int64_t BidirectionalStream::GetTotalReceivedBytes() const { 129 int64_t BidirectionalStream::GetTotalReceivedBytes() const {
116 if (!stream_impl_) 130 if (!stream_impl_)
117 return 0; 131 return 0;
118 132
119 return stream_impl_->GetTotalReceivedBytes(); 133 return stream_impl_->GetTotalReceivedBytes();
120 } 134 }
121 135
122 int64_t BidirectionalStream::GetTotalSentBytes() const { 136 int64_t BidirectionalStream::GetTotalSentBytes() const {
123 if (!stream_impl_) 137 if (!stream_impl_)
124 return 0; 138 return 0;
125 139
126 return stream_impl_->GetTotalSentBytes(); 140 return stream_impl_->GetTotalSentBytes();
127 } 141 }
128 142
129 void BidirectionalStream::OnHeadersSent() { 143 void BidirectionalStream::OnStreamReady() {
130 delegate_->OnHeadersSent(); 144 delegate_->OnStreamReady();
131 } 145 }
132 146
133 void BidirectionalStream::OnHeadersReceived( 147 void BidirectionalStream::OnHeadersReceived(
134 const SpdyHeaderBlock& response_headers) { 148 const SpdyHeaderBlock& response_headers) {
135 HttpResponseInfo response_info; 149 HttpResponseInfo response_info;
136 if (!SpdyHeadersToHttpResponse(response_headers, HTTP2, &response_info)) { 150 if (!SpdyHeadersToHttpResponse(response_headers, HTTP2, &response_info)) {
137 DLOG(WARNING) << "Invalid headers"; 151 DLOG(WARNING) << "Invalid headers";
138 delegate_->OnFailed(ERR_FAILED); 152 delegate_->OnFailed(ERR_FAILED);
139 return; 153 return;
140 } 154 }
(...skipping 27 matching lines...) Expand all
168 } 182 }
169 183
170 void BidirectionalStream::OnBidirectionalStreamImplReady( 184 void BidirectionalStream::OnBidirectionalStreamImplReady(
171 const SSLConfig& used_ssl_config, 185 const SSLConfig& used_ssl_config,
172 const ProxyInfo& used_proxy_info, 186 const ProxyInfo& used_proxy_info,
173 BidirectionalStreamImpl* stream) { 187 BidirectionalStreamImpl* stream) {
174 DCHECK(!stream_impl_); 188 DCHECK(!stream_impl_);
175 189
176 stream_request_.reset(); 190 stream_request_.reset();
177 stream_impl_.reset(stream); 191 stream_impl_.reset(stream);
178 stream_impl_->Start(request_info_.get(), net_log_, this, std::move(timer_)); 192 stream_impl_->Start(request_info_.get(), net_log_, disable_auto_flush_, this,
193 std::move(timer_));
179 } 194 }
180 195
181 void BidirectionalStream::OnWebSocketHandshakeStreamReady( 196 void BidirectionalStream::OnWebSocketHandshakeStreamReady(
182 const SSLConfig& used_ssl_config, 197 const SSLConfig& used_ssl_config,
183 const ProxyInfo& used_proxy_info, 198 const ProxyInfo& used_proxy_info,
184 WebSocketHandshakeStreamBase* stream) { 199 WebSocketHandshakeStreamBase* stream) {
185 NOTREACHED(); 200 NOTREACHED();
186 } 201 }
187 202
188 void BidirectionalStream::OnStreamFailed(int result, 203 void BidirectionalStream::OnStreamFailed(int result,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 const ProxyInfo& used_proxy_info, 243 const ProxyInfo& used_proxy_info,
229 HttpStream* stream) { 244 HttpStream* stream) {
230 DCHECK(stream_request_); 245 DCHECK(stream_request_);
231 246
232 delegate_->OnFailed(ERR_HTTPS_PROXY_TUNNEL_RESPONSE); 247 delegate_->OnFailed(ERR_HTTPS_PROXY_TUNNEL_RESPONSE);
233 } 248 }
234 249
235 void BidirectionalStream::OnQuicBroken() {} 250 void BidirectionalStream::OnQuicBroken() {}
236 251
237 } // namespace net 252 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698