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

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

Issue 2688633002: predictors: Add prefetching hit/miss histograms. (Closed)
Patch Set: Add units. Created 3 years, 10 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 std::unique_ptr<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,
91 base::Passed(std::move(stats))));
90 92
91 const std::string key = main_frame_url.host(); 93 const std::string key = main_frame_url.host();
92 auto it = prefetcher_map_.find(key); 94 auto it = prefetcher_map_.find(key);
93 DCHECK(it != prefetcher_map_.end()); 95 DCHECK(it != prefetcher_map_.end());
94 prefetcher_map_.erase(it); 96 prefetcher_map_.erase(it);
95 } 97 }
96 98
97 net::URLRequestContext* ResourcePrefetcherManager::GetURLRequestContext() { 99 net::URLRequestContext* ResourcePrefetcherManager::GetURLRequestContext() {
98 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 100 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
99 101
100 return context_getter_->GetURLRequestContext(); 102 return context_getter_->GetURLRequestContext();
101 } 103 }
102 104
103 } // namespace predictors 105 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698