OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include "chrome/browser/sync/glue/sync_backend_host.h" | 7 #include "chrome/browser/sync/glue/sync_backend_host.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 sync_service_url, | 128 sync_service_url, |
129 profile_->GetRequestContext(), | 129 profile_->GetRequestContext(), |
130 credentials, | 130 credentials, |
131 delete_sync_data_folder, | 131 delete_sync_data_folder, |
132 sync_prefs_->GetEncryptionBootstrapToken(), | 132 sync_prefs_->GetEncryptionBootstrapToken(), |
133 false)); | 133 false)); |
134 } | 134 } |
135 | 135 |
136 void SyncBackendHost::InitCore(const Core::DoInitializeOptions& options) { | 136 void SyncBackendHost::InitCore(const Core::DoInitializeOptions& options) { |
137 sync_thread_.message_loop()->PostTask(FROM_HERE, | 137 sync_thread_.message_loop()->PostTask(FROM_HERE, |
138 NewRunnableMethod(core_.get(), &SyncBackendHost::Core::DoInitialize, | 138 base::Bind(&SyncBackendHost::Core::DoInitialize, core_.get(),options)); |
139 options)); | |
140 } | 139 } |
141 | 140 |
142 void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) { | 141 void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) { |
143 sync_thread_.message_loop()->PostTask(FROM_HERE, | 142 sync_thread_.message_loop()->PostTask(FROM_HERE, |
144 NewRunnableMethod(core_.get(), | 143 base::Bind(&SyncBackendHost::Core::DoUpdateCredentials, core_.get(), |
145 &SyncBackendHost::Core::DoUpdateCredentials, | 144 credentials)); |
146 credentials)); | |
147 } | 145 } |
148 | 146 |
149 void SyncBackendHost::StartSyncingWithServer() { | 147 void SyncBackendHost::StartSyncingWithServer() { |
150 SVLOG(1) << "SyncBackendHost::StartSyncingWithServer called."; | 148 SVLOG(1) << "SyncBackendHost::StartSyncingWithServer called."; |
151 sync_thread_.message_loop()->PostTask(FROM_HERE, | 149 sync_thread_.message_loop()->PostTask(FROM_HERE, |
152 NewRunnableMethod(core_.get(), &SyncBackendHost::Core::DoStartSyncing)); | 150 base::Bind(&SyncBackendHost::Core::DoStartSyncing, core_.get())); |
153 } | 151 } |
154 | 152 |
155 void SyncBackendHost::SetPassphrase(const std::string& passphrase, | 153 void SyncBackendHost::SetPassphrase(const std::string& passphrase, |
156 bool is_explicit) { | 154 bool is_explicit) { |
157 if (!IsNigoriEnabled()) { | 155 if (!IsNigoriEnabled()) { |
158 SLOG(WARNING) << "Silently dropping SetPassphrase request."; | 156 SLOG(WARNING) << "Silently dropping SetPassphrase request."; |
159 return; | 157 return; |
160 } | 158 } |
161 | 159 |
162 // This should only be called by the frontend. | 160 // This should only be called by the frontend. |
163 DCHECK_EQ(MessageLoop::current(), frontend_loop_); | 161 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
164 | 162 |
165 // If encryption is enabled and we've got a SetPassphrase | 163 // If encryption is enabled and we've got a SetPassphrase |
166 sync_thread_.message_loop()->PostTask(FROM_HERE, | 164 sync_thread_.message_loop()->PostTask(FROM_HERE, |
167 NewRunnableMethod(core_.get(), &SyncBackendHost::Core::DoSetPassphrase, | 165 base::Bind(&SyncBackendHost::Core::DoSetPassphrase, core_.get(), |
168 passphrase, is_explicit)); | 166 passphrase, is_explicit)); |
169 } | 167 } |
170 | 168 |
171 void SyncBackendHost::StopSyncManagerForShutdown( | 169 void SyncBackendHost::StopSyncManagerForShutdown( |
172 const base::Closure& closure) { | 170 const base::Closure& closure) { |
173 DCHECK_GT(initialization_state_, NOT_ATTEMPTED); | 171 DCHECK_GT(initialization_state_, NOT_ATTEMPTED); |
174 if (initialization_state_ == CREATING_SYNC_MANAGER) { | 172 if (initialization_state_ == CREATING_SYNC_MANAGER) { |
175 // We post here to implicitly wait for the SyncManager to be created, | 173 // We post here to implicitly wait for the SyncManager to be created, |
176 // if needed. We have to wait, since we need to shutdown immediately, | 174 // if needed. We have to wait, since we need to shutdown immediately, |
177 // and we need to tell the SyncManager so it can abort any activity | 175 // and we need to tell the SyncManager so it can abort any activity |
178 // (net I/O, data application). | 176 // (net I/O, data application). |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // so the registrar won't need stopping either. | 213 // so the registrar won't need stopping either. |
216 DCHECK_EQ(NOT_ATTEMPTED, initialization_state_); | 214 DCHECK_EQ(NOT_ATTEMPTED, initialization_state_); |
217 DCHECK(!registrar_.get()); | 215 DCHECK(!registrar_.get()); |
218 } | 216 } |
219 } | 217 } |
220 | 218 |
221 void SyncBackendHost::Shutdown(bool sync_disabled) { | 219 void SyncBackendHost::Shutdown(bool sync_disabled) { |
222 // TODO(tim): DCHECK(registrar_->StoppedOnUIThread()) would be nice. | 220 // TODO(tim): DCHECK(registrar_->StoppedOnUIThread()) would be nice. |
223 if (sync_thread_.IsRunning()) { | 221 if (sync_thread_.IsRunning()) { |
224 sync_thread_.message_loop()->PostTask(FROM_HERE, | 222 sync_thread_.message_loop()->PostTask(FROM_HERE, |
225 NewRunnableMethod(core_.get(), | 223 base::Bind(&SyncBackendHost::Core::DoShutdown, core_.get(), |
226 &SyncBackendHost::Core::DoShutdown, | 224 sync_disabled)); |
227 sync_disabled)); | |
228 } | 225 } |
229 | 226 |
230 // Stop will return once the thread exits, which will be after DoShutdown | 227 // Stop will return once the thread exits, which will be after DoShutdown |
231 // runs. DoShutdown needs to run from sync_thread_ because the sync backend | 228 // runs. DoShutdown needs to run from sync_thread_ because the sync backend |
232 // requires any thread that opened sqlite handles to relinquish them | 229 // requires any thread that opened sqlite handles to relinquish them |
233 // personally. We need to join threads, because otherwise the main Chrome | 230 // personally. We need to join threads, because otherwise the main Chrome |
234 // thread (ui loop) can exit before DoShutdown finishes, at which point | 231 // thread (ui loop) can exit before DoShutdown finishes, at which point |
235 // virtually anything the sync backend does (or the post-back to | 232 // virtually anything the sync backend does (or the post-back to |
236 // frontend_loop_ by our Core) will epically fail because the CRT won't be | 233 // frontend_loop_ by our Core) will epically fail because the CRT won't be |
237 // initialized. | 234 // initialized. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 registrar_->ConfigureDataTypes(types_to_add_with_nigori, | 272 registrar_->ConfigureDataTypes(types_to_add_with_nigori, |
276 types_to_remove_with_nigori); | 273 types_to_remove_with_nigori); |
277 pending_config_mode_state_->reason = reason; | 274 pending_config_mode_state_->reason = reason; |
278 | 275 |
279 // Cleanup disabled types before starting configuration so that | 276 // Cleanup disabled types before starting configuration so that |
280 // callers can assume that the data types are cleaned up once | 277 // callers can assume that the data types are cleaned up once |
281 // configuration is done. | 278 // configuration is done. |
282 if (!types_to_remove_with_nigori.empty()) { | 279 if (!types_to_remove_with_nigori.empty()) { |
283 sync_thread_.message_loop()->PostTask( | 280 sync_thread_.message_loop()->PostTask( |
284 FROM_HERE, | 281 FROM_HERE, |
285 NewRunnableMethod( | 282 base::Bind(&SyncBackendHost::Core::DoRequestCleanupDisabledTypes, |
286 core_.get(), | 283 core_.get())); |
287 &SyncBackendHost::Core::DoRequestCleanupDisabledTypes)); | |
288 } | 284 } |
289 | 285 |
290 StartConfiguration(base::Bind( | 286 StartConfiguration( |
291 &SyncBackendHost::Core::FinishConfigureDataTypes, core_.get())); | 287 base::Bind(&SyncBackendHost::Core::FinishConfigureDataTypes, |
| 288 core_.get())); |
292 } | 289 } |
293 | 290 |
294 void SyncBackendHost::StartConfiguration(const base::Closure& callback) { | 291 void SyncBackendHost::StartConfiguration(const base::Closure& callback) { |
295 // Put syncer in the config mode. DTM will put us in normal mode once it is | 292 // Put syncer in the config mode. DTM will put us in normal mode once it is |
296 // done. This is to ensure we dont do a normal sync when we are doing model | 293 // done. This is to ensure we dont do a normal sync when we are doing model |
297 // association. | 294 // association. |
298 sync_thread_.message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 295 sync_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
299 core_.get(), &SyncBackendHost::Core::DoStartConfiguration, callback)); | 296 &SyncBackendHost::Core::DoStartConfiguration, core_.get(), callback)); |
300 } | 297 } |
301 | 298 |
302 void SyncBackendHost::EnableEncryptEverything() { | 299 void SyncBackendHost::EnableEncryptEverything() { |
303 sync_thread_.message_loop()->PostTask(FROM_HERE, | 300 sync_thread_.message_loop()->PostTask(FROM_HERE, |
304 NewRunnableMethod(core_.get(), | 301 base::Bind(&SyncBackendHost::Core::DoEnableEncryptEverything, |
305 &SyncBackendHost::Core::DoEnableEncryptEverything)); | 302 core_.get())); |
306 } | 303 } |
307 | 304 |
308 void SyncBackendHost::ActivateDataType( | 305 void SyncBackendHost::ActivateDataType( |
309 syncable::ModelType type, ModelSafeGroup group, | 306 syncable::ModelType type, ModelSafeGroup group, |
310 ChangeProcessor* change_processor) { | 307 ChangeProcessor* change_processor) { |
311 registrar_->ActivateDataType(type, group, change_processor, GetUserShare()); | 308 registrar_->ActivateDataType(type, group, change_processor, GetUserShare()); |
312 } | 309 } |
313 | 310 |
314 void SyncBackendHost::DeactivateDataType(syncable::ModelType type) { | 311 void SyncBackendHost::DeactivateDataType(syncable::ModelType type) { |
315 registrar_->DeactivateDataType(type); | 312 registrar_->DeactivateDataType(type); |
316 } | 313 } |
317 | 314 |
318 bool SyncBackendHost::RequestClearServerData() { | 315 bool SyncBackendHost::RequestClearServerData() { |
319 sync_thread_.message_loop()->PostTask(FROM_HERE, | 316 sync_thread_.message_loop()->PostTask(FROM_HERE, |
320 NewRunnableMethod(core_.get(), | 317 base::Bind(&SyncBackendHost::Core::DoRequestClearServerData, |
321 &SyncBackendHost::Core::DoRequestClearServerData)); | 318 core_.get())); |
322 return true; | 319 return true; |
323 } | 320 } |
324 | 321 |
325 | |
326 sync_api::UserShare* SyncBackendHost::GetUserShare() const { | 322 sync_api::UserShare* SyncBackendHost::GetUserShare() const { |
327 DCHECK(initialized()); | 323 DCHECK(initialized()); |
328 return core_->sync_manager()->GetUserShare(); | 324 return core_->sync_manager()->GetUserShare(); |
329 } | 325 } |
330 | 326 |
331 SyncBackendHost::Status SyncBackendHost::GetDetailedStatus() { | 327 SyncBackendHost::Status SyncBackendHost::GetDetailedStatus() { |
332 DCHECK(initialized()); | 328 DCHECK(initialized()); |
333 return core_->sync_manager()->GetDetailedStatus(); | 329 return core_->sync_manager()->GetDetailedStatus(); |
334 } | 330 } |
335 | 331 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 SyncBackendHost::Core::~Core() { | 396 SyncBackendHost::Core::~Core() { |
401 DCHECK(!sync_manager_.get()); | 397 DCHECK(!sync_manager_.get()); |
402 DCHECK(!sync_loop_); | 398 DCHECK(!sync_loop_); |
403 } | 399 } |
404 | 400 |
405 void SyncBackendHost::Core::OnSyncCycleCompleted( | 401 void SyncBackendHost::Core::OnSyncCycleCompleted( |
406 const SyncSessionSnapshot* snapshot) { | 402 const SyncSessionSnapshot* snapshot) { |
407 if (!sync_loop_) | 403 if (!sync_loop_) |
408 return; | 404 return; |
409 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 405 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
410 host_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, | 406 host_->frontend_loop_->PostTask(FROM_HERE, base::Bind( |
411 &Core::HandleSyncCycleCompletedOnFrontendLoop, | 407 &Core::HandleSyncCycleCompletedOnFrontendLoop, |
| 408 this, |
412 new SyncSessionSnapshot(*snapshot))); | 409 new SyncSessionSnapshot(*snapshot))); |
413 } | 410 } |
414 | 411 |
415 | 412 |
416 void SyncBackendHost::Core::OnInitializationComplete( | 413 void SyncBackendHost::Core::OnInitializationComplete( |
417 const WeakHandle<JsBackend>& js_backend, | 414 const WeakHandle<JsBackend>& js_backend, |
418 bool success) { | 415 bool success) { |
419 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 416 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
420 | 417 |
421 host_->frontend_loop_->PostTask(FROM_HERE, | 418 host_->frontend_loop_->PostTask(FROM_HERE, |
422 NewRunnableMethod(this, | 419 base::Bind(&Core::HandleInitializationCompletedOnFrontendLoop, this, |
423 &Core::HandleInitializationCompletedOnFrontendLoop, | 420 js_backend, success)); |
424 js_backend, success)); | |
425 | 421 |
426 // Initialization is complete, so we can schedule recurring SaveChanges. | 422 // Initialization is complete, so we can schedule recurring SaveChanges. |
427 sync_loop_->PostTask(FROM_HERE, | 423 sync_loop_->PostTask(FROM_HERE, base::Bind(&Core::StartSavingChanges, this)); |
428 NewRunnableMethod(this, &Core::StartSavingChanges)); | |
429 } | 424 } |
430 | 425 |
431 void SyncBackendHost::Core::OnAuthError(const AuthError& auth_error) { | 426 void SyncBackendHost::Core::OnAuthError(const AuthError& auth_error) { |
432 if (!sync_loop_) | 427 if (!sync_loop_) |
433 return; | 428 return; |
434 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 429 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
435 // Post to our core loop so we can modify state. Could be on another thread. | 430 // Post to our core loop so we can modify state. Could be on another thread. |
436 host_->frontend_loop_->PostTask(FROM_HERE, | 431 host_->frontend_loop_->PostTask(FROM_HERE, |
437 NewRunnableMethod(this, &Core::HandleAuthErrorEventOnFrontendLoop, | 432 base::Bind(&Core::HandleAuthErrorEventOnFrontendLoop, this, auth_error)); |
438 auth_error)); | |
439 } | 433 } |
440 | 434 |
441 void SyncBackendHost::Core::OnPassphraseRequired( | 435 void SyncBackendHost::Core::OnPassphraseRequired( |
442 sync_api::PassphraseRequiredReason reason) { | 436 sync_api::PassphraseRequiredReason reason) { |
443 if (!sync_loop_) | 437 if (!sync_loop_) |
444 return; | 438 return; |
445 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 439 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
446 host_->frontend_loop_->PostTask(FROM_HERE, | 440 host_->frontend_loop_->PostTask(FROM_HERE, |
447 NewRunnableMethod(this, &Core::NotifyPassphraseRequired, reason)); | 441 base::Bind(&Core::NotifyPassphraseRequired, this, reason)); |
448 } | 442 } |
449 | 443 |
450 void SyncBackendHost::Core::OnPassphraseAccepted( | 444 void SyncBackendHost::Core::OnPassphraseAccepted( |
451 const std::string& bootstrap_token) { | 445 const std::string& bootstrap_token) { |
452 if (!sync_loop_) | 446 if (!sync_loop_) |
453 return; | 447 return; |
454 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 448 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
455 host_->frontend_loop_->PostTask(FROM_HERE, | 449 host_->frontend_loop_->PostTask(FROM_HERE, |
456 NewRunnableMethod(this, &Core::NotifyPassphraseAccepted, | 450 base::Bind(&Core::NotifyPassphraseAccepted, this, bootstrap_token)); |
457 bootstrap_token)); | |
458 } | 451 } |
459 | 452 |
460 void SyncBackendHost::Core::OnStopSyncingPermanently() { | 453 void SyncBackendHost::Core::OnStopSyncingPermanently() { |
461 if (!sync_loop_) | 454 if (!sync_loop_) |
462 return; | 455 return; |
463 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 456 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
464 host_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, | 457 host_->frontend_loop_->PostTask(FROM_HERE, base::Bind( |
465 &Core::HandleStopSyncingPermanentlyOnFrontendLoop)); | 458 &Core::HandleStopSyncingPermanentlyOnFrontendLoop, this)); |
466 } | 459 } |
467 | 460 |
468 void SyncBackendHost::Core::OnUpdatedToken(const std::string& token) { | 461 void SyncBackendHost::Core::OnUpdatedToken(const std::string& token) { |
469 if (!sync_loop_) | 462 if (!sync_loop_) |
470 return; | 463 return; |
471 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 464 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
472 host_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, | 465 host_->frontend_loop_->PostTask(FROM_HERE, base::Bind( |
473 &Core::NotifyUpdatedToken, token)); | 466 &Core::NotifyUpdatedToken, this, token)); |
474 } | 467 } |
475 | 468 |
476 void SyncBackendHost::Core::OnClearServerDataFailed() { | 469 void SyncBackendHost::Core::OnClearServerDataFailed() { |
477 if (!sync_loop_) | 470 if (!sync_loop_) |
478 return; | 471 return; |
479 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 472 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
480 host_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, | 473 host_->frontend_loop_->PostTask(FROM_HERE, base::Bind( |
481 &Core::HandleClearServerDataFailedOnFrontendLoop)); | 474 &Core::HandleClearServerDataFailedOnFrontendLoop, this)); |
482 } | 475 } |
483 | 476 |
484 void SyncBackendHost::Core::OnClearServerDataSucceeded() { | 477 void SyncBackendHost::Core::OnClearServerDataSucceeded() { |
485 if (!sync_loop_) | 478 if (!sync_loop_) |
486 return; | 479 return; |
487 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 480 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
488 host_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, | 481 host_->frontend_loop_->PostTask(FROM_HERE, base::Bind( |
489 &Core::HandleClearServerDataSucceededOnFrontendLoop)); | 482 &Core::HandleClearServerDataSucceededOnFrontendLoop, this)); |
490 } | 483 } |
491 | 484 |
492 void SyncBackendHost::Core::OnEncryptedTypesChanged( | 485 void SyncBackendHost::Core::OnEncryptedTypesChanged( |
493 const syncable::ModelTypeSet& encrypted_types, | 486 const syncable::ModelTypeSet& encrypted_types, |
494 bool encrypt_everything) { | 487 bool encrypt_everything) { |
495 if (!sync_loop_) | 488 if (!sync_loop_) |
496 return; | 489 return; |
497 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 490 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
498 // NOTE: We're in a transaction. | 491 // NOTE: We're in a transaction. |
499 host_->frontend_loop_->PostTask( | 492 host_->frontend_loop_->PostTask( |
(...skipping 12 matching lines...) Expand all Loading... |
512 base::Bind(&Core::NotifyEncryptionComplete, this)); | 505 base::Bind(&Core::NotifyEncryptionComplete, this)); |
513 } | 506 } |
514 | 507 |
515 void SyncBackendHost::Core::OnActionableError( | 508 void SyncBackendHost::Core::OnActionableError( |
516 const browser_sync::SyncProtocolError& sync_error) { | 509 const browser_sync::SyncProtocolError& sync_error) { |
517 if (!sync_loop_) | 510 if (!sync_loop_) |
518 return; | 511 return; |
519 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 512 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
520 host_->frontend_loop_->PostTask( | 513 host_->frontend_loop_->PostTask( |
521 FROM_HERE, | 514 FROM_HERE, |
522 NewRunnableMethod(this, &Core::HandleActionableErrorEventOnFrontendLoop, | 515 base::Bind(&Core::HandleActionableErrorEventOnFrontendLoop, this, |
523 sync_error)); | 516 sync_error)); |
524 } | 517 } |
525 | 518 |
526 SyncBackendHost::Core::DoInitializeOptions::DoInitializeOptions( | 519 SyncBackendHost::Core::DoInitializeOptions::DoInitializeOptions( |
527 MessageLoop* sync_loop, | 520 MessageLoop* sync_loop, |
528 SyncBackendRegistrar* registrar, | 521 SyncBackendRegistrar* registrar, |
529 const WeakHandle<JsEventHandler>& event_handler, | 522 const WeakHandle<JsEventHandler>& event_handler, |
530 const GURL& service_url, | 523 const GURL& service_url, |
531 const scoped_refptr<net::URLRequestContextGetter>& | 524 const scoped_refptr<net::URLRequestContextGetter>& |
532 request_context_getter, | 525 request_context_getter, |
533 const sync_api::SyncCredentials& credentials, | 526 const sync_api::SyncCredentials& credentials, |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 void SyncBackendHost::Core::DeleteSyncDataFolder() { | 700 void SyncBackendHost::Core::DeleteSyncDataFolder() { |
708 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 701 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
709 if (file_util::DirectoryExists(host_->sync_data_folder_path())) { | 702 if (file_util::DirectoryExists(host_->sync_data_folder_path())) { |
710 if (!file_util::Delete(host_->sync_data_folder_path(), true)) | 703 if (!file_util::Delete(host_->sync_data_folder_path(), true)) |
711 SLOG(DFATAL) << "Could not delete the Sync Data folder."; | 704 SLOG(DFATAL) << "Could not delete the Sync Data folder."; |
712 } | 705 } |
713 } | 706 } |
714 | 707 |
715 void SyncBackendHost::Core::FinishConfigureDataTypes() { | 708 void SyncBackendHost::Core::FinishConfigureDataTypes() { |
716 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 709 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
717 host_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, | 710 host_->frontend_loop_->PostTask(FROM_HERE, base::Bind( |
718 &SyncBackendHost::Core::FinishConfigureDataTypesOnFrontendLoop)); | 711 &SyncBackendHost::Core::FinishConfigureDataTypesOnFrontendLoop, this)); |
719 } | 712 } |
720 | 713 |
721 void SyncBackendHost::Core::HandleInitializationCompletedOnFrontendLoop( | 714 void SyncBackendHost::Core::HandleInitializationCompletedOnFrontendLoop( |
722 const WeakHandle<JsBackend>& js_backend, | 715 const WeakHandle<JsBackend>& js_backend, |
723 bool success) { | 716 bool success) { |
724 if (!host_) | 717 if (!host_) |
725 return; | 718 return; |
726 host_->HandleInitializationCompletedOnFrontendLoop(js_backend, success); | 719 host_->HandleInitializationCompletedOnFrontendLoop(js_backend, success); |
727 } | 720 } |
728 | 721 |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 initialization_state_ = INITIALIZED; | 932 initialization_state_ = INITIALIZED; |
940 // Now that we've downloaded the nigori node, we can see if there are any | 933 // Now that we've downloaded the nigori node, we can see if there are any |
941 // experimental types to enable. This should be done before we inform | 934 // experimental types to enable. This should be done before we inform |
942 // the frontend to ensure they're visible in the customize screen. | 935 // the frontend to ensure they're visible in the customize screen. |
943 AddExperimentalTypes(); | 936 AddExperimentalTypes(); |
944 frontend_->OnBackendInitialized(js_backend, true); | 937 frontend_->OnBackendInitialized(js_backend, true); |
945 // Now that we're fully initialized, kick off a server | 938 // Now that we're fully initialized, kick off a server |
946 // reachability check. | 939 // reachability check. |
947 sync_thread_.message_loop()->PostTask( | 940 sync_thread_.message_loop()->PostTask( |
948 FROM_HERE, | 941 FROM_HERE, |
949 NewRunnableMethod( | 942 base::Bind(&SyncBackendHost::Core::DoCheckServerReachable, |
950 core_.get(), | 943 core_.get())); |
951 &SyncBackendHost::Core::DoCheckServerReachable)); | |
952 break; | 944 break; |
953 default: | 945 default: |
954 NOTREACHED(); | 946 NOTREACHED(); |
955 } | 947 } |
956 } | 948 } |
957 | 949 |
958 void SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop() { | 950 void SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop() { |
959 DCHECK_EQ(MessageLoop::current(), frontend_loop_); | 951 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
960 // Nudge the syncer. This is necessary for both datatype addition/deletion. | 952 // Nudge the syncer. This is necessary for both datatype addition/deletion. |
961 // | 953 // |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 | 986 |
995 // Always configure nigori if it's enabled. | 987 // Always configure nigori if it's enabled. |
996 syncable::ModelTypeSet types_to_config = | 988 syncable::ModelTypeSet types_to_config = |
997 pending_download_state_->added_types; | 989 pending_download_state_->added_types; |
998 if (IsNigoriEnabled()) { | 990 if (IsNigoriEnabled()) { |
999 types_to_config.insert(syncable::NIGORI); | 991 types_to_config.insert(syncable::NIGORI); |
1000 } | 992 } |
1001 SVLOG(1) << "Types " << ModelTypeSetToString(types_to_config) | 993 SVLOG(1) << "Types " << ModelTypeSetToString(types_to_config) |
1002 << " added; calling DoRequestConfig"; | 994 << " added; calling DoRequestConfig"; |
1003 sync_thread_.message_loop()->PostTask(FROM_HERE, | 995 sync_thread_.message_loop()->PostTask(FROM_HERE, |
1004 NewRunnableMethod(core_.get(), | 996 base::Bind(&SyncBackendHost::Core::DoRequestConfig, |
1005 &SyncBackendHost::Core::DoRequestConfig, | 997 core_.get(), |
1006 syncable::ModelTypeBitSetFromSet(types_to_config), | 998 syncable::ModelTypeBitSetFromSet(types_to_config), |
1007 pending_download_state_->reason)); | 999 pending_download_state_->reason)); |
1008 } | 1000 } |
1009 | 1001 |
1010 pending_config_mode_state_.reset(); | 1002 pending_config_mode_state_.reset(); |
1011 | 1003 |
1012 // Notify the SyncManager about the new types. | 1004 // Notify the SyncManager about the new types. |
1013 sync_thread_.message_loop()->PostTask(FROM_HERE, | 1005 sync_thread_.message_loop()->PostTask(FROM_HERE, |
1014 NewRunnableMethod(core_.get(), | 1006 base::Bind(&SyncBackendHost::Core::DoUpdateEnabledTypes, core_.get())); |
1015 &SyncBackendHost::Core::DoUpdateEnabledTypes)); | |
1016 } | 1007 } |
1017 | 1008 |
1018 sync_api::HttpPostProviderFactory* SyncBackendHost::MakeHttpBridgeFactory( | 1009 sync_api::HttpPostProviderFactory* SyncBackendHost::MakeHttpBridgeFactory( |
1019 const scoped_refptr<net::URLRequestContextGetter>& getter) { | 1010 const scoped_refptr<net::URLRequestContextGetter>& getter) { |
1020 return new HttpBridgeFactory(getter); | 1011 return new HttpBridgeFactory(getter); |
1021 } | 1012 } |
1022 | 1013 |
1023 void SyncBackendHost::PersistEncryptionBootstrapToken( | 1014 void SyncBackendHost::PersistEncryptionBootstrapToken( |
1024 const std::string& token) { | 1015 const std::string& token) { |
1025 CHECK(sync_prefs_.get()); | 1016 CHECK(sync_prefs_.get()); |
(...skipping 27 matching lines...) Expand all Loading... |
1053 FROM_HERE, | 1044 FROM_HERE, |
1054 base::Bind(&SyncBackendHost::Core::DoRefreshEncryption, | 1045 base::Bind(&SyncBackendHost::Core::DoRefreshEncryption, |
1055 core_.get(), sync_thread_done_callback)); | 1046 core_.get(), sync_thread_done_callback)); |
1056 } | 1047 } |
1057 | 1048 |
1058 #undef SVLOG | 1049 #undef SVLOG |
1059 | 1050 |
1060 #undef SLOG | 1051 #undef SLOG |
1061 | 1052 |
1062 } // namespace browser_sync | 1053 } // namespace browser_sync |
OLD | NEW |