| OLD | NEW |
| 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 { |
| 13 class PrefRegistrySyncable; |
| 14 } |
| 15 |
| 12 namespace syncer { | 16 namespace syncer { |
| 13 class Invalidator; | 17 class Invalidator; |
| 14 } | 18 } |
| 15 | 19 |
| 16 class InvalidationFrontend; | |
| 17 class Profile; | 20 class Profile; |
| 18 | 21 |
| 19 namespace invalidation { | 22 namespace invalidation { |
| 20 | 23 |
| 24 class InvalidationService; |
| 25 class P2PInvalidationService; |
| 26 class FakeInvalidationService; |
| 27 |
| 21 // A BrowserContextKeyedServiceFactory to construct InvalidationServices. The | 28 // A BrowserContextKeyedServiceFactory to construct InvalidationServices. The |
| 22 // implementation of the InvalidationService may be completely different on | 29 // implementation of the InvalidationService may be completely different on |
| 23 // 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 |
| 24 // 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 |
| 25 // on invalidations. | 32 // on invalidations. |
| 26 class InvalidationServiceFactory : public BrowserContextKeyedServiceFactory { | 33 class InvalidationServiceFactory : public BrowserContextKeyedServiceFactory { |
| 27 public: | 34 public: |
| 28 // TODO(rlarocque): Re-enable this once InvalidationFrontend can extend | 35 static InvalidationService* GetForProfile(Profile* profile); |
| 29 // BrowserContextKeyedService. | |
| 30 // static InvalidationFrontend* GetForProfile(Profile* profile); | |
| 31 | 36 |
| 32 static InvalidationServiceFactory* GetInstance(); | 37 static InvalidationServiceFactory* GetInstance(); |
| 33 | 38 |
| 34 static BrowserContextKeyedService* BuildP2PInvalidationServiceFor( | 39 // A helper function to set this factory to return a FakeInvalidationService. |
| 35 Profile* profile); | 40 void SetFakeInvalidationServiceForTest(content::BrowserContext* context); |
| 36 static BrowserContextKeyedService* BuildTestServiceInstanceFor( | 41 |
| 37 Profile* profile); | 42 // These helper functions to set the factory to build a test-only type of |
| 43 // invalidator and return the instance immeidately. |
| 44 P2PInvalidationService* BuildAndUseP2PInvalidationServiceForTest( |
| 45 content::BrowserContext* context); |
| 46 FakeInvalidationService* BuildAndUseFakeInvalidationServiceForTest( |
| 47 content::BrowserContext* context); |
| 38 | 48 |
| 39 private: | 49 private: |
| 40 friend struct DefaultSingletonTraits<InvalidationServiceFactory>; | 50 friend struct DefaultSingletonTraits<InvalidationServiceFactory>; |
| 41 | 51 |
| 42 InvalidationServiceFactory(); | 52 InvalidationServiceFactory(); |
| 43 virtual ~InvalidationServiceFactory(); | 53 virtual ~InvalidationServiceFactory(); |
| 44 | 54 |
| 45 // BrowserContextKeyedServiceFactory: | 55 // BrowserContextKeyedServiceFactory: |
| 46 virtual BrowserContextKeyedService* BuildServiceInstanceFor( | 56 virtual BrowserContextKeyedService* BuildServiceInstanceFor( |
| 47 content::BrowserContext* profile) const OVERRIDE; | 57 content::BrowserContext* context) const OVERRIDE; |
| 48 // TODO(rlarocque): Use this class, not InvalidatorStorage, to register | 58 virtual void RegisterUserPrefs( |
| 49 // for user prefs. | 59 user_prefs::PrefRegistrySyncable* registry) OVERRIDE; |
| 50 // virtual void RegisterUserPrefs(PrefRegistrySyncable* registry) OVERRIDE; | |
| 51 | 60 |
| 52 DISALLOW_COPY_AND_ASSIGN(InvalidationServiceFactory); | 61 DISALLOW_COPY_AND_ASSIGN(InvalidationServiceFactory); |
| 53 }; | 62 }; |
| 54 | 63 |
| 55 } // namespace invalidation | 64 } // namespace invalidation |
| 56 | 65 |
| 57 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_FACTORY_H_ | 66 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_FACTORY_H_ |
| OLD | NEW |