Index: net/http/http_stream_factory_impl_job.cc |
diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc |
index 8ae5f82b91e3f21b463297142d128e08675eba21..044bfd9a17864accef59dc490a97e34907cbbdbb 100644 |
--- a/net/http/http_stream_factory_impl_job.cc |
+++ b/net/http/http_stream_factory_impl_job.cc |
@@ -45,6 +45,21 @@ GURL UpgradeUrlToHttps(const GURL& original_url) { |
return original_url.ReplaceComponents(replacements); |
} |
+// Parameters associated with the creation of a Job. |
+class JobCreationParameters : public NetLog::EventParameters { |
+ public: |
+ JobCreationParameters(const std::string& url) : url_(url) {} |
+ |
+ virtual Value* ToValue() const { |
+ DictionaryValue* dict = new DictionaryValue(); |
+ dict->SetString("url", url_); |
+ return dict; |
+ } |
+ |
+ private: |
+ const std::string url_; |
+}; |
+ |
} // namespace |
HttpStreamFactoryImpl::Job::Job(HttpStreamFactoryImpl* stream_factory, |
@@ -134,6 +149,11 @@ LoadState HttpStreamFactoryImpl::Job::GetLoadState() const { |
} |
} |
+void HttpStreamFactoryImpl::Job::Orphan(const Request* request) { |
+ DCHECK_EQ(request_, request); |
+ request_ = NULL; |
+} |
+ |
bool HttpStreamFactoryImpl::Job::was_alternate_protocol_available() const { |
return was_alternate_protocol_available_; |
} |
@@ -165,59 +185,96 @@ void HttpStreamFactoryImpl::Job::GetSSLInfo() { |
void HttpStreamFactoryImpl::Job::OnStreamReadyCallback() { |
DCHECK(stream_.get()); |
- request_->Complete(was_alternate_protocol_available(), |
- was_npn_negotiated(), |
- using_spdy(), |
- net_log_.source()); |
- request_->OnStreamReady(ssl_config_, proxy_info_, stream_.release()); |
+ DCHECK(!IsPreconnecting()); |
+ if (IsOrphaned()) { |
+ stream_factory_->OnOrphanedJobComplete(this); |
+ } else { |
+ request_->Complete(was_alternate_protocol_available(), |
+ was_npn_negotiated(), |
+ using_spdy(), |
+ net_log_.source()); |
+ request_->OnStreamReady(this, ssl_config_, proxy_info_, stream_.release()); |
+ } |
// |this| may be deleted after this call. |
} |
void HttpStreamFactoryImpl::Job::OnSpdySessionReadyCallback() { |
DCHECK(!stream_.get()); |
+ DCHECK(!IsPreconnecting()); |
DCHECK(using_spdy()); |
DCHECK(new_spdy_session_); |
scoped_refptr<SpdySession> spdy_session = new_spdy_session_; |
new_spdy_session_ = NULL; |
- stream_factory_->OnSpdySessionReady(this, spdy_session, spdy_session_direct_); |
+ if (IsOrphaned()) { |
+ // TODO(willchan): This is actually probably yet another opportunity for |
+ // improving SPDY late binding. Investigate getting this to work. It'll |
+ // probably make a bigger difference when we have ip connection pooling. |
+ stream_factory_->OnOrphanedJobComplete(this); |
+ } else { |
+ request_->OnSpdySessionReady(this, spdy_session, spdy_session_direct_); |
+ } |
// |this| may be deleted after this call. |
} |
void HttpStreamFactoryImpl::Job::OnStreamFailedCallback(int result) { |
- request_->OnStreamFailed(result, ssl_config_); |
+ DCHECK(!IsPreconnecting()); |
+ if (IsOrphaned()) |
+ stream_factory_->OnOrphanedJobComplete(this); |
+ else |
+ request_->OnStreamFailed(this, result, ssl_config_); |
// |this| may be deleted after this call. |
} |
void HttpStreamFactoryImpl::Job::OnCertificateErrorCallback( |
int result, const SSLInfo& ssl_info) { |
- request_->OnCertificateError(result, ssl_config_, ssl_info); |
+ DCHECK(!IsPreconnecting()); |
+ if (IsOrphaned()) |
+ stream_factory_->OnOrphanedJobComplete(this); |
+ else |
+ request_->OnCertificateError(this, result, ssl_config_, ssl_info); |
// |this| may be deleted after this call. |
} |
void HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback( |
const HttpResponseInfo& response, |
HttpAuthController* auth_controller) { |
- request_->OnNeedsProxyAuth( |
- response, ssl_config_, proxy_info_, auth_controller); |
+ DCHECK(!IsPreconnecting()); |
+ if (IsOrphaned()) |
+ stream_factory_->OnOrphanedJobComplete(this); |
+ else |
+ request_->OnNeedsProxyAuth( |
+ this, response, ssl_config_, proxy_info_, auth_controller); |
// |this| may be deleted after this call. |
} |
void HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback( |
SSLCertRequestInfo* cert_info) { |
- request_->OnNeedsClientAuth(ssl_config_, cert_info); |
+ DCHECK(!IsPreconnecting()); |
+ if (IsOrphaned()) |
+ stream_factory_->OnOrphanedJobComplete(this); |
+ else |
+ request_->OnNeedsClientAuth(this, ssl_config_, cert_info); |
// |this| may be deleted after this call. |
} |
void HttpStreamFactoryImpl::Job::OnHttpsProxyTunnelResponseCallback( |
const HttpResponseInfo& response_info, |
HttpStream* stream) { |
- request_->OnHttpsProxyTunnelResponse( |
- response_info, ssl_config_, proxy_info_, stream); |
+ DCHECK(!IsPreconnecting()); |
+ if (IsOrphaned()) |
+ stream_factory_->OnOrphanedJobComplete(this); |
+ else |
+ request_->OnHttpsProxyTunnelResponse( |
+ this, response_info, ssl_config_, proxy_info_, stream); |
// |this| may be deleted after this call. |
} |
void HttpStreamFactoryImpl::Job::OnPreconnectsComplete() { |
- stream_factory_->OnPreconnectsComplete(this); |
+ DCHECK(!request_); |
+ if (IsOrphaned()) |
+ stream_factory_->OnOrphanedJobComplete(this); |
+ else |
+ stream_factory_->OnPreconnectsComplete(this); |
// |this| may be deleted after this call. |
} |
@@ -522,7 +579,7 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() { |
using_spdy_ = true; |
next_state_ = STATE_CREATE_STREAM; |
return OK; |
- } else if (!IsPreconnecting()) { |
+ } else if (request_) { |
// Update the spdy session key for the request that launched this job. |
request_->SetSpdySessionKey(spdy_session_key); |
} |
@@ -1134,4 +1191,8 @@ bool HttpStreamFactoryImpl::Job::IsPreconnecting() const { |
return num_streams_ > 0; |
} |
+bool HttpStreamFactoryImpl::Job::IsOrphaned() const { |
+ return !IsPreconnecting() && !request_; |
+} |
+ |
} // namespace net |