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 | 9 |
9 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
10 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
11 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
12 #include "net/base/load_flags.h" | 13 #include "net/base/load_flags.h" |
13 #include "net/base/request_priority.h" | 14 #include "net/base/request_priority.h" |
14 #include "net/url_request/url_request_context.h" | 15 #include "net/url_request/url_request_context.h" |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
(...skipping 15 matching lines...) Expand all Loading... |
33 prefetch_status(other.prefetch_status), | 34 prefetch_status(other.prefetch_status), |
34 usage_status(other.usage_status) { | 35 usage_status(other.usage_status) { |
35 } | 36 } |
36 | 37 |
37 ResourcePrefetcher::ResourcePrefetcher( | 38 ResourcePrefetcher::ResourcePrefetcher( |
38 Delegate* delegate, | 39 Delegate* delegate, |
39 const ResourcePrefetchPredictorConfig& config, | 40 const ResourcePrefetchPredictorConfig& config, |
40 const NavigationID& navigation_id, | 41 const NavigationID& navigation_id, |
41 PrefetchKeyType key_type, | 42 PrefetchKeyType key_type, |
42 scoped_ptr<RequestVector> requests) | 43 scoped_ptr<RequestVector> requests) |
43 : state_(INITIALIZED), | 44 : state_(INITIALIZED), |
44 delegate_(delegate), | 45 delegate_(delegate), |
45 config_(config), | 46 config_(config), |
46 navigation_id_(navigation_id), | 47 navigation_id_(navigation_id), |
47 key_type_(key_type), | 48 key_type_(key_type), |
48 request_vector_(requests.Pass()) { | 49 request_vector_(std::move(requests)) { |
49 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 50 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
50 DCHECK(request_vector_.get()); | 51 DCHECK(request_vector_.get()); |
51 | 52 |
52 std::copy(request_vector_->begin(), request_vector_->end(), | 53 std::copy(request_vector_->begin(), request_vector_->end(), |
53 std::back_inserter(request_queue_)); | 54 std::back_inserter(request_queue_)); |
54 } | 55 } |
55 | 56 |
56 ResourcePrefetcher::~ResourcePrefetcher() { | 57 ResourcePrefetcher::~ResourcePrefetcher() { |
57 // Delete any pending net::URLRequests. | 58 // Delete any pending net::URLRequests. |
58 STLDeleteContainerPairFirstPointers(inflight_requests_.begin(), | 59 STLDeleteContainerPairFirstPointers(inflight_requests_.begin(), |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 if (request->status().error()) { | 234 if (request->status().error()) { |
234 FinishRequest(request, Request::PREFETCH_STATUS_FAILED); | 235 FinishRequest(request, Request::PREFETCH_STATUS_FAILED); |
235 return; | 236 return; |
236 } | 237 } |
237 | 238 |
238 if (ShouldContinueReadingRequest(request, bytes_read)) | 239 if (ShouldContinueReadingRequest(request, bytes_read)) |
239 ReadFullResponse(request); | 240 ReadFullResponse(request); |
240 } | 241 } |
241 | 242 |
242 } // namespace predictors | 243 } // namespace predictors |
OLD | NEW |