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

Unified Diff: chrome/browser/predictors/resource_prefetcher_manager.cc

Issue 2553083002: predictors: Add browsertest that tests prefetching. (Closed)
Patch Set: Make all tests prefetching. (and 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/predictors/resource_prefetcher_manager.cc
diff --git a/chrome/browser/predictors/resource_prefetcher_manager.cc b/chrome/browser/predictors/resource_prefetcher_manager.cc
index 476ba79832045499ae21116bf822da2542bb2be5..884d12a059fe4abdaa7afe318bee8fc50e1e6f1b 100644
--- a/chrome/browser/predictors/resource_prefetcher_manager.cc
+++ b/chrome/browser/predictors/resource_prefetcher_manager.cc
@@ -82,10 +82,16 @@ void ResourcePrefetcherManager::ResourcePrefetcherFinished(
ResourcePrefetcher* resource_prefetcher) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- const std::string key = resource_prefetcher->main_frame_url().host();
+ const GURL main_frame_url = resource_prefetcher->main_frame_url();
Benoit L 2016/12/19 12:32:00 nit: const GURL& Might avoid one copy.
alexilin 2016/12/19 12:58:09 Bad idea: we pass it to another thread below.
alexilin 2016/12/19 15:03:42 It would cause Segmentation Fault by another reaso
+ const std::string key = main_frame_url.host();
auto it = prefetcher_map_.find(key);
DCHECK(it != prefetcher_map_.end());
prefetcher_map_.erase(it);
+
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&ResourcePrefetchPredictor::OnPrefetchingFinished,
+ base::Unretained(predictor_), main_frame_url));
}
net::URLRequestContext* ResourcePrefetcherManager::GetURLRequestContext() {

Powered by Google App Engine
This is Rietveld 408576698