Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "net/http/bidirectional_stream_create_helper.h" | |
| 6 | |
| 7 #include "base/memory/scoped_ptr.h" | |
| 8 #include "net/base/net_errors.h" | |
| 9 #include "net/http/bidirectional_stream.h" | |
| 10 #include "net/http/http_request_info.h" | |
| 11 #include "net/http/http_stream.h" | |
| 12 #include "net/http/http_transaction_factory.h" | |
| 13 #include "net/ssl/ssl_cert_request_info.h" | |
| 14 #include "net/url_request/url_request_context.h" | |
| 15 #include "url/gurl.h" | |
| 16 | |
| 17 namespace net { | |
| 18 | |
| 19 BidirectionalStreamCreateHelper::BidirectionalStreamCreateHelper( | |
| 20 const HttpRequestInfo* request_info, | |
| 21 RequestPriority priority, | |
| 22 const URLRequestContext* context, | |
| 23 Delegate* delegate) | |
| 24 : request_info_(request_info), | |
| 25 priority_(priority), | |
| 26 delegate_(delegate), | |
| 27 net_log_(BoundNetLog::Make(context->net_log(), | |
| 28 NetLog::SOURCE_BIDIRECTIONAL_STREAM)) { | |
|
mmenke
2015/10/21 22:40:16
Hrm...this log is going to look a little weird. N
xunjieli
2015/10/22 20:01:41
Should we make the embedder (who presumably will o
mmenke
2015/10/22 20:13:36
That wouldn't - the way things elsewhere is that t
xunjieli
2015/10/23 17:51:23
Done. Thanks for the detailed explanation! I think
| |
| 29 HttpTransactionFactory* factory = context->http_transaction_factory(); | |
| 30 session_ = factory->GetSession(); | |
| 31 | |
| 32 session_->ssl_config_service()->GetSSLConfig(&server_ssl_config_); | |
| 33 proxy_ssl_config_ = server_ssl_config_; | |
| 34 } | |
| 35 | |
| 36 BidirectionalStreamCreateHelper::~BidirectionalStreamCreateHelper() { | |
| 37 if (stream_) | |
| 38 stream_->Cancel(); | |
| 39 } | |
| 40 | |
| 41 void BidirectionalStreamCreateHelper::CreateBidirectionalStream() { | |
| 42 if (!request_info_->url.SchemeIs("https")) { | |
| 43 delegate_->OnStreamFailed(ERR_DISALLOWED_URL_SCHEME); | |
|
mmenke
2015/10/21 22:40:16
Do we want to invoke callbacks synchronously, or g
xunjieli
2015/10/22 20:01:41
Done. Probably the latter to be more consistent?
mmenke
2015/10/22 20:13:36
I think async is indeed the way to go - avoids re-
| |
| 44 return; | |
| 45 } | |
| 46 stream_request_.reset( | |
| 47 session_->http_stream_factory()->RequestBidirectionalStream( | |
| 48 *request_info_, priority_, server_ssl_config_, proxy_ssl_config_, | |
| 49 this, net_log_)); | |
| 50 } | |
| 51 | |
| 52 void BidirectionalStreamCreateHelper::OnStreamReady( | |
| 53 const SSLConfig& used_ssl_config, | |
| 54 const ProxyInfo& used_proxy_info, | |
| 55 HttpStream* stream) { | |
| 56 NOTREACHED(); | |
| 57 } | |
| 58 | |
| 59 void BidirectionalStreamCreateHelper::OnBidirectionalStreamReady( | |
| 60 const SSLConfig& used_ssl_config, | |
| 61 const ProxyInfo& used_proxy_info, | |
| 62 BidirectionalStream* stream) { | |
| 63 stream_.reset(stream); | |
| 64 delegate_->OnStreamCreated(); | |
|
mmenke
2015/10/21 22:40:16
Should we pass in the stream here (wrapped in a sc
xunjieli
2015/10/22 20:01:41
Done.
| |
| 65 } | |
| 66 | |
| 67 void BidirectionalStreamCreateHelper::OnWebSocketHandshakeStreamReady( | |
| 68 const SSLConfig& used_ssl_config, | |
| 69 const ProxyInfo& used_proxy_info, | |
| 70 WebSocketHandshakeStreamBase* stream) { | |
| 71 NOTREACHED(); | |
| 72 } | |
| 73 | |
| 74 void BidirectionalStreamCreateHelper::OnStreamFailed( | |
| 75 int result, | |
| 76 const SSLConfig& used_ssl_config, | |
| 77 SSLFailureState ssl_failure_state) { | |
| 78 DCHECK_NE(OK, result); | |
|
mmenke
2015/10/21 22:40:16
If we want to DCHECK the result, think we really w
xunjieli
2015/10/22 20:01:41
Done.
| |
| 79 DCHECK(stream_request_.get()); | |
|
mmenke
2015/10/21 22:40:16
nit: .get() isn't needed in any of these.
xunjieli
2015/10/22 20:01:41
Done.
| |
| 80 DCHECK(!stream_); | |
| 81 | |
| 82 delegate_->OnStreamFailed(result); | |
| 83 } | |
| 84 | |
| 85 void BidirectionalStreamCreateHelper::OnCertificateError( | |
| 86 int result, | |
| 87 const SSLConfig& used_ssl_config, | |
| 88 const SSLInfo& ssl_info) { | |
| 89 DCHECK_NE(OK, result); | |
| 90 DCHECK(stream_request_.get()); | |
| 91 DCHECK(!stream_); | |
| 92 | |
| 93 delegate_->OnStreamFailed(result); | |
| 94 } | |
| 95 | |
| 96 void BidirectionalStreamCreateHelper::OnNeedsProxyAuth( | |
| 97 const HttpResponseInfo& proxy_response, | |
| 98 const SSLConfig& used_ssl_config, | |
| 99 const ProxyInfo& used_proxy_info, | |
| 100 HttpAuthController* auth_controller) { | |
| 101 DCHECK(stream_request_.get()); | |
| 102 DCHECK(!stream_); | |
| 103 | |
| 104 delegate_->OnStreamFailed(ERR_PROXY_AUTH_REQUESTED); | |
| 105 } | |
| 106 | |
| 107 void BidirectionalStreamCreateHelper::OnNeedsClientAuth( | |
| 108 const SSLConfig& used_ssl_config, | |
| 109 SSLCertRequestInfo* cert_info) { | |
| 110 DCHECK(stream_request_.get()); | |
| 111 DCHECK(!stream_); | |
| 112 | |
| 113 delegate_->OnStreamFailed(ERR_SSL_CLIENT_AUTH_CERT_NEEDED); | |
| 114 } | |
| 115 | |
| 116 void BidirectionalStreamCreateHelper::OnHttpsProxyTunnelResponse( | |
| 117 const HttpResponseInfo& response_info, | |
| 118 const SSLConfig& used_ssl_config, | |
| 119 const ProxyInfo& used_proxy_info, | |
| 120 HttpStream* stream) { | |
| 121 NOTREACHED(); | |
|
mmenke
2015/10/21 22:40:16
nit: include base/logging.h
xunjieli
2015/10/22 20:01:41
Done.
| |
| 122 } | |
| 123 | |
| 124 } // namespace net | |
| OLD | NEW |