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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host.cc

Issue 6902101: Refactor sync passphrase setup flow and fix passphrase tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 9 years, 7 months 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 | Annotate | Revision Log
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 bool SyncBackendHost::RequestClearServerData() { 521 bool SyncBackendHost::RequestClearServerData() {
522 core_thread_.message_loop()->PostTask(FROM_HERE, 522 core_thread_.message_loop()->PostTask(FROM_HERE,
523 NewRunnableMethod(core_.get(), 523 NewRunnableMethod(core_.get(),
524 &SyncBackendHost::Core::DoRequestClearServerData)); 524 &SyncBackendHost::Core::DoRequestClearServerData));
525 return true; 525 return true;
526 } 526 }
527 527
528 SyncBackendHost::Core::~Core() { 528 SyncBackendHost::Core::~Core() {
529 } 529 }
530 530
531 void SyncBackendHost::Core::NotifyPassphraseRequired(bool for_decryption) { 531 void SyncBackendHost::Core::NotifyPassphraseRequired(
532 sync_api::PassphraseRequiredReason reason) {
532 if (!host_ || !host_->frontend_) 533 if (!host_ || !host_->frontend_)
533 return; 534 return;
534 535
535 DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_); 536 DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_);
536 537
538 // When setting a passphrase fails, unset our waiting flag.
539 if (reason == sync_api::REASON_SET_PASSPHRASE_FAILED)
540 processing_passphrase_ = false;
541
537 if (processing_passphrase_) { 542 if (processing_passphrase_) {
538 VLOG(1) << "Core received OnPassphraseRequired while processing a " 543 VLOG(1) << "Core received OnPassphraseRequired while processing a "
539 << "passphrase. Silently dropping."; 544 << "passphrase. Silently dropping.";
540 return; 545 return;
541 } 546 }
542 host_->frontend_->OnPassphraseRequired(for_decryption);
543 }
544 547
545 void SyncBackendHost::Core::NotifyPassphraseFailed() { 548 host_->frontend_->OnPassphraseRequired(reason);
546 if (!host_ || !host_->frontend_)
547 return;
548
549 DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_);
550
551 // When a passphrase fails, we just unset our waiting flag and trigger a
552 // OnPassphraseRequired(true).
553 processing_passphrase_ = false;
554 host_->frontend_->OnPassphraseRequired(true);
555 } 549 }
556 550
557 void SyncBackendHost::Core::NotifyPassphraseAccepted( 551 void SyncBackendHost::Core::NotifyPassphraseAccepted(
558 const std::string& bootstrap_token) { 552 const std::string& bootstrap_token) {
559 if (!host_ || !host_->frontend_) 553 if (!host_ || !host_->frontend_)
560 return; 554 return;
561 555
562 DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_); 556 DCHECK_EQ(MessageLoop::current(), host_->frontend_loop_);
563 557
564 processing_passphrase_ = false; 558 processing_passphrase_ = false;
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 return worker->CurrentThreadIsWorkThread(); 959 return worker->CurrentThreadIsWorkThread();
966 } 960 }
967 961
968 void SyncBackendHost::Core::OnAuthError(const AuthError& auth_error) { 962 void SyncBackendHost::Core::OnAuthError(const AuthError& auth_error) {
969 // Post to our core loop so we can modify state. Could be on another thread. 963 // Post to our core loop so we can modify state. Could be on another thread.
970 host_->frontend_loop_->PostTask(FROM_HERE, 964 host_->frontend_loop_->PostTask(FROM_HERE,
971 NewRunnableMethod(this, &Core::HandleAuthErrorEventOnFrontendLoop, 965 NewRunnableMethod(this, &Core::HandleAuthErrorEventOnFrontendLoop,
972 auth_error)); 966 auth_error));
973 } 967 }
974 968
975 void SyncBackendHost::Core::OnPassphraseRequired(bool for_decryption) { 969 void SyncBackendHost::Core::OnPassphraseRequired(
970 sync_api::PassphraseRequiredReason reason) {
976 host_->frontend_loop_->PostTask(FROM_HERE, 971 host_->frontend_loop_->PostTask(FROM_HERE,
977 NewRunnableMethod(this, &Core::NotifyPassphraseRequired, for_decryption)); 972 NewRunnableMethod(this, &Core::NotifyPassphraseRequired, reason));
978 }
979
980 void SyncBackendHost::Core::OnPassphraseFailed() {
981 host_->frontend_loop_->PostTask(FROM_HERE,
982 NewRunnableMethod(this, &Core::NotifyPassphraseFailed));
983 } 973 }
984 974
985 void SyncBackendHost::Core::OnPassphraseAccepted( 975 void SyncBackendHost::Core::OnPassphraseAccepted(
986 const std::string& bootstrap_token) { 976 const std::string& bootstrap_token) {
987 host_->frontend_loop_->PostTask(FROM_HERE, 977 host_->frontend_loop_->PostTask(FROM_HERE,
988 NewRunnableMethod(this, &Core::NotifyPassphraseAccepted, 978 NewRunnableMethod(this, &Core::NotifyPassphraseAccepted,
989 bootstrap_token)); 979 bootstrap_token));
990 } 980 }
991 981
992 void SyncBackendHost::Core::OnStopSyncingPermanently() { 982 void SyncBackendHost::Core::OnStopSyncingPermanently() {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop()); 1144 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop());
1155 syncapi_->GetJsBackend()->ProcessMessage(name, args, sender); 1145 syncapi_->GetJsBackend()->ProcessMessage(name, args, sender);
1156 } 1146 }
1157 1147
1158 void SyncBackendHost::Core::DeferNudgeForCleanup() { 1148 void SyncBackendHost::Core::DeferNudgeForCleanup() {
1159 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop()); 1149 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop());
1160 deferred_nudge_for_cleanup_requested_ = true; 1150 deferred_nudge_for_cleanup_requested_ = true;
1161 } 1151 }
1162 1152
1163 } // namespace browser_sync 1153 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698