summaryrefslogtreecommitdiff
path: root/chrome/browser/sync/profile_sync_service.h
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2014-03-18 10:20:56 +0000
committerTorne (Richard Coles) <torne@google.com>2014-03-18 10:20:56 +0000
commita1401311d1ab56c4ed0a474bd38c108f75cb0cd9 (patch)
tree3437151d9ae1ce20a1e53a0d98c19ca01c786394 /chrome/browser/sync/profile_sync_service.h
parentaf5066f1e36c6579e74752647e6c584438f80f94 (diff)
downloadchromium_org-a1401311d1ab56c4ed0a474bd38c108f75cb0cd9.tar.gz
Merge from Chromium at DEPS revision 257591
This commit was generated by merge_to_master.py. Change-Id: I0010df2ec3fbb5d4947cd026de2feb150ce7a6b5
Diffstat (limited to 'chrome/browser/sync/profile_sync_service.h')
-rw-r--r--chrome/browser/sync/profile_sync_service.h108
1 files changed, 37 insertions, 71 deletions
diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h
index 10777c95b6..eb89d2f7f2 100644
--- a/chrome/browser/sync/profile_sync_service.h
+++ b/chrome/browser/sync/profile_sync_service.h
@@ -26,8 +26,9 @@
#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/startup_controller.h"
#include "chrome/browser/sync/sync_prefs.h"
-#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
+#include "components/keyed_service/core/keyed_service.h"
#include "components/sync_driver/data_type_controller.h"
#include "components/sync_driver/data_type_encryption_handler.h"
#include "components/sync_driver/data_type_manager.h"
@@ -166,18 +167,17 @@ using browser_sync::SessionsSyncManager;
// 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 syncer::UnrecoverableErrorHandler,
- public content::NotificationObserver,
- public BrowserContextKeyedService,
- public browser_sync::DataTypeEncryptionHandler,
- public OAuth2TokenService::Consumer,
- public OAuth2TokenService::Observer,
- public SessionsSyncManager::SyncInternalApiDelegate {
+class ProfileSyncService : public ProfileSyncServiceBase,
+ public browser_sync::SyncFrontend,
+ public browser_sync::SyncPrefObserver,
+ public browser_sync::DataTypeManagerObserver,
+ public syncer::UnrecoverableErrorHandler,
+ public content::NotificationObserver,
+ public KeyedService,
+ public browser_sync::DataTypeEncryptionHandler,
+ public OAuth2TokenService::Consumer,
+ public OAuth2TokenService::Observer,
+ public SessionsSyncManager::SyncInternalApiDelegate {
public:
typedef browser_sync::SyncBackendHost::Status Status;
@@ -226,18 +226,6 @@ class ProfileSyncService
MAX_SYNC_EVENT_CODE
};
- // Defines the type of behavior the sync engine should use. If configured for
- // AUTO_START, the sync engine will automatically call SetSyncSetupCompleted()
- // and start downloading data types as soon as sync credentials are available
- // (a signed-in username and a "chromiumsync" token).
- // If configured for MANUAL_START, sync will not start until the user
- // completes sync setup, at which point the UI makes an explicit call to
- // SetSyncSetupCompleted().
- enum StartBehavior {
- AUTO_START,
- MANUAL_START,
- };
-
// Used to specify the kind of passphrase with which sync data is encrypted.
enum PassphraseType {
IMPLICIT, // The user did not provide a custom passphrase for encryption.
@@ -261,11 +249,12 @@ class ProfileSyncService
static const char* kDevServerUrl;
// Takes ownership of |factory| and |signin_wrapper|.
- ProfileSyncService(ProfileSyncComponentsFactory* factory,
- Profile* profile,
- ManagedUserSigninManagerWrapper* signin_wrapper,
- ProfileOAuth2TokenService* oauth2_token_service,
- StartBehavior start_behavior);
+ ProfileSyncService(
+ ProfileSyncComponentsFactory* factory,
+ Profile* profile,
+ ManagedUserSigninManagerWrapper* signin_wrapper,
+ ProfileOAuth2TokenService* oauth2_token_service,
+ browser_sync::ProfileSyncServiceStartBehavior start_behavior);
virtual ~ProfileSyncService();
// Initializes the object. This must be called at most once, and
@@ -292,6 +281,9 @@ class ProfileSyncService
// be missing because they have not loaded yet, or because they were deleted
// due to http://crbug.com/121755).
// Virtual to enable mocking in tests.
+ // TODO(tim): Remove this? Nothing in ProfileSyncService uses it, and outside
+ // callers use a seemingly arbitrary / redundant / bug prone combination of
+ // this method, IsSyncAccessible, and others.
virtual bool IsSyncEnabledAndLoggedIn();
// Return whether OAuth2 refresh token is loaded and available for the backend
@@ -641,9 +633,11 @@ class ProfileSyncService
virtual bool encryption_pending() const;
const GURL& sync_service_url() const { return sync_service_url_; }
- bool auto_start_enabled() const { return auto_start_enabled_; }
SigninManagerBase* signin() const;
- bool setup_in_progress() const { return setup_in_progress_; }
+
+ // Used by tests.
+ bool auto_start_enabled() const;
+ bool setup_in_progress() const;
// Stops the sync backend and sets the flag for suppressing sync startup.
void StopAndSuppress();
@@ -688,7 +682,7 @@ class ProfileSyncService
virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE;
virtual void OnRefreshTokensLoaded() OVERRIDE;
- // BrowserContextKeyedService implementation. This must be called exactly
+ // KeyedService implementation. This must be called exactly
// once (before this object is destroyed).
virtual void Shutdown() OVERRIDE;
@@ -786,10 +780,6 @@ class ProfileSyncService
// not correctly set.
void TrySyncDatatypePrefRecovery();
- // Starts up sync if it is not suppressed and preconditions are met.
- // Called from Initialize() and UnsuppressAndStart().
- void TryStart();
-
// Puts the backend's sync scheduler into NORMAL mode.
// Called when configuration is complete.
void StartSyncingWithServer();
@@ -828,12 +818,6 @@ class ProfileSyncService
void ClearUnrecoverableError();
- enum StartUpDeferredOption {
- STARTUP_BACKEND_DEFERRED,
- STARTUP_IMMEDIATE
- };
- void StartUp(StartUpDeferredOption deferred_option);
-
// Starts up the backend sync components.
void StartUpSlowBackendComponents();
@@ -872,13 +856,6 @@ class ProfileSyncService
bool delete_sync_database,
UnrecoverableErrorReason reason);
- // Returns the username (in form of an email address) that should be used in
- // 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_;
@@ -897,17 +874,6 @@ class ProfileSyncService
// Our backend notifies us whenever we should take a new snapshot.
base::Time last_synced_time_;
- // The time that StartUp() is called. This member is zero if StartUp() has
- // never been called, and is reset to zero once OnBackendInitialized() is
- // called.
- base::Time start_up_time_;
-
- // Whether we have received a signal from a SyncableService requesting that
- // sync starts as soon as possible.
- // TODO(tim): Move this and other TryStart related logic + state to separate
- // class. Bug 80149.
- bool data_type_requested_sync_startup_;
-
// The time that OnConfigureStart is called. This member is zero if
// OnConfigureStart has not yet been called, and is reset to zero once
// OnConfigureDone is called.
@@ -973,12 +939,6 @@ class ProfileSyncService
// if they e.g. don't remember their explicit passphrase.
bool encryption_pending_;
- // If true, we want to automatically start sync signin whenever we have
- // credentials (user doesn't need to go through the startup flow). This is
- // typically enabled on platforms (like ChromeOS) that have their own
- // distinct signin flow.
- const bool auto_start_enabled_;
-
scoped_ptr<browser_sync::BackendMigrator> migrator_;
// This is the last |SyncProtocolError| we received from the server that had
@@ -994,10 +954,6 @@ class ProfileSyncService
browser_sync::DataTypeManager::ConfigureStatus configure_status_;
- // If |true|, there is setup UI visible so we should not start downloading
- // data types.
- bool setup_in_progress_;
-
// The set of currently enabled sync experiments.
syncer::Experiments current_experiments_;
@@ -1030,6 +986,14 @@ class ProfileSyncService
base::WeakPtrFactory<ProfileSyncService> weak_factory_;
+ // We don't use |weak_factory_| for the StartupController because the weak
+ // ptrs should be bound to the lifetime of ProfileSyncService and not to the
+ // [Initialize -> sync disabled/shutdown] lifetime. We don't pass
+ // StartupController an Unretained reference to future-proof against
+ // the controller impl changing to post tasks. Therefore, we have a separate
+ // factory.
+ base::WeakPtrFactory<ProfileSyncService> startup_controller_weak_factory_;
+
// States related to sync token and connection.
base::Time connection_status_update_time_;
syncer::ConnectionStatus connection_status_;
@@ -1042,6 +1006,8 @@ class ProfileSyncService
scoped_ptr<syncer::NetworkResources> network_resources_;
+ browser_sync::StartupController startup_controller_;
+
DISALLOW_COPY_AND_ASSIGN(ProfileSyncService);
};