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> | 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 | 72 |
73 std::string key = main_frame_url.host(); | 73 std::string key = main_frame_url.host(); |
74 auto it = prefetcher_map_.find(key); | 74 auto it = prefetcher_map_.find(key); |
75 if (it != prefetcher_map_.end() && | 75 if (it != prefetcher_map_.end() && |
76 it->second->main_frame_url() == main_frame_url) { | 76 it->second->main_frame_url() == main_frame_url) { |
77 it->second->Stop(); | 77 it->second->Stop(); |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 void ResourcePrefetcherManager::ResourcePrefetcherFinished( | 81 void ResourcePrefetcherManager::ResourcePrefetcherFinished( |
82 ResourcePrefetcher* resource_prefetcher) { | 82 ResourcePrefetcher* resource_prefetcher, |
83 const ResourcePrefetcher::PrefetcherStats& stats) { | |
83 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 84 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
84 | 85 |
85 const GURL& main_frame_url = resource_prefetcher->main_frame_url(); | 86 const GURL& main_frame_url = resource_prefetcher->main_frame_url(); |
86 BrowserThread::PostTask( | 87 BrowserThread::PostTask( |
87 BrowserThread::UI, FROM_HERE, | 88 BrowserThread::UI, FROM_HERE, |
88 base::Bind(&ResourcePrefetchPredictor::OnPrefetchingFinished, | 89 base::Bind(&ResourcePrefetchPredictor::OnPrefetchingFinished, |
89 base::Unretained(predictor_), main_frame_url)); | 90 base::Unretained(predictor_), main_frame_url, stats)); |
alexilin
2017/02/09 15:24:18
Can we avoid copying of stats object?
I think, we
Benoit L
2017/02/13 16:13:15
It was initially because gmock doesn't like unique
| |
90 | 91 |
91 const std::string key = main_frame_url.host(); | 92 const std::string key = main_frame_url.host(); |
92 auto it = prefetcher_map_.find(key); | 93 auto it = prefetcher_map_.find(key); |
93 DCHECK(it != prefetcher_map_.end()); | 94 DCHECK(it != prefetcher_map_.end()); |
94 prefetcher_map_.erase(it); | 95 prefetcher_map_.erase(it); |
95 } | 96 } |
96 | 97 |
97 net::URLRequestContext* ResourcePrefetcherManager::GetURLRequestContext() { | 98 net::URLRequestContext* ResourcePrefetcherManager::GetURLRequestContext() { |
98 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 99 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
99 | 100 |
100 return context_getter_->GetURLRequestContext(); | 101 return context_getter_->GetURLRequestContext(); |
101 } | 102 } |
102 | 103 |
103 } // namespace predictors | 104 } // namespace predictors |
OLD | NEW |