| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/file_version_info.h" | 7 #include "base/file_version_info.h" |
| 8 #include "base/task.h" | 8 #include "base/task.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/app/chrome_version_info.h" | 10 #include "chrome/app/chrome_version_info.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 new PasswordModelWorker( | 94 new PasswordModelWorker( |
| 95 profile_->GetPasswordStore(Profile::IMPLICIT_ACCESS)); | 95 profile_->GetPasswordStore(Profile::IMPLICIT_ACCESS)); |
| 96 | 96 |
| 97 // Any datatypes that we want the syncer to pull down must | 97 // Any datatypes that we want the syncer to pull down must |
| 98 // be in the routing_info map. We set them to group passive, meaning that | 98 // be in the routing_info map. We set them to group passive, meaning that |
| 99 // updates will be applied, but not dispatched to the UI thread yet. | 99 // updates will be applied, but not dispatched to the UI thread yet. |
| 100 for (syncable::ModelTypeSet::const_iterator it = types.begin(); | 100 for (syncable::ModelTypeSet::const_iterator it = types.begin(); |
| 101 it != types.end(); ++it) { | 101 it != types.end(); ++it) { |
| 102 registrar_.routing_info[(*it)] = GROUP_PASSIVE; | 102 registrar_.routing_info[(*it)] = GROUP_PASSIVE; |
| 103 } | 103 } |
| 104 registrar_.routing_info[syncable::NIGORI] = GROUP_PASSIVE; |
| 104 | 105 |
| 105 core_thread_.message_loop()->PostTask(FROM_HERE, | 106 core_thread_.message_loop()->PostTask(FROM_HERE, |
| 106 NewRunnableMethod(core_.get(), &SyncBackendHost::Core::DoInitialize, | 107 NewRunnableMethod(core_.get(), &SyncBackendHost::Core::DoInitialize, |
| 107 Core::DoInitializeOptions( | 108 Core::DoInitializeOptions( |
| 108 sync_service_url, true, | 109 sync_service_url, true, |
| 109 network_change_notifier_thread, | 110 network_change_notifier_thread, |
| 110 new HttpBridgeFactory(baseline_context_getter), | 111 new HttpBridgeFactory(baseline_context_getter), |
| 111 new HttpBridgeFactory(baseline_context_getter), | 112 new HttpBridgeFactory(baseline_context_getter), |
| 112 lsid, | 113 lsid, |
| 113 delete_sync_data_folder, | 114 delete_sync_data_folder, |
| 114 invalidate_sync_login, | 115 invalidate_sync_login, |
| 115 invalidate_sync_xmpp_login, | 116 invalidate_sync_xmpp_login, |
| 116 notification_method))); | 117 notification_method))); |
| 117 } | 118 } |
| 118 | 119 |
| 119 void SyncBackendHost::Authenticate(const std::string& username, | 120 void SyncBackendHost::Authenticate(const std::string& username, |
| 120 const std::string& password, | 121 const std::string& password, |
| 121 const std::string& captcha) { | 122 const std::string& captcha) { |
| 122 core_thread_.message_loop()->PostTask(FROM_HERE, | 123 core_thread_.message_loop()->PostTask(FROM_HERE, |
| 123 NewRunnableMethod(core_.get(), &SyncBackendHost::Core::DoAuthenticate, | 124 NewRunnableMethod(core_.get(), &SyncBackendHost::Core::DoAuthenticate, |
| 124 username, password, captcha)); | 125 username, password, captcha)); |
| 125 } | 126 } |
| 126 | 127 |
| 127 void SyncBackendHost::StartSyncing() { | 128 void SyncBackendHost::StartSyncing() { |
| 128 core_thread_.message_loop()->PostTask(FROM_HERE, | 129 core_thread_.message_loop()->PostTask(FROM_HERE, |
| 129 NewRunnableMethod(core_.get(), &SyncBackendHost::Core::DoStartSyncing)); | 130 NewRunnableMethod(core_.get(), &SyncBackendHost::Core::DoStartSyncing)); |
| 130 } | 131 } |
| 131 | 132 |
| 133 void SyncBackendHost::SetPassphrase(const std::string& passphrase) { |
| 134 core_thread_.message_loop()->PostTask(FROM_HERE, |
| 135 NewRunnableMethod(core_.get(), &SyncBackendHost::Core::DoSetPassphrase, |
| 136 passphrase)); |
| 137 } |
| 138 |
| 132 void SyncBackendHost::Shutdown(bool sync_disabled) { | 139 void SyncBackendHost::Shutdown(bool sync_disabled) { |
| 133 // Thread shutdown should occur in the following order: | 140 // Thread shutdown should occur in the following order: |
| 134 // - SyncerThread | 141 // - SyncerThread |
| 135 // - CoreThread | 142 // - CoreThread |
| 136 // - UI Thread (stops some time after we return from this call). | 143 // - UI Thread (stops some time after we return from this call). |
| 137 core_thread_.message_loop()->PostTask(FROM_HERE, | 144 core_thread_.message_loop()->PostTask(FROM_HERE, |
| 138 NewRunnableMethod(core_.get(), | 145 NewRunnableMethod(core_.get(), |
| 139 &SyncBackendHost::Core::DoShutdown, | 146 &SyncBackendHost::Core::DoShutdown, |
| 140 sync_disabled)); | 147 sync_disabled)); |
| 141 | 148 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 NotificationService::AllSources(), | 275 NotificationService::AllSources(), |
| 269 NotificationService::NoDetails()); | 276 NotificationService::NoDetails()); |
| 270 } | 277 } |
| 271 | 278 |
| 272 void SyncBackendHost::Core::NotifyResumed() { | 279 void SyncBackendHost::Core::NotifyResumed() { |
| 273 NotificationService::current()->Notify(NotificationType::SYNC_RESUMED, | 280 NotificationService::current()->Notify(NotificationType::SYNC_RESUMED, |
| 274 NotificationService::AllSources(), | 281 NotificationService::AllSources(), |
| 275 NotificationService::NoDetails()); | 282 NotificationService::NoDetails()); |
| 276 } | 283 } |
| 277 | 284 |
| 285 void SyncBackendHost::Core::NotifyPassphraseRequired() { |
| 286 NotificationService::current()->Notify( |
| 287 NotificationType::SYNC_PASSPHRASE_REQUIRED, |
| 288 NotificationService::AllSources(), |
| 289 NotificationService::NoDetails()); |
| 290 } |
| 291 |
| 292 void SyncBackendHost::Core::NotifyPassphraseAccepted() { |
| 293 NotificationService::current()->Notify( |
| 294 NotificationType::SYNC_PASSPHRASE_ACCEPTED, |
| 295 NotificationService::AllSources(), |
| 296 NotificationService::NoDetails()); |
| 297 } |
| 298 |
| 278 SyncBackendHost::UserShareHandle SyncBackendHost::GetUserShareHandle() const { | 299 SyncBackendHost::UserShareHandle SyncBackendHost::GetUserShareHandle() const { |
| 279 return core_->syncapi()->GetUserShare(); | 300 return core_->syncapi()->GetUserShare(); |
| 280 } | 301 } |
| 281 | 302 |
| 282 SyncBackendHost::Status SyncBackendHost::GetDetailedStatus() { | 303 SyncBackendHost::Status SyncBackendHost::GetDetailedStatus() { |
| 283 return core_->syncapi()->GetDetailedStatus(); | 304 return core_->syncapi()->GetDetailedStatus(); |
| 284 } | 305 } |
| 285 | 306 |
| 286 SyncBackendHost::StatusSummary SyncBackendHost::GetStatusSummary() { | 307 SyncBackendHost::StatusSummary SyncBackendHost::GetStatusSummary() { |
| 287 return core_->syncapi()->GetStatusSummary(); | 308 return core_->syncapi()->GetStatusSummary(); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 const std::string& captcha) { | 414 const std::string& captcha) { |
| 394 DCHECK(MessageLoop::current() == host_->core_thread_.message_loop()); | 415 DCHECK(MessageLoop::current() == host_->core_thread_.message_loop()); |
| 395 syncapi_->Authenticate(username.c_str(), password.c_str(), captcha.c_str()); | 416 syncapi_->Authenticate(username.c_str(), password.c_str(), captcha.c_str()); |
| 396 } | 417 } |
| 397 | 418 |
| 398 void SyncBackendHost::Core::DoStartSyncing() { | 419 void SyncBackendHost::Core::DoStartSyncing() { |
| 399 DCHECK(MessageLoop::current() == host_->core_thread_.message_loop()); | 420 DCHECK(MessageLoop::current() == host_->core_thread_.message_loop()); |
| 400 syncapi_->StartSyncing(); | 421 syncapi_->StartSyncing(); |
| 401 } | 422 } |
| 402 | 423 |
| 424 void SyncBackendHost::Core::DoSetPassphrase(const std::string& passphrase) { |
| 425 DCHECK(MessageLoop::current() == host_->core_thread_.message_loop()); |
| 426 syncapi_->SetPassphrase(passphrase); |
| 427 } |
| 428 |
| 403 UIModelWorker* SyncBackendHost::ui_worker() { | 429 UIModelWorker* SyncBackendHost::ui_worker() { |
| 404 ModelSafeWorker* w = registrar_.workers[GROUP_UI]; | 430 ModelSafeWorker* w = registrar_.workers[GROUP_UI]; |
| 405 if (w == NULL) | 431 if (w == NULL) |
| 406 return NULL; | 432 return NULL; |
| 407 if (w->GetModelSafeGroup() != GROUP_UI) | 433 if (w->GetModelSafeGroup() != GROUP_UI) |
| 408 NOTREACHED(); | 434 NOTREACHED(); |
| 409 return static_cast<UIModelWorker*>(w); | 435 return static_cast<UIModelWorker*>(w); |
| 410 } | 436 } |
| 411 | 437 |
| 412 void SyncBackendHost::Core::DoShutdown(bool sync_disabled) { | 438 void SyncBackendHost::Core::DoShutdown(bool sync_disabled) { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 | 562 |
| 537 | 563 |
| 538 void SyncBackendHost::Core::OnAuthError(const AuthError& auth_error) { | 564 void SyncBackendHost::Core::OnAuthError(const AuthError& auth_error) { |
| 539 // We could be on SyncEngine_AuthWatcherThread. Post to our core loop so | 565 // We could be on SyncEngine_AuthWatcherThread. Post to our core loop so |
| 540 // we can modify state. | 566 // we can modify state. |
| 541 host_->frontend_loop_->PostTask(FROM_HERE, | 567 host_->frontend_loop_->PostTask(FROM_HERE, |
| 542 NewRunnableMethod(this, &Core::HandleAuthErrorEventOnFrontendLoop, | 568 NewRunnableMethod(this, &Core::HandleAuthErrorEventOnFrontendLoop, |
| 543 auth_error)); | 569 auth_error)); |
| 544 } | 570 } |
| 545 | 571 |
| 572 void SyncBackendHost::Core::OnPassphraseRequired() { |
| 573 host_->frontend_loop_->PostTask(FROM_HERE, |
| 574 NewRunnableMethod(this, &Core::NotifyPassphraseRequired)); |
| 575 } |
| 576 |
| 577 void SyncBackendHost::Core::OnPassphraseAccepted() { |
| 578 host_->frontend_loop_->PostTask(FROM_HERE, |
| 579 NewRunnableMethod(this, &Core::NotifyPassphraseAccepted)); |
| 580 } |
| 581 |
| 546 void SyncBackendHost::Core::OnPaused() { | 582 void SyncBackendHost::Core::OnPaused() { |
| 547 host_->frontend_loop_->PostTask( | 583 host_->frontend_loop_->PostTask( |
| 548 FROM_HERE, | 584 FROM_HERE, |
| 549 NewRunnableMethod(this, &Core::NotifyPaused)); | 585 NewRunnableMethod(this, &Core::NotifyPaused)); |
| 550 } | 586 } |
| 551 | 587 |
| 552 void SyncBackendHost::Core::OnResumed() { | 588 void SyncBackendHost::Core::OnResumed() { |
| 553 host_->frontend_loop_->PostTask( | 589 host_->frontend_loop_->PostTask( |
| 554 FROM_HERE, | 590 FROM_HERE, |
| 555 NewRunnableMethod(this, &Core::NotifyResumed)); | 591 NewRunnableMethod(this, &Core::NotifyResumed)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 577 } | 613 } |
| 578 | 614 |
| 579 void SyncBackendHost::Core::DeleteSyncDataFolder() { | 615 void SyncBackendHost::Core::DeleteSyncDataFolder() { |
| 580 if (file_util::DirectoryExists(host_->sync_data_folder_path())) { | 616 if (file_util::DirectoryExists(host_->sync_data_folder_path())) { |
| 581 if (!file_util::Delete(host_->sync_data_folder_path(), true)) | 617 if (!file_util::Delete(host_->sync_data_folder_path(), true)) |
| 582 LOG(DFATAL) << "Could not delete the Sync Data folder."; | 618 LOG(DFATAL) << "Could not delete the Sync Data folder."; |
| 583 } | 619 } |
| 584 } | 620 } |
| 585 | 621 |
| 586 } // namespace browser_sync | 622 } // namespace browser_sync |
| OLD | NEW |