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

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

Issue 2553083002: predictors: Add browsertest that tests prefetching. (Closed)
Patch Set: 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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 url.spec()); 496 url.spec());
497 if (!prefetch_manager_.get()) // Not enabled. 497 if (!prefetch_manager_.get()) // Not enabled.
498 return; 498 return;
499 499
500 BrowserThread::PostTask( 500 BrowserThread::PostTask(
501 BrowserThread::IO, FROM_HERE, 501 BrowserThread::IO, FROM_HERE,
502 base::Bind(&ResourcePrefetcherManager::MaybeRemovePrefetch, 502 base::Bind(&ResourcePrefetcherManager::MaybeRemovePrefetch,
503 prefetch_manager_, url)); 503 prefetch_manager_, url));
504 } 504 }
505 505
506 void ResourcePrefetchPredictor::OnPrefetchingFinished(
507 const GURL& main_frame_url) {
508 if (observer_)
509 observer_->OnPrefetchingFinished(main_frame_url);
510 }
511
506 void ResourcePrefetchPredictor::SetObserverForTesting(TestObserver* observer) { 512 void ResourcePrefetchPredictor::SetObserverForTesting(TestObserver* observer) {
507 observer_ = observer; 513 observer_ = observer;
508 } 514 }
509 515
510 void ResourcePrefetchPredictor::Shutdown() { 516 void ResourcePrefetchPredictor::Shutdown() {
511 if (prefetch_manager_.get()) { 517 if (prefetch_manager_.get()) {
512 prefetch_manager_->ShutdownOnUIThread(); 518 prefetch_manager_->ShutdownOnUIThread();
513 prefetch_manager_ = NULL; 519 prefetch_manager_ = NULL;
514 } 520 }
515 history_service_observer_.RemoveAll(); 521 history_service_observer_.RemoveAll();
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 TestObserver::~TestObserver() { 1163 TestObserver::~TestObserver() {
1158 predictor_->SetObserverForTesting(nullptr); 1164 predictor_->SetObserverForTesting(nullptr);
1159 } 1165 }
1160 1166
1161 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor) 1167 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor)
1162 : predictor_(predictor) { 1168 : predictor_(predictor) {
1163 predictor_->SetObserverForTesting(this); 1169 predictor_->SetObserverForTesting(this);
1164 } 1170 }
1165 1171
1166 } // namespace predictors 1172 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698