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

Unified Diff: chrome/browser/sync/engine/nigori_util.cc

Issue 7795002: [Sync] Gracefully handle writing to a node when the cryptographer is not ready. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reviewer comments Created 9 years, 4 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
« no previous file with comments | « chrome/browser/sync/engine/nigori_util.h ('k') | chrome/browser/sync/engine/nigori_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/engine/nigori_util.cc
diff --git a/chrome/browser/sync/engine/nigori_util.cc b/chrome/browser/sync/engine/nigori_util.cc
index ce721c289a1deb80355b574f1872381264205b4b..425b156a2371170973e8706551ae8de3cc4b6c1a 100644
--- a/chrome/browser/sync/engine/nigori_util.cc
+++ b/chrome/browser/sync/engine/nigori_util.cc
@@ -63,19 +63,29 @@ bool VerifyUnsyncedChangesAreEncrypted(
NOTREACHED();
return false;
}
- const sync_pb::EntitySpecifics& entry_specifics = entry.Get(SPECIFICS);
- ModelType type = entry.GetModelType();
- if (type == PASSWORDS)
- continue;
- if (encrypted_types.count(type) > 0 &&
- !entry_specifics.has_encrypted()) {
- // This datatype requires encryption but this data is not encrypted.
+ if (EntryNeedsEncryption(encrypted_types, entry))
return false;
- }
}
return true;
}
+bool EntryNeedsEncryption(const ModelTypeSet& encrypted_types,
+ const Entry& entry) {
+ if (!entry.Get(UNIQUE_SERVER_TAG).empty())
+ return false; // We don't encrypt unique server nodes.
+ return SpecificsNeedsEncryption(encrypted_types, entry.Get(SPECIFICS));
+}
+
+bool SpecificsNeedsEncryption(const ModelTypeSet& encrypted_types,
+ const sync_pb::EntitySpecifics& specifics) {
+ ModelType type = GetModelTypeFromSpecifics(specifics);
+ if (type == PASSWORDS || type == NIGORI)
+ return false; // These types have their own encryption schemes.
+ if (encrypted_types.count(type) == 0)
+ return false; // This type does not require encryption
+ return !specifics.has_encrypted();
+}
+
// Mainly for testing.
bool VerifyDataTypeEncryption(BaseTransaction* const trans,
browser_sync::Cryptographer* cryptographer,
« no previous file with comments | « chrome/browser/sync/engine/nigori_util.h ('k') | chrome/browser/sync/engine/nigori_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698