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/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "components/sync_driver/profile_sync_components_factory.h" | |
12 #include "sync/internal_api/public/base/model_type.h" | 11 #include "sync/internal_api/public/base/model_type.h" |
13 | 12 |
| 13 class PrefService; |
| 14 |
14 namespace autofill { | 15 namespace autofill { |
15 class AutofillWebDataService; | 16 class AutofillWebDataService; |
16 class AutocompleteSyncableService; | 17 class AutocompleteSyncableService; |
17 class PersonalDataManager; | 18 class PersonalDataManager; |
18 } // namespace autofill | 19 } // namespace autofill |
19 | 20 |
20 namespace bookmarks { | 21 namespace bookmarks { |
21 class BookmarkModel; | 22 class BookmarkModel; |
22 } // namespace bookmarks | 23 } // namespace bookmarks |
23 | 24 |
24 namespace history { | 25 namespace history { |
25 class HistoryService; | 26 class HistoryService; |
26 } // namespace history | 27 } // namespace history |
27 | 28 |
28 namespace password_manager { | 29 namespace password_manager { |
29 class PasswordStore; | 30 class PasswordStore; |
30 } // namespace password_manager | 31 } // namespace password_manager |
31 | 32 |
32 class PrefService; | 33 namespace syncer { |
| 34 class SyncableService; |
| 35 } // namespace syncer |
33 | 36 |
34 namespace sync_driver { | 37 namespace sync_driver { |
35 | 38 |
| 39 class SyncApiComponentFactory; |
| 40 class SyncService; |
| 41 |
36 // Interface for clients of the Sync API to plumb through necessary dependent | 42 // Interface for clients of the Sync API to plumb through necessary dependent |
37 // components. This interface is purely for abstracting dependencies, and | 43 // components. This interface is purely for abstracting dependencies, and |
38 // should not contain any non-trivial functional logic. | 44 // should not contain any non-trivial functional logic. |
39 // | 45 // |
40 // Note: on some platforms, getters might return nullptr. Callers are expected | 46 // Note: on some platforms, getters might return nullptr. Callers are expected |
41 // to handle these scenarios gracefully. | 47 // to handle these scenarios gracefully. |
42 // TODO(zea): crbug.com/512768 Remove the ProfileSyncComponentsFactory | 48 class SyncClient { |
43 // dependency once everything uses SyncClient instead, then have the SyncClient | |
44 // include a GetSyncApiComponentsFactory getter. | |
45 class SyncClient : public ProfileSyncComponentsFactory { | |
46 public: | 49 public: |
47 SyncClient(); | 50 SyncClient(); |
48 | 51 |
| 52 // Returns the current SyncService instance. |
| 53 virtual SyncService* GetSyncService() = 0; |
| 54 |
49 // Returns the current profile's preference service. | 55 // Returns the current profile's preference service. |
50 virtual PrefService* GetPrefService() = 0; | 56 virtual PrefService* GetPrefService() = 0; |
51 | 57 |
52 // DataType specific service getters. | 58 // DataType specific service getters. |
53 virtual bookmarks::BookmarkModel* GetBookmarkModel() = 0; | 59 virtual bookmarks::BookmarkModel* GetBookmarkModel() = 0; |
54 virtual history::HistoryService* GetHistoryService() = 0; | 60 virtual history::HistoryService* GetHistoryService() = 0; |
55 virtual scoped_refptr<password_manager::PasswordStore> GetPasswordStore() = 0; | 61 virtual scoped_refptr<password_manager::PasswordStore> GetPasswordStore() = 0; |
56 virtual autofill::PersonalDataManager* GetPersonalDataManager() = 0; | 62 virtual autofill::PersonalDataManager* GetPersonalDataManager() = 0; |
57 virtual scoped_refptr<autofill::AutofillWebDataService> | 63 virtual scoped_refptr<autofill::AutofillWebDataService> |
58 GetWebDataService() = 0; | 64 GetWebDataService() = 0; |
59 | 65 |
| 66 // Returns a weak pointer to the syncable service specified by |type|. |
| 67 // Weak pointer may be unset if service is already destroyed. |
| 68 // Note: Should only be called from the model type thread. |
| 69 virtual base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType( |
| 70 syncer::ModelType type) = 0; |
| 71 |
| 72 // Returns the current SyncApiComponentFactory instance. |
| 73 virtual SyncApiComponentFactory* GetSyncApiComponentFactory() = 0; |
| 74 |
60 protected: | 75 protected: |
61 ~SyncClient() override; | 76 virtual ~SyncClient(); |
62 | 77 |
63 private: | 78 private: |
64 DISALLOW_COPY_AND_ASSIGN(SyncClient); | 79 DISALLOW_COPY_AND_ASSIGN(SyncClient); |
65 }; | 80 }; |
66 | 81 |
67 } // namespace sync_driver | 82 } // namespace sync_driver |
68 | 83 |
69 #endif // COMPONENTS_SYNC_DRIVER_SYNC_CLIENT_H_ | 84 #endif // COMPONENTS_SYNC_DRIVER_SYNC_CLIENT_H_ |
OLD | NEW |