OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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/android/offline_pages/request_coordinator_factory.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 9 #include "base/memory/singleton.h" |
| 10 #include "chrome/browser/android/offline_pages/prerendering_offliner_factory.h" |
| 11 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 12 #include "components/offline_pages/background/offliner_factory.h" |
| 13 #include "components/offline_pages/background/offliner_policy.h" |
| 14 #include "components/offline_pages/background/request_coordinator.h" |
| 15 |
| 16 namespace offline_pages { |
| 17 |
| 18 RequestCoordinatorFactory::RequestCoordinatorFactory() |
| 19 : BrowserContextKeyedServiceFactory( |
| 20 "OfflineRequestCoordinator", |
| 21 BrowserContextDependencyManager::GetInstance()) {} |
| 22 |
| 23 // static |
| 24 RequestCoordinatorFactory* RequestCoordinatorFactory::GetInstance() { |
| 25 return base::Singleton<RequestCoordinatorFactory>::get(); |
| 26 } |
| 27 |
| 28 // static |
| 29 RequestCoordinator* RequestCoordinatorFactory::GetForBrowserContext( |
| 30 content::BrowserContext* context) { |
| 31 return static_cast<RequestCoordinator*>( |
| 32 GetInstance()->GetServiceForBrowserContext(context, true)); |
| 33 } |
| 34 |
| 35 KeyedService* RequestCoordinatorFactory::BuildServiceInstanceFor( |
| 36 content::BrowserContext* context) const { |
| 37 std::unique_ptr<OfflinerPolicy> policy(new OfflinerPolicy()); |
| 38 std::unique_ptr<OfflinerFactory> prerendererOffliner( |
| 39 new PrerenderingOfflinerFactory(context)); |
| 40 // TODO(petewil) Add support for server based offliner when it is ready. |
| 41 |
| 42 return new RequestCoordinator(std::move(policy), |
| 43 std::move(prerendererOffliner)); |
| 44 } |
| 45 |
| 46 content::BrowserContext* RequestCoordinatorFactory::GetBrowserContextToUse( |
| 47 content::BrowserContext* context) const { |
| 48 // TODO(petewil): Implement. |
| 49 return nullptr; |
| 50 } |
| 51 |
| 52 } // namespace offline_pages |
OLD | NEW |