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

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

Issue 2716413003: Initial clear server data impl (Closed)
Patch Set: Responding to Pavel's comments. Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
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..bce68a5ca399dd98bc7af4c29027983d68339a0e 100644
--- a/chrome/browser/sync/test/integration/profile_sync_service_harness.cc
+++ b/chrome/browser/sync/test/integration/profile_sync_service_harness.cc
@@ -76,16 +76,26 @@ class SyncSetupChecker : public SingleClientStatusChangeChecker {
: SingleClientStatusChangeChecker(service) {}
bool IsExitConditionSatisfied() override {
- if (!service()->IsSyncActive())
+ LOG(WARNING) << "ISEXIT";
pavely 2017/03/10 06:14:41 Cleanup.
wylieb 2017/03/10 20:44:01 Done.
+ if (!service()->IsSyncActive()) {
+ LOG(WARNING) << "ISEXIT";
return false;
- if (service()->ConfigurationDone())
+ }
+ if (service()->ConfigurationDone()) {
+ LOG(WARNING) << "ISEXIT";
return true;
+ }
// Sync is blocked because a custom passphrase is required.
- if (service()->passphrase_required_reason() == syncer::REASON_DECRYPTION)
+ if (service()->passphrase_required_reason() == syncer::REASON_DECRYPTION) {
+ LOG(WARNING) << "ISEXIT";
return true;
+ }
// Sync is blocked by an auth error.
- if (HasAuthError(service()))
+ if (HasAuthError(service())) {
+ LOG(WARNING) << "ISEXIT";
return true;
+ }
+ LOG(WARNING) << "ISEXIT";
// Still waiting on sync setup.
return false;
}
@@ -130,19 +140,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);
pavely 2017/03/10 06:14:42 Yeah... That's the issue with negative parameters.
wylieb 2017/03/10 20:44:01 Done.
+ 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 skip_passphrase_verification) {
DCHECK(!profile_->IsLegacySupervised())
<< "SetupSync should not be used for legacy supervised users.";
@@ -179,10 +200,9 @@ bool ProfileSyncServiceHarness::SetupSync(
// Now that auth is completed, request that sync actually start.
service()->RequestStart();
- if (!AwaitEngineInitialization()) {
+ if (!AwaitEngineInitialization(!skip_passphrase_verification)) {
pavely 2017/03/10 06:14:41 I think "!skip_..." should be "skip_..."
wylieb 2017/03/10 20:44:01 Done.
return false;
}
-
// Choose the datatypes to be synced. If all datatypes are to be synced,
// set sync_everything to true; otherwise, set it to false.
bool sync_everything = (synced_datatypes == syncer::UserSelectableTypes());
@@ -202,9 +222,10 @@ bool ProfileSyncServiceHarness::SetupSync(
// 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.
- if (!service()->IsUsingSecondaryPassphrase()) {
+ if (!skip_passphrase_verification &&
pavely 2017/03/10 06:14:41 Just wrap this if/else in an outer if(!skip_....).
wylieb 2017/03/10 20:44:01 I actually just passed this block entirely!
+ !service()->IsUsingSecondaryPassphrase()) {
service()->SetEncryptionPassphrase(password_, ProfileSyncService::IMPLICIT);
- } else {
+ } else if (!skip_passphrase_verification) {
LOG(ERROR) << "A passphrase is required for decryption. Sync cannot proceed"
" until SetDecryptionPassphrase is called.";
return false;
@@ -212,13 +233,44 @@ 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() {
+ DVLOG(1) << "Requesting stop for service.";
+ service()->RequestStop(ProfileSyncService::CLEAR_DATA);
+
+ std::unique_ptr<syncer::SyncSetupInProgressHandle> blocker =
+ service()->GetSetupInProgressHandle();
+ DVLOG(1) << "Requesting start for service";
+ service()->RequestStart();
+
+ if (!AwaitEngineInitialization()) {
+ LOG(ERROR) << "AwaitEngineInitialization failed.";
+ return false;
+ }
+ DVLOG(1) << "Engine Initialized successfully.";
+
+ // This passphrase should be implicit because ClearServerData should be called
+ // 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;
+ }
+ DVLOG(1) << "Passphrase decryption success.";
+
+ blocker.reset();
+ service()->SetFirstSetupComplete();
+
+ return true;
+}
+
bool ProfileSyncServiceHarness::AwaitMutualSyncCycleCompletion(
ProfileSyncServiceHarness* partner) {
std::vector<ProfileSyncServiceHarness*> harnesses;
@@ -246,7 +298,8 @@ bool ProfileSyncServiceHarness::AwaitQuiescence(
return QuiesceStatusChangeChecker(services).Wait();
}
-bool ProfileSyncServiceHarness::AwaitEngineInitialization() {
+bool ProfileSyncServiceHarness::AwaitEngineInitialization(
+ bool skip_passphrase_verification) {
if (!EngineInitializeChecker(service()).Wait()) {
LOG(ERROR) << "EngineInitializeChecker timed out.";
return false;
@@ -258,7 +311,8 @@ bool ProfileSyncServiceHarness::AwaitEngineInitialization() {
}
// Make sure that initial sync wasn't blocked by a missing passphrase.
- if (service()->passphrase_required_reason() == syncer::REASON_DECRYPTION) {
+ if (!skip_passphrase_verification &&
+ service()->passphrase_required_reason() == syncer::REASON_DECRYPTION) {
LOG(ERROR) << "A passphrase is required for decryption. Sync cannot proceed"
" until SetDecryptionPassphrase is called.";
return false;

Powered by Google App Engine
This is Rietveld 408576698