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 |
| 24 // static |
| 25 RequestCoordinatorFactory* RequestCoordinatorFactory::GetInstance() { |
| 26 return base::Singleton<RequestCoordinatorFactory>::get(); |
| 27 } |
| 28 |
| 29 // static |
| 30 RequestCoordinator* RequestCoordinatorFactory::GetForBrowserContext( |
| 31 content::BrowserContext* context) { |
| 32 return static_cast<RequestCoordinator*>( |
| 33 GetInstance()->GetServiceForBrowserContext(context, true)); |
| 34 } |
| 35 |
| 36 KeyedService* RequestCoordinatorFactory::BuildServiceInstanceFor( |
| 37 content::BrowserContext* context) const { |
| 38 std::unique_ptr<OfflinerPolicy> policy(new OfflinerPolicy()); |
| 39 std::unique_ptr<OfflinerFactory> prerendererOffliner( |
| 40 new PrerenderingOfflinerFactory(context)); |
| 41 // TODO(petewil) Add support for server based offliner when it is ready. |
| 42 |
| 43 return new RequestCoordinator( |
| 44 std::move(policy), std::move(prerendererOffliner)); |
| 45 } |
| 46 |
| 47 content::BrowserContext* RequestCoordinatorFactory::GetBrowserContextToUse( |
| 48 content::BrowserContext* context) const { |
| 49 // TODO(petewil): Implement. |
| 50 return nullptr; |
| 51 } |
| 52 |
| 53 } // namespace offline_pages |
OLD | NEW |