summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/glue/sync_backend_host.cc
diff options
context:
space:
mode:
authortim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-07 18:08:11 +0000
committertim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-07 18:08:11 +0000
commitdc39dd1b800ee76d17d2d8ee0fd3a6a273190274 (patch)
treeda0d5fa5bc2a4de56cbbf85d553c335eae2e0106 /chrome/browser/sync/glue/sync_backend_host.cc
parent4947c7fdd2e02b30168407431823ed6c7b4086bf (diff)
downloadchromium_src-dc39dd1b800ee76d17d2d8ee0fd3a6a273190274.zip
chromium_src-dc39dd1b800ee76d17d2d8ee0fd3a6a273190274.tar.gz
chromium_src-dc39dd1b800ee76d17d2d8ee0fd3a6a273190274.tar.bz2
sync: Fix Nigori download sequencing.
Only drop SetPassphrase requests if we hadn't requested NIGORI nodes in routing info. The reasoning is that NIGORI will be on-by-default always, meaning you cannot disable it, so once it is present it will remain, and it only ever gets added during init. Hence, if sync setup has completed, and NIGORI is in the routing info, we are good to go. Also make sure we remove passphrase notification observers when shutting down to avoid re-registration problems. BUG=58098, 48702 TEST=ProfileSyncPasswordsTest, point chrome at passwords-enabled server, run with --enable-sync-passwords, and successfully sync passwords. Review URL: http://codereview.chromium.org/3569022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61811 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/glue/sync_backend_host.cc')
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.cc33
1 files changed, 28 insertions, 5 deletions
diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc
index 74a8c47..05cbd7b 100644
--- a/chrome/browser/sync/glue/sync_backend_host.cc
+++ b/chrome/browser/sync/glue/sync_backend_host.cc
@@ -22,6 +22,8 @@
#include "chrome/browser/sync/glue/http_bridge.h"
#include "chrome/browser/sync/glue/password_model_worker.h"
#include "chrome/browser/sync/sessions/session_state.h"
+// TODO(tim): Remove this! We should have a syncapi pass-thru instead.
+#include "chrome/browser/sync/syncable/directory_manager.h" // Cryptographer.
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/net/gaia/gaia_constants.h"
@@ -115,12 +117,13 @@ void SyncBackendHost::Initialize(
registrar_.routing_info[(*it)] = GROUP_PASSIVE;
}
- // TODO(tim): This should be encryption-specific instead of passwords
- // specific. For now we have to do this to avoid NIGORI node lookups when
- // we haven't downloaded that node.
- if (profile_->GetPrefs()->GetBoolean(prefs::kSyncPasswords)) {
+ // TODO(tim): Remove this special case once NIGORI is populated by
+ // default. We piggy back off of the passwords flag for now to not
+ // require both encryption and passwords flags.
+ bool enable_encryption = CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableSyncPasswords) || types.count(syncable::PASSWORDS);
+ if (enable_encryption)
registrar_.routing_info[syncable::NIGORI] = GROUP_PASSIVE;
- }
InitCore(Core::DoInitializeOptions(
sync_service_url,
@@ -146,6 +149,20 @@ std::string SyncBackendHost::RestoreEncryptionBootstrapToken() {
return token;
}
+bool SyncBackendHost::IsNigoriEnabled() const {
+ AutoLock lock(registrar_lock_);
+ // Note that NIGORI is only ever added/removed from routing_info once,
+ // during initialization / first configuration, so there is no real 'race'
+ // possible here or possibility of stale return value.
+ return registrar_.routing_info.find(syncable::NIGORI) !=
+ registrar_.routing_info.end();
+}
+
+bool SyncBackendHost::IsCryptographerReady() const {
+ return syncapi_initialized_ &&
+ GetUserShareHandle()->dir_manager->cryptographer()->is_ready();
+}
+
sync_api::HttpPostProviderFactory* SyncBackendHost::MakeHttpBridgeFactory(
URLRequestContextGetter* getter) {
return new HttpBridgeFactory(getter);
@@ -170,6 +187,12 @@ void SyncBackendHost::StartSyncingWithServer() {
}
void SyncBackendHost::SetPassphrase(const std::string& passphrase) {
+ if (!IsNigoriEnabled()) {
+ LOG(WARNING) << "Silently dropping SetPassphrase request.";
+ return;
+ }
+
+ // If encryption is enabled and we've got a SetPassphrase
core_thread_.message_loop()->PostTask(FROM_HERE,
NewRunnableMethod(core_.get(), &SyncBackendHost::Core::DoSetPassphrase,
passphrase));