Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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 "components/offline_pages/content/prefetch_service_factory.h" | 5 #include "components/offline_pages/content/prefetch_service_factory.h" |
| 6 | 6 |
| 7 #include <memory> | |
| 8 | |
| 9 #include "base/memory/ptr_util.h" | |
| 7 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| 8 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 11 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 12 #include "components/offline_pages/core/prefetch/prefetch_dispatcher_impl.h" | |
| 9 #include "components/offline_pages/core/prefetch/prefetch_service_impl.h" | 13 #include "components/offline_pages/core/prefetch/prefetch_service_impl.h" |
| 14 #include "components/offline_pages/core/prefetch/prefetch_store.h" | |
| 10 #include "content/public/browser/browser_context.h" | 15 #include "content/public/browser/browser_context.h" |
| 11 | 16 |
| 12 namespace offline_pages { | 17 namespace offline_pages { |
| 13 | 18 |
| 14 PrefetchServiceFactory::PrefetchServiceFactory() | 19 PrefetchServiceFactory::PrefetchServiceFactory() |
| 15 : BrowserContextKeyedServiceFactory( | 20 : BrowserContextKeyedServiceFactory( |
| 16 "OfflinePagePrefetchService", | 21 "OfflinePagePrefetchService", |
| 17 BrowserContextDependencyManager::GetInstance()) {} | 22 BrowserContextDependencyManager::GetInstance()) {} |
| 18 | 23 |
| 19 // static | 24 // static |
| 20 PrefetchServiceFactory* PrefetchServiceFactory::GetInstance() { | 25 PrefetchServiceFactory* PrefetchServiceFactory::GetInstance() { |
| 21 return base::Singleton<PrefetchServiceFactory>::get(); | 26 return base::Singleton<PrefetchServiceFactory>::get(); |
| 22 } | 27 } |
| 23 | 28 |
| 24 // static | 29 // static |
| 25 PrefetchService* PrefetchServiceFactory::GetForBrowserContext( | 30 PrefetchService* PrefetchServiceFactory::GetForBrowserContext( |
| 26 content::BrowserContext* context) { | 31 content::BrowserContext* context) { |
| 27 return static_cast<PrefetchService*>( | 32 return static_cast<PrefetchService*>( |
| 28 GetInstance()->GetServiceForBrowserContext(context, true)); | 33 GetInstance()->GetServiceForBrowserContext(context, true)); |
| 29 } | 34 } |
| 30 | 35 |
| 31 KeyedService* PrefetchServiceFactory::BuildServiceInstanceFor( | 36 KeyedService* PrefetchServiceFactory::BuildServiceInstanceFor( |
| 32 content::BrowserContext* context) const { | 37 content::BrowserContext* context) const { |
| 33 return new PrefetchServiceImpl(); | 38 // TODO(carlosk): instantiate actual store implementation once it exists. |
| 39 std::unique_ptr<PrefetchStore> prefetch_store; | |
| 40 std::unique_ptr<PrefetchDispatcher> prefetch_dispatcher_impl = | |
|
fgorski
2017/05/30 17:21:45
nit: prefetch_dispatcher would be suitable I guess
carlosk
2017/06/01 01:49:59
As here it is specifically an instance of the impl
| |
| 41 base::MakeUnique<PrefetchDispatcherImpl>(); | |
| 42 return new PrefetchServiceImpl(std::move(prefetch_store), | |
| 43 std::move(prefetch_dispatcher_impl)); | |
| 34 } | 44 } |
| 35 | 45 |
| 36 } // namespace offline_pages | 46 } // namespace offline_pages |
| OLD | NEW |