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

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: Use HttpStreamFactoryImpl::Job Created 9 years, 5 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
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-inl.h" 8 #include "base/stl_util-inl.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 25 matching lines...) Expand all
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 STLDeleteElements(&jobs_); 43 STLDeleteElements(&jobs_);
44 44
45 RemoveRequestFromSpdySessionRequestMap(); 45 RemoveRequestFromSpdySessionRequestMap();
46 RemoveRequestFromHttpPipeliningRequestMap();
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) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 RequestSet& request_set = 229 RequestSet& request_set =
219 spdy_session_request_map[*spdy_session_key_]; 230 spdy_session_request_map[*spdy_session_key_];
220 DCHECK(ContainsKey(request_set, this)); 231 DCHECK(ContainsKey(request_set, this));
221 request_set.erase(this); 232 request_set.erase(this);
222 if (request_set.empty()) 233 if (request_set.empty())
223 spdy_session_request_map.erase(*spdy_session_key_); 234 spdy_session_request_map.erase(*spdy_session_key_);
224 spdy_session_key_.reset(); 235 spdy_session_key_.reset();
225 } 236 }
226 } 237 }
227 238
239 void
240 HttpStreamFactoryImpl::Request::RemoveRequestFromHttpPipeliningRequestMap() {
241 if (http_pipelining_key_.get()) {
242 HttpPipeliningRequestMap& http_pipelining_request_map =
243 factory_->http_pipelining_request_map_;
244 DCHECK(ContainsKey(http_pipelining_request_map, *http_pipelining_key_));
245 RequestSet& request_set =
246 http_pipelining_request_map[*http_pipelining_key_];
247 DCHECK(ContainsKey(request_set, this));
248 request_set.erase(this);
249 if (request_set.empty())
250 http_pipelining_request_map.erase(*http_pipelining_key_);
251 http_pipelining_key_.reset();
252 }
253 }
254
228 void HttpStreamFactoryImpl::Request::OnSpdySessionReady( 255 void HttpStreamFactoryImpl::Request::OnSpdySessionReady(
229 Job* job, 256 Job* job,
230 scoped_refptr<SpdySession> spdy_session, 257 scoped_refptr<SpdySession> spdy_session,
231 bool direct) { 258 bool direct) {
232 DCHECK(job); 259 DCHECK(job);
233 DCHECK(job->using_spdy()); 260 DCHECK(job->using_spdy());
234 261
235 // The first case is the usual case. 262 // The first case is the usual case.
236 if (!bound_job_.get()) { 263 if (!bound_job_.get()) {
237 OrphanJobsExcept(job); 264 OrphanJobsExcept(job);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 DCHECK(ContainsKey(jobs_, job)); 298 DCHECK(ContainsKey(jobs_, job));
272 bound_job_.reset(job); 299 bound_job_.reset(job);
273 jobs_.erase(job); 300 jobs_.erase(job);
274 factory_->request_map_.erase(job); 301 factory_->request_map_.erase(job);
275 302
276 OrphanJobs(); 303 OrphanJobs();
277 } 304 }
278 305
279 void HttpStreamFactoryImpl::Request::OrphanJobs() { 306 void HttpStreamFactoryImpl::Request::OrphanJobs() {
280 RemoveRequestFromSpdySessionRequestMap(); 307 RemoveRequestFromSpdySessionRequestMap();
308 RemoveRequestFromHttpPipeliningRequestMap();
281 309
282 std::set<Job*> tmp; 310 std::set<Job*> tmp;
283 tmp.swap(jobs_); 311 tmp.swap(jobs_);
284 312
285 for (std::set<Job*>::iterator it = tmp.begin(); it != tmp.end(); ++it) 313 for (std::set<Job*>::iterator it = tmp.begin(); it != tmp.end(); ++it)
286 factory_->OrphanJob(*it, this); 314 factory_->OrphanJob(*it, this);
287 } 315 }
288 316
289 } // namespace net 317 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698