| 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_impl.h" | 5 #include "components/sync/driver/glue/sync_backend_host_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "components/invalidation/public/invalidation_service.h" | 14 #include "components/invalidation/public/invalidation_service.h" |
| 15 #include "components/invalidation/public/object_id_invalidation_map.h" | 15 #include "components/invalidation/public/object_id_invalidation_map.h" |
| 16 #include "components/signin/core/browser/signin_client.h" | 16 #include "components/signin/core/browser/signin_client.h" |
| 17 #include "components/sync/base/experiments.h" | 17 #include "components/sync/base/experiments.h" |
| 18 #include "components/sync/base/invalidation_helper.h" | 18 #include "components/sync/base/invalidation_helper.h" |
| 19 #include "components/sync/base/sync_prefs.h" | 19 #include "components/sync/base/sync_prefs.h" |
| 20 #include "components/sync/core/activation_context.h" | |
| 21 #include "components/sync/core/internal_components_factory.h" | |
| 22 #include "components/sync/core/internal_components_factory_impl.h" | |
| 23 #include "components/sync/core/sync_manager_factory.h" | |
| 24 #include "components/sync/driver/glue/sync_backend_host_core.h" | 20 #include "components/sync/driver/glue/sync_backend_host_core.h" |
| 25 #include "components/sync/driver/glue/sync_backend_registrar.h" | 21 #include "components/sync/driver/glue/sync_backend_registrar.h" |
| 26 #include "components/sync/driver/sync_client.h" | 22 #include "components/sync/driver/sync_client.h" |
| 27 #include "components/sync/driver/sync_driver_switches.h" | 23 #include "components/sync/driver/sync_driver_switches.h" |
| 28 #include "components/sync/driver/sync_frontend.h" | 24 #include "components/sync/driver/sync_frontend.h" |
| 25 #include "components/sync/engine/activation_context.h" |
| 26 #include "components/sync/engine/engine_components_factory.h" |
| 27 #include "components/sync/engine/engine_components_factory_impl.h" |
| 29 #include "components/sync/engine/events/protocol_event.h" | 28 #include "components/sync/engine/events/protocol_event.h" |
| 30 #include "components/sync/engine/net/http_bridge.h" | 29 #include "components/sync/engine/net/http_bridge.h" |
| 30 #include "components/sync/engine/sync_manager_factory.h" |
| 31 #include "components/sync/engine/sync_string_conversions.h" | 31 #include "components/sync/engine/sync_string_conversions.h" |
| 32 #include "components/sync/syncable/base_transaction.h" | 32 #include "components/sync/syncable/base_transaction.h" |
| 33 | 33 |
| 34 // Helper macros to log with the syncer thread name; useful when there | 34 // Helper macros to log with the syncer thread name; useful when there |
| 35 // are multiple syncers involved. | 35 // are multiple syncers involved. |
| 36 | 36 |
| 37 #define SLOG(severity) LOG(severity) << name_ << ": " | 37 #define SLOG(severity) LOG(severity) << name_ << ": " |
| 38 | 38 |
| 39 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": " | 39 #define SDVLOG(verbose_level) DVLOG(verbose_level) << name_ << ": " |
| 40 | 40 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 std::move(sync_thread), ui_thread_, | 87 std::move(sync_thread), ui_thread_, |
| 88 db_thread, file_thread)); | 88 db_thread, file_thread)); |
| 89 CHECK(registrar_->sync_thread()); | 89 CHECK(registrar_->sync_thread()); |
| 90 | 90 |
| 91 frontend_ = frontend; | 91 frontend_ = frontend; |
| 92 DCHECK(frontend); | 92 DCHECK(frontend); |
| 93 | 93 |
| 94 std::vector<scoped_refptr<ModelSafeWorker>> workers; | 94 std::vector<scoped_refptr<ModelSafeWorker>> workers; |
| 95 registrar_->GetWorkers(&workers); | 95 registrar_->GetWorkers(&workers); |
| 96 | 96 |
| 97 InternalComponentsFactory::Switches factory_switches = { | 97 EngineComponentsFactory::Switches factory_switches = { |
| 98 InternalComponentsFactory::ENCRYPTION_KEYSTORE, | 98 EngineComponentsFactory::ENCRYPTION_KEYSTORE, |
| 99 InternalComponentsFactory::BACKOFF_NORMAL}; | 99 EngineComponentsFactory::BACKOFF_NORMAL}; |
| 100 | 100 |
| 101 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); | 101 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); |
| 102 if (cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) { | 102 if (cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) { |
| 103 factory_switches.backoff_override = | 103 factory_switches.backoff_override = |
| 104 InternalComponentsFactory::BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE; | 104 EngineComponentsFactory::BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE; |
| 105 } | 105 } |
| 106 if (cl->HasSwitch(switches::kSyncEnableGetUpdateAvoidance)) { | 106 if (cl->HasSwitch(switches::kSyncEnableGetUpdateAvoidance)) { |
| 107 factory_switches.pre_commit_updates_policy = | 107 factory_switches.pre_commit_updates_policy = |
| 108 InternalComponentsFactory::FORCE_ENABLE_PRE_COMMIT_UPDATE_AVOIDANCE; | 108 EngineComponentsFactory::FORCE_ENABLE_PRE_COMMIT_UPDATE_AVOIDANCE; |
| 109 } | 109 } |
| 110 | 110 |
| 111 std::map<ModelType, int64_t> invalidation_versions; | 111 std::map<ModelType, int64_t> invalidation_versions; |
| 112 sync_prefs_->GetInvalidationVersions(&invalidation_versions); | 112 sync_prefs_->GetInvalidationVersions(&invalidation_versions); |
| 113 | 113 |
| 114 std::unique_ptr<DoInitializeOptions> init_opts(new DoInitializeOptions( | 114 std::unique_ptr<DoInitializeOptions> init_opts(new DoInitializeOptions( |
| 115 registrar_->sync_thread()->message_loop(), registrar_.get(), workers, | 115 registrar_->sync_thread()->message_loop(), registrar_.get(), workers, |
| 116 sync_client_->GetExtensionsActivity(), event_handler, sync_service_url, | 116 sync_client_->GetExtensionsActivity(), event_handler, sync_service_url, |
| 117 sync_user_agent, http_post_provider_factory_getter.Run( | 117 sync_user_agent, http_post_provider_factory_getter.Run( |
| 118 core_->GetRequestContextCancelationSignal()), | 118 core_->GetRequestContextCancelationSignal()), |
| 119 credentials, invalidator_ ? invalidator_->GetInvalidatorClientId() : "", | 119 credentials, invalidator_ ? invalidator_->GetInvalidatorClientId() : "", |
| 120 std::move(sync_manager_factory), delete_sync_data_folder, | 120 std::move(sync_manager_factory), delete_sync_data_folder, |
| 121 sync_prefs_->GetEncryptionBootstrapToken(), | 121 sync_prefs_->GetEncryptionBootstrapToken(), |
| 122 sync_prefs_->GetKeystoreEncryptionBootstrapToken(), | 122 sync_prefs_->GetKeystoreEncryptionBootstrapToken(), |
| 123 std::unique_ptr<InternalComponentsFactory>( | 123 std::unique_ptr<EngineComponentsFactory>( |
| 124 new InternalComponentsFactoryImpl(factory_switches)), | 124 new EngineComponentsFactoryImpl(factory_switches)), |
| 125 unrecoverable_error_handler, report_unrecoverable_error_function, | 125 unrecoverable_error_handler, report_unrecoverable_error_function, |
| 126 std::move(saved_nigori_state), invalidation_versions)); | 126 std::move(saved_nigori_state), invalidation_versions)); |
| 127 InitCore(std::move(init_opts)); | 127 InitCore(std::move(init_opts)); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void SyncBackendHostImpl::TriggerRefresh(const ModelTypeSet& types) { | 130 void SyncBackendHostImpl::TriggerRefresh(const ModelTypeSet& types) { |
| 131 DCHECK(ui_thread_->BelongsToCurrentThread()); | 131 DCHECK(ui_thread_->BelongsToCurrentThread()); |
| 132 registrar_->sync_thread()->task_runner()->PostTask( | 132 registrar_->sync_thread()->task_runner()->PostTask( |
| 133 FROM_HERE, | 133 FROM_HERE, |
| 134 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types)); | 134 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types)); |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 const SyncManager::ClearServerDataCallback& frontend_callback) { | 816 const SyncManager::ClearServerDataCallback& frontend_callback) { |
| 817 DCHECK(ui_thread_->BelongsToCurrentThread()); | 817 DCHECK(ui_thread_->BelongsToCurrentThread()); |
| 818 frontend_callback.Run(); | 818 frontend_callback.Run(); |
| 819 } | 819 } |
| 820 | 820 |
| 821 } // namespace syncer | 821 } // namespace syncer |
| 822 | 822 |
| 823 #undef SDVLOG | 823 #undef SDVLOG |
| 824 | 824 |
| 825 #undef SLOG | 825 #undef SLOG |
| OLD | NEW |