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

Unified Diff: net/http/http_stream_factory_impl.cc

Issue 6591030: Add HttpStreamFactory Job orphaning semantics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated comment. Created 9 years, 10 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
« no previous file with comments | « net/http/http_stream_factory_impl.h ('k') | net/http/http_stream_factory_impl_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_stream_factory_impl.cc
diff --git a/net/http/http_stream_factory_impl.cc b/net/http/http_stream_factory_impl.cc
index 74942a31307dfa5ad0c6f84f50826cb98e6db7ad..c7b0c9308d637c4e66c9f094a9289c37ae36417c 100644
--- a/net/http/http_stream_factory_impl.cc
+++ b/net/http/http_stream_factory_impl.cc
@@ -35,8 +35,7 @@ HttpStreamRequest* HttpStreamFactoryImpl::RequestStream(
const BoundNetLog& net_log) {
Job* job = new Job(this, session_);
Request* request = new Request(request_info.url, this, delegate, net_log);
- request_map_[job] = request;
- request->BindJob(job);
+ request->AttachJob(job);
job->Start(request, request_info, ssl_config, net_log);
return request;
}
@@ -59,27 +58,53 @@ bool HttpStreamFactoryImpl::IsTLSIntolerantServer(const GURL& url) const {
return ContainsKey(tls_intolerant_servers_, GetHostAndPort(url));
}
-LoadState HttpStreamFactoryImpl::GetLoadState(const Request& request) const {
- // TODO(willchan): Will break when we do late binding.
- return request.job()->GetLoadState();
+void HttpStreamFactoryImpl::OrphanJob(Job* job, const Request* request) {
+ DCHECK(ContainsKey(request_map_, job));
+ DCHECK_EQ(request_map_[job], request);
+ DCHECK(!ContainsKey(orphaned_job_set_, job));
+
+ request_map_.erase(job);
+
+ orphaned_job_set_.insert(job);
+ job->Orphan(request);
}
void HttpStreamFactoryImpl::OnSpdySessionReady(
- const Job* job,
scoped_refptr<SpdySession> spdy_session,
- bool direct) {
- DCHECK(job->using_spdy());
- DCHECK(ContainsKey(request_map_, job));
- Request* request = request_map_[job];
- request->Complete(job->was_alternate_protocol_available(),
- job->was_npn_negotiated(),
- job->using_spdy(),
- job->net_log().source());
- bool use_relative_url = direct || request->url().SchemeIs("https");
- request->OnStreamReady(
- job->ssl_config(),
- job->proxy_info(),
- new SpdyHttpStream(spdy_session, use_relative_url));
+ bool direct,
+ const SSLConfig& used_ssl_config,
+ const ProxyInfo& used_proxy_info,
+ bool was_alternate_protocol_available,
+ bool was_npn_negotiated,
+ bool using_spdy,
+ const NetLog::Source& source) {
+ const HostPortProxyPair& spdy_session_key =
+ spdy_session->host_port_proxy_pair();
+ while (!spdy_session->IsClosed()) {
+ // Each iteration may empty out the RequestSet for |spdy_session_key_ in
+ // |spdy_session_request_map_|. So each time, check for RequestSet and use
+ // the first one.
+ //
+ // TODO(willchan): If it's important, switch RequestSet out for a FIFO
+ // pqueue (Order by priority first, then FIFO within same priority). Unclear
+ // that it matters here.
+ if (!ContainsKey(spdy_session_request_map_, spdy_session_key))
+ break;
+ Request* request = *spdy_session_request_map_[spdy_session_key].begin();
+ request->Complete(was_alternate_protocol_available,
+ was_npn_negotiated,
+ using_spdy,
+ source);
+ bool use_relative_url = direct || request->url().SchemeIs("https");
+ request->OnStreamReady(NULL, used_ssl_config, used_proxy_info,
+ new SpdyHttpStream(spdy_session, use_relative_url));
+ }
+ // TODO(mbelshe): Alert other valid requests.
+}
+
+void HttpStreamFactoryImpl::OnOrphanedJobComplete(const Job* job) {
+ orphaned_job_set_.erase(job);
+ delete job;
}
void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) {
« no previous file with comments | « net/http/http_stream_factory_impl.h ('k') | net/http/http_stream_factory_impl_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698