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

Unified Diff: sync/internal_api/sync_manager_impl.cc

Issue 10540149: [Sync] Persist keystore key across restarts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix rebase Created 8 years, 5 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 | « sync/internal_api/sync_manager_impl.h ('k') | sync/internal_api/syncapi_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/internal_api/sync_manager_impl.cc
diff --git a/sync/internal_api/sync_manager_impl.cc b/sync/internal_api/sync_manager_impl.cc
index e069df41be6383fbfeb590daed9aca48f1207847..aeb0940a6bda59555823f9f149696ca2fe9a413a 100644
--- a/sync/internal_api/sync_manager_impl.cc
+++ b/sync/internal_api/sync_manager_impl.cc
@@ -376,6 +376,7 @@ bool SyncManagerImpl::Init(
const SyncCredentials& credentials,
scoped_ptr<SyncNotifier> sync_notifier,
const std::string& restored_key_for_bootstrapping,
+ const std::string& restored_keystore_key_for_bootstrapping,
bool keystore_encryption_enabled,
scoped_ptr<InternalComponentsFactory> internal_components_factory,
Encryptor* encryptor,
@@ -485,6 +486,8 @@ bool SyncManagerImpl::Init(
// |initialized_| is set to true.
ReadTransaction trans(FROM_HERE, GetUserShare());
trans.GetCryptographer()->Bootstrap(restored_key_for_bootstrapping);
+ trans.GetCryptographer()->BootstrapKeystoreKey(
+ restored_keystore_key_for_bootstrapping);
trans.GetCryptographer()->AddObserver(this);
FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
@@ -1062,6 +1065,11 @@ bool SyncManagerImpl::IsUsingExplicitPassphrase() {
return node.GetNigoriSpecifics().using_explicit_passphrase();
}
+bool SyncManagerImpl::GetKeystoreKeyBootstrapToken(std::string* token) {
+ ReadTransaction trans(FROM_HERE, GetUserShare());
+ return trans.GetCryptographer()->GetKeystoreKeyBootstrapToken(token);
+}
+
void SyncManagerImpl::RefreshEncryption() {
DCHECK(initialized_);
@@ -1505,13 +1513,15 @@ void SyncManagerImpl::OnSyncEngineEvent(const SyncEngineEvent& event) {
}
if (!event.snapshot.has_more_to_sync()) {
- // To account for a nigori node arriving with stale/bad data, we ensure
- // that the nigori node is up to date at the end of each cycle.
- WriteTransaction trans(FROM_HERE, GetUserShare());
- WriteNode nigori_node(&trans);
- if (nigori_node.InitByTagLookup(kNigoriTag) == BaseNode::INIT_OK) {
- Cryptographer* cryptographer = trans.GetCryptographer();
- UpdateNigoriEncryptionState(cryptographer, &nigori_node);
+ {
+ // To account for a nigori node arriving with stale/bad data, we ensure
+ // that the nigori node is up to date at the end of each cycle.
+ WriteTransaction trans(FROM_HERE, GetUserShare());
+ WriteNode nigori_node(&trans);
+ if (nigori_node.InitByTagLookup(kNigoriTag) == BaseNode::INIT_OK) {
+ Cryptographer* cryptographer = trans.GetCryptographer();
+ UpdateNigoriEncryptionState(cryptographer, &nigori_node);
+ }
}
DVLOG(1) << "Sending OnSyncCycleCompleted";
« no previous file with comments | « sync/internal_api/sync_manager_impl.h ('k') | sync/internal_api/syncapi_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698