| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 DCHECK(!jobs_.empty()); | 139 DCHECK(!jobs_.empty()); |
| 140 // NOTE(willchan): We do *NOT* call OrphanJobs() here. The reason is because | 140 // NOTE(willchan): We do *NOT* call OrphanJobs() here. The reason is because |
| 141 // we *WANT* to cancel the unnecessary Jobs from other requests if another | 141 // we *WANT* to cancel the unnecessary Jobs from other requests if another |
| 142 // Job completes first. | 142 // Job completes first. |
| 143 } else if (!bound_job_.get()) { | 143 } else if (!bound_job_.get()) { |
| 144 // Hey, we've got other jobs! Maybe one of them will succeed, let's just | 144 // Hey, we've got other jobs! Maybe one of them will succeed, let's just |
| 145 // ignore this failure. | 145 // ignore this failure. |
| 146 if (jobs_.size() > 1) { | 146 if (jobs_.size() > 1) { |
| 147 jobs_.erase(job); | 147 jobs_.erase(job); |
| 148 factory_->request_map_.erase(job); | 148 factory_->request_map_.erase(job); |
| 149 // Notify all the other jobs that this one failed. |
| 150 for (std::set<Job*>::iterator it = jobs_.begin(); it != jobs_.end(); ++it) |
| 151 (*it)->MarkOtherJobComplete(*job); |
| 149 delete job; | 152 delete job; |
| 150 return; | 153 return; |
| 151 } else { | 154 } else { |
| 152 bound_job_.reset(job); | 155 bound_job_.reset(job); |
| 153 jobs_.erase(job); | 156 jobs_.erase(job); |
| 154 DCHECK(jobs_.empty()); | 157 DCHECK(jobs_.empty()); |
| 155 factory_->request_map_.erase(job); | 158 factory_->request_map_.erase(job); |
| 156 } | 159 } |
| 157 } else { | 160 } else { |
| 158 DCHECK(jobs_.empty()); | 161 DCHECK(jobs_.empty()); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 // TODO(mbelshe): Revisit this when we implement ip connection pooling of | 381 // TODO(mbelshe): Revisit this when we implement ip connection pooling of |
| 379 // SpdySessions. Do we want to orphan the jobs for a different hostname so | 382 // SpdySessions. Do we want to orphan the jobs for a different hostname so |
| 380 // they complete? Or do we want to prevent connecting a new SpdySession if | 383 // they complete? Or do we want to prevent connecting a new SpdySession if |
| 381 // we've already got one available for a different hostname where the ip | 384 // we've already got one available for a different hostname where the ip |
| 382 // address matches up? | 385 // address matches up? |
| 383 return; | 386 return; |
| 384 } | 387 } |
| 385 if (!bound_job_.get()) { | 388 if (!bound_job_.get()) { |
| 386 if (jobs_.size() > 1) | 389 if (jobs_.size() > 1) |
| 387 job->ReportJobSuccededForRequest(); | 390 job->ReportJobSuccededForRequest(); |
| 391 // Notify all the other jobs that this one succeeded. |
| 392 for (std::set<Job*>::iterator it = jobs_.begin(); it != jobs_.end(); ++it) { |
| 393 if (*it != job) { |
| 394 (*it)->MarkOtherJobComplete(*job); |
| 395 } |
| 396 } |
| 388 // We may have other jobs in |jobs_|. For example, if we start multiple jobs | 397 // We may have other jobs in |jobs_|. For example, if we start multiple jobs |
| 389 // for Alternate-Protocol. | 398 // for Alternate-Protocol. |
| 390 OrphanJobsExcept(job); | 399 OrphanJobsExcept(job); |
| 391 return; | 400 return; |
| 392 } | 401 } |
| 393 DCHECK(jobs_.empty()); | 402 DCHECK(jobs_.empty()); |
| 394 } | 403 } |
| 395 | 404 |
| 396 } // namespace net | 405 } // namespace net |
| OLD | NEW |