Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(536)

Side by Side Diff: chrome/browser/predictors/resource_prefetcher_manager.cc

Issue 2845103002: predictors: Remove ResourcePrefetchPredictorConfig from ResourcePrefetcher. (Closed)
Patch Set: . Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 void ResourcePrefetcherManager::MaybeAddPrefetch( 53 void ResourcePrefetcherManager::MaybeAddPrefetch(
54 const GURL& main_frame_url, 54 const GURL& main_frame_url,
55 const std::vector<GURL>& urls) { 55 const std::vector<GURL>& urls) {
56 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 56 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
57 57
58 // Don't add a duplicate prefetch for the same host. 58 // Don't add a duplicate prefetch for the same host.
59 std::string key = main_frame_url.host(); 59 std::string key = main_frame_url.host();
60 if (base::ContainsKey(prefetcher_map_, key)) 60 if (base::ContainsKey(prefetcher_map_, key))
61 return; 61 return;
62 62
63 auto prefetcher = 63 auto prefetcher = base::MakeUnique<ResourcePrefetcher>(
64 base::MakeUnique<ResourcePrefetcher>(this, config_, main_frame_url, urls); 64 this, config_.max_prefetches_inflight_per_navigation,
alexilin 2017/04/27 16:39:15 Does it make a sense to remove ResourcePrefetchPre
Benoit L 2017/04/27 17:14:42 This will be merged into the policy part, that wil
65 config_.max_prefetches_inflight_per_host_per_navigation, main_frame_url,
66 urls);
65 prefetcher->Start(); 67 prefetcher->Start();
66 prefetcher_map_[key] = std::move(prefetcher); 68 prefetcher_map_[key] = std::move(prefetcher);
67 } 69 }
68 70
69 void ResourcePrefetcherManager::MaybeRemovePrefetch( 71 void ResourcePrefetcherManager::MaybeRemovePrefetch(
70 const GURL& main_frame_url) { 72 const GURL& main_frame_url) {
71 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 73 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
72 74
73 std::string key = main_frame_url.host(); 75 std::string key = main_frame_url.host();
74 auto it = prefetcher_map_.find(key); 76 auto it = prefetcher_map_.find(key);
(...skipping 21 matching lines...) Expand all
96 prefetcher_map_.erase(it); 98 prefetcher_map_.erase(it);
97 } 99 }
98 100
99 net::URLRequestContext* ResourcePrefetcherManager::GetURLRequestContext() { 101 net::URLRequestContext* ResourcePrefetcherManager::GetURLRequestContext() {
100 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 102 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
101 103
102 return context_getter_->GetURLRequestContext(); 104 return context_getter_->GetURLRequestContext();
103 } 105 }
104 106
105 } // namespace predictors 107 } // namespace predictors
OLDNEW
« no previous file with comments | « chrome/browser/predictors/resource_prefetcher.cc ('k') | chrome/browser/predictors/resource_prefetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698