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

Unified Diff: chrome/browser/sync/profile_sync_service_harness.cc

Issue 5801003: Fix passphrase initialization flow in ProfileSyncServiceHarness (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding 2 new tests for Passphrases. Created 10 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/profile_sync_service_harness.cc
diff --git a/chrome/browser/sync/profile_sync_service_harness.cc b/chrome/browser/sync/profile_sync_service_harness.cc
index 7922a0e95958cb04298a290eb82a38f0850656c7..a95ba3fb53f353c99ca72b709f5f5ffe34d0204b 100644
--- a/chrome/browser/sync/profile_sync_service_harness.cc
+++ b/chrome/browser/sync/profile_sync_service_harness.cc
@@ -95,7 +95,6 @@ ProfileSyncServiceHarness::ProfileSyncServiceHarness(
min_timestamp_needed_(kMinTimestampNeededNone),
username_(username),
password_(password),
- passphrase_acceptance_counter_(0),
id_(id) {
if (IsSyncAlreadySetup()) {
service_ = profile_->GetProfileSyncService();
@@ -133,16 +132,6 @@ bool ProfileSyncServiceHarness::SetupSync() {
return SetupSync(synced_datatypes);
}
-void ProfileSyncServiceHarness::StartObservingPassphraseEvents() {
- // Prime the counter to account for the implicit set passphrase due to
- // gaia login.
- passphrase_acceptance_counter_--;
- registrar_.Add(this, NotificationType::SYNC_PASSPHRASE_ACCEPTED,
- Source<browser_sync::SyncBackendHost>(service_->backend()));
- registrar_.Add(this, NotificationType::SYNC_PASSPHRASE_REQUIRED,
- Source<browser_sync::SyncBackendHost>(service_->backend()));
-}
-
bool ProfileSyncServiceHarness::SetupSync(
const syncable::ModelTypeSet& synced_datatypes) {
// Initialize the sync client's profile sync service object.
@@ -185,10 +174,6 @@ bool ProfileSyncServiceHarness::SetupSync(
return false;
}
- DCHECK(service()->observed_passphrase_required());
- if (id_ == 0)
- DCHECK(!service()->passphrase_required_for_decryption());
-
// Wait for initial gaia passphrase to be accepted.
DCHECK_EQ(wait_state_, WAITING_FOR_PASSPHRASE_ACCEPTED);
if (!AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs,
@@ -231,21 +216,26 @@ bool ProfileSyncServiceHarness::RunStateChangeMachine() {
case WAITING_FOR_ON_BACKEND_INITIALIZED: {
LogClientInfo("WAITING_FOR_ON_BACKEND_INITIALIZED");
if (service()->sync_initialized()) {
- // The sync backend is initialized. Watch for passphrase events.
- StartObservingPassphraseEvents();
+ // The sync backend is initialized. We now wait for passphrase events.
SignalStateCompleteWithNextState(WAITING_FOR_PASSPHRASE_REQUIRED);
}
break;
}
case WAITING_FOR_PASSPHRASE_REQUIRED: {
LogClientInfo("WAITING_FOR_PASSPHRASE_REQUIRED");
- if (service_->observed_passphrase_required())
+ if (service()->observed_passphrase_required()) {
+ // Special case when the first client signs in to sync.
+ if (id_ == 0)
+ DCHECK(!service()->passphrase_required_for_decryption());
+ // The SYNC_PASSPHRASE_REQUIRED notification has been seen.
SignalStateCompleteWithNextState(WAITING_FOR_PASSPHRASE_ACCEPTED);
+ }
break;
}
case WAITING_FOR_PASSPHRASE_ACCEPTED: {
LogClientInfo("WAITING_FOR_PASSPHRASE_ACCEPTED");
- if (passphrase_acceptance_counter_ >= 0)
+ if (service()->ShouldPushChanges())
+ // The SYNC_PASSPHRASE_ACCEPTED notification has been seen.
SignalStateCompleteWithNextState(WAITING_FOR_INITIAL_SYNC);
break;
}
@@ -319,25 +309,11 @@ bool ProfileSyncServiceHarness::AwaitPassphraseAccepted() {
LOG(ERROR) << "Sync disabled for Client " << id_ << ".";
return false;
}
- passphrase_acceptance_counter_--;
- if (passphrase_acceptance_counter_ >= 0)
- return true;
wait_state_ = WAITING_FOR_PASSPHRASE_ACCEPTED;
return AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs,
"Waiting for passphrase accepted.");
}
-void ProfileSyncServiceHarness::Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- if (NotificationType::SYNC_PASSPHRASE_ACCEPTED == type.value) {
- passphrase_acceptance_counter_++;
- RunStateChangeMachine();
- } else if (NotificationType::SYNC_PASSPHRASE_REQUIRED == type.value) {
- RunStateChangeMachine();
- }
-}
-
bool ProfileSyncServiceHarness::AwaitSyncCycleCompletion(
const std::string& reason) {
LogClientInfo("AwaitSyncCycleCompletion");
« no previous file with comments | « chrome/browser/sync/profile_sync_service_harness.h ('k') | chrome/test/live_sync/two_client_live_passwords_sync_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698