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

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: 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..a2b9a95ec8c9ad88945f959fd4314331b7561150 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) {
mmenke 2013/06/17 19:55:01 nit: Was great to keep this here for easy review,
yhirano 2013/06/18 08:34:14 Done.
// |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,23 @@ 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));
+ 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);
}
@@ -340,6 +370,16 @@ void HttpStreamFactoryImpl::Request::OrphanJobs() {
for (std::set<Job*>::iterator it = tmp.begin(); it != tmp.end(); ++it)
factory_->OrphanJob(*it, this);
+
+ if (factory_->for_websockets_) {
mmenke 2013/06/17 19:55:01 I think this should go in Job::Orphan - we already
yhirano 2013/06/18 08:34:14 Done.
+ // We cancel orphaned jobs because WebSocketStream can't be created
+ // without a WebSocketStreamBase::Factory which is stored in this class
+ // and isn't accessible from an orphaned job.
+ for (std::set<Job*>::iterator it = tmp.begin(); it != tmp.end(); ++it) {
+ factory_->OnOrphanedJobComplete(*it);
+ // |*it| is deleted here.
+ }
+ }
}
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698