diff options
author | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-18 08:58:01 +0000 |
---|---|---|
committer | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-18 08:58:01 +0000 |
commit | 12bb3e11aac582a23034e3538a689e9a3a28da86 (patch) | |
tree | cdf611cb421039d437f245b091fe5455ff9a3c46 /chrome/browser/sync/util | |
parent | d9245d3adab9e01f5b062f5ec2d3cd9d4e25359a (diff) | |
download | chromium_src-12bb3e11aac582a23034e3538a689e9a3a28da86.zip chromium_src-12bb3e11aac582a23034e3538a689e9a3a28da86.tar.gz chromium_src-12bb3e11aac582a23034e3538a689e9a3a28da86.tar.bz2 |
[Sync] Pave the way for fewer asynchronous calls and UI spin while setting a passphrase
As of today, when a user sets a passphrase, SetPassphrase() is invoked
from the UI thread, but the actual work is performed on the syncer
thread. This means that when the UI thread sets a decryption passphrase,
it doesn't actually know right away whether the passphrase was accepted
or not, resulting in the user having to see a spinner during this time.
This patch does the following:
- Changes the OnPassphraseRequired API to include a
sync_pb::EncryptedData parameter, that contains a copy of the
cryptographer's pending keys when the reason is REASON_DECRYPTION.
- Adds the cached_pending_keys_ data member to ProfileSyncService, so
that it can cache the cryptographer's pending keys when
OnPassphraseRequired is called.
- Adds a new API called CheckPassphraseAgainstCachedPendingKeys to
ProfileSyncService that can be called by the UI to first try to decrypt the
cached pending keys with the passphrase that was entered, and if this
fails, directly bubble up an incorrect passphrase dialog instead of
showing the user a spinner.
BUG=108718
TEST=try to enter an incorrect passphrase; try to enter an old
passphrase, sync_integration_tests
Review URL: http://codereview.chromium.org/9107027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118081 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/util')
-rw-r--r-- | chrome/browser/sync/util/cryptographer.cc | 7 | ||||
-rw-r--r-- | chrome/browser/sync/util/cryptographer.h | 9 |
2 files changed, 14 insertions, 2 deletions
diff --git a/chrome/browser/sync/util/cryptographer.cc b/chrome/browser/sync/util/cryptographer.cc index 5d1e450..de83652 100644 --- a/chrome/browser/sync/util/cryptographer.cc +++ b/chrome/browser/sync/util/cryptographer.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -172,6 +172,11 @@ void Cryptographer::SetPendingKeys(const sync_pb::EncryptedData& encrypted) { pending_keys_.reset(new sync_pb::EncryptedData(encrypted)); } +const sync_pb::EncryptedData& Cryptographer::GetPendingKeys() const { + DCHECK(has_pending_keys()); + return *(pending_keys_.get()); +} + bool Cryptographer::DecryptPendingKeys(const KeyParams& params) { Nigori nigori; if (!nigori.InitByDerivation(params.hostname, diff --git a/chrome/browser/sync/util/cryptographer.h b/chrome/browser/sync/util/cryptographer.h index cb78e6c..2c319ab 100644 --- a/chrome/browser/sync/util/cryptographer.h +++ b/chrome/browser/sync/util/cryptographer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,6 +13,7 @@ #include "base/memory/linked_ptr.h" #include "base/memory/scoped_ptr.h" #include "base/observer_list.h" +#include "chrome/browser/sync/protocol/encryption.pb.h" #include "chrome/browser/sync/protocol/nigori_specifics.pb.h" #include "chrome/browser/sync/syncable/model_type.h" #include "chrome/browser/sync/util/nigori.h" @@ -140,6 +141,12 @@ class Cryptographer { // false. void SetPendingKeys(const sync_pb::EncryptedData& encrypted); + // Makes |pending_keys_| available to callers that may want to cache its + // value for later use on the UI thread. It is illegal to call this if the + // cryptographer has no pending keys. Like other calls that access the + // cryptographer, this method must be called from within a transaction. + const sync_pb::EncryptedData& GetPendingKeys() const; + // Attempts to decrypt the set of keys that was copied in the previous call to // SetPendingKeys using |params|. Returns true if the pending keys were // successfully decrypted and installed. |