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

Unified Diff: chrome/browser/sync/profile_sync_service.h

Issue 15421011: Use OAuth2 token for sync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years, 6 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 | « chrome/browser/sync/glue/sync_backend_host.cc ('k') | chrome/browser/sync/profile_sync_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 39f94dd4360a5b8d7c570adefa6a936e4851c3cb..6dd6797b07111e48aae0565265d396c2c25aa4bd 100644
--- a/chrome/browser/sync/profile_sync_service.h
+++ b/chrome/browser/sync/profile_sync_service.h
@@ -21,6 +21,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/glue/data_type_controller.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"
@@ -164,7 +166,8 @@ class ProfileSyncService : public ProfileSyncServiceBase,
public content::NotificationObserver,
public BrowserContextKeyedService,
public invalidation::InvalidationFrontend,
- public browser_sync::DataTypeEncryptionHandler {
+ public browser_sync::DataTypeEncryptionHandler,
+ public OAuth2TokenService::Consumer {
public:
typedef browser_sync::SyncBackendHost::Status Status;
@@ -249,9 +252,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
@@ -612,6 +615,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;
@@ -722,6 +734,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);
@@ -940,6 +958,24 @@ class ProfileSyncService : public ProfileSyncServiceBase,
// and association information.
syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_;
+ // Specifies whenever to use oauth2 access token or ClientLogin token in
+ // communications with sync and xmpp servers.
+ // TODO(pavely): Remove once android is converted to oauth2 tokens.
+ bool use_oauth2_token_;
+
+ // 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);
};
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host.cc ('k') | chrome/browser/sync/profile_sync_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698