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 <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 : request_info_(std::move(request_info)), | 83 : request_info_(std::move(request_info)), |
84 net_log_(BoundNetLog::Make(session->net_log(), | 84 net_log_(BoundNetLog::Make(session->net_log(), |
85 NetLog::SOURCE_BIDIRECTIONAL_STREAM)), | 85 NetLog::SOURCE_BIDIRECTIONAL_STREAM)), |
86 session_(session), | 86 session_(session), |
87 disable_auto_flush_(disable_auto_flush), | 87 disable_auto_flush_(disable_auto_flush), |
88 delegate_(delegate), | 88 delegate_(delegate), |
89 timer_(std::move(timer)) { | 89 timer_(std::move(timer)) { |
90 DCHECK(delegate_); | 90 DCHECK(delegate_); |
91 DCHECK(request_info_); | 91 DCHECK(request_info_); |
92 | 92 |
93 if (net_log_.IsCapturing()) { | |
mef
2016/06/01 17:25:40
Should this go down below the failure exit if not
xunjieli
2016/06/01 17:38:45
I think it should be before the failure exit. In c
mef
2016/06/01 17:45:33
sgtm, thanks for explanation!
xunjieli
2016/06/01 22:23:28
thanks for the review!
| |
94 net_log_.BeginEvent( | |
95 NetLog::TYPE_BIDIRECTIONAL_STREAM_ALIVE, | |
96 base::Bind(&NetLogCallback, &request_info_->url, &request_info_->method, | |
97 base::Unretained(&request_info_->extra_headers))); | |
98 } | |
99 | |
93 SSLConfig server_ssl_config; | 100 SSLConfig server_ssl_config; |
94 session->ssl_config_service()->GetSSLConfig(&server_ssl_config); | 101 session->ssl_config_service()->GetSSLConfig(&server_ssl_config); |
95 session->GetAlpnProtos(&server_ssl_config.alpn_protos); | 102 session->GetAlpnProtos(&server_ssl_config.alpn_protos); |
96 session->GetNpnProtos(&server_ssl_config.npn_protos); | 103 session->GetNpnProtos(&server_ssl_config.npn_protos); |
97 | 104 |
98 if (!request_info_->url.SchemeIs(url::kHttpsScheme)) { | 105 if (!request_info_->url.SchemeIs(url::kHttpsScheme)) { |
99 base::ThreadTaskRunnerHandle::Get()->PostTask( | 106 base::ThreadTaskRunnerHandle::Get()->PostTask( |
100 FROM_HERE, | 107 FROM_HERE, |
101 base::Bind(&BidirectionalStream::Delegate::OnFailed, | 108 base::Bind(&BidirectionalStream::Delegate::OnFailed, |
102 base::Unretained(delegate_), ERR_DISALLOWED_URL_SCHEME)); | 109 base::Unretained(delegate_), ERR_DISALLOWED_URL_SCHEME)); |
103 return; | 110 return; |
104 } | 111 } |
105 | 112 |
106 HttpRequestInfo http_request_info; | 113 HttpRequestInfo http_request_info; |
107 http_request_info.url = request_info_->url; | 114 http_request_info.url = request_info_->url; |
108 http_request_info.method = request_info_->method; | 115 http_request_info.method = request_info_->method; |
109 http_request_info.extra_headers = request_info_->extra_headers; | 116 http_request_info.extra_headers = request_info_->extra_headers; |
110 stream_request_.reset( | 117 stream_request_.reset( |
111 session->http_stream_factory()->RequestBidirectionalStreamImpl( | 118 session->http_stream_factory()->RequestBidirectionalStreamImpl( |
112 http_request_info, request_info_->priority, server_ssl_config, | 119 http_request_info, request_info_->priority, server_ssl_config, |
113 server_ssl_config, this, net_log_)); | 120 server_ssl_config, this, net_log_)); |
114 // Check that this call cannot fail to set a non-NULL |stream_request_|. | 121 // Check that this call cannot fail to set a non-NULL |stream_request_|. |
115 DCHECK(stream_request_); | 122 DCHECK(stream_request_); |
116 // Check that HttpStreamFactory does not invoke OnBidirectionalStreamImplReady | 123 // Check that HttpStreamFactory does not invoke OnBidirectionalStreamImplReady |
117 // synchronously. | 124 // synchronously. |
118 DCHECK(!stream_impl_); | 125 DCHECK(!stream_impl_); |
119 if (net_log_.IsCapturing()) { | |
120 net_log_.BeginEvent( | |
121 NetLog::TYPE_BIDIRECTIONAL_STREAM_ALIVE, | |
122 base::Bind(&NetLogCallback, &request_info_->url, &request_info_->method, | |
123 base::Unretained(&request_info_->extra_headers))); | |
124 } | |
125 } | 126 } |
126 | 127 |
127 BidirectionalStream::~BidirectionalStream() { | 128 BidirectionalStream::~BidirectionalStream() { |
128 Cancel(); | 129 Cancel(); |
129 if (net_log_.IsCapturing()) { | 130 if (net_log_.IsCapturing()) { |
130 net_log_.EndEvent(NetLog::TYPE_BIDIRECTIONAL_STREAM_ALIVE); | 131 net_log_.EndEvent(NetLog::TYPE_BIDIRECTIONAL_STREAM_ALIVE); |
131 } | 132 } |
132 } | 133 } |
133 | 134 |
134 int BidirectionalStream::ReadData(IOBuffer* buf, int buf_len) { | 135 int BidirectionalStream::ReadData(IOBuffer* buf, int buf_len) { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 const ProxyInfo& used_proxy_info, | 333 const ProxyInfo& used_proxy_info, |
333 HttpStream* stream) { | 334 HttpStream* stream) { |
334 DCHECK(stream_request_); | 335 DCHECK(stream_request_); |
335 | 336 |
336 delegate_->OnFailed(ERR_HTTPS_PROXY_TUNNEL_RESPONSE); | 337 delegate_->OnFailed(ERR_HTTPS_PROXY_TUNNEL_RESPONSE); |
337 } | 338 } |
338 | 339 |
339 void BidirectionalStream::OnQuicBroken() {} | 340 void BidirectionalStream::OnQuicBroken() {} |
340 | 341 |
341 } // namespace net | 342 } // namespace net |
OLD | NEW |