OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/predictors/resource_prefetcher.h" | 5 #include "chrome/browser/predictors/resource_prefetcher.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 request_vector_(std::move(requests)) { | 50 request_vector_(std::move(requests)) { |
51 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 51 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
52 DCHECK(request_vector_.get()); | 52 DCHECK(request_vector_.get()); |
53 | 53 |
54 std::copy(request_vector_->begin(), request_vector_->end(), | 54 std::copy(request_vector_->begin(), request_vector_->end(), |
55 std::back_inserter(request_queue_)); | 55 std::back_inserter(request_queue_)); |
56 } | 56 } |
57 | 57 |
58 ResourcePrefetcher::~ResourcePrefetcher() { | 58 ResourcePrefetcher::~ResourcePrefetcher() { |
59 // Delete any pending net::URLRequests. | 59 // Delete any pending net::URLRequests. |
60 STLDeleteContainerPairFirstPointers(inflight_requests_.begin(), | 60 base::STLDeleteContainerPairFirstPointers(inflight_requests_.begin(), |
61 inflight_requests_.end()); | 61 inflight_requests_.end()); |
62 } | 62 } |
63 | 63 |
64 void ResourcePrefetcher::Start() { | 64 void ResourcePrefetcher::Start() { |
65 DCHECK(thread_checker_.CalledOnValidThread()); | 65 DCHECK(thread_checker_.CalledOnValidThread()); |
66 | 66 |
67 CHECK_EQ(state_, INITIALIZED); | 67 CHECK_EQ(state_, INITIALIZED); |
68 state_ = RUNNING; | 68 state_ = RUNNING; |
69 | 69 |
70 TryToLaunchPrefetchRequests(); | 70 TryToLaunchPrefetchRequests(); |
71 } | 71 } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 if (!request->status().is_success()) { | 236 if (!request->status().is_success()) { |
237 FinishRequest(request, Request::PREFETCH_STATUS_FAILED); | 237 FinishRequest(request, Request::PREFETCH_STATUS_FAILED); |
238 return; | 238 return; |
239 } | 239 } |
240 | 240 |
241 if (ShouldContinueReadingRequest(request, bytes_read)) | 241 if (ShouldContinueReadingRequest(request, bytes_read)) |
242 ReadFullResponse(request); | 242 ReadFullResponse(request); |
243 } | 243 } |
244 | 244 |
245 } // namespace predictors | 245 } // namespace predictors |
OLD | NEW |