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

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

Issue 1326503003: Added a net::BidirectionalStream to expose a bidirectional streaming interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Comments Created 5 years, 2 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
(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/http_request_info.h"
10 #include "net/http/http_stream.h"
11 #include "net/http/http_transaction_factory.h"
12 #include "net/ssl/ssl_cert_request_info.h"
13 #include "net/url_request/url_request_context.h"
14 #include "url/gurl.h"
15
16 namespace net {
17
18 BidirectionalStreamCreateHelper::BidirectionalStreamCreateHelper(
19 const HttpRequestInfo* request_info,
20 RequestPriority priority,
21 const URLRequestContext* context,
22 Delegate* delegate)
23 : request_info_(request_info),
24 priority_(priority),
25 delegate_(delegate),
26 net_log_(BoundNetLog::Make(context->net_log(),
27 NetLog::SOURCE_BIDIRECTIONAL_STREAM)) {
28 HttpTransactionFactory* factory = context->http_transaction_factory();
29 session_ = factory->GetSession();
30
31 session_->ssl_config_service()->GetSSLConfig(&server_ssl_config_);
32 proxy_ssl_config_ = server_ssl_config_;
33 }
34
35 BidirectionalStreamCreateHelper::~BidirectionalStreamCreateHelper() {
36 if (stream_)
37 stream_->Cancel();
38 }
39
40 void BidirectionalStreamCreateHelper::CreateBidirectionalStream() {
41 if (!request_info_->url.SchemeIs("https")) {
42 delegate_->OnStreamFailed(ERR_DISALLOWED_URL_SCHEME);
43 return;
44 }
45 stream_request_.reset(
46 session_->http_stream_factory()->RequestBidirectionalStream(
47 *request_info_, priority_, server_ssl_config_, proxy_ssl_config_,
48 this, net_log_));
49 }
50
51 void BidirectionalStreamCreateHelper::OnStreamReady(
52 const SSLConfig& used_ssl_config,
53 const ProxyInfo& used_proxy_info,
54 HttpStream* stream) {
55 NOTREACHED();
56 }
57
58 void BidirectionalStreamCreateHelper::OnBidirectionalStreamReady(
59 const SSLConfig& used_ssl_config,
60 const ProxyInfo& used_proxy_info,
61 BidirectionalStream* stream) {
62 stream_.reset(stream);
63 delegate_->OnStreamCreated();
64 }
65
66 void BidirectionalStreamCreateHelper::OnWebSocketHandshakeStreamReady(
67 const SSLConfig& used_ssl_config,
68 const ProxyInfo& used_proxy_info,
69 WebSocketHandshakeStreamBase* stream) {
70 NOTREACHED();
71 }
72
73 void BidirectionalStreamCreateHelper::OnStreamFailed(
74 int result,
75 const SSLConfig& used_ssl_config,
76 SSLFailureState ssl_failure_state) {
77 DCHECK_NE(OK, result);
78 DCHECK(stream_request_.get());
79 DCHECK(!stream_);
80
81 delegate_->OnStreamFailed(result);
82 }
83
84 void BidirectionalStreamCreateHelper::OnCertificateError(
85 int result,
86 const SSLConfig& used_ssl_config,
87 const SSLInfo& ssl_info) {
88 DCHECK_NE(OK, result);
89 DCHECK(stream_request_.get());
90 DCHECK(!stream_);
91
92 delegate_->OnStreamFailed(result);
93 }
94
95 void BidirectionalStreamCreateHelper::OnNeedsProxyAuth(
96 const HttpResponseInfo& proxy_response,
97 const SSLConfig& used_ssl_config,
98 const ProxyInfo& used_proxy_info,
99 HttpAuthController* auth_controller) {
100 DCHECK(stream_request_.get());
101 DCHECK(!stream_);
102
103 delegate_->OnStreamFailed(ERR_PROXY_AUTH_REQUESTED);
104 }
105
106 void BidirectionalStreamCreateHelper::OnNeedsClientAuth(
107 const SSLConfig& used_ssl_config,
108 SSLCertRequestInfo* cert_info) {
109 DCHECK(stream_request_.get());
110 DCHECK(!stream_);
111
112 delegate_->OnStreamFailed(ERR_SSL_CLIENT_AUTH_CERT_NEEDED);
113 }
114
115 void BidirectionalStreamCreateHelper::OnHttpsProxyTunnelResponse(
116 const HttpResponseInfo& response_info,
117 const SSLConfig& used_ssl_config,
118 const ProxyInfo& used_proxy_info,
119 HttpStream* stream) {
120 NOTREACHED();
121 }
122
123 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698