| Index: chrome/browser/sync/profile_sync_service.h
|
| diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h
|
| index c8f8e0396766ba4dfb2d8e772ad8b20f3696637c..5065aee1ccc7c39de5fc8861f4599809ff0b2bb3 100644
|
| --- a/chrome/browser/sync/profile_sync_service.h
|
| +++ b/chrome/browser/sync/profile_sync_service.h
|
| @@ -22,6 +22,7 @@
|
| #include "base/timer.h"
|
| #include "chrome/browser/invalidation/invalidation_frontend.h"
|
| #include "chrome/browser/invalidation/invalidator_storage.h"
|
| +#include "chrome/browser/signin/oauth2_token_service.h"
|
| #include "chrome/browser/signin/signin_global_error.h"
|
| #include "chrome/browser/sync/backend_unrecoverable_error_handler.h"
|
| #include "chrome/browser/sync/failed_datatypes_handler.h"
|
| @@ -38,6 +39,7 @@
|
| #include "content/public/browser/notification_types.h"
|
| #include "google_apis/gaia/google_service_auth_error.h"
|
| #include "googleurl/src/gurl.h"
|
| +#include "net/base/backoff_entry.h"
|
| #include "sync/internal_api/public/base/model_type.h"
|
| #include "sync/internal_api/public/engine/model_safe_worker.h"
|
| #include "sync/internal_api/public/sync_manager_factory.h"
|
| @@ -62,6 +64,7 @@ namespace sessions { class SyncSessionSnapshot; }
|
| }
|
|
|
| namespace syncer {
|
| +class BackoffDelayProvider;
|
| class BaseTransaction;
|
| class InvalidatorRegistrar;
|
| struct SyncCredentials;
|
| @@ -162,7 +165,8 @@ class ProfileSyncService : public ProfileSyncServiceBase,
|
| public syncer::UnrecoverableErrorHandler,
|
| public content::NotificationObserver,
|
| public BrowserContextKeyedService,
|
| - public invalidation::InvalidationFrontend {
|
| + public invalidation::InvalidationFrontend,
|
| + public OAuth2TokenService::Consumer {
|
| public:
|
| typedef browser_sync::SyncBackendHost::Status Status;
|
|
|
| @@ -247,9 +251,9 @@ class ProfileSyncService : public ProfileSyncServiceBase,
|
| // Virtual to enable mocking in tests.
|
| virtual bool IsSyncEnabledAndLoggedIn();
|
|
|
| - // Return whether all sync tokens are loaded and available for the backend to
|
| - // start up. Virtual to enable mocking in tests.
|
| - virtual bool IsSyncTokenAvailable();
|
| + // Return whether OAuth2 refresh token is loaded and available for the backend
|
| + // to start up. Virtual to enable mocking in tests.
|
| + virtual bool IsOAuthRefreshTokenAvailable();
|
|
|
| // Registers a data type controller with the sync service. This
|
| // makes the data type controller available for use, it does not
|
| @@ -617,6 +621,15 @@ class ProfileSyncService : public ProfileSyncServiceBase,
|
|
|
| virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE;
|
|
|
| + // OAuth2TokenService::Consumer implementation
|
| + virtual void OnGetTokenSuccess(
|
| + const OAuth2TokenService::Request* request,
|
| + const std::string& access_token,
|
| + const base::Time& expiration_time) OVERRIDE;
|
| + virtual void OnGetTokenFailure(
|
| + const OAuth2TokenService::Request* request,
|
| + const GoogleServiceAuthError& error) OVERRIDE;
|
| +
|
| // BrowserContextKeyedService implementation. This must be called exactly
|
| // once (before this object is destroyed).
|
| virtual void Shutdown() OVERRIDE;
|
| @@ -727,6 +740,12 @@ class ProfileSyncService : public ProfileSyncServiceBase,
|
| // cached passphrase and clear it out when it is done.
|
| void ConsumeCachedPassphraseIfPossible();
|
|
|
| + // RequestAccessToken initiates RPC to request downscoped access token from
|
| + // refresh token. This happens when TokenService loads OAuth2 login token and
|
| + // when sync server returns AUTH_ERROR which indicates it is time to refresh
|
| + // token.
|
| + virtual void RequestAccessToken();
|
| +
|
| // If |delete_sync_data_folder| is true, then this method will delete all
|
| // previous "Sync Data" folders. (useful if the folder is partial/corrupt).
|
| void InitializeBackend(bool delete_sync_data_folder);
|
| @@ -949,6 +968,19 @@ class ProfileSyncService : public ProfileSyncServiceBase,
|
| // and association information.
|
| syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_;
|
|
|
| + // ProfileSyncService needs to remember access token in order to invalidate it
|
| + // with OAuth2TokenService.
|
| + std::string access_token_;
|
| +
|
| + // ProfileSyncService needs to hold reference to access_token_request_ for
|
| + // the duration of request in order to receive callbacks.
|
| + scoped_ptr<OAuth2TokenService::Request> access_token_request_;
|
| +
|
| + // If RequestAccessToken fails with transient error then retry requesting
|
| + // access token with exponential backoff.
|
| + base::OneShotTimer<ProfileSyncService> request_access_token_retry_timer_;
|
| + net::BackoffEntry request_access_token_backoff_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(ProfileSyncService);
|
| };
|
|
|
|
|