Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: components/sync/driver/sync_client.h

Issue 2769113002: [Sync] Stop accessing BrowserContextKeyedServiceFactory on non-UI thread. (Closed)
Patch Set: Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
62 SyncClient(); 64 SyncClient();
63 virtual ~SyncClient(); 65 virtual ~SyncClient();
64 66
65 // Initializes the sync client with the specified sync service. 67 // Initializes the sync client with the specified sync service.
66 virtual void Initialize() = 0; 68 virtual void Initialize() = 0;
67 69
68 // Returns SequencedWorkerPool to be used by ProfileSyncService for blocking 70 // Returns SequencedWorkerPool to be used by ProfileSyncService for blocking
69 // operations. 71 // operations.
70 virtual base::SequencedWorkerPool* GetBlockingPool() = 0; 72 virtual base::SequencedWorkerPool* GetBlockingPool() = 0;
71 73
(...skipping 21 matching lines...) Expand all
93 // Returns a callback that will be invoked when password sync state has 95 // Returns a callback that will be invoked when password sync state has
94 // potentially been changed. 96 // potentially been changed.
95 virtual base::Closure GetPasswordStateChangedCallback() = 0; 97 virtual base::Closure GetPasswordStateChangedCallback() = 0;
96 98
97 virtual autofill::PersonalDataManager* GetPersonalDataManager() = 0; 99 virtual autofill::PersonalDataManager* GetPersonalDataManager() = 0;
98 virtual BookmarkUndoService* GetBookmarkUndoServiceIfExists() = 0; 100 virtual BookmarkUndoService* GetBookmarkUndoServiceIfExists() = 0;
99 virtual invalidation::InvalidationService* GetInvalidationService() = 0; 101 virtual invalidation::InvalidationService* GetInvalidationService() = 0;
100 virtual scoped_refptr<ExtensionsActivity> GetExtensionsActivity() = 0; 102 virtual scoped_refptr<ExtensionsActivity> GetExtensionsActivity() = 0;
101 virtual sync_sessions::SyncSessionsClient* GetSyncSessionsClient() = 0; 103 virtual sync_sessions::SyncSessionsClient* GetSyncSessionsClient() = 0;
102 104
103 // Returns a weak pointer to the syncable service specified by |type|. 105 // Returns a callback to retrieve a syncable service specified by |type|.
104 // Weak pointer may be unset if service is already destroyed. 106 // Both the provider and the resulting weak pointer should only be accessed
pavely 2017/03/27 19:38:25 nit: "should only be accessed" => "will only be ac
skym 2017/03/27 21:45:26 Done.
105 // Note: Should only be dereferenced from the model type thread. 107 // on the model thread.
106 virtual base::WeakPtr<SyncableService> GetSyncableServiceForType( 108 virtual ServiceProvider GetSyncableServiceForType(ModelType type) = 0;
107 ModelType type) = 0;
108 109
109 // Returns a weak pointer to the ModelTypeSyncBridge specified by |type|. Weak 110 // Returns a weak pointer to the ModelTypeSyncBridge specified by |type|. Weak
110 // pointer may be unset if service is already destroyed. 111 // pointer may be unset if service is already destroyed.
111 // Note: Should only be dereferenced from the model type thread. 112 // Note: Should only be dereferenced from the model type thread.
112 virtual base::WeakPtr<ModelTypeSyncBridge> GetSyncBridgeForModelType( 113 virtual base::WeakPtr<ModelTypeSyncBridge> GetSyncBridgeForModelType(
113 ModelType type) = 0; 114 ModelType type) = 0;
114 115
115 // Creates and returns a new ModelSafeWorker for the group, or null if one 116 // Creates and returns a new ModelSafeWorker for the group, or null if one
116 // cannot be created. 117 // cannot be created.
117 // TODO(maxbogue): Move this inside SyncApiComponentFactory. 118 // TODO(maxbogue): Move this inside SyncApiComponentFactory.
118 virtual scoped_refptr<ModelSafeWorker> CreateModelWorkerForGroup( 119 virtual scoped_refptr<ModelSafeWorker> CreateModelWorkerForGroup(
119 ModelSafeGroup group) = 0; 120 ModelSafeGroup group) = 0;
120 121
121 // Returns the current SyncApiComponentFactory instance. 122 // Returns the current SyncApiComponentFactory instance.
122 virtual SyncApiComponentFactory* GetSyncApiComponentFactory() = 0; 123 virtual SyncApiComponentFactory* GetSyncApiComponentFactory() = 0;
123 124
124 private: 125 private:
125 DISALLOW_COPY_AND_ASSIGN(SyncClient); 126 DISALLOW_COPY_AND_ASSIGN(SyncClient);
126 }; 127 };
127 128
128 } // namespace syncer 129 } // namespace syncer
129 130
130 #endif // COMPONENTS_SYNC_DRIVER_SYNC_CLIENT_H_ 131 #endif // COMPONENTS_SYNC_DRIVER_SYNC_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698