segmentation_platform_service_factory.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2021 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 CHROME_BROWSER_SEGMENTATION_PLATFORM_SEGMENTATION_PLATFORM_SERVICE_FACTORY_H_
  5. #define CHROME_BROWSER_SEGMENTATION_PLATFORM_SEGMENTATION_PLATFORM_SERVICE_FACTORY_H_
  6. #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
  7. namespace base {
  8. template <typename T>
  9. struct DefaultSingletonTraits;
  10. } // namespace base
  11. namespace content {
  12. class BrowserContext;
  13. } // namespace content
  14. class Profile;
  15. namespace segmentation_platform {
  16. class SegmentationPlatformService;
  17. // A factory to create a unique SegmentationPlatformService.
  18. class SegmentationPlatformServiceFactory
  19. : public BrowserContextKeyedServiceFactory {
  20. public:
  21. // Gets the SegmentationPlatformService for the profile. Returns a dummy one
  22. // if the feature isn't enabled.
  23. static SegmentationPlatformService* GetForProfile(Profile* profile);
  24. // Gets the lazy singleton instance of SegmentationPlatformService.
  25. static SegmentationPlatformServiceFactory* GetInstance();
  26. // Disallow copy/assign.
  27. SegmentationPlatformServiceFactory(
  28. const SegmentationPlatformServiceFactory&) = delete;
  29. SegmentationPlatformServiceFactory& operator=(
  30. const SegmentationPlatformServiceFactory&) = delete;
  31. private:
  32. friend struct base::DefaultSingletonTraits<
  33. SegmentationPlatformServiceFactory>;
  34. SegmentationPlatformServiceFactory();
  35. ~SegmentationPlatformServiceFactory() override;
  36. // BrowserContextKeyedServiceFactory overrides.
  37. KeyedService* BuildServiceInstanceFor(
  38. content::BrowserContext* context) const override;
  39. };
  40. } // namespace segmentation_platform
  41. #endif // CHROME_BROWSER_SEGMENTATION_PLATFORM_SEGMENTATION_PLATFORM_SERVICE_FACTORY_H_