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/callback.h" | 7 #include "base/callback.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "net/http/http_stream_factory_impl_job.h" | 10 #include "net/http/http_stream_factory_impl_job.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 for (std::set<Job*>::iterator it = jobs_.begin(); it != jobs_.end(); ++it) | 47 for (std::set<Job*>::iterator it = jobs_.begin(); it != jobs_.end(); ++it) |
48 factory_->request_map_.erase(*it); | 48 factory_->request_map_.erase(*it); |
49 | 49 |
50 RemoveRequestFromSpdySessionRequestMap(); | 50 RemoveRequestFromSpdySessionRequestMap(); |
51 | 51 |
52 STLDeleteElements(&jobs_); | 52 STLDeleteElements(&jobs_); |
53 } | 53 } |
54 | 54 |
55 void HttpStreamFactoryImpl::Request::SetSpdySessionKey( | 55 void HttpStreamFactoryImpl::Request::SetSpdySessionKey( |
56 const SpdySessionKey& spdy_session_key) { | 56 const SpdySessionKey& spdy_session_key) { |
57 DCHECK(!spdy_session_key_.get()); | 57 CHECK(!spdy_session_key_.get()); |
58 spdy_session_key_.reset(new SpdySessionKey(spdy_session_key)); | 58 spdy_session_key_.reset(new SpdySessionKey(spdy_session_key)); |
59 RequestSet& request_set = | 59 RequestSet& request_set = |
60 factory_->spdy_session_request_map_[spdy_session_key]; | 60 factory_->spdy_session_request_map_[spdy_session_key]; |
61 DCHECK(!ContainsKey(request_set, this)); | 61 DCHECK(!ContainsKey(request_set, this)); |
62 request_set.insert(this); | 62 request_set.insert(this); |
63 } | 63 } |
64 | 64 |
65 void HttpStreamFactoryImpl::Request::AttachJob(Job* job) { | 65 void HttpStreamFactoryImpl::Request::AttachJob(Job* job) { |
66 DCHECK(job); | 66 DCHECK(job); |
67 jobs_.insert(job); | 67 jobs_.insert(job); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 RequestSet& request_set = | 243 RequestSet& request_set = |
244 spdy_session_request_map[*spdy_session_key_]; | 244 spdy_session_request_map[*spdy_session_key_]; |
245 DCHECK(ContainsKey(request_set, this)); | 245 DCHECK(ContainsKey(request_set, this)); |
246 request_set.erase(this); | 246 request_set.erase(this); |
247 if (request_set.empty()) | 247 if (request_set.empty()) |
248 spdy_session_request_map.erase(*spdy_session_key_); | 248 spdy_session_request_map.erase(*spdy_session_key_); |
249 spdy_session_key_.reset(); | 249 spdy_session_key_.reset(); |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
| 253 bool HttpStreamFactoryImpl::Request::HasSpdySessionKey() const { |
| 254 return spdy_session_key_.get() != NULL; |
| 255 } |
| 256 |
253 // TODO(jgraettinger): Currently, HttpStreamFactoryImpl::Job notifies a | 257 // TODO(jgraettinger): Currently, HttpStreamFactoryImpl::Job notifies a |
254 // Request that the session is ready, which in turn notifies it's delegate, | 258 // Request that the session is ready, which in turn notifies it's delegate, |
255 // and then it notifies HttpStreamFactoryImpl so that /other/ requests may | 259 // and then it notifies HttpStreamFactoryImpl so that /other/ requests may |
256 // be woken, but only if the spdy_session is still okay. This is tough to grok. | 260 // be woken, but only if the spdy_session is still okay. This is tough to grok. |
257 // Instead, see if Job can notify HttpStreamFactoryImpl only, and have one | 261 // Instead, see if Job can notify HttpStreamFactoryImpl only, and have one |
258 // path for notifying any requests waiting for the session (including the | 262 // path for notifying any requests waiting for the session (including the |
259 // request which spawned it). | 263 // request which spawned it). |
260 void HttpStreamFactoryImpl::Request::OnNewSpdySessionReady( | 264 void HttpStreamFactoryImpl::Request::OnNewSpdySessionReady( |
261 Job* job, | 265 Job* job, |
262 scoped_ptr<HttpStream> stream, | 266 scoped_ptr<HttpStream> stream, |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 } | 363 } |
360 // We may have other jobs in |jobs_|. For example, if we start multiple jobs | 364 // We may have other jobs in |jobs_|. For example, if we start multiple jobs |
361 // for Alternate-Protocol. | 365 // for Alternate-Protocol. |
362 OrphanJobsExcept(job); | 366 OrphanJobsExcept(job); |
363 return; | 367 return; |
364 } | 368 } |
365 DCHECK(jobs_.empty()); | 369 DCHECK(jobs_.empty()); |
366 } | 370 } |
367 | 371 |
368 } // namespace net | 372 } // namespace net |
OLD | NEW |