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

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

Issue 2804963002: predictors: Put manifests for ResourcePrefetchPredictor behind a flag. (Closed)
Patch Set: Created 3 years, 8 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_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 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 } 1460 }
1461 } 1461 }
1462 1462
1463 void ResourcePrefetchPredictor::OnManifestFetched( 1463 void ResourcePrefetchPredictor::OnManifestFetched(
1464 const std::string& host, 1464 const std::string& host,
1465 const precache::PrecacheManifest& manifest) { 1465 const precache::PrecacheManifest& manifest) {
1466 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1466 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1467 if (initialization_state_ != INITIALIZED) 1467 if (initialization_state_ != INITIALIZED)
1468 return; 1468 return;
1469 1469
1470 if (host.length() > ResourcePrefetchPredictorTables::kMaxStringLength || 1470 if (!config_.is_manifests_enabled ||
1471 host.length() > ResourcePrefetchPredictorTables::kMaxStringLength ||
1471 static_cast<uint32_t>(manifest.ByteSize()) > kMaxManifestByteSize) { 1472 static_cast<uint32_t>(manifest.ByteSize()) > kMaxManifestByteSize) {
1472 return; 1473 return;
1473 } 1474 }
1474 1475
1475 auto cache_entry = manifest_table_cache_->find(host); 1476 auto cache_entry = manifest_table_cache_->find(host);
1476 if (cache_entry == manifest_table_cache_->end()) { 1477 if (cache_entry == manifest_table_cache_->end()) {
1477 if (manifest_table_cache_->size() >= config_.max_hosts_to_track) 1478 if (manifest_table_cache_->size() >= config_.max_hosts_to_track)
1478 RemoveOldestEntryInManifestDataMap(manifest_table_cache_.get()); 1479 RemoveOldestEntryInManifestDataMap(manifest_table_cache_.get());
1479 cache_entry = 1480 cache_entry =
1480 manifest_table_cache_->insert(std::make_pair(host, manifest)).first; 1481 manifest_table_cache_->insert(std::make_pair(host, manifest)).first;
(...skipping 30 matching lines...) Expand all
1511 TestObserver::~TestObserver() { 1512 TestObserver::~TestObserver() {
1512 predictor_->SetObserverForTesting(nullptr); 1513 predictor_->SetObserverForTesting(nullptr);
1513 } 1514 }
1514 1515
1515 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor) 1516 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor)
1516 : predictor_(predictor) { 1517 : predictor_(predictor) {
1517 predictor_->SetObserverForTesting(this); 1518 predictor_->SetObserverForTesting(this);
1518 } 1519 }
1519 1520
1520 } // namespace predictors 1521 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698