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

Side by Side Diff: net/http/http_stream_factory_impl_request.cc

Issue 7289006: Basic HTTP pipelining support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 9 years, 2 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_request.h ('k') | net/http/http_stream_parser.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_request.h" 5 #include "net/http/http_stream_factory_impl_request.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "net/http/http_stream_factory_impl_job.h" 9 #include "net/http/http_stream_factory_impl_job.h"
10 #include "net/spdy/spdy_http_stream.h" 10 #include "net/spdy/spdy_http_stream.h"
(...skipping 22 matching lines...) Expand all
33 if (bound_job_.get()) 33 if (bound_job_.get())
34 DCHECK(jobs_.empty()); 34 DCHECK(jobs_.empty());
35 else 35 else
36 DCHECK(!jobs_.empty()); 36 DCHECK(!jobs_.empty());
37 37
38 net_log_.EndEvent(NetLog::TYPE_HTTP_STREAM_REQUEST, NULL); 38 net_log_.EndEvent(NetLog::TYPE_HTTP_STREAM_REQUEST, NULL);
39 39
40 for (std::set<Job*>::iterator it = jobs_.begin(); it != jobs_.end(); ++it) 40 for (std::set<Job*>::iterator it = jobs_.begin(); it != jobs_.end(); ++it)
41 factory_->request_map_.erase(*it); 41 factory_->request_map_.erase(*it);
42 42
43 RemoveRequestFromSpdySessionRequestMap();
44 RemoveRequestFromHttpPipeliningRequestMap();
45
43 STLDeleteElements(&jobs_); 46 STLDeleteElements(&jobs_);
44
45 RemoveRequestFromSpdySessionRequestMap();
46 } 47 }
47 48
48 void HttpStreamFactoryImpl::Request::SetSpdySessionKey( 49 void HttpStreamFactoryImpl::Request::SetSpdySessionKey(
49 const HostPortProxyPair& spdy_session_key) { 50 const HostPortProxyPair& spdy_session_key) {
50 DCHECK(!spdy_session_key_.get()); 51 DCHECK(!spdy_session_key_.get());
51 spdy_session_key_.reset(new HostPortProxyPair(spdy_session_key)); 52 spdy_session_key_.reset(new HostPortProxyPair(spdy_session_key));
52 RequestSet& request_set = 53 RequestSet& request_set =
53 factory_->spdy_session_request_map_[spdy_session_key]; 54 factory_->spdy_session_request_map_[spdy_session_key];
54 DCHECK(!ContainsKey(request_set, this)); 55 DCHECK(!ContainsKey(request_set, this));
55 request_set.insert(this); 56 request_set.insert(this);
56 } 57 }
57 58
59 void HttpStreamFactoryImpl::Request::SetHttpPipeliningKey(
60 const HostPortPair& http_pipelining_key) {
61 DCHECK(!http_pipelining_key_.get());
62 http_pipelining_key_.reset(new HostPortPair(http_pipelining_key));
63 RequestSet& request_set =
64 factory_->http_pipelining_request_map_[http_pipelining_key];
65 DCHECK(!ContainsKey(request_set, this));
66 request_set.insert(this);
67 }
68
58 void HttpStreamFactoryImpl::Request::AttachJob(Job* job) { 69 void HttpStreamFactoryImpl::Request::AttachJob(Job* job) {
59 DCHECK(job); 70 DCHECK(job);
60 jobs_.insert(job); 71 jobs_.insert(job);
61 factory_->request_map_[job] = this; 72 factory_->request_map_[job] = this;
62 } 73 }
63 74
64 void HttpStreamFactoryImpl::Request::Complete( 75 void HttpStreamFactoryImpl::Request::Complete(
65 bool was_npn_negotiated, 76 bool was_npn_negotiated,
66 bool using_spdy, 77 bool using_spdy,
67 const NetLog::Source& job_source) { 78 const NetLog::Source& job_source) {
68 DCHECK(!completed_); 79 DCHECK(!completed_);
69 completed_ = true; 80 completed_ = true;
70 was_npn_negotiated_ = was_npn_negotiated; 81 was_npn_negotiated_ = was_npn_negotiated;
71 using_spdy_ = using_spdy; 82 using_spdy_ = using_spdy;
72 net_log_.AddEvent( 83 net_log_.AddEvent(
73 NetLog::TYPE_HTTP_STREAM_REQUEST_BOUND_TO_JOB, 84 NetLog::TYPE_HTTP_STREAM_REQUEST_BOUND_TO_JOB,
74 make_scoped_refptr(new NetLogSourceParameter( 85 make_scoped_refptr(new NetLogSourceParameter(
75 "source_dependency", job_source))); 86 "source_dependency", job_source)));
76 } 87 }
77 88
78 void HttpStreamFactoryImpl::Request::OnStreamReady( 89 void HttpStreamFactoryImpl::Request::OnStreamReady(
79 Job* job, 90 Job* job,
80 const SSLConfig& used_ssl_config, 91 const SSLConfig& used_ssl_config,
81 const ProxyInfo& used_proxy_info, 92 const ProxyInfo& used_proxy_info,
82 HttpStream* stream) { 93 HttpStream* stream) {
83 DCHECK(stream); 94 DCHECK(stream);
84 DCHECK(completed_); 95 DCHECK(completed_);
85 96
86 // |job| should only be NULL if we're being serviced by a late bound 97 // |job| should only be NULL if we're being serviced by a late bound
87 // SpdySession (one that was not created by a job in our |jobs_| set). 98 // SpdySession or HttpPipelinedConnection (one that was not created by a job
99 // in our |jobs_| set).
88 if (!job) { 100 if (!job) {
89 DCHECK(!bound_job_.get()); 101 DCHECK(!bound_job_.get());
90 DCHECK(!jobs_.empty()); 102 DCHECK(!jobs_.empty());
91 // NOTE(willchan): We do *NOT* call OrphanJobs() here. The reason is because 103 // NOTE(willchan): We do *NOT* call OrphanJobs() here. The reason is because
92 // we *WANT* to cancel the unnecessary Jobs from other requests if another 104 // we *WANT* to cancel the unnecessary Jobs from other requests if another
93 // Job completes first. 105 // Job completes first.
94 // TODO(mbelshe): Revisit this when we implement ip connection pooling of 106 // TODO(mbelshe): Revisit this when we implement ip connection pooling of
95 // SpdySessions. Do we want to orphan the jobs for a different hostname so 107 // SpdySessions. Do we want to orphan the jobs for a different hostname so
96 // they complete? Or do we want to prevent connecting a new SpdySession if 108 // they complete? Or do we want to prevent connecting a new SpdySession if
97 // we've already got one available for a different hostname where the ip 109 // we've already got one available for a different hostname where the ip
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 RequestSet& request_set = 230 RequestSet& request_set =
219 spdy_session_request_map[*spdy_session_key_]; 231 spdy_session_request_map[*spdy_session_key_];
220 DCHECK(ContainsKey(request_set, this)); 232 DCHECK(ContainsKey(request_set, this));
221 request_set.erase(this); 233 request_set.erase(this);
222 if (request_set.empty()) 234 if (request_set.empty())
223 spdy_session_request_map.erase(*spdy_session_key_); 235 spdy_session_request_map.erase(*spdy_session_key_);
224 spdy_session_key_.reset(); 236 spdy_session_key_.reset();
225 } 237 }
226 } 238 }
227 239
240 void
241 HttpStreamFactoryImpl::Request::RemoveRequestFromHttpPipeliningRequestMap() {
242 if (http_pipelining_key_.get()) {
243 HttpPipeliningRequestMap& http_pipelining_request_map =
244 factory_->http_pipelining_request_map_;
245 DCHECK(ContainsKey(http_pipelining_request_map, *http_pipelining_key_));
246 RequestSet& request_set =
247 http_pipelining_request_map[*http_pipelining_key_];
248 DCHECK(ContainsKey(request_set, this));
249 request_set.erase(this);
250 if (request_set.empty())
251 http_pipelining_request_map.erase(*http_pipelining_key_);
252 http_pipelining_key_.reset();
253 }
254 }
255
228 void HttpStreamFactoryImpl::Request::OnSpdySessionReady( 256 void HttpStreamFactoryImpl::Request::OnSpdySessionReady(
229 Job* job, 257 Job* job,
230 scoped_refptr<SpdySession> spdy_session, 258 scoped_refptr<SpdySession> spdy_session,
231 bool direct) { 259 bool direct) {
232 DCHECK(job); 260 DCHECK(job);
233 DCHECK(job->using_spdy()); 261 DCHECK(job->using_spdy());
234 262
235 // The first case is the usual case. 263 // The first case is the usual case.
236 if (!bound_job_.get()) { 264 if (!bound_job_.get()) {
237 OrphanJobsExcept(job); 265 OrphanJobsExcept(job);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 DCHECK(ContainsKey(jobs_, job)); 299 DCHECK(ContainsKey(jobs_, job));
272 bound_job_.reset(job); 300 bound_job_.reset(job);
273 jobs_.erase(job); 301 jobs_.erase(job);
274 factory_->request_map_.erase(job); 302 factory_->request_map_.erase(job);
275 303
276 OrphanJobs(); 304 OrphanJobs();
277 } 305 }
278 306
279 void HttpStreamFactoryImpl::Request::OrphanJobs() { 307 void HttpStreamFactoryImpl::Request::OrphanJobs() {
280 RemoveRequestFromSpdySessionRequestMap(); 308 RemoveRequestFromSpdySessionRequestMap();
309 RemoveRequestFromHttpPipeliningRequestMap();
281 310
282 std::set<Job*> tmp; 311 std::set<Job*> tmp;
283 tmp.swap(jobs_); 312 tmp.swap(jobs_);
284 313
285 for (std::set<Job*>::iterator it = tmp.begin(); it != tmp.end(); ++it) 314 for (std::set<Job*>::iterator it = tmp.begin(); it != tmp.end(); ++it)
286 factory_->OrphanJob(*it, this); 315 factory_->OrphanJob(*it, this);
287 } 316 }
288 317
289 } // namespace net 318 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl_request.h ('k') | net/http/http_stream_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698