fixup! [M120 Migration] Notify media device state to webbrowser
[platform/framework/web/chromium-efl.git] / components / background_task_scheduler / background_task_scheduler_factory.cc
1 // Copyright 2020 The Chromium Authors
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 "components/background_task_scheduler/background_task_scheduler_factory.h"
6
7 #include <memory>
8
9 #include "base/memory/singleton.h"
10 #include "build/build_config.h"
11 #include "components/background_task_scheduler/background_task_scheduler.h"
12 #include "components/keyed_service/core/simple_dependency_manager.h"
13
14 #if BUILDFLAG(IS_ANDROID)
15 #include "components/background_task_scheduler/internal/android/native_task_scheduler.h"
16 #endif
17
18 namespace background_task {
19
20 // static
21 BackgroundTaskSchedulerFactory* BackgroundTaskSchedulerFactory::GetInstance() {
22   return base::Singleton<BackgroundTaskSchedulerFactory>::get();
23 }
24
25 // static
26 BackgroundTaskScheduler* BackgroundTaskSchedulerFactory::GetForKey(
27     SimpleFactoryKey* key) {
28   return static_cast<BackgroundTaskScheduler*>(
29       GetInstance()->GetServiceForKey(key, true));
30 }
31
32 BackgroundTaskSchedulerFactory::BackgroundTaskSchedulerFactory()
33     : SimpleKeyedServiceFactory("BackgroundTaskScheduler",
34                                 SimpleDependencyManager::GetInstance()) {}
35
36 BackgroundTaskSchedulerFactory::~BackgroundTaskSchedulerFactory() = default;
37
38 std::unique_ptr<KeyedService>
39 BackgroundTaskSchedulerFactory::BuildServiceInstanceFor(
40     SimpleFactoryKey* key) const {
41 #if BUILDFLAG(IS_ANDROID)
42   return std::make_unique<NativeTaskScheduler>();
43 #else
44   return nullptr;
45 #endif
46 }
47
48 SimpleFactoryKey* BackgroundTaskSchedulerFactory::GetKeyToUse(
49     SimpleFactoryKey* key) const {
50   return key;
51 }
52
53 }  // namespace background_task