[email protected] | 4b7111f2 | 2013-06-18 14:22:12 | [diff] [blame] | 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 | |||||
5 | #ifndef APPS_APP_LIFETIME_MONITOR_FACTORY_H_ | ||||
6 | #define APPS_APP_LIFETIME_MONITOR_FACTORY_H_ | ||||
7 | |||||
8 | #include "base/memory/singleton.h" | ||||
[email protected] | 12b7af3 | 2014-03-13 05:28:20 | [diff] [blame] | 9 | #include "components/keyed_service/content/browser_context_keyed_service_factory.h" |
[email protected] | 4b7111f2 | 2013-06-18 14:22:12 | [diff] [blame] | 10 | |
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 11 | namespace content { |
12 | class BrowserContext; | ||||
13 | } | ||||
[email protected] | 4b7111f2 | 2013-06-18 14:22:12 | [diff] [blame] | 14 | |
15 | namespace apps { | ||||
16 | |||||
17 | class AppLifetimeMonitor; | ||||
18 | |||||
19 | // Singleton that owns all AppLifetimeMonitors and associates them with | ||||
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 20 | // BrowserContexts. Listens for the BrowserContext's destruction notification |
21 | // and cleans up the associated AppLifetimeMonitor. | ||||
[email protected] | 4b7111f2 | 2013-06-18 14:22:12 | [diff] [blame] | 22 | class AppLifetimeMonitorFactory : public BrowserContextKeyedServiceFactory { |
23 | public: | ||||
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 24 | static AppLifetimeMonitor* GetForBrowserContext( |
25 | content::BrowserContext* context); | ||||
[email protected] | 4b7111f2 | 2013-06-18 14:22:12 | [diff] [blame] | 26 | |
27 | static AppLifetimeMonitorFactory* GetInstance(); | ||||
28 | |||||
29 | private: | ||||
olli.raula | 36aa8be | 2015-09-10 11:14:22 | [diff] [blame] | 30 | friend struct base::DefaultSingletonTraits<AppLifetimeMonitorFactory>; |
[email protected] | 4b7111f2 | 2013-06-18 14:22:12 | [diff] [blame] | 31 | |
32 | AppLifetimeMonitorFactory(); | ||||
dcheng | 2f5be41 | 2014-10-22 01:46:08 | [diff] [blame] | 33 | ~AppLifetimeMonitorFactory() override; |
[email protected] | 4b7111f2 | 2013-06-18 14:22:12 | [diff] [blame] | 34 | |
35 | // BrowserContextKeyedServiceFactory: | ||||
dcheng | 2f5be41 | 2014-10-22 01:46:08 | [diff] [blame] | 36 | KeyedService* BuildServiceInstanceFor( |
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 37 | content::BrowserContext* context) const override; |
dcheng | 2f5be41 | 2014-10-22 01:46:08 | [diff] [blame] | 38 | bool ServiceIsCreatedWithBrowserContext() const override; |
39 | content::BrowserContext* GetBrowserContextToUse( | ||||
40 | content::BrowserContext* context) const override; | ||||
[email protected] | 4b7111f2 | 2013-06-18 14:22:12 | [diff] [blame] | 41 | }; |
42 | |||||
43 | } // namespace apps | ||||
44 | |||||
45 | #endif // APPS_APP_LIFETIME_MONITOR_FACTORY_H_ |