1 // Copyright 2015 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.
5 #ifndef IOS_PUBLIC_PROVIDER_CHROME_BROWSER_KEYED_SERVICE_PROVIDER_H_
6 #define IOS_PUBLIC_PROVIDER_CHROME_BROWSER_KEYED_SERVICE_PROVIDER_H_
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
11 enum class ServiceAccessType
;
13 class KeyedServiceBaseFactory
;
16 class ManagedBookmarkService
;
19 namespace invalidation
{
20 class ProfileInvalidationProvider
;
23 namespace sync_driver
{
29 class ChromeBrowserState
;
30 class KeyedServiceProvider
;
32 // Registers and returns the global KeyedService provider.
33 void SetKeyedServiceProvider(KeyedServiceProvider
* provider
);
34 KeyedServiceProvider
* GetKeyedServiceProvider();
36 // A class that provides access to KeyedService that do not have a pure iOS
37 // implementation yet.
38 class KeyedServiceProvider
{
40 KeyedServiceProvider();
41 virtual ~KeyedServiceProvider();
43 // Ensures that all KeyedService factories are instantiated. Must be called
44 // before any BrowserState instance is created so that dependencies are
46 void AssertKeyedFactoriesBuilt();
48 // Returns the bookmarks::ManagedBookmarkService factory for dependencies.
49 virtual KeyedServiceBaseFactory
* GetManagedBookmarkServiceFactory() = 0;
51 // Returns an instance of bookmarks::ManagedBookmarkService tied to
53 virtual bookmarks::ManagedBookmarkService
*
54 GetManagedBookmarkServiceForBrowserState(
55 ChromeBrowserState
* browser_state
) = 0;
57 // Returns the sync_driver::SyncService factory for dependencies.
58 virtual KeyedServiceBaseFactory
* GetSyncServiceFactory() = 0;
60 // Returns an instance of sync_driver::SyncService tied to |browser_state|.
61 virtual sync_driver::SyncService
* GetSyncServiceForBrowserState(
62 ChromeBrowserState
* browser_state
) = 0;
64 // Returns the invalidation::ProfileInvalidationProvider factory for
66 virtual KeyedServiceBaseFactory
* GetProfileInvalidationProviderFactory() = 0;
68 // Returns an instance of invalidation::ProfileInvalidationProvider tied to
70 virtual invalidation::ProfileInvalidationProvider
*
71 GetProfileInvalidationProviderForBrowserState(
72 ChromeBrowserState
* browser_state
) = 0;
75 DISALLOW_COPY_AND_ASSIGN(KeyedServiceProvider
);
80 #endif // IOS_PUBLIC_PROVIDER_CHROME_BROWSER_KEYED_SERVICE_PROVIDER_H_