diff options
author | Torne (Richard Coles) <torne@google.com> | 2013-11-28 11:55:43 +0000 |
---|---|---|
committer | Torne (Richard Coles) <torne@google.com> | 2013-11-28 11:55:43 +0000 |
commit | f2477e01787aa58f445919b809d89e252beef54f (patch) | |
tree | 2db962b4af39f0db3a5f83b314373d0530c484b8 /chrome/browser/sync/profile_sync_service.h | |
parent | 7daea1dd5ff7e419322de831b642d81af3247912 (diff) | |
download | chromium_org-f2477e01787aa58f445919b809d89e252beef54f.tar.gz |
Merge from Chromium at DEPS revision 237746
This commit was generated by merge_to_master.py.
Change-Id: I8997af4cddfeb09a7c26f7e8e672c712cab461ea
Diffstat (limited to 'chrome/browser/sync/profile_sync_service.h')
-rw-r--r-- | chrome/browser/sync/profile_sync_service.h | 125 |
1 files changed, 96 insertions, 29 deletions
diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h index 73da61e2f3..c9bfd849a9 100644 --- a/chrome/browser/sync/profile_sync_service.h +++ b/chrome/browser/sync/profile_sync_service.h @@ -20,7 +20,6 @@ #include "base/strings/string16.h" #include "base/time/time.h" #include "base/timer/timer.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" #include "chrome/browser/sync/glue/data_type_encryption_handler.h" @@ -28,9 +27,11 @@ #include "chrome/browser/sync/glue/data_type_manager_observer.h" #include "chrome/browser/sync/glue/failed_data_types_handler.h" #include "chrome/browser/sync/glue/sync_backend_host.h" +#include "chrome/browser/sync/glue/sync_frontend.h" #include "chrome/browser/sync/glue/synced_device_tracker.h" #include "chrome/browser/sync/profile_sync_service_base.h" #include "chrome/browser/sync/profile_sync_service_observer.h" +#include "chrome/browser/sync/sessions2/sessions_sync_manager.h" #include "chrome/browser/sync/sync_prefs.h" #include "components/browser_context_keyed_service/browser_context_keyed_service.h" #include "content/public/browser/notification_observer.h" @@ -47,8 +48,8 @@ #include "sync/js/sync_js_controller.h" #include "url/gurl.h" -class ProfileOAuth2TokenService; class Profile; +class ProfileOAuth2TokenService; class ProfileSyncComponentsFactory; class SigninManagerBase; class SyncGlobalError; @@ -58,7 +59,9 @@ class BackendMigrator; class ChangeProcessor; class DataTypeManager; class DeviceInfo; +class FaviconCache; class JsController; +class OpenTabsUIDelegate; class SessionModelAssociator; namespace sessions { @@ -76,6 +79,8 @@ namespace sync_pb { class EncryptedData; } // namespace sync_pb +using browser_sync::SessionsSyncManager; + // ProfileSyncService is the layer between browser subsystems like bookmarks, // and the sync backend. Each subsystem is logically thought of as being // a sync datatype. @@ -159,20 +164,40 @@ class EncryptedData; // tell the sync engine that setup is completed and it can begin downloading // data from the sync server. // -class ProfileSyncService : public ProfileSyncServiceBase, - public browser_sync::SyncFrontend, - public browser_sync::SyncPrefObserver, - public browser_sync::DataTypeManagerObserver, - public SigninGlobalError::AuthStatusProvider, - public syncer::UnrecoverableErrorHandler, - public content::NotificationObserver, - public BrowserContextKeyedService, - public browser_sync::DataTypeEncryptionHandler, - public OAuth2TokenService::Consumer, - public OAuth2TokenService::Observer { +class ProfileSyncService + : public ProfileSyncServiceBase, + public browser_sync::SyncFrontend, + public browser_sync::SyncPrefObserver, + public browser_sync::DataTypeManagerObserver, + public syncer::UnrecoverableErrorHandler, + public content::NotificationObserver, + public BrowserContextKeyedService, + public browser_sync::DataTypeEncryptionHandler, + public OAuth2TokenService::Consumer, + public OAuth2TokenService::Observer, + public SessionsSyncManager::SyncInternalApiDelegate { public: typedef browser_sync::SyncBackendHost::Status Status; + // Status of sync server connection, sync token and token request. + struct SyncTokenStatus { + SyncTokenStatus(); + ~SyncTokenStatus(); + + // Sync server connection status reported by sync backend. + base::Time connection_status_update_time; + syncer::ConnectionStatus connection_status; + + // Times when OAuth2 access token is requested and received. + base::Time token_request_time; + base::Time token_receive_time; + + // Error returned by OAuth2TokenService for token request and time when + // next request is scheduled. + GoogleServiceAuthError last_get_token_error; + base::Time next_token_request_time; + }; + enum SyncEventCodes { MIN_SYNC_EVENT_CODE = 0, @@ -281,13 +306,34 @@ class ProfileSyncService : public ProfileSyncServiceBase, // Returns the session model associator associated with this type, but only if // the associator is running. If it is doing anything else, it will return // null. - // TODO(zea): Figure out a better way to expose this to the UI elements that - // need it. - virtual browser_sync::SessionModelAssociator* GetSessionModelAssociator(); + // + // *** DONT USE THIS ANYMORE! *** + // If you think you want to use this, think again! Can you use + // GetOpenTabsUIDelegate instead? + // TODO(tim): Remove this method. + virtual browser_sync::SessionModelAssociator* + GetSessionModelAssociatorDeprecated(); + + // Return the active OpenTabsUIDelegate. If sessions is not enabled or not + // currently syncing, returns NULL. + virtual browser_sync::OpenTabsUIDelegate* GetOpenTabsUIDelegate(); + // Returns the SyncableService for syncer::SESSIONS. + virtual syncer::SyncableService* GetSessionsSyncableService(); + + // SyncInternalApiDelegate implementation. + // // Returns sync's representation of the local device info. // Return value is an empty scoped_ptr if the device info is unavailable. - virtual scoped_ptr<browser_sync::DeviceInfo> GetLocalDeviceInfo() const; + virtual scoped_ptr<browser_sync::DeviceInfo> GetLocalDeviceInfo() + const OVERRIDE; + + // Gets the guid for the local device. Can be used by other layers to + // to distinguish sync data that belongs to the local device vs data + // that belongs to remote devices. Returns empty string if sync is not + // initialized. The GUID is not persistent across Chrome signout/signin. + // If you sign out of Chrome and sign in, a new GUID is generated. + virtual std::string GetLocalSyncCacheGUID() const OVERRIDE; // Returns sync's representation of the device info for a client identified // by |client_id|. Return value is an empty scoped ptr if the device info @@ -299,12 +345,6 @@ class ProfileSyncService : public ProfileSyncServiceBase, // with this profile. virtual ScopedVector<browser_sync::DeviceInfo> GetAllSignedInDevices() const; - // Gets the partnership guid for the local device. Can be used by other - // layers to distinguish sync data that belongs to the local device vs - // data that belong to remote devices. Returns null if sync is not - // initialized. - virtual std::string GetLocalDeviceGUID() const; - // Notifies the observer of any device info changes. virtual void AddObserverForDeviceInfoChange( browser_sync::SyncedDeviceTracker::Observer* observer); @@ -454,10 +494,6 @@ class ProfileSyncService : public ProfileSyncServiceBase, // management. If so, the user is not allowed to configure sync. virtual bool IsManaged() const; - // SigninGlobalError::AuthStatusProvider implementation. - virtual std::string GetAccountId() const OVERRIDE; - virtual GoogleServiceAuthError GetAuthStatus() const OVERRIDE; - // syncer::UnrecoverableErrorHandler implementation. virtual void OnUnrecoverableError( const tracked_objects::Location& from_here, @@ -494,6 +530,12 @@ class ProfileSyncService : public ProfileSyncServiceBase, // Used by ProfileSyncServiceHarness. May return NULL. browser_sync::BackendMigrator* GetBackendMigratorForTest(); + // Used by tests to inspect interaction with OAuth2TokenService. + bool IsRetryingAccessTokenFetchForTest() const; + + // Used by tests to inspect the OAuth2 access tokens used by PSS. + std::string GetAccessTokenForTest() const; + // TODO(sync): This is only used in tests. Can we remove it? void GetModelSafeRoutingInfo(syncer::ModelSafeRoutingInfo* out) const; @@ -652,6 +694,11 @@ class ProfileSyncService : public ProfileSyncServiceBase, // told to MergeDataAndStartSyncing yet. void OnDataTypeRequestsSyncStartup(syncer::ModelType type); + // Return sync token status. + SyncTokenStatus GetSyncTokenStatus() const; + + browser_sync::FaviconCache* GetFaviconCache(); + protected: // Used by test classes that derive from ProfileSyncService. virtual browser_sync::SyncBackendHost* GetBackendForTest(); @@ -667,7 +714,7 @@ class ProfileSyncService : public ProfileSyncServiceBase, // to claim ownership of sync thread from backend. void ShutdownImpl(browser_sync::SyncBackendHost::ShutdownOption option); - // Return SyncCredentials from the TokenService. + // Return SyncCredentials from the OAuth2TokenService. syncer::SyncCredentials GetCredentials(); virtual syncer::WeakHandle<syncer::JsEventHandler> GetJsEventHandler(); @@ -719,6 +766,13 @@ class ProfileSyncService : public ProfileSyncServiceBase, ERROR_REASON_ACTIONABLE_ERROR, ERROR_REASON_LIMIT }; + + enum AuthErrorMetric { + AUTH_ERROR_ENCOUNTERED, + AUTH_ERROR_FIXED, + AUTH_ERROR_LIMIT + }; + friend class ProfileSyncServicePasswordTest; friend class SyncTest; friend class TestProfileSyncService; @@ -752,7 +806,7 @@ class ProfileSyncService : public ProfileSyncServiceBase, void ConsumeCachedPassphraseIfPossible(); // RequestAccessToken initiates RPC to request downscoped access token from - // refresh token. This happens when TokenService loads OAuth2 login token and + // refresh token. This happens when a new OAuth2 login token is loaded and // when sync server returns AUTH_ERROR which indicates it is time to refresh // token. virtual void RequestAccessToken(); @@ -822,6 +876,9 @@ class ProfileSyncService : public ProfileSyncServiceBase, // the credentials. std::string GetEffectiveUsername(); + // Returns the account ID to use to get tokens. + std::string GetAccountIdToUse(); + // Factory used to create various dependent objects. scoped_ptr<ProfileSyncComponentsFactory> factory_; @@ -973,6 +1030,16 @@ class ProfileSyncService : public ProfileSyncServiceBase, base::WeakPtrFactory<ProfileSyncService> weak_factory_; + // States related to sync token and connection. + base::Time connection_status_update_time_; + syncer::ConnectionStatus connection_status_; + base::Time token_request_time_; + base::Time token_receive_time_; + GoogleServiceAuthError last_get_token_error_; + base::Time next_token_request_time_; + + scoped_ptr<SessionsSyncManager> sessions_sync_manager_; + DISALLOW_COPY_AND_ASSIGN(ProfileSyncService); }; |