OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 DCHECK(!ContainsKey(request_set, this)); | 56 DCHECK(!ContainsKey(request_set, this)); |
57 request_set.insert(this); | 57 request_set.insert(this); |
58 } | 58 } |
59 | 59 |
60 bool HttpStreamFactoryImpl::Request::SetHttpPipeliningKey( | 60 bool HttpStreamFactoryImpl::Request::SetHttpPipeliningKey( |
61 const HttpPipelinedHost::Key& http_pipelining_key) { | 61 const HttpPipelinedHost::Key& http_pipelining_key) { |
62 DCHECK(!http_pipelining_key_.get()); | 62 DCHECK(!http_pipelining_key_.get()); |
63 http_pipelining_key_.reset(new HttpPipelinedHost::Key(http_pipelining_key)); | 63 http_pipelining_key_.reset(new HttpPipelinedHost::Key(http_pipelining_key)); |
64 bool was_new_key = !ContainsKey(factory_->http_pipelining_request_map_, | 64 bool was_new_key = !ContainsKey(factory_->http_pipelining_request_map_, |
65 http_pipelining_key); | 65 http_pipelining_key); |
66 RequestSet& request_set = | 66 RequestVector& request_vector = |
67 factory_->http_pipelining_request_map_[http_pipelining_key]; | 67 factory_->http_pipelining_request_map_[http_pipelining_key]; |
68 DCHECK(!ContainsKey(request_set, this)); | 68 request_vector.push_back(this); |
69 request_set.insert(this); | |
70 return was_new_key; | 69 return was_new_key; |
71 } | 70 } |
72 | 71 |
73 void HttpStreamFactoryImpl::Request::AttachJob(Job* job) { | 72 void HttpStreamFactoryImpl::Request::AttachJob(Job* job) { |
74 DCHECK(job); | 73 DCHECK(job); |
75 jobs_.insert(job); | 74 jobs_.insert(job); |
76 factory_->request_map_[job] = this; | 75 factory_->request_map_[job] = this; |
77 } | 76 } |
78 | 77 |
79 void HttpStreamFactoryImpl::Request::Complete( | 78 void HttpStreamFactoryImpl::Request::Complete( |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 spdy_session_key_.reset(); | 259 spdy_session_key_.reset(); |
261 } | 260 } |
262 } | 261 } |
263 | 262 |
264 void | 263 void |
265 HttpStreamFactoryImpl::Request::RemoveRequestFromHttpPipeliningRequestMap() { | 264 HttpStreamFactoryImpl::Request::RemoveRequestFromHttpPipeliningRequestMap() { |
266 if (http_pipelining_key_.get()) { | 265 if (http_pipelining_key_.get()) { |
267 HttpPipeliningRequestMap& http_pipelining_request_map = | 266 HttpPipeliningRequestMap& http_pipelining_request_map = |
268 factory_->http_pipelining_request_map_; | 267 factory_->http_pipelining_request_map_; |
269 DCHECK(ContainsKey(http_pipelining_request_map, *http_pipelining_key_)); | 268 DCHECK(ContainsKey(http_pipelining_request_map, *http_pipelining_key_)); |
270 RequestSet& request_set = | 269 RequestVector& request_vector = |
271 http_pipelining_request_map[*http_pipelining_key_]; | 270 http_pipelining_request_map[*http_pipelining_key_]; |
272 DCHECK(ContainsKey(request_set, this)); | 271 for (RequestVector::iterator it = request_vector.begin(); |
273 request_set.erase(this); | 272 it != request_vector.end(); ++it) { |
274 if (request_set.empty()) | 273 if (*it == this) { |
| 274 request_vector.erase(it); |
| 275 break; |
| 276 } |
| 277 } |
| 278 if (request_vector.empty()) |
275 http_pipelining_request_map.erase(*http_pipelining_key_); | 279 http_pipelining_request_map.erase(*http_pipelining_key_); |
276 http_pipelining_key_.reset(); | 280 http_pipelining_key_.reset(); |
277 } | 281 } |
278 } | 282 } |
279 | 283 |
280 void HttpStreamFactoryImpl::Request::OnSpdySessionReady( | 284 void HttpStreamFactoryImpl::Request::OnSpdySessionReady( |
281 Job* job, | 285 Job* job, |
282 scoped_refptr<SpdySession> spdy_session, | 286 scoped_refptr<SpdySession> spdy_session, |
283 bool direct) { | 287 bool direct) { |
284 DCHECK(job); | 288 DCHECK(job); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 RemoveRequestFromHttpPipeliningRequestMap(); | 337 RemoveRequestFromHttpPipeliningRequestMap(); |
334 | 338 |
335 std::set<Job*> tmp; | 339 std::set<Job*> tmp; |
336 tmp.swap(jobs_); | 340 tmp.swap(jobs_); |
337 | 341 |
338 for (std::set<Job*>::iterator it = tmp.begin(); it != tmp.end(); ++it) | 342 for (std::set<Job*>::iterator it = tmp.begin(); it != tmp.end(); ++it) |
339 factory_->OrphanJob(*it, this); | 343 factory_->OrphanJob(*it, this); |
340 } | 344 } |
341 | 345 |
342 } // namespace net | 346 } // namespace net |
OLD | NEW |