OLD | NEW |
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 resource_url(i_resource_url), | 97 resource_url(i_resource_url), |
98 resource_type(i_resource_type), | 98 resource_type(i_resource_type), |
99 number_of_hits(i_number_of_hits), | 99 number_of_hits(i_number_of_hits), |
100 number_of_misses(i_number_of_misses), | 100 number_of_misses(i_number_of_misses), |
101 consecutive_misses(i_consecutive_misses), | 101 consecutive_misses(i_consecutive_misses), |
102 average_position(i_average_position) { | 102 average_position(i_average_position) { |
103 UpdateScore(); | 103 UpdateScore(); |
104 } | 104 } |
105 | 105 |
106 void ResourcePrefetchPredictorTables::ResourceRow::UpdateScore() { | 106 void ResourcePrefetchPredictorTables::ResourceRow::UpdateScore() { |
107 // The score is calculated so that when the rows are sorted, the stylesheets | 107 // The score is calculated so that when the rows are sorted, stylesheets, |
108 // and scripts appear first, sorted by position(ascending) and then the rest | 108 // scripts and fonts appear first, sorted by position(ascending) and then the |
109 // of the resources sorted by position(ascending). | 109 // rest of the resources sorted by position (ascending). |
110 static const int kMaxResourcesPerType = 100; | 110 static const int kMaxResourcesPerType = 100; |
111 switch (resource_type) { | 111 switch (resource_type) { |
112 case content::RESOURCE_TYPE_STYLESHEET: | 112 case content::RESOURCE_TYPE_STYLESHEET: |
113 case content::RESOURCE_TYPE_SCRIPT: | 113 case content::RESOURCE_TYPE_SCRIPT: |
| 114 case content::RESOURCE_TYPE_FONT_RESOURCE: |
114 score = (2 * kMaxResourcesPerType) - average_position; | 115 score = (2 * kMaxResourcesPerType) - average_position; |
115 break; | 116 break; |
116 | 117 |
117 case content::RESOURCE_TYPE_IMAGE: | 118 case content::RESOURCE_TYPE_IMAGE: |
118 default: | 119 default: |
119 score = kMaxResourcesPerType - average_position; | 120 score = kMaxResourcesPerType - average_position; |
120 break; | 121 break; |
121 } | 122 } |
122 } | 123 } |
123 | 124 |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 | 512 |
512 Statement* ResourcePrefetchPredictorTables::GetHostMetadataUpdateStatement() { | 513 Statement* ResourcePrefetchPredictorTables::GetHostMetadataUpdateStatement() { |
513 return new Statement(DB()->GetCachedStatement( | 514 return new Statement(DB()->GetCachedStatement( |
514 SQL_FROM_HERE, | 515 SQL_FROM_HERE, |
515 base::StringPrintf( | 516 base::StringPrintf( |
516 "INSERT INTO %s (main_page_url, last_visit_time) VALUES (?,?)", | 517 "INSERT INTO %s (main_page_url, last_visit_time) VALUES (?,?)", |
517 kHostMetadataTableName).c_str())); | 518 kHostMetadataTableName).c_str())); |
518 } | 519 } |
519 | 520 |
520 } // namespace predictors | 521 } // namespace predictors |
OLD | NEW |