| Index: net/http/bidirectional_stream_create_helper.cc
|
| diff --git a/net/http/bidirectional_stream_create_helper.cc b/net/http/bidirectional_stream_create_helper.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6ec3d5de882e78cebea230d8d71300ebdaf11aeb
|
| --- /dev/null
|
| +++ b/net/http/bidirectional_stream_create_helper.cc
|
| @@ -0,0 +1,123 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "net/http/bidirectional_stream_create_helper.h"
|
| +
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "net/base/net_errors.h"
|
| +#include "net/http/http_request_info.h"
|
| +#include "net/http/http_stream.h"
|
| +#include "net/http/http_transaction_factory.h"
|
| +#include "net/ssl/ssl_cert_request_info.h"
|
| +#include "net/url_request/url_request_context.h"
|
| +#include "url/gurl.h"
|
| +
|
| +namespace net {
|
| +
|
| +BidirectionalStreamCreateHelper::BidirectionalStreamCreateHelper(
|
| + const HttpRequestInfo* request_info,
|
| + RequestPriority priority,
|
| + const URLRequestContext* context,
|
| + Delegate* delegate)
|
| + : request_info_(request_info),
|
| + priority_(priority),
|
| + delegate_(delegate),
|
| + net_log_(BoundNetLog::Make(context->net_log(),
|
| + NetLog::SOURCE_BIDIRECTIONAL_STREAM)) {
|
| + HttpTransactionFactory* factory = context->http_transaction_factory();
|
| + session_ = factory->GetSession();
|
| +
|
| + session_->ssl_config_service()->GetSSLConfig(&server_ssl_config_);
|
| + proxy_ssl_config_ = server_ssl_config_;
|
| +}
|
| +
|
| +BidirectionalStreamCreateHelper::~BidirectionalStreamCreateHelper() {
|
| + if (stream_)
|
| + stream_->Cancel();
|
| +}
|
| +
|
| +void BidirectionalStreamCreateHelper::CreateBidirectionalStream() {
|
| + if (!request_info_->url.SchemeIs("https")) {
|
| + delegate_->OnStreamFailed(ERR_DISALLOWED_URL_SCHEME);
|
| + return;
|
| + }
|
| + stream_request_.reset(
|
| + session_->http_stream_factory()->RequestBidirectionalStream(
|
| + *request_info_, priority_, server_ssl_config_, proxy_ssl_config_,
|
| + this, net_log_));
|
| +}
|
| +
|
| +void BidirectionalStreamCreateHelper::OnStreamReady(
|
| + const SSLConfig& used_ssl_config,
|
| + const ProxyInfo& used_proxy_info,
|
| + HttpStream* stream) {
|
| + NOTREACHED();
|
| +}
|
| +
|
| +void BidirectionalStreamCreateHelper::OnBidirectionalStreamReady(
|
| + const SSLConfig& used_ssl_config,
|
| + const ProxyInfo& used_proxy_info,
|
| + BidirectionalStream* stream) {
|
| + stream_.reset(stream);
|
| + delegate_->OnStreamCreated();
|
| +}
|
| +
|
| +void BidirectionalStreamCreateHelper::OnWebSocketHandshakeStreamReady(
|
| + const SSLConfig& used_ssl_config,
|
| + const ProxyInfo& used_proxy_info,
|
| + WebSocketHandshakeStreamBase* stream) {
|
| + NOTREACHED();
|
| +}
|
| +
|
| +void BidirectionalStreamCreateHelper::OnStreamFailed(
|
| + int result,
|
| + const SSLConfig& used_ssl_config,
|
| + SSLFailureState ssl_failure_state) {
|
| + DCHECK_NE(OK, result);
|
| + DCHECK(stream_request_.get());
|
| + DCHECK(!stream_);
|
| +
|
| + delegate_->OnStreamFailed(result);
|
| +}
|
| +
|
| +void BidirectionalStreamCreateHelper::OnCertificateError(
|
| + int result,
|
| + const SSLConfig& used_ssl_config,
|
| + const SSLInfo& ssl_info) {
|
| + DCHECK_NE(OK, result);
|
| + DCHECK(stream_request_.get());
|
| + DCHECK(!stream_);
|
| +
|
| + delegate_->OnStreamFailed(result);
|
| +}
|
| +
|
| +void BidirectionalStreamCreateHelper::OnNeedsProxyAuth(
|
| + const HttpResponseInfo& proxy_response,
|
| + const SSLConfig& used_ssl_config,
|
| + const ProxyInfo& used_proxy_info,
|
| + HttpAuthController* auth_controller) {
|
| + DCHECK(stream_request_.get());
|
| + DCHECK(!stream_);
|
| +
|
| + delegate_->OnStreamFailed(ERR_PROXY_AUTH_REQUESTED);
|
| +}
|
| +
|
| +void BidirectionalStreamCreateHelper::OnNeedsClientAuth(
|
| + const SSLConfig& used_ssl_config,
|
| + SSLCertRequestInfo* cert_info) {
|
| + DCHECK(stream_request_.get());
|
| + DCHECK(!stream_);
|
| +
|
| + delegate_->OnStreamFailed(ERR_SSL_CLIENT_AUTH_CERT_NEEDED);
|
| +}
|
| +
|
| +void BidirectionalStreamCreateHelper::OnHttpsProxyTunnelResponse(
|
| + const HttpResponseInfo& response_info,
|
| + const SSLConfig& used_ssl_config,
|
| + const ProxyInfo& used_proxy_info,
|
| + HttpStream* stream) {
|
| + NOTREACHED();
|
| +}
|
| +
|
| +} // namespace net
|
|
|