OLD | NEW |
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 #include "components/sync/driver/glue/sync_backend_host_core.h" | 5 #include "components/sync/driver/glue/sync_backend_host_core.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
14 #include "components/data_use_measurement/core/data_use_user_data.h" | 14 #include "components/data_use_measurement/core/data_use_user_data.h" |
15 #include "components/invalidation/public/invalidation_util.h" | 15 #include "components/invalidation/public/invalidation_util.h" |
16 #include "components/invalidation/public/object_id_invalidation_map.h" | 16 #include "components/invalidation/public/object_id_invalidation_map.h" |
17 #include "components/sync/base/invalidation_adapter.h" | 17 #include "components/sync/base/invalidation_adapter.h" |
18 #include "components/sync/core/internal_components_factory.h" | |
19 #include "components/sync/core/sync_manager.h" | |
20 #include "components/sync/core/sync_manager_factory.h" | |
21 #include "components/sync/device_info/local_device_info_provider_impl.h" | 18 #include "components/sync/device_info/local_device_info_provider_impl.h" |
22 #include "components/sync/driver/glue/sync_backend_registrar.h" | 19 #include "components/sync/driver/glue/sync_backend_registrar.h" |
23 #include "components/sync/engine/cycle/commit_counters.h" | 20 #include "components/sync/engine/cycle/commit_counters.h" |
24 #include "components/sync/engine/cycle/status_counters.h" | 21 #include "components/sync/engine/cycle/status_counters.h" |
25 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" | 22 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" |
26 #include "components/sync/engine/cycle/update_counters.h" | 23 #include "components/sync/engine/cycle/update_counters.h" |
| 24 #include "components/sync/engine/engine_components_factory.h" |
27 #include "components/sync/engine/events/protocol_event.h" | 25 #include "components/sync/engine/events/protocol_event.h" |
28 #include "components/sync/engine/net/http_post_provider_factory.h" | 26 #include "components/sync/engine/net/http_post_provider_factory.h" |
| 27 #include "components/sync/engine/sync_manager.h" |
| 28 #include "components/sync/engine/sync_manager_factory.h" |
29 | 29 |
30 // Helper macros to log with the syncer thread name; useful when there | 30 // Helper macros to log with the syncer thread name; useful when there |
31 // are multiple syncers involved. | 31 // are multiple syncers involved. |
32 | 32 |
33 #define SLOG(severity) LOG(severity) << name_ << ": " | 33 #define SLOG(severity) LOG(severity) << name_ << ": " |
34 | 34 |
35 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": " | 35 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": " |
36 | 36 |
37 static const int kSaveChangesIntervalSeconds = 10; | 37 static const int kSaveChangesIntervalSeconds = 10; |
38 | 38 |
39 namespace syncer { | |
40 class InternalComponentsFactory; | |
41 } // namespace syncer | |
42 | |
43 namespace net { | 39 namespace net { |
44 class URLFetcher; | 40 class URLFetcher; |
45 } | 41 } |
46 | 42 |
47 namespace { | 43 namespace { |
48 | 44 |
49 void BindFetcherToDataTracker(net::URLFetcher* fetcher) { | 45 void BindFetcherToDataTracker(net::URLFetcher* fetcher) { |
50 data_use_measurement::DataUseUserData::AttachToFetcher( | 46 data_use_measurement::DataUseUserData::AttachToFetcher( |
51 fetcher, data_use_measurement::DataUseUserData::SYNC); | 47 fetcher, data_use_measurement::DataUseUserData::SYNC); |
52 } | 48 } |
53 | 49 |
54 } // namespace | 50 } // namespace |
55 | 51 |
56 namespace syncer { | 52 namespace syncer { |
57 | 53 |
| 54 class EngineComponentsFactory; |
| 55 |
58 DoInitializeOptions::DoInitializeOptions( | 56 DoInitializeOptions::DoInitializeOptions( |
59 base::MessageLoop* sync_loop, | 57 base::MessageLoop* sync_loop, |
60 SyncBackendRegistrar* registrar, | 58 SyncBackendRegistrar* registrar, |
61 const std::vector<scoped_refptr<ModelSafeWorker>>& workers, | 59 const std::vector<scoped_refptr<ModelSafeWorker>>& workers, |
62 const scoped_refptr<ExtensionsActivity>& extensions_activity, | 60 const scoped_refptr<ExtensionsActivity>& extensions_activity, |
63 const WeakHandle<JsEventHandler>& event_handler, | 61 const WeakHandle<JsEventHandler>& event_handler, |
64 const GURL& service_url, | 62 const GURL& service_url, |
65 const std::string& sync_user_agent, | 63 const std::string& sync_user_agent, |
66 std::unique_ptr<HttpPostProviderFactory> http_bridge_factory, | 64 std::unique_ptr<HttpPostProviderFactory> http_bridge_factory, |
67 const SyncCredentials& credentials, | 65 const SyncCredentials& credentials, |
68 const std::string& invalidator_client_id, | 66 const std::string& invalidator_client_id, |
69 std::unique_ptr<SyncManagerFactory> sync_manager_factory, | 67 std::unique_ptr<SyncManagerFactory> sync_manager_factory, |
70 bool delete_sync_data_folder, | 68 bool delete_sync_data_folder, |
71 const std::string& restored_key_for_bootstrapping, | 69 const std::string& restored_key_for_bootstrapping, |
72 const std::string& restored_keystore_key_for_bootstrapping, | 70 const std::string& restored_keystore_key_for_bootstrapping, |
73 std::unique_ptr<InternalComponentsFactory> internal_components_factory, | 71 std::unique_ptr<EngineComponentsFactory> engine_components_factory, |
74 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, | 72 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, |
75 const base::Closure& report_unrecoverable_error_function, | 73 const base::Closure& report_unrecoverable_error_function, |
76 std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state, | 74 std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state, |
77 const std::map<ModelType, int64_t>& invalidation_versions) | 75 const std::map<ModelType, int64_t>& invalidation_versions) |
78 : sync_loop(sync_loop), | 76 : sync_loop(sync_loop), |
79 registrar(registrar), | 77 registrar(registrar), |
80 workers(workers), | 78 workers(workers), |
81 extensions_activity(extensions_activity), | 79 extensions_activity(extensions_activity), |
82 event_handler(event_handler), | 80 event_handler(event_handler), |
83 service_url(service_url), | 81 service_url(service_url), |
84 sync_user_agent(sync_user_agent), | 82 sync_user_agent(sync_user_agent), |
85 http_bridge_factory(std::move(http_bridge_factory)), | 83 http_bridge_factory(std::move(http_bridge_factory)), |
86 credentials(credentials), | 84 credentials(credentials), |
87 invalidator_client_id(invalidator_client_id), | 85 invalidator_client_id(invalidator_client_id), |
88 sync_manager_factory(std::move(sync_manager_factory)), | 86 sync_manager_factory(std::move(sync_manager_factory)), |
89 delete_sync_data_folder(delete_sync_data_folder), | 87 delete_sync_data_folder(delete_sync_data_folder), |
90 restored_key_for_bootstrapping(restored_key_for_bootstrapping), | 88 restored_key_for_bootstrapping(restored_key_for_bootstrapping), |
91 restored_keystore_key_for_bootstrapping( | 89 restored_keystore_key_for_bootstrapping( |
92 restored_keystore_key_for_bootstrapping), | 90 restored_keystore_key_for_bootstrapping), |
93 internal_components_factory(std::move(internal_components_factory)), | 91 engine_components_factory(std::move(engine_components_factory)), |
94 unrecoverable_error_handler(unrecoverable_error_handler), | 92 unrecoverable_error_handler(unrecoverable_error_handler), |
95 report_unrecoverable_error_function(report_unrecoverable_error_function), | 93 report_unrecoverable_error_function(report_unrecoverable_error_function), |
96 saved_nigori_state(std::move(saved_nigori_state)), | 94 saved_nigori_state(std::move(saved_nigori_state)), |
97 invalidation_versions(invalidation_versions) {} | 95 invalidation_versions(invalidation_versions) {} |
98 | 96 |
99 DoInitializeOptions::~DoInitializeOptions() {} | 97 DoInitializeOptions::~DoInitializeOptions() {} |
100 | 98 |
101 DoConfigureSyncerTypes::DoConfigureSyncerTypes() {} | 99 DoConfigureSyncerTypes::DoConfigureSyncerTypes() {} |
102 | 100 |
103 DoConfigureSyncerTypes::DoConfigureSyncerTypes( | 101 DoConfigureSyncerTypes::DoConfigureSyncerTypes( |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 args.service_url = options->service_url; | 409 args.service_url = options->service_url; |
412 args.post_factory = std::move(options->http_bridge_factory); | 410 args.post_factory = std::move(options->http_bridge_factory); |
413 args.workers = options->workers; | 411 args.workers = options->workers; |
414 args.extensions_activity = options->extensions_activity.get(); | 412 args.extensions_activity = options->extensions_activity.get(); |
415 args.change_delegate = options->registrar; // as SyncManager::ChangeDelegate | 413 args.change_delegate = options->registrar; // as SyncManager::ChangeDelegate |
416 args.credentials = options->credentials; | 414 args.credentials = options->credentials; |
417 args.invalidator_client_id = options->invalidator_client_id; | 415 args.invalidator_client_id = options->invalidator_client_id; |
418 args.restored_key_for_bootstrapping = options->restored_key_for_bootstrapping; | 416 args.restored_key_for_bootstrapping = options->restored_key_for_bootstrapping; |
419 args.restored_keystore_key_for_bootstrapping = | 417 args.restored_keystore_key_for_bootstrapping = |
420 options->restored_keystore_key_for_bootstrapping; | 418 options->restored_keystore_key_for_bootstrapping; |
421 args.internal_components_factory = | 419 args.engine_components_factory = |
422 std::move(options->internal_components_factory); | 420 std::move(options->engine_components_factory); |
423 args.encryptor = &encryptor_; | 421 args.encryptor = &encryptor_; |
424 args.unrecoverable_error_handler = options->unrecoverable_error_handler; | 422 args.unrecoverable_error_handler = options->unrecoverable_error_handler; |
425 args.report_unrecoverable_error_function = | 423 args.report_unrecoverable_error_function = |
426 options->report_unrecoverable_error_function; | 424 options->report_unrecoverable_error_function; |
427 args.cancelation_signal = &stop_syncing_signal_; | 425 args.cancelation_signal = &stop_syncing_signal_; |
428 args.saved_nigori_state = std::move(options->saved_nigori_state); | 426 args.saved_nigori_state = std::move(options->saved_nigori_state); |
429 sync_manager_->Init(&args); | 427 sync_manager_->Init(&args); |
430 } | 428 } |
431 | 429 |
432 void SyncBackendHostCore::DoUpdateCredentials( | 430 void SyncBackendHostCore::DoUpdateCredentials( |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 } | 682 } |
685 | 683 |
686 void SyncBackendHostCore::ClearServerDataDone( | 684 void SyncBackendHostCore::ClearServerDataDone( |
687 const base::Closure& frontend_callback) { | 685 const base::Closure& frontend_callback) { |
688 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); | 686 DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread()); |
689 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop, | 687 host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop, |
690 frontend_callback); | 688 frontend_callback); |
691 } | 689 } |
692 | 690 |
693 } // namespace syncer | 691 } // namespace syncer |
OLD | NEW |