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

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

Issue 6465005: [Sync] Initial support for encrypting any datatype (no UI hookup yet). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. Rest of unit tests. Created 9 years, 10 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/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 95eaff179992291f3dd132f4a1a61044bb8f72ec..7c482f01ff1b61a0f71b4ba67782660e430124fd 100644
--- a/chrome/browser/sync/profile_sync_service_harness.cc
+++ b/chrome/browser/sync/profile_sync_service_harness.cc
@@ -288,6 +288,12 @@ bool ProfileSyncServiceHarness::RunStateChangeMachine() {
LogClientInfo("SYNC_DISABLED");
break;
}
+ case WAITING_FOR_ENCRYPTION: {
+ // Sync has finished encrypting the datatypes. There is nothing to do.
Raghu Simha 2011/02/14 05:29:52 This seems wrong. Just because you're in RunStateC
Nicolas Zea 2011/02/14 21:18:41 Done.
+ LogClientInfo("WAITING_FOR_ENCRYPTION");
+ SignalStateCompleteWithNextState(FULLY_SYNCED);
+ break;
+ }
default:
// Invalid state during observer callback which may be triggered by other
// classes using the the UI message loop. Defer to their handling.
@@ -597,3 +603,38 @@ void ProfileSyncServiceHarness::LogClientInfo(std::string message) {
<< ": Sync service not available.";
}
}
+
+bool ProfileSyncServiceHarness::EnableEncryptionForType(
+ syncable::ModelType type) {
+ syncable::ModelTypeSet encrypted_types;
+ service_->GetEncryptedDataTypes(&encrypted_types);
+ encrypted_types.insert(type);
+ service_->EncryptDataTypes(encrypted_types);
+
+ // Wait some time to let the enryption finish.
+ std::string reason = "Waiting for encryption.";
+ wait_state_ = WAITING_FOR_ENCRYPTION;
+ if (!AwaitStatusChangeWithTimeout(kLiveSyncOperationTimeoutMs, reason)) {
+ LOG(ERROR) << "Did not receive EncryptionComplete notification after"
+ << kLiveSyncOperationTimeoutMs / 1000
+ << " seconds.";
+ return false;
+ }
+
+ syncable::ModelTypeSet newly_encrypted_types;
+ service_->GetEncryptedDataTypes(&newly_encrypted_types);
+ if (newly_encrypted_types != encrypted_types) {
+ return false;
+ }
Raghu Simha 2011/02/14 05:29:52 The above block seems to be doing the same as IsTy
Nicolas Zea 2011/02/14 21:18:41 Done.
+
+ return true;
+}
+
+bool ProfileSyncServiceHarness::IsTypeEncrypted(syncable::ModelType type) {
+ syncable::ModelTypeSet encrypted_types;
+ service_->GetEncryptedDataTypes(&encrypted_types);
+ if (encrypted_types.count(type) == 0) {
+ return false;
+ }
+ return true;
+}

Powered by Google App Engine
This is Rietveld 408576698