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

Unified Diff: chrome/browser/invalidation/profile_invalidation_provider_factory.h

Issue 327243003: Introduce ProfileInvalidationProvider wrapper for InvalidationService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix clang compilation. Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/invalidation/profile_invalidation_provider_factory.h
diff --git a/chrome/browser/invalidation/profile_invalidation_provider_factory.h b/chrome/browser/invalidation/profile_invalidation_provider_factory.h
new file mode 100644
index 0000000000000000000000000000000000000000..112e69c3d0833c15e8bf44f5d472169d747969bc
--- /dev/null
+++ b/chrome/browser/invalidation/profile_invalidation_provider_factory.h
@@ -0,0 +1,65 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_INVALIDATION_PROFILE_INVALIDATION_PROVIDER_FACTORY_H_
+#define CHROME_BROWSER_INVALIDATION_PROFILE_INVALIDATION_PROVIDER_FACTORY_H_
+
+#include "base/basictypes.h"
+#include "base/memory/singleton.h"
+#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
+
+namespace user_prefs {
+class PrefRegistrySyncable;
+}
+
+namespace syncer {
+class Invalidator;
+}
+
+class Profile;
+
+namespace invalidation {
+
+class ProfileInvalidationProvider;
+
+// A BrowserContextKeyedServiceFactory to construct InvalidationServices wrapped
+// in ProfileInvalidationProviders. The implementation of InvalidationService
+// may be completely different on different platforms; this class should help to
+// hide this complexity. It also exposes some factory methods that are useful
+// for setting up tests that rely on invalidations.
+class ProfileInvalidationProviderFactory
+ : public BrowserContextKeyedServiceFactory {
+ public:
+ // Returns the ProfileInvalidationProvider for the given |profile|, lazily
+ // creating one first if required. If |profile| does not support invalidation
+ // (Chrome OS login profile, Chrome OS guest), returns NULL instead.
+ static ProfileInvalidationProvider* GetForProfile(Profile* profile);
+
+ static ProfileInvalidationProviderFactory* GetInstance();
+
+ // Switches service creation to go through |testing_factory| for all browser
+ // contexts.
+ void RegisterTestingFactory(TestingFactoryFunction testing_factory);
+
+ private:
+ friend class ProfileInvalidationProviderFactoryTestBase;
+ friend struct DefaultSingletonTraits<ProfileInvalidationProviderFactory>;
+
+ ProfileInvalidationProviderFactory();
+ virtual ~ProfileInvalidationProviderFactory();
+
+ // BrowserContextKeyedServiceFactory:
+ virtual KeyedService* BuildServiceInstanceFor(
+ content::BrowserContext* context) const OVERRIDE;
+ virtual void RegisterProfilePrefs(
+ user_prefs::PrefRegistrySyncable* registry) OVERRIDE;
+
+ TestingFactoryFunction testing_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ProfileInvalidationProviderFactory);
+};
+
+} // namespace invalidation
+
+#endif // CHROME_BROWSER_INVALIDATION_PROFILE_INVALIDATION_PROVIDER_FACTORY_H_

Powered by Google App Engine
This is Rietveld 408576698