Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: chrome/browser/invalidation/invalidation_service_factory.h

Issue 183803026: Clean up InvalidationService test infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_FACTORY_H_ 5 #ifndef CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_FACTORY_H_
6 #define CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_FACTORY_H_ 6 #define CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_FACTORY_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "components/browser_context_keyed_service/browser_context_keyed_service _factory.h" 10 #include "components/browser_context_keyed_service/browser_context_keyed_service _factory.h"
11 11
12 namespace user_prefs { 12 namespace user_prefs {
13 class PrefRegistrySyncable; 13 class PrefRegistrySyncable;
14 } 14 }
15 15
16 namespace syncer { 16 namespace syncer {
17 class Invalidator; 17 class Invalidator;
18 } 18 }
19 19
20 class Profile; 20 class Profile;
21 21
22 namespace invalidation { 22 namespace invalidation {
23 23
24 class FakeInvalidationService;
24 class InvalidationService; 25 class InvalidationService;
25 class P2PInvalidationService; 26 class P2PInvalidationService;
26 class FakeInvalidationService;
27 27
28 // A BrowserContextKeyedServiceFactory to construct InvalidationServices. The 28 // A BrowserContextKeyedServiceFactory to construct InvalidationServices. The
29 // implementation of the InvalidationService may be completely different on 29 // implementation of the InvalidationService may be completely different on
30 // different platforms; this class should help to hide this complexity. It also 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 31 // exposes some factory methods that are useful for setting up tests that rely
32 // on invalidations. 32 // on invalidations.
33 class InvalidationServiceFactory : public BrowserContextKeyedServiceFactory { 33 class InvalidationServiceFactory : public BrowserContextKeyedServiceFactory {
34 public: 34 public:
35 static InvalidationService* GetForProfile(Profile* profile); 35 static InvalidationService* GetForProfile(Profile* profile);
36 36
37 static InvalidationServiceFactory* GetInstance(); 37 static InvalidationServiceFactory* GetInstance();
38 38
39 // A helper function to set this factory to return FakeInvalidationServices 39 // Switches service creation to go through |testing_factory| for all browser
40 // instead of the default InvalidationService objects. 40 // contexts.
41 void SetBuildOnlyFakeInvalidatorsForTest(bool test_mode_enabled); 41 void RegisterTestingFactory(TestingFactoryFunction testing_factory);
42
43 // These helper functions to set the factory to build a test-only type of
44 // invalidator and return the instance immeidately.
45 P2PInvalidationService* BuildAndUseP2PInvalidationServiceForTest(
46 content::BrowserContext* context);
47 42
48 private: 43 private:
49 friend struct DefaultSingletonTraits<InvalidationServiceFactory>; 44 friend struct DefaultSingletonTraits<InvalidationServiceFactory>;
50 45
51 InvalidationServiceFactory(); 46 InvalidationServiceFactory();
52 virtual ~InvalidationServiceFactory(); 47 virtual ~InvalidationServiceFactory();
53 48
54 // BrowserContextKeyedServiceFactory: 49 // BrowserContextKeyedServiceFactory:
55 virtual BrowserContextKeyedService* BuildServiceInstanceFor( 50 virtual BrowserContextKeyedService* BuildServiceInstanceFor(
56 content::BrowserContext* context) const OVERRIDE; 51 content::BrowserContext* context) const OVERRIDE;
57 virtual void RegisterProfilePrefs( 52 virtual void RegisterProfilePrefs(
58 user_prefs::PrefRegistrySyncable* registry) OVERRIDE; 53 user_prefs::PrefRegistrySyncable* registry) OVERRIDE;
59 54
60 // If true, this factory will return only FakeInvalidationService instances. 55 TestingFactoryFunction testing_factory_;
61 bool build_fake_invalidators_;
62 56
63 DISALLOW_COPY_AND_ASSIGN(InvalidationServiceFactory); 57 DISALLOW_COPY_AND_ASSIGN(InvalidationServiceFactory);
64 }; 58 };
65 59
66 } // namespace invalidation 60 } // namespace invalidation
67 61
68 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_FACTORY_H_ 62 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698