Chromium Code Reviews| 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" | |
| 15 #include "chrome/browser/predictors/resource_prefetch_predictor_factory.h" | |
| 14 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/sync/profile_sync_service_factory.h" | 17 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 16 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 18 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 17 #include "components/keyed_service/core/service_access_type.h" | 19 #include "components/keyed_service/core/service_access_type.h" |
| 18 #include "components/precache/content/precache_manager.h" | 20 #include "components/precache/content/precache_manager.h" |
| 19 #include "components/precache/core/precache_database.h" | 21 #include "components/precache/core/precache_database.h" |
| 20 #include "content/public/browser/browser_context.h" | 22 #include "content/public/browser/browser_context.h" |
| 21 | 23 |
| 22 namespace precache { | 24 namespace precache { |
| 23 | 25 |
| 24 // static | 26 // static |
| 25 PrecacheManager* PrecacheManagerFactory::GetForBrowserContext( | 27 PrecacheManager* PrecacheManagerFactory::GetForBrowserContext( |
| 26 content::BrowserContext* browser_context) { | 28 content::BrowserContext* browser_context) { |
| 27 return static_cast<PrecacheManager*>( | 29 return static_cast<PrecacheManager*>( |
| 28 GetInstance()->GetServiceForBrowserContext(browser_context, true)); | 30 GetInstance()->GetServiceForBrowserContext(browser_context, true)); |
| 29 } | 31 } |
| 30 | 32 |
| 31 // static | 33 // static |
| 32 PrecacheManagerFactory* PrecacheManagerFactory::GetInstance() { | 34 PrecacheManagerFactory* PrecacheManagerFactory::GetInstance() { |
| 33 return base::Singleton<PrecacheManagerFactory>::get(); | 35 return base::Singleton<PrecacheManagerFactory>::get(); |
| 34 } | 36 } |
| 35 | 37 |
| 36 PrecacheManagerFactory::PrecacheManagerFactory() | 38 PrecacheManagerFactory::PrecacheManagerFactory() |
| 37 : BrowserContextKeyedServiceFactory( | 39 : BrowserContextKeyedServiceFactory( |
| 38 "PrecacheManager", | 40 "PrecacheManager", |
| 39 BrowserContextDependencyManager::GetInstance()) { | 41 BrowserContextDependencyManager::GetInstance()) { |
| 40 DependsOn(ProfileSyncServiceFactory::GetInstance()); | 42 DependsOn(ProfileSyncServiceFactory::GetInstance()); |
| 41 DependsOn(HistoryServiceFactory::GetInstance()); | 43 DependsOn(HistoryServiceFactory::GetInstance()); |
| 42 DependsOn(DataReductionProxyChromeSettingsFactory::GetInstance()); | 44 DependsOn(DataReductionProxyChromeSettingsFactory::GetInstance()); |
| 45 DependsOn(predictors::ResourcePrefetchPredictorFactory::GetInstance()); | |
| 43 } | 46 } |
| 44 | 47 |
| 45 PrecacheManagerFactory::~PrecacheManagerFactory() { | 48 PrecacheManagerFactory::~PrecacheManagerFactory() { |
| 46 } | 49 } |
| 47 | 50 |
| 48 KeyedService* PrecacheManagerFactory::BuildServiceInstanceFor( | 51 KeyedService* PrecacheManagerFactory::BuildServiceInstanceFor( |
| 49 content::BrowserContext* browser_context) const { | 52 content::BrowserContext* browser_context) const { |
| 50 std::unique_ptr<PrecacheDatabase> precache_database( | 53 std::unique_ptr<PrecacheDatabase> precache_database( |
| 51 new PrecacheDatabase()); | 54 new PrecacheDatabase()); |
| 52 base::FilePath db_path(browser_context->GetPath().Append( | 55 base::FilePath db_path(browser_context->GetPath().Append( |
| 53 base::FilePath(FILE_PATH_LITERAL("PrecacheDatabase")))); | 56 base::FilePath(FILE_PATH_LITERAL("PrecacheDatabase")))); |
| 54 return new PrecacheManager( | 57 return new PrecacheManager( |
| 55 browser_context, | 58 browser_context, |
| 56 ProfileSyncServiceFactory::GetSyncServiceForBrowserContext( | 59 ProfileSyncServiceFactory::GetSyncServiceForBrowserContext( |
| 57 browser_context), | 60 browser_context), |
| 58 HistoryServiceFactory::GetForProfile( | 61 HistoryServiceFactory::GetForProfile( |
| 59 Profile::FromBrowserContext(browser_context), | 62 Profile::FromBrowserContext(browser_context), |
| 60 ServiceAccessType::IMPLICIT_ACCESS), | 63 ServiceAccessType::IMPLICIT_ACCESS), |
| 61 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( | 64 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( |
| 62 browser_context), | 65 browser_context), |
| 66 predictors::ResourcePrefetchPredictorFactory::GetForProfile( | |
|
Benoit L
2017/03/21 13:24:15
here (see below) :-)
alexilin
2017/03/21 15:32:13
Replied (see below) (-:
| |
| 67 browser_context), | |
| 63 db_path, std::move(precache_database)); | 68 db_path, std::move(precache_database)); |
| 64 } | 69 } |
| 65 | 70 |
| 66 } // namespace precache | 71 } // namespace precache |
| OLD | NEW |