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

Unified Diff: net/http/http_stream_factory_impl_request.cc

Issue 14813024: Introduce RequestWebSocketStream into HttpStreamFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: net/http/http_stream_factory_impl_request.cc
diff --git a/net/http/http_stream_factory_impl_request.cc b/net/http/http_stream_factory_impl_request.cc
index 3fcc7aed1b8863c767ddaddda5669d93607f0579..42969567e6cacd5406a1f55ad84ee74ecaa7a3e9 100644
--- a/net/http/http_stream_factory_impl_request.cc
+++ b/net/http/http_stream_factory_impl_request.cc
@@ -13,12 +13,15 @@
namespace net {
-HttpStreamFactoryImpl::Request::Request(const GURL& url,
- HttpStreamFactoryImpl* factory,
- HttpStreamRequest::Delegate* delegate,
- const BoundNetLog& net_log)
+HttpStreamFactoryImpl::Request::Request(
+ const GURL& url,
+ HttpStreamFactoryImpl* factory,
+ HttpStreamRequest::Delegate* delegate,
+ WebSocketStreamBase::Factory* websocket_stream_factory,
+ const BoundNetLog& net_log)
: url_(url),
factory_(factory),
+ websocket_stream_factory_(websocket_stream_factory),
delegate_(delegate),
net_log_(net_log),
completed_(false),
@@ -94,14 +97,7 @@ void HttpStreamFactoryImpl::Request::Complete(
net_log_.source().ToEventParametersCallback());
}
-void HttpStreamFactoryImpl::Request::OnStreamReady(
- Job* job,
- const SSLConfig& used_ssl_config,
- const ProxyInfo& used_proxy_info,
- HttpStreamBase* stream) {
- DCHECK(stream);
- DCHECK(completed_);
-
+void HttpStreamFactoryImpl::Request::OnJobSucceeded(Job* job) {
// |job| should only be NULL if we're being serviced by a late bound
// SpdySession or HttpPipelinedConnection (one that was not created by a job
// in our |jobs_| set).
@@ -123,9 +119,34 @@ void HttpStreamFactoryImpl::Request::OnStreamReady(
} else {
DCHECK(jobs_.empty());
}
+}
+
+void HttpStreamFactoryImpl::Request::OnStreamReady(
+ Job* job,
+ const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info,
+ HttpStreamBase* stream) {
+ DCHECK(!factory_->for_websockets_);
+ DCHECK(stream);
+ DCHECK(completed_);
+
+ OnJobSucceeded(job);
delegate_->OnStreamReady(used_ssl_config, used_proxy_info, stream);
}
+void HttpStreamFactoryImpl::Request::OnWebSocketStreamReady(
+ Job* job,
+ const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info,
+ WebSocketStreamBase* stream) {
+ DCHECK(factory_->for_websockets_);
+ DCHECK(stream);
+ DCHECK(completed_);
+
+ OnJobSucceeded(job);
+ delegate_->OnWebSocketStreamReady(used_ssl_config, used_proxy_info, stream);
+}
+
void HttpStreamFactoryImpl::Request::OnStreamFailed(
Job* job,
int status,
@@ -280,7 +301,7 @@ HttpStreamFactoryImpl::Request::RemoveRequestFromHttpPipeliningRequestMap() {
}
}
-void HttpStreamFactoryImpl::Request::OnSpdySessionReady(
+void HttpStreamFactoryImpl::Request::OnNewSpdySessionReady(
Job* job,
scoped_refptr<SpdySession> spdy_session,
bool direct) {
@@ -290,7 +311,7 @@ void HttpStreamFactoryImpl::Request::OnSpdySessionReady(
// The first case is the usual case.
if (!bound_job_.get()) {
OrphanJobsExcept(job);
- } else { // This is the case for HTTPS proxy tunneling.
+ } else { // This is the case for HTTPS proxy tunneling.
DCHECK_EQ(bound_job_.get(), job);
DCHECK(jobs_.empty());
}
@@ -308,14 +329,25 @@ void HttpStreamFactoryImpl::Request::OnSpdySessionReady(
// Cache this so we can still use it if the request is deleted.
HttpStreamFactoryImpl* factory = factory_;
-
- bool use_relative_url = direct || url().SchemeIs("https");
- delegate_->OnStreamReady(
- job->server_ssl_config(),
- job->proxy_info(),
- new SpdyHttpStream(spdy_session.get(), use_relative_url));
+ WebSocketStreamBase::Factory* websocket_stream_factory =
+ websocket_stream_factory_;
mmenke 2013/06/10 20:26:03 nit: This should be below the "if (factory->for_w
yhirano 2013/06/11 11:13:16 I deleted this variable.
+ if (factory->for_websockets_) {
+ DCHECK(websocket_stream_factory);
+ bool use_relative_url = direct || url().SchemeIs("wss");
+ delegate_->OnWebSocketStreamReady(
+ job->server_ssl_config(),
+ job->proxy_info(),
+ websocket_stream_factory->CreateSpdyStream(
+ spdy_session, use_relative_url));
+ } else {
+ bool use_relative_url = direct || url().SchemeIs("https");
+ delegate_->OnStreamReady(
+ job->server_ssl_config(),
+ job->proxy_info(),
+ new SpdyHttpStream(spdy_session, use_relative_url));
+ }
// |this| may be deleted after this point.
- factory->OnSpdySessionReady(
+ factory->OnNewSpdySessionReady(
spdy_session, direct, used_ssl_config, used_proxy_info,
was_npn_negotiated, protocol_negotiated, using_spdy, net_log);
}

Powered by Google App Engine
This is Rietveld 408576698