OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_INVALIDATION_PROFILE_INVALIDATION_PROVIDER_FACTORY_H_ |
| 6 #define CHROME_BROWSER_INVALIDATION_PROFILE_INVALIDATION_PROVIDER_FACTORY_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/memory/singleton.h" |
| 10 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
| 11 |
| 12 namespace user_prefs { |
| 13 class PrefRegistrySyncable; |
| 14 } |
| 15 |
| 16 namespace syncer { |
| 17 class Invalidator; |
| 18 } |
| 19 |
| 20 class Profile; |
| 21 |
| 22 namespace invalidation { |
| 23 |
| 24 class ProfileInvalidationProvider; |
| 25 |
| 26 // A BrowserContextKeyedServiceFactory to construct InvalidationServices wrapped |
| 27 // in ProfileInvalidationProviders. The implementation of InvalidationService |
| 28 // may be completely different on different platforms; this class should help to |
| 29 // hide this complexity. It also exposes some factory methods that are useful |
| 30 // for setting up tests that rely on invalidations. |
| 31 class ProfileInvalidationProviderFactory |
| 32 : public BrowserContextKeyedServiceFactory { |
| 33 public: |
| 34 // Returns the ProfileInvalidationProvider for the given |profile|, lazily |
| 35 // creating one first if required. If |profile| does not support invalidation |
| 36 // (Chrome OS login profile, Chrome OS guest), returns NULL instead. |
| 37 static ProfileInvalidationProvider* GetForProfile(Profile* profile); |
| 38 |
| 39 static ProfileInvalidationProviderFactory* GetInstance(); |
| 40 |
| 41 // Switches service creation to go through |testing_factory| for all browser |
| 42 // contexts. |
| 43 void RegisterTestingFactory(TestingFactoryFunction testing_factory); |
| 44 |
| 45 private: |
| 46 friend class ProfileInvalidationProviderFactoryTestBase; |
| 47 friend struct DefaultSingletonTraits<ProfileInvalidationProviderFactory>; |
| 48 |
| 49 ProfileInvalidationProviderFactory(); |
| 50 virtual ~ProfileInvalidationProviderFactory(); |
| 51 |
| 52 // BrowserContextKeyedServiceFactory: |
| 53 virtual KeyedService* BuildServiceInstanceFor( |
| 54 content::BrowserContext* context) const OVERRIDE; |
| 55 virtual void RegisterProfilePrefs( |
| 56 user_prefs::PrefRegistrySyncable* registry) OVERRIDE; |
| 57 |
| 58 TestingFactoryFunction testing_factory_; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(ProfileInvalidationProviderFactory); |
| 61 }; |
| 62 |
| 63 } // namespace invalidation |
| 64 |
| 65 #endif // CHROME_BROWSER_INVALIDATION_PROFILE_INVALIDATION_PROVIDER_FACTORY_H_ |
OLD | NEW |