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

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

Issue 2397943004: predictors: Use redirect data in prefetch. (Closed)
Patch Set: . Created 4 years, 2 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_tables.h" 5 #include "chrome/browser/predictors/resource_prefetch_predictor_tables.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 367
368 constexpr int kMaxResourcesPerType = 100; 368 constexpr int kMaxResourcesPerType = 100;
369 return kMaxResourcesPerType * 369 return kMaxResourcesPerType *
370 (priority_multiplier * 100 + type_multiplier * 10) - 370 (priority_multiplier * 100 + type_multiplier * 10) -
371 data.average_position(); 371 data.average_position();
372 } 372 }
373 373
374 // static 374 // static
375 float ResourcePrefetchPredictorTables::ComputeRedirectScore( 375 float ResourcePrefetchPredictorTables::ComputeRedirectScore(
376 const RedirectStat& data) { 376 const RedirectStat& data) {
377 // TODO(alexilin): Invent some scoring. 377 return (data.number_of_hits() + 0.0) /
378 return 0.0; 378 (data.number_of_hits() + data.number_of_misses());
pasko 2016/10/07 11:42:43 If this is not covered by any tests, it would be n
alexilin 2016/10/07 13:09:29 I've just realized that we don't have to sort redi
379 } 379 }
380 380
381 // static 381 // static
382 bool ResourcePrefetchPredictorTables::DropTablesIfOutdated( 382 bool ResourcePrefetchPredictorTables::DropTablesIfOutdated(
383 sql::Connection* db) { 383 sql::Connection* db) {
384 int version = GetDatabaseVersion(db); 384 int version = GetDatabaseVersion(db);
385 bool success = true; 385 bool success = true;
386 // Too new is also a problem. 386 // Too new is also a problem.
387 bool incompatible_version = version != kDatabaseVersion; 387 bool incompatible_version = version != kDatabaseVersion;
388 388
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 return is_host ? kHostResourceTableName : kUrlResourceTableName; 517 return is_host ? kHostResourceTableName : kUrlResourceTableName;
518 case PrefetchDataType::REDIRECT: 518 case PrefetchDataType::REDIRECT:
519 return is_host ? kHostRedirectTableName : kUrlRedirectTableName; 519 return is_host ? kHostRedirectTableName : kUrlRedirectTableName;
520 } 520 }
521 521
522 NOTREACHED(); 522 NOTREACHED();
523 return nullptr; 523 return nullptr;
524 } 524 }
525 525
526 } // namespace predictors 526 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698