OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 COMPONENTS_SYNC_DRIVER_SYNC_CLIENT_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_SYNC_CLIENT_H_ |
6 #define COMPONENTS_SYNC_DRIVER_SYNC_CLIENT_H_ | 6 #define COMPONENTS_SYNC_DRIVER_SYNC_CLIENT_H_ |
7 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 class SyncableService; | 52 class SyncableService; |
53 | 53 |
54 // Interface for clients of the Sync API to plumb through necessary dependent | 54 // Interface for clients of the Sync API to plumb through necessary dependent |
55 // components. This interface is purely for abstracting dependencies, and | 55 // components. This interface is purely for abstracting dependencies, and |
56 // should not contain any non-trivial functional logic. | 56 // should not contain any non-trivial functional logic. |
57 // | 57 // |
58 // Note: on some platforms, getters might return nullptr. Callers are expected | 58 // Note: on some platforms, getters might return nullptr. Callers are expected |
59 // to handle these scenarios gracefully. | 59 // to handle these scenarios gracefully. |
60 class SyncClient { | 60 class SyncClient { |
61 public: | 61 public: |
62 using ServiceProvider = base::Callback<base::WeakPtr<SyncableService>()>; | |
63 | |
64 SyncClient(); | 62 SyncClient(); |
65 virtual ~SyncClient(); | 63 virtual ~SyncClient(); |
66 | 64 |
67 // Initializes the sync client with the specified sync service. | 65 // Initializes the sync client with the specified sync service. |
68 virtual void Initialize() = 0; | 66 virtual void Initialize() = 0; |
69 | 67 |
70 // Returns SequencedWorkerPool to be used by ProfileSyncService for blocking | 68 // Returns SequencedWorkerPool to be used by ProfileSyncService for blocking |
71 // operations. | 69 // operations. |
72 virtual base::SequencedWorkerPool* GetBlockingPool() = 0; | 70 virtual base::SequencedWorkerPool* GetBlockingPool() = 0; |
73 | 71 |
(...skipping 21 matching lines...) Expand all Loading... |
95 // Returns a callback that will be invoked when password sync state has | 93 // Returns a callback that will be invoked when password sync state has |
96 // potentially been changed. | 94 // potentially been changed. |
97 virtual base::Closure GetPasswordStateChangedCallback() = 0; | 95 virtual base::Closure GetPasswordStateChangedCallback() = 0; |
98 | 96 |
99 virtual autofill::PersonalDataManager* GetPersonalDataManager() = 0; | 97 virtual autofill::PersonalDataManager* GetPersonalDataManager() = 0; |
100 virtual BookmarkUndoService* GetBookmarkUndoServiceIfExists() = 0; | 98 virtual BookmarkUndoService* GetBookmarkUndoServiceIfExists() = 0; |
101 virtual invalidation::InvalidationService* GetInvalidationService() = 0; | 99 virtual invalidation::InvalidationService* GetInvalidationService() = 0; |
102 virtual scoped_refptr<ExtensionsActivity> GetExtensionsActivity() = 0; | 100 virtual scoped_refptr<ExtensionsActivity> GetExtensionsActivity() = 0; |
103 virtual sync_sessions::SyncSessionsClient* GetSyncSessionsClient() = 0; | 101 virtual sync_sessions::SyncSessionsClient* GetSyncSessionsClient() = 0; |
104 | 102 |
105 // Returns a callback to retrieve a syncable service specified by |type|. | 103 // Returns a weak pointer to the syncable service specified by |type|. |
106 // Both the provider and the resulting weak pointer will only be accessed on | 104 // Weak pointer may be unset if service is already destroyed. |
107 // the model thread. | 105 // Note: Should only be dereferenced from the model type thread. |
108 virtual ServiceProvider GetSyncableServiceForType(ModelType type) = 0; | 106 virtual base::WeakPtr<SyncableService> GetSyncableServiceForType( |
| 107 ModelType type) = 0; |
109 | 108 |
110 // Returns a weak pointer to the ModelTypeSyncBridge specified by |type|. Weak | 109 // Returns a weak pointer to the ModelTypeSyncBridge specified by |type|. Weak |
111 // pointer may be unset if service is already destroyed. | 110 // pointer may be unset if service is already destroyed. |
112 // Note: Should only be dereferenced from the model type thread. | 111 // Note: Should only be dereferenced from the model type thread. |
113 virtual base::WeakPtr<ModelTypeSyncBridge> GetSyncBridgeForModelType( | 112 virtual base::WeakPtr<ModelTypeSyncBridge> GetSyncBridgeForModelType( |
114 ModelType type) = 0; | 113 ModelType type) = 0; |
115 | 114 |
116 // Creates and returns a new ModelSafeWorker for the group, or null if one | 115 // Creates and returns a new ModelSafeWorker for the group, or null if one |
117 // cannot be created. | 116 // cannot be created. |
118 // TODO(maxbogue): Move this inside SyncApiComponentFactory. | 117 // TODO(maxbogue): Move this inside SyncApiComponentFactory. |
119 virtual scoped_refptr<ModelSafeWorker> CreateModelWorkerForGroup( | 118 virtual scoped_refptr<ModelSafeWorker> CreateModelWorkerForGroup( |
120 ModelSafeGroup group) = 0; | 119 ModelSafeGroup group) = 0; |
121 | 120 |
122 // Returns the current SyncApiComponentFactory instance. | 121 // Returns the current SyncApiComponentFactory instance. |
123 virtual SyncApiComponentFactory* GetSyncApiComponentFactory() = 0; | 122 virtual SyncApiComponentFactory* GetSyncApiComponentFactory() = 0; |
124 | 123 |
125 private: | 124 private: |
126 DISALLOW_COPY_AND_ASSIGN(SyncClient); | 125 DISALLOW_COPY_AND_ASSIGN(SyncClient); |
127 }; | 126 }; |
128 | 127 |
129 } // namespace syncer | 128 } // namespace syncer |
130 | 129 |
131 #endif // COMPONENTS_SYNC_DRIVER_SYNC_CLIENT_H_ | 130 #endif // COMPONENTS_SYNC_DRIVER_SYNC_CLIENT_H_ |
OLD | NEW |