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 
5 #ifndef CHROME_BROWSER_CHROMEOS_CHILD_ACCOUNTS_FAMILY_USER_METRICS_SERVICE_FACTORY_H_
6 #define CHROME_BROWSER_CHROMEOS_CHILD_ACCOUNTS_FAMILY_USER_METRICS_SERVICE_FACTORY_H_
7 
8 #include "base/no_destructor.h"
9 #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
10 
11 namespace content {
12 class BrowserContext;
13 }
14 
15 namespace chromeos {
16 class FamilyUserMetricsService;
17 
18 // Singleton that owns FamilyUserMetricsService object and associates
19 // them with corresponding BrowserContexts. Listens for the BrowserContext's
20 // destruction notification and cleans up the associated
21 // FamilyUserMetricsService.
22 class FamilyUserMetricsServiceFactory
23     : public BrowserContextKeyedServiceFactory {
24  public:
25   static FamilyUserMetricsService* GetForBrowserContext(
26       content::BrowserContext* context);
27 
28   static FamilyUserMetricsServiceFactory* GetInstance();
29 
30  private:
31   friend class base::NoDestructor<FamilyUserMetricsServiceFactory>;
32 
33   FamilyUserMetricsServiceFactory();
34   FamilyUserMetricsServiceFactory(const FamilyUserMetricsServiceFactory&) =
35       delete;
36   FamilyUserMetricsServiceFactory& operator=(
37       const FamilyUserMetricsServiceFactory&) = delete;
38 
39   ~FamilyUserMetricsServiceFactory() override;
40 
41   // BrowserContextKeyedServiceFactory:
42   KeyedService* BuildServiceInstanceFor(
43       content::BrowserContext* context) const override;
44 };
45 
46 }  // namespace chromeos
47 
48 #endif  // CHROME_BROWSER_CHROMEOS_CHILD_ACCOUNTS_FAMILY_USER_METRICS_SERVICE_FACTORY_H_
49