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

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

Issue 2553083002: predictors: Add browsertest that tests prefetching. (Closed)
Patch Set: Rebase. Created 4 years 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
« no previous file with comments | « chrome/browser/predictors/resource_prefetch_predictor_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 83 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
84 84
85 const std::string key = resource_prefetcher->main_frame_url().host(); 85 const GURL& main_frame_url = resource_prefetcher->main_frame_url();
86 BrowserThread::PostTask(
87 BrowserThread::UI, FROM_HERE,
88 base::Bind(&ResourcePrefetchPredictor::OnPrefetchingFinished,
89 base::Unretained(predictor_), main_frame_url));
90
91 const std::string key = main_frame_url.host();
86 auto it = prefetcher_map_.find(key); 92 auto it = prefetcher_map_.find(key);
87 DCHECK(it != prefetcher_map_.end()); 93 DCHECK(it != prefetcher_map_.end());
88 prefetcher_map_.erase(it); 94 prefetcher_map_.erase(it);
89 } 95 }
90 96
91 net::URLRequestContext* ResourcePrefetcherManager::GetURLRequestContext() { 97 net::URLRequestContext* ResourcePrefetcherManager::GetURLRequestContext() {
92 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 98 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
93 99
94 return context_getter_->GetURLRequestContext(); 100 return context_getter_->GetURLRequestContext();
95 } 101 }
96 102
97 } // namespace predictors 103 } // namespace predictors
OLDNEW
« no previous file with comments | « chrome/browser/predictors/resource_prefetch_predictor_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698