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

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

Issue 1817583002: Process Alternative Service headers in net::BidirectionalStream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@toggle2
Patch Set: Address comments and rebased Created 4 years, 9 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
« no previous file with comments | « net/http/bidirectional_stream.h ('k') | net/http/bidirectional_stream_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_stream.h" 19 #include "net/http/http_stream.h"
20 #include "net/spdy/spdy_http_utils.h"
19 #include "net/ssl/ssl_cert_request_info.h" 21 #include "net/ssl/ssl_cert_request_info.h"
20 #include "net/ssl/ssl_config.h" 22 #include "net/ssl/ssl_config.h"
21 #include "url/gurl.h" 23 #include "url/gurl.h"
22 24
23 namespace net { 25 namespace net {
24 26
25 BidirectionalStream::Delegate::Delegate() {} 27 BidirectionalStream::Delegate::Delegate() {}
26 28
27 BidirectionalStream::Delegate::~Delegate() {} 29 BidirectionalStream::Delegate::~Delegate() {}
28 30
29 BidirectionalStream::BidirectionalStream( 31 BidirectionalStream::BidirectionalStream(
30 scoped_ptr<BidirectionalStreamRequestInfo> request_info, 32 scoped_ptr<BidirectionalStreamRequestInfo> request_info,
31 HttpNetworkSession* session, 33 HttpNetworkSession* session,
32 Delegate* delegate) 34 Delegate* delegate)
33 : BidirectionalStream(std::move(request_info), 35 : BidirectionalStream(std::move(request_info),
34 session, 36 session,
35 delegate, 37 delegate,
36 make_scoped_ptr(new base::Timer(false, false))) {} 38 make_scoped_ptr(new base::Timer(false, false))) {}
37 39
38 BidirectionalStream::BidirectionalStream( 40 BidirectionalStream::BidirectionalStream(
39 scoped_ptr<BidirectionalStreamRequestInfo> request_info, 41 scoped_ptr<BidirectionalStreamRequestInfo> request_info,
40 HttpNetworkSession* session, 42 HttpNetworkSession* session,
41 Delegate* delegate, 43 Delegate* delegate,
42 scoped_ptr<base::Timer> timer) 44 scoped_ptr<base::Timer> timer)
43 : request_info_(std::move(request_info)), 45 : request_info_(std::move(request_info)),
44 net_log_(BoundNetLog::Make(session->net_log(), 46 net_log_(BoundNetLog::Make(session->net_log(),
45 NetLog::SOURCE_BIDIRECTIONAL_STREAM)), 47 NetLog::SOURCE_BIDIRECTIONAL_STREAM)),
48 session_(session),
46 delegate_(delegate), 49 delegate_(delegate),
47 timer_(std::move(timer)) { 50 timer_(std::move(timer)) {
48 DCHECK(delegate_); 51 DCHECK(delegate_);
49 DCHECK(request_info_); 52 DCHECK(request_info_);
50 53
51 SSLConfig server_ssl_config; 54 SSLConfig server_ssl_config;
52 session->ssl_config_service()->GetSSLConfig(&server_ssl_config); 55 session->ssl_config_service()->GetSSLConfig(&server_ssl_config);
53 session->GetAlpnProtos(&server_ssl_config.alpn_protos); 56 session->GetAlpnProtos(&server_ssl_config.alpn_protos);
54 session->GetNpnProtos(&server_ssl_config.npn_protos); 57 session->GetNpnProtos(&server_ssl_config.npn_protos);
55 58
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 125
123 return stream_job_->GetTotalSentBytes(); 126 return stream_job_->GetTotalSentBytes();
124 } 127 }
125 128
126 void BidirectionalStream::OnHeadersSent() { 129 void BidirectionalStream::OnHeadersSent() {
127 delegate_->OnHeadersSent(); 130 delegate_->OnHeadersSent();
128 } 131 }
129 132
130 void BidirectionalStream::OnHeadersReceived( 133 void BidirectionalStream::OnHeadersReceived(
131 const SpdyHeaderBlock& response_headers) { 134 const SpdyHeaderBlock& response_headers) {
135 HttpResponseInfo response_info;
136 if (!SpdyHeadersToHttpResponse(response_headers, HTTP2, &response_info)) {
137 DLOG(WARNING) << "Invalid headers";
138 delegate_->OnFailed(ERR_FAILED);
139 return;
140 }
141
142 session_->http_stream_factory()->ProcessAlternativeServices(
143 session_, response_info.headers.get(),
144 HostPortPair::FromURL(request_info_->url));
132 delegate_->OnHeadersReceived(response_headers); 145 delegate_->OnHeadersReceived(response_headers);
133 } 146 }
134 147
135 void BidirectionalStream::OnDataRead(int bytes_read) { 148 void BidirectionalStream::OnDataRead(int bytes_read) {
136 delegate_->OnDataRead(bytes_read); 149 delegate_->OnDataRead(bytes_read);
137 } 150 }
138 151
139 void BidirectionalStream::OnDataSent() { 152 void BidirectionalStream::OnDataSent() {
140 delegate_->OnDataSent(); 153 delegate_->OnDataSent();
141 } 154 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 const ProxyInfo& used_proxy_info, 228 const ProxyInfo& used_proxy_info,
216 HttpStream* stream) { 229 HttpStream* stream) {
217 DCHECK(stream_request_); 230 DCHECK(stream_request_);
218 231
219 delegate_->OnFailed(ERR_HTTPS_PROXY_TUNNEL_RESPONSE); 232 delegate_->OnFailed(ERR_HTTPS_PROXY_TUNNEL_RESPONSE);
220 } 233 }
221 234
222 void BidirectionalStream::OnQuicBroken() {} 235 void BidirectionalStream::OnQuicBroken() {}
223 236
224 } // namespace net 237 } // namespace net
OLDNEW
« no previous file with comments | « net/http/bidirectional_stream.h ('k') | net/http/bidirectional_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698