Index: chrome/browser/sync/test/integration/profile_sync_service_harness.cc |
diff --git a/chrome/browser/sync/test/integration/profile_sync_service_harness.cc b/chrome/browser/sync/test/integration/profile_sync_service_harness.cc |
index 97f45645a54a9bc05db265383cc7f7fa1849b5c1..0e823f1339bb0f2cd1b26e44af3ffbce54ea5d1c 100644 |
--- a/chrome/browser/sync/test/integration/profile_sync_service_harness.cc |
+++ b/chrome/browser/sync/test/integration/profile_sync_service_harness.cc |
@@ -130,19 +130,30 @@ void ProfileSyncServiceHarness::SetCredentials(const std::string& username, |
} |
bool ProfileSyncServiceHarness::SetupSync() { |
- bool result = SetupSync(syncer::UserSelectableTypes()); |
- if (result == false) { |
- std::string status = GetServiceStatus(); |
- LOG(ERROR) << profile_debug_name_ |
- << ": SetupSync failed. Syncer status:\n" << status; |
+ bool result = SetupSync(syncer::UserSelectableTypes(), false); |
+ if (!result) { |
+ LOG(ERROR) << profile_debug_name_ << ": SetupSync failed. Syncer status:\n" |
+ << GetServiceStatus(); |
} else { |
DVLOG(1) << profile_debug_name_ << ": SetupSync successful."; |
} |
return result; |
} |
-bool ProfileSyncServiceHarness::SetupSync( |
- syncer::ModelTypeSet synced_datatypes) { |
+bool ProfileSyncServiceHarness::SetupSyncForClear() { |
+ bool result = SetupSync(syncer::UserSelectableTypes(), true); |
+ if (!result) { |
+ LOG(ERROR) << profile_debug_name_ |
+ << ": SetupSyncForClear failed. Syncer status:\n" |
+ << GetServiceStatus(); |
+ } else { |
+ DVLOG(1) << profile_debug_name_ << ": SetupSyncForClear successful."; |
+ } |
+ return result; |
+} |
+ |
+bool ProfileSyncServiceHarness::SetupSync(syncer::ModelTypeSet synced_datatypes, |
+ bool forClear) { |
skym
2017/03/08 00:23:48
should be named for_clear. https://google.github.i
wylieb
2017/03/08 00:58:51
Done.
|
DCHECK(!profile_->IsLegacySupervised()) |
<< "SetupSync should not be used for legacy supervised users."; |
@@ -179,7 +190,9 @@ bool ProfileSyncServiceHarness::SetupSync( |
// Now that auth is completed, request that sync actually start. |
service()->RequestStart(); |
- if (!AwaitEngineInitialization()) { |
+ if (forClear && !AwaitEngineInitializationForClear()) { |
+ return false; |
+ } else if (!forClear && !AwaitEngineInitialization()) { |
return false; |
} |
@@ -199,6 +212,12 @@ bool ProfileSyncServiceHarness::SetupSync( |
return false; |
} |
+ // If we're setting up for clear, we don't need to wait for passphrase |
+ // decryption or setup completion. |
skym
2017/03/08 00:23:48
I'd just drop the "passphrase description or", I'm
wylieb
2017/03/08 00:58:51
Done.
|
+ if (forClear) { |
+ return true; |
+ } |
+ |
// Set an implicit passphrase for encryption if an explicit one hasn't already |
// been set. If an explicit passphrase has been set, immediately return false, |
// since a decryption passphrase is required. |
@@ -212,13 +231,40 @@ bool ProfileSyncServiceHarness::SetupSync( |
// Wait for initial sync cycle to be completed. |
if (!AwaitSyncSetupCompletion()) { |
- LOG(ERROR) << "Initial sync cycle timed out."; |
return false; |
} |
return true; |
} |
+bool ProfileSyncServiceHarness::RestartSyncService() { |
+ auto blocker = service()->GetSetupInProgressHandle(); |
skym
2017/03/08 00:23:48
I think auto is bad here. You're obscuring if this
wylieb
2017/03/08 00:58:51
Done.
|
+ DVLOG(1) << "Requesting stop for service."; |
+ service()->RequestStop(ProfileSyncService::CLEAR_DATA); |
+ DVLOG(1) << "Requesting start for service"; |
+ |
+ service()->RequestStart(); |
+ if (!AwaitEngineInitialization()) { |
+ LOG(ERROR) << "AwaitEngineInitialization failed."; |
+ return false; |
+ } |
+ |
+ // This passphrase should be implicit because ClearServerData should be called |
skym
2017/03/08 00:23:48
Erm, doesn't implicit mean that it is the GAIA pas
wylieb
2017/03/08 00:58:51
Done.
|
+ // prior. |
+ if (!service()->IsUsingSecondaryPassphrase()) { |
+ service()->SetEncryptionPassphrase(password_, ProfileSyncService::IMPLICIT); |
+ } else { |
+ LOG(ERROR) << "A passphrase is required for decryption. Sync cannot proceed" |
+ " until SetDecryptionPassphrase is called."; |
+ return false; |
+ } |
+ |
+ blocker.reset(); |
skym
2017/03/08 00:23:48
You shouldn't need this, it'll be destructed when
wylieb
2017/03/08 00:58:51
Done.
|
+ service()->SetFirstSetupComplete(); |
skym
2017/03/08 00:23:48
I'm confused why you need both the blocker and thi
wylieb
2017/03/08 00:58:51
Seems like something to be addressed in another CL
skym
2017/03/08 19:15:02
Okay... I'm okay with you having both the SetFirst
|
+ |
+ return true; |
+} |
+ |
bool ProfileSyncServiceHarness::AwaitMutualSyncCycleCompletion( |
ProfileSyncServiceHarness* partner) { |
std::vector<ProfileSyncServiceHarness*> harnesses; |
@@ -272,6 +318,27 @@ bool ProfileSyncServiceHarness::AwaitEngineInitialization() { |
return true; |
} |
+bool ProfileSyncServiceHarness::AwaitEngineInitializationForClear() { |
+ if (!EngineInitializeChecker(service()).Wait()) { |
+ LOG(ERROR) |
+ << "Initializing up for clear: EngineInitializeChecker timed out."; |
+ return false; |
+ } |
+ |
+ if (!service()->IsEngineInitialized()) { |
+ LOG(ERROR) << "Initializing up for clear: Service engine not initialized."; |
+ return false; |
+ } |
+ |
+ if (HasAuthError(service())) { |
+ LOG(ERROR) << "Initializing up for clear: Credentials were rejected. Sync " |
+ "cannot proceed."; |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
bool ProfileSyncServiceHarness::AwaitSyncSetupCompletion() { |
if (!SyncSetupChecker(service()).Wait()) { |
LOG(ERROR) << "SyncSetupChecker timed out."; |