OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/precache/precache_manager_factory.h" | 5 #include "chrome/browser/precache/precache_manager_factory.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "chrome/browser/history/history_service_factory.h" | 11 #include "chrome/browser/history/history_service_factory.h" |
12 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 12 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
13 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" | 13 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" |
14 #include "chrome/browser/predictors/resource_prefetch_predictor.h" | 14 #include "chrome/browser/predictors/loading_predictor.h" |
15 #include "chrome/browser/predictors/resource_prefetch_predictor_factory.h" | 15 #include "chrome/browser/predictors/loading_predictor_factory.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/sync/profile_sync_service_factory.h" | 17 #include "chrome/browser/sync/profile_sync_service_factory.h" |
18 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 18 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
19 #include "components/keyed_service/core/service_access_type.h" | 19 #include "components/keyed_service/core/service_access_type.h" |
20 #include "components/precache/content/precache_manager.h" | 20 #include "components/precache/content/precache_manager.h" |
21 #include "components/precache/core/precache_database.h" | 21 #include "components/precache/core/precache_database.h" |
22 #include "content/public/browser/browser_context.h" | 22 #include "content/public/browser/browser_context.h" |
23 | 23 |
24 namespace precache { | 24 namespace precache { |
25 | 25 |
26 // static | 26 // static |
27 PrecacheManager* PrecacheManagerFactory::GetForBrowserContext( | 27 PrecacheManager* PrecacheManagerFactory::GetForBrowserContext( |
28 content::BrowserContext* browser_context) { | 28 content::BrowserContext* browser_context) { |
29 return static_cast<PrecacheManager*>( | 29 return static_cast<PrecacheManager*>( |
30 GetInstance()->GetServiceForBrowserContext(browser_context, true)); | 30 GetInstance()->GetServiceForBrowserContext(browser_context, true)); |
31 } | 31 } |
32 | 32 |
33 // static | 33 // static |
34 PrecacheManagerFactory* PrecacheManagerFactory::GetInstance() { | 34 PrecacheManagerFactory* PrecacheManagerFactory::GetInstance() { |
35 return base::Singleton<PrecacheManagerFactory>::get(); | 35 return base::Singleton<PrecacheManagerFactory>::get(); |
36 } | 36 } |
37 | 37 |
38 PrecacheManagerFactory::PrecacheManagerFactory() | 38 PrecacheManagerFactory::PrecacheManagerFactory() |
39 : BrowserContextKeyedServiceFactory( | 39 : BrowserContextKeyedServiceFactory( |
40 "PrecacheManager", | 40 "PrecacheManager", |
41 BrowserContextDependencyManager::GetInstance()) { | 41 BrowserContextDependencyManager::GetInstance()) { |
42 DependsOn(ProfileSyncServiceFactory::GetInstance()); | 42 DependsOn(ProfileSyncServiceFactory::GetInstance()); |
43 DependsOn(HistoryServiceFactory::GetInstance()); | 43 DependsOn(HistoryServiceFactory::GetInstance()); |
44 DependsOn(DataReductionProxyChromeSettingsFactory::GetInstance()); | 44 DependsOn(DataReductionProxyChromeSettingsFactory::GetInstance()); |
45 DependsOn(predictors::ResourcePrefetchPredictorFactory::GetInstance()); | 45 DependsOn(predictors::LoadingPredictorFactory::GetInstance()); |
46 } | 46 } |
47 | 47 |
48 PrecacheManagerFactory::~PrecacheManagerFactory() { | 48 PrecacheManagerFactory::~PrecacheManagerFactory() { |
49 } | 49 } |
50 | 50 |
51 KeyedService* PrecacheManagerFactory::BuildServiceInstanceFor( | 51 KeyedService* PrecacheManagerFactory::BuildServiceInstanceFor( |
52 content::BrowserContext* browser_context) const { | 52 content::BrowserContext* browser_context) const { |
53 std::unique_ptr<PrecacheDatabase> precache_database( | 53 std::unique_ptr<PrecacheDatabase> precache_database( |
54 new PrecacheDatabase()); | 54 new PrecacheDatabase()); |
55 base::FilePath db_path(browser_context->GetPath().Append( | 55 base::FilePath db_path(browser_context->GetPath().Append( |
56 base::FilePath(FILE_PATH_LITERAL("PrecacheDatabase")))); | 56 base::FilePath(FILE_PATH_LITERAL("PrecacheDatabase")))); |
| 57 auto* loading_predictor = predictors::LoadingPredictorFactory::GetForProfile( |
| 58 Profile::FromBrowserContext(browser_context)); |
57 return new PrecacheManager( | 59 return new PrecacheManager( |
58 browser_context, | 60 browser_context, |
59 ProfileSyncServiceFactory::GetSyncServiceForBrowserContext( | 61 ProfileSyncServiceFactory::GetSyncServiceForBrowserContext( |
60 browser_context), | 62 browser_context), |
61 HistoryServiceFactory::GetForProfile( | 63 HistoryServiceFactory::GetForProfile( |
62 Profile::FromBrowserContext(browser_context), | 64 Profile::FromBrowserContext(browser_context), |
63 ServiceAccessType::IMPLICIT_ACCESS), | 65 ServiceAccessType::IMPLICIT_ACCESS), |
64 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( | 66 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( |
65 browser_context), | 67 browser_context), |
66 predictors::ResourcePrefetchPredictorFactory::GetForProfile( | 68 loading_predictor ? loading_predictor->resource_prefetch_predictor() |
67 browser_context), | 69 : nullptr, |
68 db_path, std::move(precache_database)); | 70 db_path, std::move(precache_database)); |
69 } | 71 } |
70 | 72 |
71 } // namespace precache | 73 } // namespace precache |
OLD | NEW |