Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / predictors / resource_prefetch_predictor_factory.cc
blob6bb42878394df72331e706d1a631be5ff37cef88
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
3 // found in the LICENSE file.
5 #include "chrome/browser/predictors/resource_prefetch_predictor_factory.h"
7 #include "chrome/browser/history/history_service_factory.h"
8 #include "chrome/browser/predictors/predictor_database_factory.h"
9 #include "chrome/browser/predictors/resource_prefetch_common.h"
10 #include "chrome/browser/predictors/resource_prefetch_predictor.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"
15 namespace predictors {
17 // static
18 ResourcePrefetchPredictor* ResourcePrefetchPredictorFactory::GetForProfile(
19 content::BrowserContext* context) {
20 return static_cast<ResourcePrefetchPredictor*>(
21 GetInstance()->GetServiceForBrowserContext(context, true));
24 // static
25 ResourcePrefetchPredictorFactory*
26 ResourcePrefetchPredictorFactory::GetInstance() {
27 return Singleton<ResourcePrefetchPredictorFactory>::get();
30 ResourcePrefetchPredictorFactory::ResourcePrefetchPredictorFactory()
31 : BrowserContextKeyedServiceFactory(
32 "ResourcePrefetchPredictor",
33 BrowserContextDependencyManager::GetInstance()) {
34 DependsOn(HistoryServiceFactory::GetInstance());
35 DependsOn(PredictorDatabaseFactory::GetInstance());
38 ResourcePrefetchPredictorFactory::~ResourcePrefetchPredictorFactory() {}
40 KeyedService*
41 ResourcePrefetchPredictorFactory::BuildServiceInstanceFor(
42 content::BrowserContext* context) const {
43 Profile* profile = Profile::FromBrowserContext(context);
45 ResourcePrefetchPredictorConfig config;
46 if (!IsSpeculativeResourcePrefetchingEnabled(profile, &config))
47 return NULL;
49 return new ResourcePrefetchPredictor(config, profile);
52 } // namespace predictors