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_manager.h" | 5 #include "chrome/browser/predictors/resource_prefetcher_manager.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
9 #include "chrome/browser/predictors/resource_prefetch_predictor.h" | 11 #include "chrome/browser/predictors/resource_prefetch_predictor.h" |
10 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
11 #include "net/url_request/url_request.h" | 13 #include "net/url_request/url_request.h" |
12 #include "net/url_request/url_request_context_getter.h" | 14 #include "net/url_request/url_request_context_getter.h" |
13 | 15 |
14 using content::BrowserThread; | 16 using content::BrowserThread; |
15 | 17 |
16 namespace predictors { | 18 namespace predictors { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 scoped_ptr<ResourcePrefetcher::RequestVector> requests) { | 56 scoped_ptr<ResourcePrefetcher::RequestVector> requests) { |
55 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 57 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
56 | 58 |
57 // Don't add a duplicate prefetch for the same host or URL. | 59 // Don't add a duplicate prefetch for the same host or URL. |
58 std::string key = key_type == PREFETCH_KEY_TYPE_HOST ? | 60 std::string key = key_type == PREFETCH_KEY_TYPE_HOST ? |
59 navigation_id.main_frame_url.host() : navigation_id.main_frame_url.spec(); | 61 navigation_id.main_frame_url.host() : navigation_id.main_frame_url.spec(); |
60 if (ContainsKey(prefetcher_map_, key)) | 62 if (ContainsKey(prefetcher_map_, key)) |
61 return; | 63 return; |
62 | 64 |
63 ResourcePrefetcher* prefetcher = new ResourcePrefetcher( | 65 ResourcePrefetcher* prefetcher = new ResourcePrefetcher( |
64 this, config_, navigation_id, key_type, requests.Pass()); | 66 this, config_, navigation_id, key_type, std::move(requests)); |
65 prefetcher_map_.insert(std::make_pair(key, prefetcher)); | 67 prefetcher_map_.insert(std::make_pair(key, prefetcher)); |
66 prefetcher->Start(); | 68 prefetcher->Start(); |
67 } | 69 } |
68 | 70 |
69 void ResourcePrefetcherManager::MaybeRemovePrefetch( | 71 void ResourcePrefetcherManager::MaybeRemovePrefetch( |
70 const NavigationID& navigation_id) { | 72 const NavigationID& navigation_id) { |
71 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 73 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
72 | 74 |
73 // Look for a URL based prefetch first. | 75 // Look for a URL based prefetch first. |
74 PrefetcherMap::iterator it = prefetcher_map_.find( | 76 PrefetcherMap::iterator it = prefetcher_map_.find( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 } | 128 } |
127 } | 129 } |
128 | 130 |
129 net::URLRequestContext* ResourcePrefetcherManager::GetURLRequestContext() { | 131 net::URLRequestContext* ResourcePrefetcherManager::GetURLRequestContext() { |
130 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 132 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
131 | 133 |
132 return context_getter_->GetURLRequestContext(); | 134 return context_getter_->GetURLRequestContext(); |
133 } | 135 } |
134 | 136 |
135 } // namespace predictors | 137 } // namespace predictors |
OLD | NEW |