app_lifetime_monitor_factory.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2013 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 APPS_APP_LIFETIME_MONITOR_FACTORY_H_
  5. #define APPS_APP_LIFETIME_MONITOR_FACTORY_H_
  6. #include "base/memory/singleton.h"
  7. #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
  8. namespace content {
  9. class BrowserContext;
  10. }
  11. namespace apps {
  12. class AppLifetimeMonitor;
  13. // Singleton that owns all AppLifetimeMonitors and associates them with
  14. // BrowserContexts. Listens for the BrowserContext's destruction notification
  15. // and cleans up the associated AppLifetimeMonitor.
  16. class AppLifetimeMonitorFactory : public BrowserContextKeyedServiceFactory {
  17. public:
  18. static AppLifetimeMonitor* GetForBrowserContext(
  19. content::BrowserContext* context);
  20. static AppLifetimeMonitorFactory* GetInstance();
  21. private:
  22. friend struct base::DefaultSingletonTraits<AppLifetimeMonitorFactory>;
  23. AppLifetimeMonitorFactory();
  24. ~AppLifetimeMonitorFactory() override;
  25. // BrowserContextKeyedServiceFactory:
  26. KeyedService* BuildServiceInstanceFor(
  27. content::BrowserContext* context) const override;
  28. bool ServiceIsCreatedWithBrowserContext() const override;
  29. content::BrowserContext* GetBrowserContextToUse(
  30. content::BrowserContext* context) const override;
  31. };
  32. } // namespace apps
  33. #endif // APPS_APP_LIFETIME_MONITOR_FACTORY_H_