Chromium Code Reviews| 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/glowplug_predictor_factory.h" | |
| 6 | |
| 7 #include "chrome/browser/history/history_service_factory.h" | |
| 8 #include "chrome/browser/predictors/glowplug_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 GlowplugPredictor* GlowplugPredictorFactory::GetForProfile( | |
|
alexilin
2017/05/11 16:53:12
Shouldn't we rename it to GetForBrowserContext?
Benoit L
2017/05/12 12:12:53
It seems that there is no consistent convention in
| |
| 19 content::BrowserContext* context) { | |
| 20 return static_cast<GlowplugPredictor*>( | |
| 21 GetInstance()->GetServiceForBrowserContext(context, true)); | |
| 22 } | |
| 23 | |
| 24 // static | |
| 25 GlowplugPredictorFactory* GlowplugPredictorFactory::GetInstance() { | |
| 26 return base::Singleton<GlowplugPredictorFactory>::get(); | |
| 27 } | |
| 28 | |
| 29 GlowplugPredictorFactory::GlowplugPredictorFactory() | |
| 30 : BrowserContextKeyedServiceFactory( | |
| 31 "GlowplugPredictor", | |
| 32 BrowserContextDependencyManager::GetInstance()) { | |
| 33 DependsOn(HistoryServiceFactory::GetInstance()); | |
| 34 DependsOn(PredictorDatabaseFactory::GetInstance()); | |
| 35 } | |
| 36 | |
| 37 GlowplugPredictorFactory::~GlowplugPredictorFactory() {} | |
| 38 | |
| 39 KeyedService* GlowplugPredictorFactory::BuildServiceInstanceFor( | |
| 40 content::BrowserContext* context) const { | |
| 41 Profile* profile = Profile::FromBrowserContext(context); | |
| 42 | |
| 43 GlowplugPredictorConfig config; | |
| 44 if (!IsGlowplugEnabled(profile, &config)) | |
| 45 return nullptr; | |
| 46 | |
| 47 return new GlowplugPredictor(config, profile); | |
| 48 } | |
| 49 | |
| 50 } // namespace predictors | |
| OLD | NEW |