diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-08 02:29:22 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-08 02:29:22 +0000 |
commit | 5fffc50972ed03d5a0ae5d669f08302281dadaf9 (patch) | |
tree | 46b78947c5691f88654cbe5e9e74920e93c2d747 /sync | |
parent | e8bbdb4981a1192890bb0e9f7dbb9c81d4f6d47c (diff) | |
download | chromium_src-5fffc50972ed03d5a0ae5d669f08302281dadaf9.zip chromium_src-5fffc50972ed03d5a0ae5d669f08302281dadaf9.tar.gz chromium_src-5fffc50972ed03d5a0ae5d669f08302281dadaf9.tar.bz2 |
sync: fix sync / xmpp auth error notification plumbing
When forging a sync auth error from an xmpp auth error, we need to also
set the ServerConnectionManager's server_status code to SYNC_AUTH_ERROR
so that it realizes it needs to handle a credential update later on by
trying to sync again.
BUG=159628,127397,171975
Review URL: https://codereview.chromium.org/12208073
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181413 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r-- | sync/engine/net/server_connection_manager.cc | 14 | ||||
-rw-r--r-- | sync/engine/net/server_connection_manager.h | 19 | ||||
-rw-r--r-- | sync/engine/sync_scheduler_impl.cc | 8 | ||||
-rw-r--r-- | sync/internal_api/sync_manager_impl.cc | 2 |
4 files changed, 33 insertions, 10 deletions
diff --git a/sync/engine/net/server_connection_manager.cc b/sync/engine/net/server_connection_manager.cc index 228dbb9..c2bb951 100644 --- a/sync/engine/net/server_connection_manager.cc +++ b/sync/engine/net/server_connection_manager.cc @@ -222,6 +222,20 @@ void ServerConnectionManager::OnConnectionDestroyed(Connection* connection) { active_connection_ = NULL; } +void ServerConnectionManager::OnInvalidationCredentialsRejected() { + InvalidateAndClearAuthToken(); + server_status_ = HttpResponse::SYNC_AUTH_ERROR; +} + +void ServerConnectionManager::InvalidateAndClearAuthToken() { + DCHECK(thread_checker_.CalledOnValidThread()); + // Copy over the token to previous invalid token. + if (!auth_token_.empty()) { + previously_invalidated_token.assign(auth_token_); + auth_token_ = std::string(); + } +} + void ServerConnectionManager::NotifyStatusChanged() { DCHECK(thread_checker_.CalledOnValidThread()); FOR_EACH_OBSERVER(ServerConnectionEventListener, listeners_, diff --git a/sync/engine/net/server_connection_manager.h b/sync/engine/net/server_connection_manager.h index a074d47..0603340 100644 --- a/sync/engine/net/server_connection_manager.h +++ b/sync/engine/net/server_connection_manager.h @@ -235,14 +235,12 @@ class SYNC_EXPORT_PRIVATE ServerConnectionManager { return false; } - void InvalidateAndClearAuthToken() { - DCHECK(thread_checker_.CalledOnValidThread()); - // Copy over the token to previous invalid token. - if (!auth_token_.empty()) { - previously_invalidated_token.assign(auth_token_); - auth_token_ = std::string(); - } - } + // Our out-of-band invalidations channel can encounter auth errors, + // and when it does so it tells us via this method to prevent making more + // requests with known-bad tokens. This will put the + // ServerConnectionManager in an auth error state as if it received an + // HTTP 401 from sync servers. + void OnInvalidationCredentialsRejected(); bool HasInvalidAuthToken() { return auth_token_.empty(); @@ -270,6 +268,11 @@ class SYNC_EXPORT_PRIVATE ServerConnectionManager { const std::string& auth_token, ScopedServerStatusWatcher* watcher); + // An internal helper to clear our auth_token_ and cache the old version + // in |previously_invalidated_token_| to shelter us from retrying with a + // known bad token. + void InvalidateAndClearAuthToken(); + // Helper to check terminated flags and build a Connection object, installing // it as the |active_connection_|. If this ServerConnectionManager has been // terminated, this will return NULL. diff --git a/sync/engine/sync_scheduler_impl.cc b/sync/engine/sync_scheduler_impl.cc index 897c182..64d79d7 100644 --- a/sync/engine/sync_scheduler_impl.cc +++ b/sync/engine/sync_scheduler_impl.cc @@ -199,7 +199,13 @@ void SyncSchedulerImpl::OnCredentialsUpdated() { // back to SYNC_AUTH_ERROR at the end of the sync cycle. The // referenced bug explores the option of removing gettime calls // altogethere - if (HttpResponse::SYNC_AUTH_ERROR == connection_code_) { + // TODO(rogerta): this code no longer checks |connection_code_|. It uses + // ServerConnectionManager::server_status() instead. This is to resolve a + // missing notitification during re-auth. |connection_code_| is a duplicate + // value and should probably be removed, see comment in the function + // SyncSchedulerImpl::FinishSyncSessionJob() below. + if (HttpResponse::SYNC_AUTH_ERROR == + session_context_->connection_manager()->server_status()) { OnServerConnectionErrorFixed(); } } diff --git a/sync/internal_api/sync_manager_impl.cc b/sync/internal_api/sync_manager_impl.cc index b2b9ed5..41ef5b2 100644 --- a/sync/internal_api/sync_manager_impl.cc +++ b/sync/internal_api/sync_manager_impl.cc @@ -1219,7 +1219,7 @@ void SyncManagerImpl::OnInvalidatorStateChange(InvalidatorState state) { if (invalidator_state_ == syncer::INVALIDATION_CREDENTIALS_REJECTED) { // If the invalidator's credentials were rejected, that means that // our sync credentials are also bad, so invalidate those. - connection_manager_->InvalidateAndClearAuthToken(); + connection_manager_->OnInvalidationCredentialsRejected(); FOR_EACH_OBSERVER(SyncManager::Observer, observers_, OnConnectionStatusChange(CONNECTION_AUTH_ERROR)); } |