background_task_scheduler_factory.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2020 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. #ifndef COMPONENTS_BACKGROUND_TASK_SCHEDULER_BACKGROUND_TASK_SCHEDULER_FACTORY_H_
  5. #define COMPONENTS_BACKGROUND_TASK_SCHEDULER_BACKGROUND_TASK_SCHEDULER_FACTORY_H_
  6. #include <memory>
  7. #include "components/keyed_service/core/simple_keyed_service_factory.h"
  8. class SimpleFactoryKey;
  9. namespace base {
  10. template <typename T>
  11. struct DefaultSingletonTraits;
  12. } // namespace base
  13. namespace background_task {
  14. class BackgroundTaskScheduler;
  15. // A factory for creating BackgroundTaskScheduler.
  16. class BackgroundTaskSchedulerFactory : public SimpleKeyedServiceFactory {
  17. public:
  18. // Returns singleton instance of BackgroundTaskSchedulerFactory.
  19. static BackgroundTaskSchedulerFactory* GetInstance();
  20. // Returns the BackgroundTaskScheuler associated with |key|.
  21. static BackgroundTaskScheduler* GetForKey(SimpleFactoryKey* key);
  22. BackgroundTaskSchedulerFactory(const BackgroundTaskSchedulerFactory&) =
  23. delete;
  24. BackgroundTaskSchedulerFactory& operator=(
  25. const BackgroundTaskSchedulerFactory&) = delete;
  26. private:
  27. friend struct base::DefaultSingletonTraits<BackgroundTaskSchedulerFactory>;
  28. BackgroundTaskSchedulerFactory();
  29. ~BackgroundTaskSchedulerFactory() override;
  30. // SimpleKeyedServiceFactory overrides.
  31. std::unique_ptr<KeyedService> BuildServiceInstanceFor(
  32. SimpleFactoryKey* key) const override;
  33. SimpleFactoryKey* GetKeyToUse(SimpleFactoryKey* key) const override;
  34. };
  35. } // namespace background_task
  36. #endif // COMPONENTS_BACKGROUND_TASK_SCHEDULER_BACKGROUND_TASK_SCHEDULER_FACTORY_H_