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