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

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

Issue 2538023002: [Sync] Pass a TaskRunner into SBHI/SBHC, not a thread or message loop. (Closed)
Patch Set: 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
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>
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/single_thread_task_runner.h"
17 #include "base/timer/timer.h" 18 #include "base/timer/timer.h"
18 #include "base/trace_event/memory_dump_provider.h" 19 #include "base/trace_event/memory_dump_provider.h"
19 #include "components/invalidation/public/invalidation.h" 20 #include "components/invalidation/public/invalidation.h"
20 #include "components/sync/base/cancelation_signal.h" 21 #include "components/sync/base/cancelation_signal.h"
21 #include "components/sync/base/system_encryptor.h" 22 #include "components/sync/base/system_encryptor.h"
22 #include "components/sync/driver/glue/sync_backend_host_impl.h" 23 #include "components/sync/driver/glue/sync_backend_host_impl.h"
23 #include "components/sync/engine/cycle/type_debug_info_observer.h" 24 #include "components/sync/engine/cycle/type_debug_info_observer.h"
24 #include "components/sync/engine/shutdown_reason.h" 25 #include "components/sync/engine/shutdown_reason.h"
25 #include "components/sync/engine/sync_encryption_handler.h" 26 #include "components/sync/engine/sync_encryption_handler.h"
26 #include "url/gurl.h" 27 #include "url/gurl.h"
27 28
28 namespace syncer { 29 namespace syncer {
29 30
30 class SyncBackendHostImpl; 31 class SyncBackendHostImpl;
31 32
32 // Utility struct for holding initialization options. 33 // Utility struct for holding initialization options.
33 struct DoInitializeOptions { 34 struct DoInitializeOptions {
34 DoInitializeOptions( 35 DoInitializeOptions(
35 base::MessageLoop* sync_loop, 36 scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner,
36 SyncBackendRegistrar* registrar, 37 SyncBackendRegistrar* registrar,
37 const std::vector<scoped_refptr<ModelSafeWorker>>& workers, 38 const std::vector<scoped_refptr<ModelSafeWorker>>& workers,
38 const scoped_refptr<ExtensionsActivity>& extensions_activity, 39 const scoped_refptr<ExtensionsActivity>& extensions_activity,
39 const WeakHandle<JsEventHandler>& event_handler, 40 const WeakHandle<JsEventHandler>& event_handler,
40 const GURL& service_url, 41 const GURL& service_url,
41 const std::string& sync_user_agent, 42 const std::string& sync_user_agent,
42 std::unique_ptr<HttpPostProviderFactory> http_bridge_factory, 43 std::unique_ptr<HttpPostProviderFactory> http_bridge_factory,
43 const SyncCredentials& credentials, 44 const SyncCredentials& credentials,
44 const std::string& invalidator_client_id, 45 const std::string& invalidator_client_id,
45 std::unique_ptr<SyncManagerFactory> sync_manager_factory, 46 std::unique_ptr<SyncManagerFactory> sync_manager_factory,
46 bool delete_sync_data_folder, 47 bool delete_sync_data_folder,
47 bool enable_local_sync_backend, 48 bool enable_local_sync_backend,
48 const base::FilePath& local_sync_backend_folder, 49 const base::FilePath& local_sync_backend_folder,
49 const std::string& restored_key_for_bootstrapping, 50 const std::string& restored_key_for_bootstrapping,
50 const std::string& restored_keystore_key_for_bootstrapping, 51 const std::string& restored_keystore_key_for_bootstrapping,
51 std::unique_ptr<EngineComponentsFactory> engine_components_factory, 52 std::unique_ptr<EngineComponentsFactory> engine_components_factory,
52 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, 53 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler,
53 const base::Closure& report_unrecoverable_error_function, 54 const base::Closure& report_unrecoverable_error_function,
54 std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state, 55 std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state,
55 const std::map<ModelType, int64_t>& invalidation_versions); 56 const std::map<ModelType, int64_t>& invalidation_versions);
56 ~DoInitializeOptions(); 57 ~DoInitializeOptions();
57 58
58 base::MessageLoop* sync_loop; 59 scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner;
59 SyncBackendRegistrar* registrar; 60 SyncBackendRegistrar* registrar;
60 std::vector<scoped_refptr<ModelSafeWorker>> workers; 61 std::vector<scoped_refptr<ModelSafeWorker>> workers;
61 scoped_refptr<ExtensionsActivity> extensions_activity; 62 scoped_refptr<ExtensionsActivity> extensions_activity;
62 WeakHandle<JsEventHandler> event_handler; 63 WeakHandle<JsEventHandler> event_handler;
63 GURL service_url; 64 GURL service_url;
64 std::string sync_user_agent; 65 std::string sync_user_agent;
65 // Overridden by tests. 66 // Overridden by tests.
66 std::unique_ptr<HttpPostProviderFactory> http_bridge_factory; 67 std::unique_ptr<HttpPostProviderFactory> http_bridge_factory;
67 SyncCredentials credentials; 68 SyncCredentials credentials;
68 const std::string invalidator_client_id; 69 const std::string invalidator_client_id;
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 271
271 // Name used for debugging. 272 // Name used for debugging.
272 const std::string name_; 273 const std::string name_;
273 274
274 // Path of the folder that stores the sync data files. 275 // Path of the folder that stores the sync data files.
275 const base::FilePath sync_data_folder_path_; 276 const base::FilePath sync_data_folder_path_;
276 277
277 // Our parent SyncBackendHost. 278 // Our parent SyncBackendHost.
278 WeakHandle<SyncBackendHostImpl> host_; 279 WeakHandle<SyncBackendHostImpl> host_;
279 280
280 // The loop where all the sync backend operations happen. 281 // The task runner where all the sync engine operations happen.
281 // Non-null only between calls to DoInitialize() and ~Core(). 282 scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner_;
282 base::MessageLoop* sync_loop_;
283 283
284 // Our parent's registrar (not owned). Non-null only between 284 // Our parent's registrar (not owned). Non-null only between
285 // calls to DoInitialize() and DoShutdown(). 285 // calls to DoInitialize() and DoShutdown().
286 SyncBackendRegistrar* registrar_; 286 SyncBackendRegistrar* registrar_;
287 287
288 // The timer used to periodically call SaveChanges. 288 // The timer used to periodically call SaveChanges.
289 std::unique_ptr<base::RepeatingTimer> save_changes_timer_; 289 std::unique_ptr<base::RepeatingTimer> save_changes_timer_;
290 290
291 // Our encryptor, which uses Chrome's encryption functions. 291 // Our encryptor, which uses Chrome's encryption functions.
292 SystemEncryptor encryptor_; 292 SystemEncryptor encryptor_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 std::map<ModelType, int64_t> last_invalidation_versions_; 325 std::map<ModelType, int64_t> last_invalidation_versions_;
326 326
327 base::WeakPtrFactory<SyncBackendHostCore> weak_ptr_factory_; 327 base::WeakPtrFactory<SyncBackendHostCore> weak_ptr_factory_;
328 328
329 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostCore); 329 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostCore);
330 }; 330 };
331 331
332 } // namespace syncer 332 } // namespace syncer
333 333
334 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_ 334 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698