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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor.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 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_prefetch_predictor.h" 5 #include "chrome/browser/predictors/resource_prefetch_predictor.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 url.spec()); 490 url.spec());
491 if (!prefetch_manager_.get()) // Not enabled. 491 if (!prefetch_manager_.get()) // Not enabled.
492 return; 492 return;
493 493
494 BrowserThread::PostTask( 494 BrowserThread::PostTask(
495 BrowserThread::IO, FROM_HERE, 495 BrowserThread::IO, FROM_HERE,
496 base::Bind(&ResourcePrefetcherManager::MaybeRemovePrefetch, 496 base::Bind(&ResourcePrefetcherManager::MaybeRemovePrefetch,
497 prefetch_manager_, url)); 497 prefetch_manager_, url));
498 } 498 }
499 499
500 void ResourcePrefetchPredictor::OnPrefetchingFinished(
501 const GURL& main_frame_url) {
502 if (observer_)
503 observer_->OnPrefetchingFinished(main_frame_url);
504 }
505
500 void ResourcePrefetchPredictor::SetObserverForTesting(TestObserver* observer) { 506 void ResourcePrefetchPredictor::SetObserverForTesting(TestObserver* observer) {
501 observer_ = observer; 507 observer_ = observer;
502 } 508 }
503 509
504 void ResourcePrefetchPredictor::Shutdown() { 510 void ResourcePrefetchPredictor::Shutdown() {
505 if (prefetch_manager_.get()) { 511 if (prefetch_manager_.get()) {
506 prefetch_manager_->ShutdownOnUIThread(); 512 prefetch_manager_->ShutdownOnUIThread();
507 prefetch_manager_ = NULL; 513 prefetch_manager_ = NULL;
508 } 514 }
509 history_service_observer_.RemoveAll(); 515 history_service_observer_.RemoveAll();
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 TestObserver::~TestObserver() { 1157 TestObserver::~TestObserver() {
1152 predictor_->SetObserverForTesting(nullptr); 1158 predictor_->SetObserverForTesting(nullptr);
1153 } 1159 }
1154 1160
1155 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor) 1161 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor)
1156 : predictor_(predictor) { 1162 : predictor_(predictor) {
1157 predictor_->SetObserverForTesting(this); 1163 predictor_->SetObserverForTesting(this);
1158 } 1164 }
1159 1165
1160 } // namespace predictors 1166 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698