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

Unified Diff: chrome/browser/sync/internal_api/sync_manager.cc

Issue 8759019: [Sync] Add intelligent re-encryption support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase again Created 9 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
« no previous file with comments | « chrome/browser/sync/internal_api/base_node.h ('k') | chrome/browser/sync/internal_api/syncapi_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/internal_api/sync_manager.cc
diff --git a/chrome/browser/sync/internal_api/sync_manager.cc b/chrome/browser/sync/internal_api/sync_manager.cc
index 8c9f02dbd905b411aca21ba617764376a35a9c20..ea7a238646cbee46d64fcd208d9a1c5233253471 100644
--- a/chrome/browser/sync/internal_api/sync_manager.cc
+++ b/chrome/browser/sync/internal_api/sync_manager.cc
@@ -854,7 +854,10 @@ bool SyncManager::SyncInternal::UpdateCryptographerAndNigori() {
// are present in the nigori node. If they're not, we write the current set of
// keys.
if (!nigori.has_encrypted() && cryptographer->is_ready()) {
- cryptographer->GetKeys(nigori.mutable_encrypted());
+ if (!cryptographer->GetKeys(nigori.mutable_encrypted())) {
+ NOTREACHED();
+ return false;
+ }
}
// Ensure the nigori node reflects the most recent set of sensitive types
@@ -1057,17 +1060,21 @@ void SyncManager::SyncInternal::SetPassphrase(
return;
cryptographer->AddKey(params);
+ }
- // TODO(tim): Bug 58231. It would be nice if SetPassphrase didn't require
- // messing with the Nigori node, because we can't call SetPassphrase until
- // download conditions are met vs Cryptographer init. It seems like it's
- // safe to defer this work.
- sync_pb::NigoriSpecifics specifics(node.GetNigoriSpecifics());
- specifics.clear_encrypted();
- cryptographer->GetKeys(specifics.mutable_encrypted());
- specifics.set_using_explicit_passphrase(is_explicit);
- node.SetNigoriSpecifics(specifics);
+ // TODO(tim): Bug 58231. It would be nice if SetPassphrase didn't require
+ // messing with the Nigori node, because we can't call SetPassphrase until
+ // download conditions are met vs Cryptographer init. It seems like it's
+ // safe to defer this work.
+ sync_pb::NigoriSpecifics specifics(node.GetNigoriSpecifics());
+ // Does not modify specifics.encrypted() if the original decrypted data was
+ // the same.
+ if (!cryptographer->GetKeys(specifics.mutable_encrypted())) {
+ NOTREACHED();
+ return;
}
+ specifics.set_using_explicit_passphrase(is_explicit);
+ node.SetNigoriSpecifics(specifics);
// Does nothing if everything is already encrypted or the cryptographer has
// pending keys.
@@ -1129,8 +1136,6 @@ void SyncManager::SyncInternal::RefreshEncryption() {
ReEncryptEverything(&trans);
}
-// TODO(zea): Add unit tests that ensure no sync changes are made when not
-// needed.
void SyncManager::SyncInternal::ReEncryptEverything(WriteTransaction* trans) {
Cryptographer* cryptographer = trans->GetCryptographer();
if (!cryptographer || !cryptographer->is_ready())
« no previous file with comments | « chrome/browser/sync/internal_api/base_node.h ('k') | chrome/browser/sync/internal_api/syncapi_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698