OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "extensions/browser/service_worker_task_queue_factory.h" |
| 6 |
| 7 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 8 #include "extensions/browser/extensions_browser_client.h" |
| 9 #include "extensions/browser/service_worker_task_queue.h" |
| 10 |
| 11 using content::BrowserContext; |
| 12 namespace extensions { |
| 13 |
| 14 // static |
| 15 ServiceWorkerTaskQueue* ServiceWorkerTaskQueueFactory::GetForBrowserContext( |
| 16 BrowserContext* context) { |
| 17 return static_cast<ServiceWorkerTaskQueue*>( |
| 18 GetInstance()->GetServiceForBrowserContext(context, true)); |
| 19 } |
| 20 |
| 21 // static |
| 22 ServiceWorkerTaskQueueFactory* ServiceWorkerTaskQueueFactory::GetInstance() { |
| 23 return base::Singleton<ServiceWorkerTaskQueueFactory>::get(); |
| 24 } |
| 25 |
| 26 ServiceWorkerTaskQueueFactory::ServiceWorkerTaskQueueFactory() |
| 27 : BrowserContextKeyedServiceFactory( |
| 28 "ServiceWorkerTaskQueue", |
| 29 BrowserContextDependencyManager::GetInstance()) {} |
| 30 |
| 31 ServiceWorkerTaskQueueFactory::~ServiceWorkerTaskQueueFactory() {} |
| 32 |
| 33 KeyedService* ServiceWorkerTaskQueueFactory::BuildServiceInstanceFor( |
| 34 BrowserContext* context) const { |
| 35 return new ServiceWorkerTaskQueue(context); |
| 36 } |
| 37 |
| 38 BrowserContext* ServiceWorkerTaskQueueFactory::GetBrowserContextToUse( |
| 39 BrowserContext* context) const { |
| 40 // Redirected in incognito. |
| 41 return ExtensionsBrowserClient::Get()->GetOriginalContext(context); |
| 42 } |
| 43 |
| 44 } // namespace extensions |
OLD | NEW |