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

Side by Side Diff: components/sync/driver/glue/sync_backend_host_impl.cc

Issue 2481313002: [Sync] Move sync thread ownership to ProfileSyncService. (Closed)
Patch Set: Address comments. Created 4 years, 1 month 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 #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/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 weak_ptr_factory_.GetWeakPtr()); 65 weak_ptr_factory_.GetWeakPtr());
66 } 66 }
67 67
68 SyncBackendHostImpl::~SyncBackendHostImpl() { 68 SyncBackendHostImpl::~SyncBackendHostImpl() {
69 DCHECK(!core_.get() && !frontend_) << "Must call Shutdown before destructor."; 69 DCHECK(!core_.get() && !frontend_) << "Must call Shutdown before destructor.";
70 DCHECK(!registrar_.get()); 70 DCHECK(!registrar_.get());
71 } 71 }
72 72
73 void SyncBackendHostImpl::Initialize( 73 void SyncBackendHostImpl::Initialize(
74 SyncFrontend* frontend, 74 SyncFrontend* frontend,
75 std::unique_ptr<base::Thread> sync_thread, 75 base::Thread* sync_thread,
76 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, 76 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread,
77 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread, 77 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread,
78 const WeakHandle<JsEventHandler>& event_handler, 78 const WeakHandle<JsEventHandler>& event_handler,
79 const GURL& sync_service_url, 79 const GURL& sync_service_url,
80 const std::string& sync_user_agent, 80 const std::string& sync_user_agent,
81 const SyncCredentials& credentials, 81 const SyncCredentials& credentials,
82 bool delete_sync_data_folder, 82 bool delete_sync_data_folder,
83 bool enable_local_sync_backend, 83 bool enable_local_sync_backend,
84 const base::FilePath& local_sync_backend_folder, 84 const base::FilePath& local_sync_backend_folder,
85 std::unique_ptr<SyncManagerFactory> sync_manager_factory, 85 std::unique_ptr<SyncManagerFactory> sync_manager_factory,
86 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, 86 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler,
87 const base::Closure& report_unrecoverable_error_function, 87 const base::Closure& report_unrecoverable_error_function,
88 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, 88 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter,
89 std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state) { 89 std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state) {
90 CHECK(sync_thread);
91 sync_thread_ = sync_thread;
92
90 registrar_ = base::MakeUnique<SyncBackendRegistrar>( 93 registrar_ = base::MakeUnique<SyncBackendRegistrar>(
91 name_, sync_client_, std::move(sync_thread), ui_thread_, db_thread, 94 name_, sync_client_, ui_thread_, db_thread, file_thread);
92 file_thread);
93 CHECK(registrar_->sync_thread());
94 95
96 DCHECK(frontend);
95 frontend_ = frontend; 97 frontend_ = frontend;
96 DCHECK(frontend);
97 98
98 std::vector<scoped_refptr<ModelSafeWorker>> workers; 99 std::vector<scoped_refptr<ModelSafeWorker>> workers;
99 registrar_->GetWorkers(&workers); 100 registrar_->GetWorkers(&workers);
100 101
101 EngineComponentsFactory::Switches factory_switches = { 102 EngineComponentsFactory::Switches factory_switches = {
102 EngineComponentsFactory::ENCRYPTION_KEYSTORE, 103 EngineComponentsFactory::ENCRYPTION_KEYSTORE,
103 EngineComponentsFactory::BACKOFF_NORMAL}; 104 EngineComponentsFactory::BACKOFF_NORMAL};
104 105
105 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); 106 base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
106 if (cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) { 107 if (cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) {
107 factory_switches.backoff_override = 108 factory_switches.backoff_override =
108 EngineComponentsFactory::BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE; 109 EngineComponentsFactory::BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE;
109 } 110 }
110 if (cl->HasSwitch(switches::kSyncEnableGetUpdateAvoidance)) { 111 if (cl->HasSwitch(switches::kSyncEnableGetUpdateAvoidance)) {
111 factory_switches.pre_commit_updates_policy = 112 factory_switches.pre_commit_updates_policy =
112 EngineComponentsFactory::FORCE_ENABLE_PRE_COMMIT_UPDATE_AVOIDANCE; 113 EngineComponentsFactory::FORCE_ENABLE_PRE_COMMIT_UPDATE_AVOIDANCE;
113 } 114 }
114 115
115 std::map<ModelType, int64_t> invalidation_versions; 116 std::map<ModelType, int64_t> invalidation_versions;
116 sync_prefs_->GetInvalidationVersions(&invalidation_versions); 117 sync_prefs_->GetInvalidationVersions(&invalidation_versions);
117 118
118 std::unique_ptr<DoInitializeOptions> init_opts(new DoInitializeOptions( 119 std::unique_ptr<DoInitializeOptions> init_opts(new DoInitializeOptions(
119 registrar_->sync_thread()->message_loop(), registrar_.get(), workers, 120 sync_thread_->message_loop(), registrar_.get(), workers,
120 sync_client_->GetExtensionsActivity(), event_handler, sync_service_url, 121 sync_client_->GetExtensionsActivity(), event_handler, sync_service_url,
121 sync_user_agent, http_post_provider_factory_getter.Run( 122 sync_user_agent, http_post_provider_factory_getter.Run(
122 core_->GetRequestContextCancelationSignal()), 123 core_->GetRequestContextCancelationSignal()),
123 credentials, invalidator_ ? invalidator_->GetInvalidatorClientId() : "", 124 credentials, invalidator_ ? invalidator_->GetInvalidatorClientId() : "",
124 std::move(sync_manager_factory), delete_sync_data_folder, 125 std::move(sync_manager_factory), delete_sync_data_folder,
125 enable_local_sync_backend, local_sync_backend_folder, 126 enable_local_sync_backend, local_sync_backend_folder,
126 sync_prefs_->GetEncryptionBootstrapToken(), 127 sync_prefs_->GetEncryptionBootstrapToken(),
127 sync_prefs_->GetKeystoreEncryptionBootstrapToken(), 128 sync_prefs_->GetKeystoreEncryptionBootstrapToken(),
128 std::unique_ptr<EngineComponentsFactory>( 129 std::unique_ptr<EngineComponentsFactory>(
129 new EngineComponentsFactoryImpl(factory_switches)), 130 new EngineComponentsFactoryImpl(factory_switches)),
130 unrecoverable_error_handler, report_unrecoverable_error_function, 131 unrecoverable_error_handler, report_unrecoverable_error_function,
131 std::move(saved_nigori_state), invalidation_versions)); 132 std::move(saved_nigori_state), invalidation_versions));
132 InitCore(std::move(init_opts)); 133 InitCore(std::move(init_opts));
133 } 134 }
134 135
135 void SyncBackendHostImpl::TriggerRefresh(const ModelTypeSet& types) { 136 void SyncBackendHostImpl::TriggerRefresh(const ModelTypeSet& types) {
136 DCHECK(ui_thread_->BelongsToCurrentThread()); 137 DCHECK(ui_thread_->BelongsToCurrentThread());
137 registrar_->sync_thread()->task_runner()->PostTask( 138 sync_thread_->task_runner()->PostTask(
138 FROM_HERE, 139 FROM_HERE,
139 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types)); 140 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types));
140 } 141 }
141 142
142 void SyncBackendHostImpl::UpdateCredentials( 143 void SyncBackendHostImpl::UpdateCredentials(
143 const SyncCredentials& credentials) { 144 const SyncCredentials& credentials) {
144 DCHECK(registrar_->sync_thread()->IsRunning()); 145 DCHECK(sync_thread_->IsRunning());
145 registrar_->sync_thread()->task_runner()->PostTask( 146 sync_thread_->task_runner()->PostTask(
146 FROM_HERE, base::Bind(&SyncBackendHostCore::DoUpdateCredentials, 147 FROM_HERE, base::Bind(&SyncBackendHostCore::DoUpdateCredentials, core_,
147 core_, credentials)); 148 credentials));
148 } 149 }
149 150
150 void SyncBackendHostImpl::StartSyncingWithServer() { 151 void SyncBackendHostImpl::StartSyncingWithServer() {
151 SDVLOG(1) << "SyncBackendHostImpl::StartSyncingWithServer called."; 152 SDVLOG(1) << "SyncBackendHostImpl::StartSyncingWithServer called.";
152 153
153 ModelSafeRoutingInfo routing_info; 154 ModelSafeRoutingInfo routing_info;
154 registrar_->GetModelSafeRoutingInfo(&routing_info); 155 registrar_->GetModelSafeRoutingInfo(&routing_info);
155 156
156 registrar_->sync_thread()->task_runner()->PostTask( 157 sync_thread_->task_runner()->PostTask(
157 FROM_HERE, base::Bind(&SyncBackendHostCore::DoStartSyncing, core_, 158 FROM_HERE, base::Bind(&SyncBackendHostCore::DoStartSyncing, core_,
158 routing_info, sync_prefs_->GetLastPollTime())); 159 routing_info, sync_prefs_->GetLastPollTime()));
159 } 160 }
160 161
161 void SyncBackendHostImpl::SetEncryptionPassphrase(const std::string& passphrase, 162 void SyncBackendHostImpl::SetEncryptionPassphrase(const std::string& passphrase,
162 bool is_explicit) { 163 bool is_explicit) {
163 DCHECK(registrar_->sync_thread()->IsRunning()); 164 DCHECK(sync_thread_->IsRunning());
164 if (!IsNigoriEnabled()) { 165 if (!IsNigoriEnabled()) {
165 NOTREACHED() << "SetEncryptionPassphrase must never be called when nigori" 166 NOTREACHED() << "SetEncryptionPassphrase must never be called when nigori"
166 " is disabled."; 167 " is disabled.";
167 return; 168 return;
168 } 169 }
169 170
170 // We should never be called with an empty passphrase. 171 // We should never be called with an empty passphrase.
171 DCHECK(!passphrase.empty()); 172 DCHECK(!passphrase.empty());
172 173
173 // This should only be called by the frontend. 174 // This should only be called by the frontend.
174 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); 175 DCHECK(frontend_task_runner_->BelongsToCurrentThread());
175 176
176 // SetEncryptionPassphrase should never be called if we are currently 177 // SetEncryptionPassphrase should never be called if we are currently
177 // encrypted with an explicit passphrase. 178 // encrypted with an explicit passphrase.
178 DCHECK(cached_passphrase_type_ == PassphraseType::KEYSTORE_PASSPHRASE || 179 DCHECK(cached_passphrase_type_ == PassphraseType::KEYSTORE_PASSPHRASE ||
179 cached_passphrase_type_ == PassphraseType::IMPLICIT_PASSPHRASE); 180 cached_passphrase_type_ == PassphraseType::IMPLICIT_PASSPHRASE);
180 181
181 // Post an encryption task on the syncer thread. 182 // Post an encryption task on the syncer thread.
182 registrar_->sync_thread()->task_runner()->PostTask( 183 sync_thread_->task_runner()->PostTask(
183 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetEncryptionPassphrase, 184 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetEncryptionPassphrase,
184 core_, passphrase, is_explicit)); 185 core_, passphrase, is_explicit));
185 } 186 }
186 187
187 bool SyncBackendHostImpl::SetDecryptionPassphrase( 188 bool SyncBackendHostImpl::SetDecryptionPassphrase(
188 const std::string& passphrase) { 189 const std::string& passphrase) {
189 if (!IsNigoriEnabled()) { 190 if (!IsNigoriEnabled()) {
190 NOTREACHED() << "SetDecryptionPassphrase must never be called when nigori" 191 NOTREACHED() << "SetDecryptionPassphrase must never be called when nigori"
191 " is disabled."; 192 " is disabled.";
192 return false; 193 return false;
193 } 194 }
194 195
195 // We should never be called with an empty passphrase. 196 // We should never be called with an empty passphrase.
196 DCHECK(!passphrase.empty()); 197 DCHECK(!passphrase.empty());
197 198
198 // This should only be called by the frontend. 199 // This should only be called by the frontend.
199 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); 200 DCHECK(frontend_task_runner_->BelongsToCurrentThread());
200 201
201 // This should only be called when we have cached pending keys. 202 // This should only be called when we have cached pending keys.
202 DCHECK(cached_pending_keys_.has_blob()); 203 DCHECK(cached_pending_keys_.has_blob());
203 204
204 // Check the passphrase that was provided against our local cache of the 205 // Check the passphrase that was provided against our local cache of the
205 // cryptographer's pending keys. If this was unsuccessful, the UI layer can 206 // cryptographer's pending keys. If this was unsuccessful, the UI layer can
206 // immediately call OnPassphraseRequired without showing the user a spinner. 207 // immediately call OnPassphraseRequired without showing the user a spinner.
207 if (!CheckPassphraseAgainstCachedPendingKeys(passphrase)) 208 if (!CheckPassphraseAgainstCachedPendingKeys(passphrase))
208 return false; 209 return false;
209 210
210 // Post a decryption task on the syncer thread. 211 // Post a decryption task on the syncer thread.
211 registrar_->sync_thread()->task_runner()->PostTask( 212 sync_thread_->task_runner()->PostTask(
212 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetDecryptionPassphrase, 213 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetDecryptionPassphrase,
213 core_, passphrase)); 214 core_, passphrase));
214 215
215 // Since we were able to decrypt the cached pending keys with the passphrase 216 // Since we were able to decrypt the cached pending keys with the passphrase
216 // provided, we immediately alert the UI layer that the passphrase was 217 // provided, we immediately alert the UI layer that the passphrase was
217 // accepted. This will avoid the situation where a user enters a passphrase, 218 // accepted. This will avoid the situation where a user enters a passphrase,
218 // clicks OK, immediately reopens the advanced settings dialog, and gets an 219 // clicks OK, immediately reopens the advanced settings dialog, and gets an
219 // unnecessary prompt for a passphrase. 220 // unnecessary prompt for a passphrase.
220 // Note: It is not guaranteed that the passphrase will be accepted by the 221 // Note: It is not guaranteed that the passphrase will be accepted by the
221 // syncer thread, since we could receive a new nigori node while the task is 222 // syncer thread, since we could receive a new nigori node while the task is
222 // pending. This scenario is a valid race, and SetDecryptionPassphrase can 223 // pending. This scenario is a valid race, and SetDecryptionPassphrase can
223 // trigger a new OnPassphraseRequired if it needs to. 224 // trigger a new OnPassphraseRequired if it needs to.
224 NotifyPassphraseAccepted(); 225 NotifyPassphraseAccepted();
225 return true; 226 return true;
226 } 227 }
227 228
228 void SyncBackendHostImpl::StopSyncingForShutdown() { 229 void SyncBackendHostImpl::StopSyncingForShutdown() {
229 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); 230 DCHECK(frontend_task_runner_->BelongsToCurrentThread());
230 231
231 // Immediately stop sending messages to the frontend. 232 // Immediately stop sending messages to the frontend.
232 frontend_ = nullptr; 233 frontend_ = nullptr;
233 234
234 DCHECK(registrar_->sync_thread()->IsRunning()); 235 DCHECK(sync_thread_->IsRunning());
235 236
236 registrar_->RequestWorkerStopOnUIThread(); 237 registrar_->RequestWorkerStopOnUIThread();
237 238
238 core_->ShutdownOnUIThread(); 239 core_->ShutdownOnUIThread();
239 } 240 }
240 241
241 std::unique_ptr<base::Thread> SyncBackendHostImpl::Shutdown( 242 void SyncBackendHostImpl::Shutdown(ShutdownReason reason) {
242 ShutdownReason reason) {
243 // StopSyncingForShutdown() (which nulls out |frontend_|) should be 243 // StopSyncingForShutdown() (which nulls out |frontend_|) should be
244 // called first. 244 // called first.
245 DCHECK(!frontend_); 245 DCHECK(!frontend_);
246 DCHECK(registrar_->sync_thread()->IsRunning()); 246 DCHECK(sync_thread_->IsRunning());
247 247
248 if (invalidation_handler_registered_) { 248 if (invalidation_handler_registered_) {
249 if (reason == DISABLE_SYNC) { 249 if (reason == DISABLE_SYNC) {
250 UnregisterInvalidationIds(); 250 UnregisterInvalidationIds();
251 } 251 }
252 invalidator_->UnregisterInvalidationHandler(this); 252 invalidator_->UnregisterInvalidationHandler(this);
253 invalidator_ = nullptr; 253 invalidator_ = nullptr;
254 } 254 }
255 invalidation_handler_registered_ = false; 255 invalidation_handler_registered_ = false;
256 256
257 model_type_connector_.reset(); 257 model_type_connector_.reset();
258 258
259 // Shut down and destroy SyncManager. SyncManager holds a pointer to 259 // Shut down and destroy SyncManager. SyncManager holds a pointer to
260 // |registrar_| so its destruction must be sequenced before the destruction of 260 // |registrar_| so its destruction must be sequenced before the destruction of
261 // |registrar_|. 261 // |registrar_|.
262 registrar_->sync_thread()->task_runner()->PostTask( 262 sync_thread_->task_runner()->PostTask(
263 FROM_HERE, 263 FROM_HERE, base::Bind(&SyncBackendHostCore::DoShutdown, core_, reason));
264 base::Bind(&SyncBackendHostCore::DoShutdown, core_, reason));
265 core_ = nullptr; 264 core_ = nullptr;
266 265
267 // Destroy |registrar_|. 266 // Destroy |registrar_|.
268 std::unique_ptr<base::Thread> released_sync_thread = 267 sync_thread_->task_runner()->DeleteSoon(FROM_HERE, registrar_.release());
269 registrar_->ReleaseSyncThread();
270 released_sync_thread->task_runner()->DeleteSoon(FROM_HERE,
271 registrar_.release());
272
273 return released_sync_thread;
274 } 268 }
275 269
276 void SyncBackendHostImpl::UnregisterInvalidationIds() { 270 void SyncBackendHostImpl::UnregisterInvalidationIds() {
277 if (invalidation_handler_registered_) { 271 if (invalidation_handler_registered_) {
278 CHECK(invalidator_->UpdateRegisteredInvalidationIds(this, ObjectIdSet())); 272 CHECK(invalidator_->UpdateRegisteredInvalidationIds(this, ObjectIdSet()));
279 } 273 }
280 } 274 }
281 275
282 ModelTypeSet SyncBackendHostImpl::ConfigureDataTypes( 276 ModelTypeSet SyncBackendHostImpl::ConfigureDataTypes(
283 ConfigureReason reason, 277 ConfigureReason reason,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 ready_task, retry_callback); 381 ready_task, retry_callback);
388 382
389 DCHECK(Intersection(active_types, types_to_purge).Empty()); 383 DCHECK(Intersection(active_types, types_to_purge).Empty());
390 DCHECK(Intersection(active_types, fatal_types).Empty()); 384 DCHECK(Intersection(active_types, fatal_types).Empty());
391 DCHECK(Intersection(active_types, unapply_types).Empty()); 385 DCHECK(Intersection(active_types, unapply_types).Empty());
392 DCHECK(Intersection(active_types, inactive_types).Empty()); 386 DCHECK(Intersection(active_types, inactive_types).Empty());
393 return Difference(active_types, types_to_download); 387 return Difference(active_types, types_to_download);
394 } 388 }
395 389
396 void SyncBackendHostImpl::EnableEncryptEverything() { 390 void SyncBackendHostImpl::EnableEncryptEverything() {
397 registrar_->sync_thread()->task_runner()->PostTask( 391 sync_thread_->task_runner()->PostTask(
398 FROM_HERE, 392 FROM_HERE,
399 base::Bind(&SyncBackendHostCore::DoEnableEncryptEverything, core_)); 393 base::Bind(&SyncBackendHostCore::DoEnableEncryptEverything, core_));
400 } 394 }
401 395
402 void SyncBackendHostImpl::ActivateDirectoryDataType( 396 void SyncBackendHostImpl::ActivateDirectoryDataType(
403 ModelType type, 397 ModelType type,
404 ModelSafeGroup group, 398 ModelSafeGroup group,
405 ChangeProcessor* change_processor) { 399 ChangeProcessor* change_processor) {
406 registrar_->ActivateDataType(type, group, change_processor, GetUserShare()); 400 registrar_->ActivateDataType(type, group, change_processor, GetUserShare());
407 } 401 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 if (initialized()) { 458 if (initialized()) {
465 CHECK(registrar_.get()); 459 CHECK(registrar_.get());
466 registrar_->GetModelSafeRoutingInfo(out); 460 registrar_->GetModelSafeRoutingInfo(out);
467 } else { 461 } else {
468 NOTREACHED(); 462 NOTREACHED();
469 } 463 }
470 } 464 }
471 465
472 void SyncBackendHostImpl::FlushDirectory() const { 466 void SyncBackendHostImpl::FlushDirectory() const {
473 DCHECK(initialized()); 467 DCHECK(initialized());
474 registrar_->sync_thread()->task_runner()->PostTask( 468 sync_thread_->task_runner()->PostTask(
475 FROM_HERE, base::Bind(&SyncBackendHostCore::SaveChanges, core_)); 469 FROM_HERE, base::Bind(&SyncBackendHostCore::SaveChanges, core_));
476 } 470 }
477 471
478 void SyncBackendHostImpl::RequestBufferedProtocolEventsAndEnableForwarding() { 472 void SyncBackendHostImpl::RequestBufferedProtocolEventsAndEnableForwarding() {
479 registrar_->sync_thread()->task_runner()->PostTask( 473 sync_thread_->task_runner()->PostTask(
480 FROM_HERE, 474 FROM_HERE,
481 base::Bind( 475 base::Bind(
482 &SyncBackendHostCore::SendBufferedProtocolEventsAndEnableForwarding, 476 &SyncBackendHostCore::SendBufferedProtocolEventsAndEnableForwarding,
483 core_)); 477 core_));
484 } 478 }
485 479
486 void SyncBackendHostImpl::DisableProtocolEventForwarding() { 480 void SyncBackendHostImpl::DisableProtocolEventForwarding() {
487 registrar_->sync_thread()->task_runner()->PostTask( 481 sync_thread_->task_runner()->PostTask(
488 FROM_HERE, 482 FROM_HERE,
489 base::Bind(&SyncBackendHostCore::DisableProtocolEventForwarding, core_)); 483 base::Bind(&SyncBackendHostCore::DisableProtocolEventForwarding, core_));
490 } 484 }
491 485
492 void SyncBackendHostImpl::EnableDirectoryTypeDebugInfoForwarding() { 486 void SyncBackendHostImpl::EnableDirectoryTypeDebugInfoForwarding() {
493 DCHECK(initialized()); 487 DCHECK(initialized());
494 registrar_->sync_thread()->task_runner()->PostTask( 488 sync_thread_->task_runner()->PostTask(
495 FROM_HERE, 489 FROM_HERE,
496 base::Bind(&SyncBackendHostCore::EnableDirectoryTypeDebugInfoForwarding, 490 base::Bind(&SyncBackendHostCore::EnableDirectoryTypeDebugInfoForwarding,
497 core_)); 491 core_));
498 } 492 }
499 493
500 void SyncBackendHostImpl::DisableDirectoryTypeDebugInfoForwarding() { 494 void SyncBackendHostImpl::DisableDirectoryTypeDebugInfoForwarding() {
501 DCHECK(initialized()); 495 DCHECK(initialized());
502 registrar_->sync_thread()->task_runner()->PostTask( 496 sync_thread_->task_runner()->PostTask(
503 FROM_HERE, 497 FROM_HERE,
504 base::Bind(&SyncBackendHostCore::DisableDirectoryTypeDebugInfoForwarding, 498 base::Bind(&SyncBackendHostCore::DisableDirectoryTypeDebugInfoForwarding,
505 core_)); 499 core_));
506 } 500 }
507 501
508 void SyncBackendHostImpl::InitCore( 502 void SyncBackendHostImpl::InitCore(
509 std::unique_ptr<DoInitializeOptions> options) { 503 std::unique_ptr<DoInitializeOptions> options) {
510 registrar_->sync_thread()->task_runner()->PostTask( 504 sync_thread_->task_runner()->PostTask(
511 FROM_HERE, base::Bind(&SyncBackendHostCore::DoInitialize, core_, 505 FROM_HERE, base::Bind(&SyncBackendHostCore::DoInitialize, core_,
512 base::Passed(&options))); 506 base::Passed(&options)));
513 } 507 }
514 508
515 void SyncBackendHostImpl::RequestConfigureSyncer( 509 void SyncBackendHostImpl::RequestConfigureSyncer(
516 ConfigureReason reason, 510 ConfigureReason reason,
517 ModelTypeSet to_download, 511 ModelTypeSet to_download,
518 ModelTypeSet to_purge, 512 ModelTypeSet to_purge,
519 ModelTypeSet to_journal, 513 ModelTypeSet to_journal,
520 ModelTypeSet to_unapply, 514 ModelTypeSet to_unapply,
521 ModelTypeSet to_ignore, 515 ModelTypeSet to_ignore,
522 const ModelSafeRoutingInfo& routing_info, 516 const ModelSafeRoutingInfo& routing_info,
523 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task, 517 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task,
524 const base::Closure& retry_callback) { 518 const base::Closure& retry_callback) {
525 DoConfigureSyncerTypes config_types; 519 DoConfigureSyncerTypes config_types;
526 config_types.to_download = to_download; 520 config_types.to_download = to_download;
527 config_types.to_purge = to_purge; 521 config_types.to_purge = to_purge;
528 config_types.to_journal = to_journal; 522 config_types.to_journal = to_journal;
529 config_types.to_unapply = to_unapply; 523 config_types.to_unapply = to_unapply;
530 registrar_->sync_thread()->task_runner()->PostTask( 524 sync_thread_->task_runner()->PostTask(
531 FROM_HERE, 525 FROM_HERE,
532 base::Bind(&SyncBackendHostCore::DoConfigureSyncer, core_, reason, 526 base::Bind(&SyncBackendHostCore::DoConfigureSyncer, core_, reason,
533 config_types, routing_info, ready_task, retry_callback)); 527 config_types, routing_info, ready_task, retry_callback));
534 } 528 }
535 529
536 void SyncBackendHostImpl::FinishConfigureDataTypesOnFrontendLoop( 530 void SyncBackendHostImpl::FinishConfigureDataTypesOnFrontendLoop(
537 const ModelTypeSet enabled_types, 531 const ModelTypeSet enabled_types,
538 const ModelTypeSet succeeded_configuration_types, 532 const ModelTypeSet succeeded_configuration_types,
539 const ModelTypeSet failed_configuration_types, 533 const ModelTypeSet failed_configuration_types,
540 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task) { 534 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 640
647 void SyncBackendHostImpl::HandleMigrationRequestedOnFrontendLoop( 641 void SyncBackendHostImpl::HandleMigrationRequestedOnFrontendLoop(
648 ModelTypeSet types) { 642 ModelTypeSet types) {
649 if (!frontend_) 643 if (!frontend_)
650 return; 644 return;
651 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); 645 DCHECK(frontend_task_runner_->BelongsToCurrentThread());
652 frontend_->OnMigrationNeededForTypes(types); 646 frontend_->OnMigrationNeededForTypes(types);
653 } 647 }
654 648
655 void SyncBackendHostImpl::OnInvalidatorStateChange(InvalidatorState state) { 649 void SyncBackendHostImpl::OnInvalidatorStateChange(InvalidatorState state) {
656 registrar_->sync_thread()->task_runner()->PostTask( 650 sync_thread_->task_runner()->PostTask(
657 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnInvalidatorStateChange, 651 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnInvalidatorStateChange,
658 core_, state)); 652 core_, state));
659 } 653 }
660 654
661 void SyncBackendHostImpl::OnIncomingInvalidation( 655 void SyncBackendHostImpl::OnIncomingInvalidation(
662 const ObjectIdInvalidationMap& invalidation_map) { 656 const ObjectIdInvalidationMap& invalidation_map) {
663 registrar_->sync_thread()->task_runner()->PostTask( 657 sync_thread_->task_runner()->PostTask(
664 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnIncomingInvalidation, 658 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnIncomingInvalidation,
665 core_, invalidation_map)); 659 core_, invalidation_map));
666 } 660 }
667 661
668 std::string SyncBackendHostImpl::GetOwnerName() const { 662 std::string SyncBackendHostImpl::GetOwnerName() const {
669 return "SyncBackendHostImpl"; 663 return "SyncBackendHostImpl";
670 } 664 }
671 665
672 bool SyncBackendHostImpl::CheckPassphraseAgainstCachedPendingKeys( 666 bool SyncBackendHostImpl::CheckPassphraseAgainstCachedPendingKeys(
673 const std::string& passphrase) const { 667 const std::string& passphrase) const {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 if (!frontend_) 773 if (!frontend_)
780 return; 774 return;
781 frontend_->OnDatatypeStatusCounterUpdated(type, counters); 775 frontend_->OnDatatypeStatusCounterUpdated(type, counters);
782 } 776 }
783 777
784 void SyncBackendHostImpl::UpdateInvalidationVersions( 778 void SyncBackendHostImpl::UpdateInvalidationVersions(
785 const std::map<ModelType, int64_t>& invalidation_versions) { 779 const std::map<ModelType, int64_t>& invalidation_versions) {
786 sync_prefs_->UpdateInvalidationVersions(invalidation_versions); 780 sync_prefs_->UpdateInvalidationVersions(invalidation_versions);
787 } 781 }
788 782
789 base::MessageLoop* SyncBackendHostImpl::GetSyncLoopForTesting() {
790 return registrar_->sync_thread()->message_loop();
791 }
792
793 void SyncBackendHostImpl::RefreshTypesForTest(ModelTypeSet types) { 783 void SyncBackendHostImpl::RefreshTypesForTest(ModelTypeSet types) {
794 DCHECK(ui_thread_->BelongsToCurrentThread()); 784 DCHECK(ui_thread_->BelongsToCurrentThread());
795 785
796 registrar_->sync_thread()->task_runner()->PostTask( 786 sync_thread_->task_runner()->PostTask(
797 FROM_HERE, 787 FROM_HERE,
798 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types)); 788 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types));
799 } 789 }
800 790
801 void SyncBackendHostImpl::ClearServerData( 791 void SyncBackendHostImpl::ClearServerData(
802 const SyncManager::ClearServerDataCallback& callback) { 792 const SyncManager::ClearServerDataCallback& callback) {
803 DCHECK(ui_thread_->BelongsToCurrentThread()); 793 DCHECK(ui_thread_->BelongsToCurrentThread());
804 registrar_->sync_thread()->task_runner()->PostTask( 794 sync_thread_->task_runner()->PostTask(
805 FROM_HERE, base::Bind(&SyncBackendHostCore::DoClearServerData, 795 FROM_HERE,
806 core_, callback)); 796 base::Bind(&SyncBackendHostCore::DoClearServerData, core_, callback));
807 } 797 }
808 798
809 void SyncBackendHostImpl::OnCookieJarChanged(bool account_mismatch, 799 void SyncBackendHostImpl::OnCookieJarChanged(bool account_mismatch,
810 bool empty_jar) { 800 bool empty_jar) {
811 DCHECK(ui_thread_->BelongsToCurrentThread()); 801 DCHECK(ui_thread_->BelongsToCurrentThread());
812 registrar_->sync_thread()->task_runner()->PostTask( 802 sync_thread_->task_runner()->PostTask(
813 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnCookieJarChanged, 803 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnCookieJarChanged, core_,
814 core_, account_mismatch, empty_jar)); 804 account_mismatch, empty_jar));
815 } 805 }
816 806
817 void SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop( 807 void SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop(
818 const SyncManager::ClearServerDataCallback& frontend_callback) { 808 const SyncManager::ClearServerDataCallback& frontend_callback) {
819 DCHECK(ui_thread_->BelongsToCurrentThread()); 809 DCHECK(ui_thread_->BelongsToCurrentThread());
820 frontend_callback.Run(); 810 frontend_callback.Run();
821 } 811 }
822 812
823 } // namespace syncer 813 } // namespace syncer
824 814
825 #undef SDVLOG 815 #undef SDVLOG
826 816
827 #undef SLOG 817 #undef SLOG
OLDNEW
« no previous file with comments | « components/sync/driver/glue/sync_backend_host_impl.h ('k') | components/sync/driver/glue/sync_backend_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698