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

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

Issue 7806005: Revert 98770 - Merge 98758 - [Sync] Gracefully handle writing to a node when the cryptographer is... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/835/src/
Patch Set: 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/get_commit_ids_command.cc ('k') | chrome/browser/sync/engine/syncer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/engine/syncapi.cc
===================================================================
--- chrome/browser/sync/engine/syncapi.cc (revision 98772)
+++ chrome/browser/sync/engine/syncapi.cc (working copy)
@@ -1927,7 +1927,6 @@
allstatus_.SetCryptographerReady(cryptographer->is_ready());
allstatus_.SetCryptoHasPendingKeys(cryptographer->has_pending_keys());
- allstatus_.SetEncryptedTypes(cryptographer->GetEncryptedTypes());
return cryptographer->is_ready();
}
@@ -2115,12 +2114,9 @@
cryptographer->GetKeys(specifics.mutable_encrypted());
specifics.set_using_explicit_passphrase(is_explicit);
node.SetNigoriSpecifics(specifics);
+ ReEncryptEverything(&trans);
}
- // Does nothing if everything is already encrypted or the cryptographer has
- // pending keys.
- ReEncryptEverything(&trans);
-
VLOG(1) << "Passphrase accepted, bootstrapping encryption.";
std::string bootstrap_token;
cryptographer->GetBootstrapToken(&bootstrap_token);
@@ -2158,7 +2154,7 @@
Cryptographer* cryptographer = trans.GetCryptographer();
- if (!cryptographer->is_ready()) {
+ if (!cryptographer->is_initialized()) {
VLOG(1) << "Attempting to encrypt datatypes when cryptographer not "
<< "initialized, prompting for passphrase.";
ObserverList<SyncManager::Observer> temp_obs_list;
@@ -2182,13 +2178,22 @@
std::inserter(newly_encrypted_types,
newly_encrypted_types.begin()));
allstatus_.SetEncryptedTypes(newly_encrypted_types);
+ if (newly_encrypted_types == current_encrypted_types) {
+ // Set of encrypted types has not changed, just notify and return.
+ ObserverList<SyncManager::Observer> temp_obs_list;
+ CopyObservers(&temp_obs_list);
+ FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list,
+ OnEncryptionComplete(current_encrypted_types));
+ return;
+ }
syncable::FillNigoriEncryptedTypes(newly_encrypted_types, &nigori);
node.SetNigoriSpecifics(nigori);
cryptographer->SetEncryptedTypes(nigori);
- // We reencrypt everything regardless of whether the set of encrypted
- // types changed to ensure that any stray unencrypted entries are overwritten.
+ // TODO(zea): only reencrypt this datatype? ReEncrypting everything is a
+ // safer approach, and should not impact anything that is already encrypted
+ // (redundant changes are ignored).
ReEncryptEverything(&trans);
return;
}
@@ -2196,10 +2201,8 @@
// 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())
- return;
- syncable::ModelTypeSet encrypted_types = GetEncryptedTypes(trans);
+ syncable::ModelTypeSet encrypted_types =
+ GetEncryptedTypes(trans);
ModelSafeRoutingInfo routes;
registrar_->GetModelSafeRoutingInfo(&routes);
std::string tag;
« no previous file with comments | « chrome/browser/sync/engine/get_commit_ids_command.cc ('k') | chrome/browser/sync/engine/syncer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698