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 21 matching lines...) Expand all Loading... |
32 } // namespace favicon | 32 } // namespace favicon |
33 | 33 |
34 namespace history { | 34 namespace history { |
35 class HistoryService; | 35 class HistoryService; |
36 } // namespace history | 36 } // namespace history |
37 | 37 |
38 namespace invalidation { | 38 namespace invalidation { |
39 class InvalidationService; | 39 class InvalidationService; |
40 } // namespace invalidation | 40 } // namespace invalidation |
41 | 41 |
42 namespace syncer { | |
43 class SyncableService; | |
44 } // namespace syncer | |
45 | |
46 namespace sync_sessions { | 42 namespace sync_sessions { |
47 class SyncSessionsClient; | 43 class SyncSessionsClient; |
48 } // namespace sync_sessions | 44 } // namespace sync_sessions |
49 | 45 |
50 namespace sync_driver { | 46 namespace syncer { |
51 | 47 |
52 class SyncService; | 48 class SyncService; |
| 49 class SyncableService; |
53 | 50 |
54 // Interface for clients of the Sync API to plumb through necessary dependent | 51 // Interface for clients of the Sync API to plumb through necessary dependent |
55 // components. This interface is purely for abstracting dependencies, and | 52 // components. This interface is purely for abstracting dependencies, and |
56 // should not contain any non-trivial functional logic. | 53 // should not contain any non-trivial functional logic. |
57 // | 54 // |
58 // Note: on some platforms, getters might return nullptr. Callers are expected | 55 // Note: on some platforms, getters might return nullptr. Callers are expected |
59 // to handle these scenarios gracefully. | 56 // to handle these scenarios gracefully. |
60 class SyncClient { | 57 class SyncClient { |
61 public: | 58 public: |
62 SyncClient(); | 59 SyncClient(); |
63 virtual ~SyncClient(); | 60 virtual ~SyncClient(); |
64 | 61 |
65 // Initializes the sync client with the specified sync service. | 62 // Initializes the sync client with the specified sync service. |
66 virtual void Initialize() = 0; | 63 virtual void Initialize() = 0; |
67 | 64 |
68 // Returns the current SyncService instance. | 65 // Returns the current SyncService instance. |
69 virtual SyncService* GetSyncService() = 0; | 66 virtual SyncService* GetSyncService() = 0; |
70 | 67 |
71 // Returns the current profile's preference service. | 68 // Returns the current profile's preference service. |
72 virtual PrefService* GetPrefService() = 0; | 69 virtual PrefService* GetPrefService() = 0; |
73 | 70 |
74 // DataType specific service getters. | 71 // DataType specific service getters. |
75 virtual bookmarks::BookmarkModel* GetBookmarkModel() = 0; | 72 virtual bookmarks::BookmarkModel* GetBookmarkModel() = 0; |
76 virtual favicon::FaviconService* GetFaviconService() = 0; | 73 virtual favicon::FaviconService* GetFaviconService() = 0; |
77 virtual history::HistoryService* GetHistoryService() = 0; | 74 virtual history::HistoryService* GetHistoryService() = 0; |
78 | 75 |
79 // Returns a callback that will register the types specific to the current | 76 // Returns a callback that will register the types specific to the current |
80 // platform. | 77 // platform. |
81 virtual sync_driver::SyncApiComponentFactory::RegisterDataTypesMethod | 78 virtual SyncApiComponentFactory::RegisterDataTypesMethod |
82 GetRegisterPlatformTypesCallback() = 0; | 79 GetRegisterPlatformTypesCallback() = 0; |
83 | 80 |
84 // Returns a callback that will be invoked when password sync state has | 81 // Returns a callback that will be invoked when password sync state has |
85 // potentially been changed. | 82 // potentially been changed. |
86 virtual base::Closure GetPasswordStateChangedCallback() = 0; | 83 virtual base::Closure GetPasswordStateChangedCallback() = 0; |
87 | 84 |
88 virtual autofill::PersonalDataManager* GetPersonalDataManager() = 0; | 85 virtual autofill::PersonalDataManager* GetPersonalDataManager() = 0; |
89 virtual BookmarkUndoService* GetBookmarkUndoServiceIfExists() = 0; | 86 virtual BookmarkUndoService* GetBookmarkUndoServiceIfExists() = 0; |
90 virtual invalidation::InvalidationService* GetInvalidationService() = 0; | 87 virtual invalidation::InvalidationService* GetInvalidationService() = 0; |
91 virtual scoped_refptr<syncer::ExtensionsActivity> GetExtensionsActivity() = 0; | 88 virtual scoped_refptr<ExtensionsActivity> GetExtensionsActivity() = 0; |
92 virtual sync_sessions::SyncSessionsClient* GetSyncSessionsClient() = 0; | 89 virtual sync_sessions::SyncSessionsClient* GetSyncSessionsClient() = 0; |
93 | 90 |
94 // Returns a weak pointer to the syncable service specified by |type|. | 91 // Returns a weak pointer to the syncable service specified by |type|. |
95 // Weak pointer may be unset if service is already destroyed. | 92 // Weak pointer may be unset if service is already destroyed. |
96 // Note: Should only be dereferenced from the model type thread. | 93 // Note: Should only be dereferenced from the model type thread. |
97 virtual base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType( | 94 virtual base::WeakPtr<SyncableService> GetSyncableServiceForType( |
98 syncer::ModelType type) = 0; | 95 ModelType type) = 0; |
99 | 96 |
100 // Returns a weak pointer to the ModelTypeService specified by |type|. Weak | 97 // Returns a weak pointer to the ModelTypeService specified by |type|. Weak |
101 // pointer may be unset if service is already destroyed. | 98 // pointer may be unset if service is already destroyed. |
102 // Note: Should only be dereferenced from the model type thread. | 99 // Note: Should only be dereferenced from the model type thread. |
103 virtual base::WeakPtr<syncer_v2::ModelTypeService> GetModelTypeServiceForType( | 100 virtual base::WeakPtr<ModelTypeService> GetModelTypeServiceForType( |
104 syncer::ModelType type) = 0; | 101 ModelType type) = 0; |
105 | 102 |
106 // Creates and returns a new ModelSafeWorker for the group, or null if one | 103 // Creates and returns a new ModelSafeWorker for the group, or null if one |
107 // cannot be created. | 104 // cannot be created. |
108 // TODO(maxbogue): Move this inside SyncApiComponentFactory. | 105 // TODO(maxbogue): Move this inside SyncApiComponentFactory. |
109 virtual scoped_refptr<syncer::ModelSafeWorker> CreateModelWorkerForGroup( | 106 virtual scoped_refptr<ModelSafeWorker> CreateModelWorkerForGroup( |
110 syncer::ModelSafeGroup group, | 107 ModelSafeGroup group, |
111 syncer::WorkerLoopDestructionObserver* observer) = 0; | 108 WorkerLoopDestructionObserver* observer) = 0; |
112 | 109 |
113 // Returns the current SyncApiComponentFactory instance. | 110 // Returns the current SyncApiComponentFactory instance. |
114 virtual SyncApiComponentFactory* GetSyncApiComponentFactory() = 0; | 111 virtual SyncApiComponentFactory* GetSyncApiComponentFactory() = 0; |
115 | 112 |
116 private: | 113 private: |
117 DISALLOW_COPY_AND_ASSIGN(SyncClient); | 114 DISALLOW_COPY_AND_ASSIGN(SyncClient); |
118 }; | 115 }; |
119 | 116 |
120 } // namespace sync_driver | 117 } // namespace syncer |
121 | 118 |
122 #endif // COMPONENTS_SYNC_DRIVER_SYNC_CLIENT_H_ | 119 #endif // COMPONENTS_SYNC_DRIVER_SYNC_CLIENT_H_ |
OLD | NEW |