| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "chrome/browser/history/history_database.h" | 17 #include "chrome/browser/history/history_database.h" |
| 18 #include "chrome/browser/history/history_notifications.h" | 18 #include "chrome/browser/history/history_notifications.h" |
| 19 #include "chrome/browser/history/history_service.h" | 19 #include "chrome/browser/history/history_service.h" |
| 20 #include "chrome/browser/history/history_service_factory.h" | 20 #include "chrome/browser/history/history_service_factory.h" |
| 21 #include "chrome/browser/predictors/predictor_database.h" | |
| 22 #include "chrome/browser/predictors/predictor_database_factory.h" | 21 #include "chrome/browser/predictors/predictor_database_factory.h" |
| 22 #include "chrome/browser/predictors/predictor_database_service.h" |
| 23 #include "chrome/browser/predictors/resource_prefetcher_manager.h" | 23 #include "chrome/browser/predictors/resource_prefetcher_manager.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
| 26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 28 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
| 29 #include "content/public/browser/load_from_memory_cache_details.h" | 29 #include "content/public/browser/load_from_memory_cache_details.h" |
| 30 #include "content/public/browser/navigation_controller.h" | 30 #include "content/public/browser/navigation_controller.h" |
| 31 #include "content/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
| 32 #include "content/public/browser/notification_source.h" | 32 #include "content/public/browser/notification_source.h" |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 //////////////////////////////////////////////////////////////////////////////// | 285 //////////////////////////////////////////////////////////////////////////////// |
| 286 // ResourcePrefetchPredictor. | 286 // ResourcePrefetchPredictor. |
| 287 | 287 |
| 288 ResourcePrefetchPredictor::ResourcePrefetchPredictor( | 288 ResourcePrefetchPredictor::ResourcePrefetchPredictor( |
| 289 const ResourcePrefetchPredictorConfig& config, | 289 const ResourcePrefetchPredictorConfig& config, |
| 290 Profile* profile) | 290 Profile* profile) |
| 291 : profile_(profile), | 291 : profile_(profile), |
| 292 config_(config), | 292 config_(config), |
| 293 initialization_state_(NOT_INITIALIZED), | 293 initialization_state_(NOT_INITIALIZED), |
| 294 tables_(PredictorDatabaseFactory::GetForProfile( | 294 tables_(PredictorDatabaseFactory::GetForProfile( |
| 295 profile)->resource_prefetch_tables()), | 295 profile)->GetDatabase()->resource_prefetch_tables()), |
| 296 results_map_deleter_(&results_map_) { | 296 results_map_deleter_(&results_map_) { |
| 297 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 297 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 298 | 298 |
| 299 // Some form of learning has to be enabled. | 299 // Some form of learning has to be enabled. |
| 300 DCHECK(config_.IsLearningEnabled()); | 300 DCHECK(config_.IsLearningEnabled()); |
| 301 if (config_.IsURLPrefetchingEnabled()) | 301 if (config_.IsURLPrefetchingEnabled()) |
| 302 DCHECK(config_.IsURLLearningEnabled()); | 302 DCHECK(config_.IsURLLearningEnabled()); |
| 303 if (config_.IsHostPrefetchingEnabled()) | 303 if (config_.IsHostPrefetchingEnabled()) |
| 304 DCHECK(config_.IsHostLearningEnabled()); | 304 DCHECK(config_.IsHostLearningEnabled()); |
| 305 | 305 |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1237 RPP_PREDICTED_HISTOGRAM_PERCENTAGE( | 1237 RPP_PREDICTED_HISTOGRAM_PERCENTAGE( |
| 1238 "PrefetchFromNetworkPercentOfTotalFromNetwork", | 1238 "PrefetchFromNetworkPercentOfTotalFromNetwork", |
| 1239 prefetch_network * 100.0 / total_resources_fetched_from_network); | 1239 prefetch_network * 100.0 / total_resources_fetched_from_network); |
| 1240 } | 1240 } |
| 1241 | 1241 |
| 1242 #undef RPP_PREDICTED_HISTOGRAM_PERCENTAGE | 1242 #undef RPP_PREDICTED_HISTOGRAM_PERCENTAGE |
| 1243 #undef RPP_PREDICTED_HISTOGRAM_COUNTS | 1243 #undef RPP_PREDICTED_HISTOGRAM_COUNTS |
| 1244 } | 1244 } |
| 1245 | 1245 |
| 1246 } // namespace predictors | 1246 } // namespace predictors |
| OLD | NEW |