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

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

Issue 8356026: [Sync] Cache encrypted types info in ProfileSyncService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test failures Created 9 years, 2 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/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 c8435b65b996a08fe7dab7efb01fca927e24a726..005208fc81a01be8ebff0c1ed7787395f3363452 100644
--- a/chrome/browser/sync/internal_api/sync_manager.cc
+++ b/chrome/browser/sync/internal_api/sync_manager.cc
@@ -1216,8 +1216,10 @@ void SyncManager::SyncInternal::ReEncryptEverything(WriteTransaction* trans) {
}
}
- FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
- OnEncryptionComplete(encrypted_types));
+ FOR_EACH_OBSERVER(
+ SyncManager::Observer, observers_,
+ OnEncryptionComplete(
+ encrypted_types, cryptographer->encrypt_everything()));
}
SyncManager::~SyncManager() {
@@ -1600,6 +1602,10 @@ void SyncManager::SyncInternal::OnSyncEngineEvent(
if (event.what_happened == SyncEngineEvent::SYNC_CYCLE_ENDED) {
ModelSafeRoutingInfo enabled_types;
registrar_->GetModelSafeRoutingInfo(&enabled_types);
+ bool send_encryption_complete_notification = false;
+ syncable::ModelTypeSet encrypted_types(
+ browser_sync::Cryptographer::SensitiveTypes());
+ bool encrypt_everything = false;
{
// Check to see if we need to notify the frontend that we have newly
// encrypted types or that we require a passphrase.
@@ -1617,16 +1623,31 @@ void SyncManager::SyncInternal::OnSyncEngineEvent(
<< "ready";
FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
OnPassphraseRequired(sync_api::REASON_ENCRYPTION));
+ } else {
+ send_encryption_complete_notification = true;
}
+ encrypted_types = cryptographer->GetEncryptedTypes();
+ encrypt_everything = cryptographer->encrypt_everything();
allstatus_.SetCryptographerReady(cryptographer->is_ready());
allstatus_.SetCryptoHasPendingKeys(cryptographer->has_pending_keys());
- allstatus_.SetEncryptedTypes(cryptographer->GetEncryptedTypes());
+ allstatus_.SetEncryptedTypes(encrypted_types);
+
+ // If everything is in order (we have the passphrase) then we
+ // inform the listeners below right after we close the
+ // transaction.
+ }
- // If everything is in order(we have the passphrase) then there is no
- // need to inform the listeners. They will just wait for sync
- // completion event and if no errors have been raised it means
- // encryption was succesful.
+ if (send_encryption_complete_notification) {
+ VLOG(1) << "Sending OnEncryptionComplete";
Nicolas Zea 2011/10/20 18:40:41 Should probably be VLOG(2), since this is going to
akalin 2011/10/21 02:24:17 Removed. Probably not necessary.
+ // TODO(akalin): Ideally, the Cryptographer would be the one
+ // sending out this notification, as it knows exactly when it
+ // does encryption (whereas we always send this at the end of a
+ // sync cycle, regardless of whether encryption was actually
+ // done).
+ FOR_EACH_OBSERVER(
+ SyncManager::Observer, observers_,
+ OnEncryptionComplete(encrypted_types, encrypt_everything));
}
if (!initialized_) {
@@ -1636,7 +1657,7 @@ void SyncManager::SyncInternal::OnSyncEngineEvent(
}
if (!event.snapshot->has_more_to_sync) {
- VLOG(1) << "OnSyncCycleCompleted sent";
+ VLOG(1) << "Sending OnSyncCycleCompleted";
FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
OnSyncCycleCompleted(event.snapshot));
}

Powered by Google App Engine
This is Rietveld 408576698