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

Side by Side Diff: components/sync/driver/glue/sync_backend_host_core.h

Issue 2559123002: [Sync] SyncEngine refactor part 2: SyncServiceBase. (Closed)
Patch Set: Address comments. Created 4 years 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
« no previous file with comments | « components/sync/driver/DEPS ('k') | components/sync/driver/glue/sync_backend_host_core.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_GLUE_SYNC_BACKEND_HOST_CORE_H_ 5 #ifndef COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_
6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_ 6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 13 matching lines...) Expand all
24 #include "components/sync/driver/glue/sync_backend_host_impl.h" 24 #include "components/sync/driver/glue/sync_backend_host_impl.h"
25 #include "components/sync/engine/cycle/type_debug_info_observer.h" 25 #include "components/sync/engine/cycle/type_debug_info_observer.h"
26 #include "components/sync/engine/shutdown_reason.h" 26 #include "components/sync/engine/shutdown_reason.h"
27 #include "components/sync/engine/sync_encryption_handler.h" 27 #include "components/sync/engine/sync_encryption_handler.h"
28 #include "url/gurl.h" 28 #include "url/gurl.h"
29 29
30 namespace syncer { 30 namespace syncer {
31 31
32 class SyncBackendHostImpl; 32 class SyncBackendHostImpl;
33 33
34 // Utility struct for holding initialization options.
35 struct DoInitializeOptions {
36 DoInitializeOptions(
37 scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner,
38 SyncBackendRegistrar* registrar,
39 const std::vector<scoped_refptr<ModelSafeWorker>>& workers,
40 const scoped_refptr<ExtensionsActivity>& extensions_activity,
41 const WeakHandle<JsEventHandler>& event_handler,
42 const GURL& service_url,
43 const std::string& sync_user_agent,
44 std::unique_ptr<HttpPostProviderFactory> http_bridge_factory,
45 const SyncCredentials& credentials,
46 const std::string& invalidator_client_id,
47 std::unique_ptr<SyncManagerFactory> sync_manager_factory,
48 bool delete_sync_data_folder,
49 bool enable_local_sync_backend,
50 const base::FilePath& local_sync_backend_folder,
51 const std::string& restored_key_for_bootstrapping,
52 const std::string& restored_keystore_key_for_bootstrapping,
53 std::unique_ptr<EngineComponentsFactory> engine_components_factory,
54 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler,
55 const base::Closure& report_unrecoverable_error_function,
56 std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state,
57 const std::map<ModelType, int64_t>& invalidation_versions);
58 ~DoInitializeOptions();
59
60 scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner;
61 SyncBackendRegistrar* registrar;
62 std::vector<scoped_refptr<ModelSafeWorker>> workers;
63 scoped_refptr<ExtensionsActivity> extensions_activity;
64 WeakHandle<JsEventHandler> event_handler;
65 GURL service_url;
66 std::string sync_user_agent;
67 // Overridden by tests.
68 std::unique_ptr<HttpPostProviderFactory> http_bridge_factory;
69 SyncCredentials credentials;
70 const std::string invalidator_client_id;
71 std::unique_ptr<SyncManagerFactory> sync_manager_factory;
72 std::string lsid;
73 bool delete_sync_data_folder;
74 bool enable_local_sync_backend;
75 const base::FilePath local_sync_backend_folder;
76 std::string restored_key_for_bootstrapping;
77 std::string restored_keystore_key_for_bootstrapping;
78 std::unique_ptr<EngineComponentsFactory> engine_components_factory;
79 const WeakHandle<UnrecoverableErrorHandler> unrecoverable_error_handler;
80 base::Closure report_unrecoverable_error_function;
81 std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state;
82 const std::map<ModelType, int64_t> invalidation_versions;
83 };
84
85 class SyncBackendHostCore 34 class SyncBackendHostCore
86 : public base::RefCountedThreadSafe<SyncBackendHostCore>, 35 : public base::RefCountedThreadSafe<SyncBackendHostCore>,
87 public base::trace_event::MemoryDumpProvider, 36 public base::trace_event::MemoryDumpProvider,
88 public SyncEncryptionHandler::Observer, 37 public SyncEncryptionHandler::Observer,
89 public SyncManager::Observer, 38 public SyncManager::Observer,
90 public TypeDebugInfoObserver { 39 public TypeDebugInfoObserver {
91 public: 40 public:
92 SyncBackendHostCore(const std::string& name, 41 SyncBackendHostCore(const std::string& name,
93 const base::FilePath& sync_data_folder_path, 42 const base::FilePath& sync_data_folder_path,
94 const base::WeakPtr<SyncBackendHostImpl>& backend); 43 const base::WeakPtr<SyncBackendHostImpl>& backend);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 const ObjectIdInvalidationMap& invalidation_map); 92 const ObjectIdInvalidationMap& invalidation_map);
144 93
145 // Note: 94 // Note:
146 // 95 //
147 // The Do* methods are the various entry points from our SyncBackendHostImpl. 96 // The Do* methods are the various entry points from our SyncBackendHostImpl.
148 // They are all called on the sync thread to actually perform synchronous (and 97 // They are all called on the sync thread to actually perform synchronous (and
149 // potentially blocking) syncapi operations. 98 // potentially blocking) syncapi operations.
150 // 99 //
151 // Called to perform initialization of the syncapi on behalf of 100 // Called to perform initialization of the syncapi on behalf of
152 // SyncEngine::Initialize. 101 // SyncEngine::Initialize.
153 void DoInitialize(std::unique_ptr<DoInitializeOptions> options); 102 void DoInitialize(SyncEngine::InitParams params);
154 103
155 // Called to perform credential update on behalf of 104 // Called to perform credential update on behalf of
156 // SyncEngine::UpdateCredentials. 105 // SyncEngine::UpdateCredentials.
157 void DoUpdateCredentials(const SyncCredentials& credentials); 106 void DoUpdateCredentials(const SyncCredentials& credentials);
158 107
159 // Called to tell the syncapi to start syncing (generally after 108 // Called to tell the syncapi to start syncing (generally after
160 // initialization and authentication). 109 // initialization and authentication).
161 void DoStartSyncing(const ModelSafeRoutingInfo& routing_info, 110 void DoStartSyncing(const ModelSafeRoutingInfo& routing_info,
162 base::Time last_poll_time); 111 base::Time last_poll_time);
163 112
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 void EnableDirectoryTypeDebugInfoForwarding(); 171 void EnableDirectoryTypeDebugInfoForwarding();
223 172
224 // Disables forwarding of directory type debug counters. 173 // Disables forwarding of directory type debug counters.
225 void DisableDirectoryTypeDebugInfoForwarding(); 174 void DisableDirectoryTypeDebugInfoForwarding();
226 175
227 // Delete the sync data folder to cleanup backend data. Happens the first 176 // Delete the sync data folder to cleanup backend data. Happens the first
228 // time sync is enabled for a user (to prevent accidentally reusing old 177 // time sync is enabled for a user (to prevent accidentally reusing old
229 // sync databases), as well as shutdown when you're no longer syncing. 178 // sync databases), as well as shutdown when you're no longer syncing.
230 void DeleteSyncDataFolder(); 179 void DeleteSyncDataFolder();
231 180
232 // We expose this member because it's required in the construction of the
233 // HttpBridgeFactory.
234 CancelationSignal* GetRequestContextCancelationSignal() {
235 return &release_request_context_signal_;
236 }
237
238 // Tell the sync manager to persist its state by writing to disk. 181 // Tell the sync manager to persist its state by writing to disk.
239 // Called on the sync thread, both by a timer and, on Android, when the 182 // Called on the sync thread, both by a timer and, on Android, when the
240 // application is backgrounded. 183 // application is backgrounded.
241 void SaveChanges(); 184 void SaveChanges();
242 185
243 void DoClearServerData( 186 void DoClearServerData(
244 const SyncManager::ClearServerDataCallback& frontend_callback); 187 const SyncManager::ClearServerDataCallback& frontend_callback);
245 188
246 // Notify the syncer that the cookie jar has changed. 189 // Notify the syncer that the cookie jar has changed.
247 void DoOnCookieJarChanged(bool account_mismatch, bool empty_jar); 190 void DoOnCookieJarChanged(bool account_mismatch, bool empty_jar);
(...skipping 13 matching lines...) Expand all
261 204
262 // Name used for debugging. 205 // Name used for debugging.
263 const std::string name_; 206 const std::string name_;
264 207
265 // Path of the folder that stores the sync data files. 208 // Path of the folder that stores the sync data files.
266 const base::FilePath sync_data_folder_path_; 209 const base::FilePath sync_data_folder_path_;
267 210
268 // Our parent SyncBackendHostImpl. 211 // Our parent SyncBackendHostImpl.
269 WeakHandle<SyncBackendHostImpl> host_; 212 WeakHandle<SyncBackendHostImpl> host_;
270 213
271 // Our parent's registrar (not owned). Non-null only between 214 // Non-null only between calls to DoInitialize() and DoShutdown().
272 // calls to DoInitialize() and DoShutdown(). 215 std::unique_ptr<SyncBackendRegistrar> registrar_;
273 SyncBackendRegistrar* registrar_ = nullptr;
274 216
275 // The timer used to periodically call SaveChanges. 217 // The timer used to periodically call SaveChanges.
276 std::unique_ptr<base::RepeatingTimer> save_changes_timer_; 218 std::unique_ptr<base::RepeatingTimer> save_changes_timer_;
277 219
278 // Our encryptor, which uses Chrome's encryption functions. 220 // Our encryptor, which uses Chrome's encryption functions.
279 SystemEncryptor encryptor_; 221 SystemEncryptor encryptor_;
280 222
281 // The top-level syncapi entry point. Lives on the sync thread. 223 // The top-level syncapi entry point. Lives on the sync thread.
282 std::unique_ptr<SyncManager> sync_manager_; 224 std::unique_ptr<SyncManager> sync_manager_;
283 225
(...skipping 27 matching lines...) Expand all
311 base::ThreadChecker thread_checker_; 253 base::ThreadChecker thread_checker_;
312 254
313 base::WeakPtrFactory<SyncBackendHostCore> weak_ptr_factory_; 255 base::WeakPtrFactory<SyncBackendHostCore> weak_ptr_factory_;
314 256
315 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostCore); 257 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostCore);
316 }; 258 };
317 259
318 } // namespace syncer 260 } // namespace syncer
319 261
320 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_ 262 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_
OLDNEW
« no previous file with comments | « components/sync/driver/DEPS ('k') | components/sync/driver/glue/sync_backend_host_core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698