| 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/keyed_service/content/browser_context_keyed_service_factory
.h" | 10 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 class InvalidationService; | 25 class InvalidationService; |
| 26 class P2PInvalidationService; | 26 class P2PInvalidationService; |
| 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 // 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. |
| 35 static InvalidationService* GetForProfile(Profile* profile); | 38 static InvalidationService* GetForProfile(Profile* profile); |
| 36 | 39 |
| 37 static InvalidationServiceFactory* GetInstance(); | 40 static InvalidationServiceFactory* GetInstance(); |
| 38 | 41 |
| 39 // Switches service creation to go through |testing_factory| for all browser | 42 // Switches service creation to go through |testing_factory| for all browser |
| 40 // contexts. | 43 // contexts. |
| 41 void RegisterTestingFactory(TestingFactoryFunction testing_factory); | 44 void RegisterTestingFactory(TestingFactoryFunction testing_factory); |
| 42 | 45 |
| 43 private: | 46 private: |
| 44 friend struct DefaultSingletonTraits<InvalidationServiceFactory>; | 47 friend struct DefaultSingletonTraits<InvalidationServiceFactory>; |
| 45 | 48 |
| 46 InvalidationServiceFactory(); | 49 InvalidationServiceFactory(); |
| 47 virtual ~InvalidationServiceFactory(); | 50 virtual ~InvalidationServiceFactory(); |
| 48 | 51 |
| 49 // BrowserContextKeyedServiceFactory: | 52 // BrowserContextKeyedServiceFactory: |
| 50 virtual KeyedService* BuildServiceInstanceFor( | 53 virtual KeyedService* BuildServiceInstanceFor( |
| 51 content::BrowserContext* context) const OVERRIDE; | 54 content::BrowserContext* context) const OVERRIDE; |
| 52 virtual void RegisterProfilePrefs( | 55 virtual void RegisterProfilePrefs( |
| 53 user_prefs::PrefRegistrySyncable* registry) OVERRIDE; | 56 user_prefs::PrefRegistrySyncable* registry) OVERRIDE; |
| 54 | 57 |
| 55 TestingFactoryFunction testing_factory_; | 58 TestingFactoryFunction testing_factory_; |
| 56 | 59 |
| 57 DISALLOW_COPY_AND_ASSIGN(InvalidationServiceFactory); | 60 DISALLOW_COPY_AND_ASSIGN(InvalidationServiceFactory); |
| 58 }; | 61 }; |
| 59 | 62 |
| 60 } // namespace invalidation | 63 } // namespace invalidation |
| 61 | 64 |
| 62 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_FACTORY_H_ | 65 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_SERVICE_FACTORY_H_ |
| OLD | NEW |