[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / invalidation / invalidation_service_factory.h
bloba82ed4c063e7e91c01fc207746ada9e24b91166c
1 // Copyright (c) 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.
5 #ifndef CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_FACTORY_H_
6 #define CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_FACTORY_H_
8 #include "base/basictypes.h"
9 #include "base/memory/singleton.h"
10 #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
12 namespace user_prefs {
13 class PrefRegistrySyncable;
16 namespace syncer {
17 class Invalidator;
20 class Profile;
22 namespace invalidation {
24 class FakeInvalidationService;
25 class InvalidationService;
26 class P2PInvalidationService;
28 // A BrowserContextKeyedServiceFactory to construct InvalidationServices. The
29 // implementation of the InvalidationService may be completely different on
30 // different platforms; this class should help to hide this complexity. It also
31 // exposes some factory methods that are useful for setting up tests that rely
32 // on invalidations.
33 class InvalidationServiceFactory : public BrowserContextKeyedServiceFactory {
34 public:
35 // Returns the InvalidationService for the given |profile|, lazily creating
36 // one first if required. If |profile| does not support invalidation
37 // (Chrome OS login profile, Chrome OS guest), returns NULL instead.
38 static InvalidationService* GetForProfile(Profile* profile);
40 static InvalidationServiceFactory* GetInstance();
42 // Switches service creation to go through |testing_factory| for all browser
43 // contexts.
44 void RegisterTestingFactory(TestingFactoryFunction testing_factory);
46 private:
47 friend class InvalidationServiceFactoryTestBase;
48 friend struct DefaultSingletonTraits<InvalidationServiceFactory>;
50 InvalidationServiceFactory();
51 virtual ~InvalidationServiceFactory();
53 // BrowserContextKeyedServiceFactory:
54 virtual KeyedService* BuildServiceInstanceFor(
55 content::BrowserContext* context) const OVERRIDE;
56 virtual void RegisterProfilePrefs(
57 user_prefs::PrefRegistrySyncable* registry) OVERRIDE;
59 TestingFactoryFunction testing_factory_;
61 DISALLOW_COPY_AND_ASSIGN(InvalidationServiceFactory);
64 } // namespace invalidation
66 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_FACTORY_H_