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

Side by Side 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: Add support for SPDY late binding. Created 9 years, 9 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 | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_stream_factory_impl.h" 5 #include "net/http/http_stream_factory_impl.h"
6 6
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 #include "net/base/net_log.h" 9 #include "net/base/net_log.h"
10 #include "net/base/net_util.h" 10 #include "net/base/net_util.h"
(...skipping 17 matching lines...) Expand all
28 DCHECK(preconnect_job_set_.empty()); 28 DCHECK(preconnect_job_set_.empty());
29 } 29 }
30 30
31 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( 31 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream(
32 const HttpRequestInfo& request_info, 32 const HttpRequestInfo& request_info,
33 const SSLConfig& ssl_config, 33 const SSLConfig& ssl_config,
34 HttpStreamRequest::Delegate* delegate, 34 HttpStreamRequest::Delegate* delegate,
35 const BoundNetLog& net_log) { 35 const BoundNetLog& net_log) {
36 Job* job = new Job(this, session_); 36 Job* job = new Job(this, session_);
37 Request* request = new Request(request_info.url, this, delegate, net_log); 37 Request* request = new Request(request_info.url, this, delegate, net_log);
38 request_map_[job] = request; 38 request->AttachJob(job);
39 request->BindJob(job);
40 job->Start(request, request_info, ssl_config, net_log); 39 job->Start(request, request_info, ssl_config, net_log);
41 return request; 40 return request;
42 } 41 }
43 42
44 void HttpStreamFactoryImpl::PreconnectStreams( 43 void HttpStreamFactoryImpl::PreconnectStreams(
45 int num_streams, 44 int num_streams,
46 const HttpRequestInfo& request_info, 45 const HttpRequestInfo& request_info,
47 const SSLConfig& ssl_config, 46 const SSLConfig& ssl_config,
48 const BoundNetLog& net_log) { 47 const BoundNetLog& net_log) {
49 Job* job = new Job(this, session_); 48 Job* job = new Job(this, session_);
50 preconnect_job_set_.insert(job); 49 preconnect_job_set_.insert(job);
51 job->Preconnect(num_streams, request_info, ssl_config, net_log); 50 job->Preconnect(num_streams, request_info, ssl_config, net_log);
52 } 51 }
53 52
54 void HttpStreamFactoryImpl::AddTLSIntolerantServer(const GURL& url) { 53 void HttpStreamFactoryImpl::AddTLSIntolerantServer(const GURL& url) {
55 tls_intolerant_servers_.insert(GetHostAndPort(url)); 54 tls_intolerant_servers_.insert(GetHostAndPort(url));
56 } 55 }
57 56
58 bool HttpStreamFactoryImpl::IsTLSIntolerantServer(const GURL& url) const { 57 bool HttpStreamFactoryImpl::IsTLSIntolerantServer(const GURL& url) const {
59 return ContainsKey(tls_intolerant_servers_, GetHostAndPort(url)); 58 return ContainsKey(tls_intolerant_servers_, GetHostAndPort(url));
60 } 59 }
61 60
62 LoadState HttpStreamFactoryImpl::GetLoadState(const Request& request) const { 61 void HttpStreamFactoryImpl::OrphanJob(Job* job, const Request* request) {
63 // TODO(willchan): Will break when we do late binding. 62 DCHECK(ContainsKey(request_map_, job));
64 return request.job()->GetLoadState(); 63 DCHECK_EQ(request_map_[job], request);
64 DCHECK(!ContainsKey(orphaned_job_set_, job));
65
66 request_map_.erase(job);
67
68 orphaned_job_set_.insert(job);
69 job->Orphan(request);
65 } 70 }
66 71
67 void HttpStreamFactoryImpl::OnSpdySessionReady( 72 void HttpStreamFactoryImpl::OnSpdySessionReady(
68 const Job* job,
69 scoped_refptr<SpdySession> spdy_session, 73 scoped_refptr<SpdySession> spdy_session,
70 bool direct) { 74 bool direct,
71 DCHECK(job->using_spdy()); 75 const SSLConfig& used_ssl_config,
72 DCHECK(ContainsKey(request_map_, job)); 76 const ProxyInfo& used_proxy_info,
73 Request* request = request_map_[job]; 77 bool was_alternate_protocol_available,
74 request->Complete(job->was_alternate_protocol_available(), 78 bool was_npn_negotiated,
75 job->was_npn_negotiated(), 79 bool using_spdy,
76 job->using_spdy(), 80 const NetLog::Source& source) {
77 job->net_log().source()); 81 const HostPortProxyPair& spdy_session_key =
78 bool use_relative_url = direct || request->url().SchemeIs("https"); 82 spdy_session->host_port_proxy_pair();
79 request->OnStreamReady( 83 while (!spdy_session->IsClosed()) {
80 job->ssl_config(), 84 // Each iteration may empty out the RequestSet for |spdy_session_key_ in
81 job->proxy_info(), 85 // |spdy_session_request_map_|. So each time, check for RequestSet and use
82 new SpdyHttpStream(spdy_session, use_relative_url)); 86 // the first one.
87 //
88 // TODO(willchan): If it's important, switch RequestSet out for a FIFO
willchan no longer on Chromium 2011/03/01 00:22:42 Please comment here if you think this is important
89 // pqueue (Order by priority first, then FIFO within same priority). Unclear
90 // that it matters here.
91 if (!ContainsKey(spdy_session_request_map_, spdy_session_key))
92 break;
93 Request* request = *spdy_session_request_map_[spdy_session_key].begin();
94 request->Complete(was_alternate_protocol_available,
95 was_npn_negotiated,
96 using_spdy,
97 source);
98 bool use_relative_url = direct || request->url().SchemeIs("https");
99 request->OnStreamReady(NULL, used_ssl_config, used_proxy_info,
100 new SpdyHttpStream(spdy_session, use_relative_url));
101 }
102 // TODO(mbelshe): Alert other valid requests.
willchan no longer on Chromium 2011/03/01 00:22:42 You will need to update this to search other valid
103 }
104
105 void HttpStreamFactoryImpl::OnOrphanedJobComplete(const Job* job) {
106 orphaned_job_set_.erase(job);
107 delete job;
83 } 108 }
84 109
85 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { 110 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) {
86 preconnect_job_set_.erase(job); 111 preconnect_job_set_.erase(job);
87 delete job; 112 delete job;
88 OnPreconnectsCompleteInternal(); 113 OnPreconnectsCompleteInternal();
89 } 114 }
90 115
91 } // namespace net 116 } // namespace net
OLDNEW
« 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