OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/predictors/loading_predictor_factory.h" |
| 6 |
| 7 #include "chrome/browser/history/history_service_factory.h" |
| 8 #include "chrome/browser/predictors/loading_predictor.h" |
| 9 #include "chrome/browser/predictors/predictor_database_factory.h" |
| 10 #include "chrome/browser/predictors/resource_prefetch_common.h" |
| 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 13 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
| 14 |
| 15 namespace predictors { |
| 16 |
| 17 // static |
| 18 LoadingPredictor* LoadingPredictorFactory::GetForProfile(Profile* profile) { |
| 19 return static_cast<LoadingPredictor*>( |
| 20 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 21 } |
| 22 |
| 23 // static |
| 24 LoadingPredictorFactory* LoadingPredictorFactory::GetInstance() { |
| 25 return base::Singleton<LoadingPredictorFactory>::get(); |
| 26 } |
| 27 |
| 28 LoadingPredictorFactory::LoadingPredictorFactory() |
| 29 : BrowserContextKeyedServiceFactory( |
| 30 "LoadingPredictor", |
| 31 BrowserContextDependencyManager::GetInstance()) { |
| 32 DependsOn(HistoryServiceFactory::GetInstance()); |
| 33 DependsOn(PredictorDatabaseFactory::GetInstance()); |
| 34 } |
| 35 |
| 36 LoadingPredictorFactory::~LoadingPredictorFactory() {} |
| 37 |
| 38 KeyedService* LoadingPredictorFactory::BuildServiceInstanceFor( |
| 39 content::BrowserContext* context) const { |
| 40 Profile* profile = Profile::FromBrowserContext(context); |
| 41 |
| 42 LoadingPredictorConfig config; |
| 43 if (!IsLoadingPredictortEnabled(profile, &config)) |
| 44 return nullptr; |
| 45 |
| 46 return new LoadingPredictor(config, profile); |
| 47 } |
| 48 |
| 49 } // namespace predictors |
OLD | NEW |