| Index: sync/internal_api/public/sync_manager.h
|
| diff --git a/sync/internal_api/public/sync_manager.h b/sync/internal_api/public/sync_manager.h
|
| index 75e55aa540ce32494521b617f3c1b6c24e0141a3..bafec90aefbb47d478a02acfb917a7b81e4c2f87 100644
|
| --- a/sync/internal_api/public/sync_manager.h
|
| +++ b/sync/internal_api/public/sync_manager.h
|
| @@ -31,6 +31,7 @@ struct Experiments;
|
| class ExtensionsActivityMonitor;
|
| class JsBackend;
|
| class JsEventHandler;
|
| +class SyncScheduler;
|
|
|
| namespace sessions {
|
| class SyncSessionSnapshot;
|
| @@ -371,41 +372,43 @@ class SyncManager {
|
| //
|
| // TODO(akalin): Replace the |post_factory| parameter with a
|
| // URLFetcher parameter.
|
| - bool Init(const FilePath& database_location,
|
| - const syncer::WeakHandle<syncer::JsEventHandler>&
|
| - event_handler,
|
| - const std::string& sync_server_and_path,
|
| - int sync_server_port,
|
| - bool use_ssl,
|
| - const scoped_refptr<base::TaskRunner>& blocking_task_runner,
|
| - HttpPostProviderFactory* post_factory,
|
| - const syncer::ModelSafeRoutingInfo& model_safe_routing_info,
|
| - const std::vector<syncer::ModelSafeWorker*>& workers,
|
| - syncer::ExtensionsActivityMonitor*
|
| - extensions_activity_monitor,
|
| - ChangeDelegate* change_delegate,
|
| - const SyncCredentials& credentials,
|
| - syncer::SyncNotifier* sync_notifier,
|
| - const std::string& restored_key_for_bootstrapping,
|
| - TestingMode testing_mode,
|
| - syncer::Encryptor* encryptor,
|
| - syncer::UnrecoverableErrorHandler*
|
| - unrecoverable_error_handler,
|
| - syncer::ReportUnrecoverableErrorFunction
|
| - report_unrecoverable_error_function);
|
| + virtual bool Init(
|
| + const FilePath& database_location,
|
| + const syncer::WeakHandle<syncer::JsEventHandler>& event_handler,
|
| + const std::string& sync_server_and_path,
|
| + int sync_server_port,
|
| + bool use_ssl,
|
| + const scoped_refptr<base::TaskRunner>& blocking_task_runner,
|
| + scoped_ptr<HttpPostProviderFactory> post_factory,
|
| + const syncer::ModelSafeRoutingInfo& model_safe_routing_info,
|
| + const std::vector<syncer::ModelSafeWorker*>& workers,
|
| + syncer::ExtensionsActivityMonitor* extensions_activity_monitor,
|
| + ChangeDelegate* change_delegate,
|
| + const SyncCredentials& credentials,
|
| + scoped_ptr<syncer::SyncNotifier> sync_notifier,
|
| + const std::string& restored_key_for_bootstrapping,
|
| + TestingMode testing_mode,
|
| + syncer::Encryptor* encryptor,
|
| + syncer::UnrecoverableErrorHandler* unrecoverable_error_handler,
|
| + syncer::ReportUnrecoverableErrorFunction
|
| + report_unrecoverable_error_function);
|
|
|
| // Throw an unrecoverable error from a transaction (mostly used for
|
| // testing).
|
| void ThrowUnrecoverableError();
|
|
|
| - // Returns the set of types for which we have stored some sync data.
|
| - syncer::ModelTypeSet InitialSyncEndedTypes();
|
| + virtual syncer::ModelTypeSet InitialSyncEndedTypes();
|
| +
|
| + // Returns those types within |types| that have an empty progress marker
|
| + // token.
|
| + virtual syncer::ModelTypeSet GetTypesWithEmptyProgressMarkerToken(
|
| + syncer::ModelTypeSet types);
|
|
|
| // Update tokens that we're using in Sync. Email must stay the same.
|
| void UpdateCredentials(const SyncCredentials& credentials);
|
|
|
| // Called when the user disables or enables a sync type.
|
| - void UpdateEnabledTypes(const syncer::ModelTypeSet& enabled_types);
|
| + virtual void UpdateEnabledTypes(const syncer::ModelTypeSet& enabled_types);
|
|
|
| // Put the syncer in normal mode ready to perform nudges and polls.
|
| void StartSyncingNormally(
|
| @@ -428,30 +431,30 @@ class SyncManager {
|
| // error to call this when we don't have pending keys.
|
| void SetDecryptionPassphrase(const std::string& passphrase);
|
|
|
| - // Puts the SyncScheduler into a mode where no normal nudge or poll traffic
|
| - // will occur, but calls to RequestConfig will be supported. If |callback|
|
| - // is provided, it will be invoked (from the internal SyncScheduler) when
|
| - // the thread has changed to configuration mode.
|
| - void StartConfigurationMode(const base::Closure& callback);
|
| -
|
| - // Switches the mode of operation to CONFIGURATION_MODE and
|
| - // schedules a config task to fetch updates for |types|.
|
| - void RequestConfig(const syncer::ModelSafeRoutingInfo& routing_info,
|
| - const syncer::ModelTypeSet& types,
|
| - syncer::ConfigureReason reason);
|
| -
|
| - void RequestCleanupDisabledTypes(
|
| - const syncer::ModelSafeRoutingInfo& routing_info);
|
| + // Switches the mode of operation to CONFIGURATION_MODE and performs
|
| + // any configuration tasks needed as determined by the params. Once complete,
|
| + // syncer will remain in CONFIGURATION_MODE until StartSyncingNormally is
|
| + // called.
|
| + // |ready_task| is invoked when the configuration completes.
|
| + // |retry_task| is invoked if the configuration job could not immediately
|
| + // execute. |ready_task| will still be called when it eventually
|
| + // does finish.
|
| + virtual void ConfigureSyncer(
|
| + ConfigureReason reason,
|
| + const syncer::ModelTypeSet& types_to_config,
|
| + const syncer::ModelSafeRoutingInfo& new_routing_info,
|
| + const base::Closure& ready_task,
|
| + const base::Closure& retry_task);
|
|
|
| // Adds a listener to be notified of sync events.
|
| // NOTE: It is OK (in fact, it's probably a good idea) to call this before
|
| // having received OnInitializationCompleted.
|
| - void AddObserver(Observer* observer);
|
| + virtual void AddObserver(Observer* observer);
|
|
|
| // Remove the given observer. Make sure to call this if the
|
| // Observer is being destroyed so the SyncManager doesn't
|
| // potentially dereference garbage.
|
| - void RemoveObserver(Observer* observer);
|
| + virtual void RemoveObserver(Observer* observer);
|
|
|
| // Status-related getter. May be called on any thread.
|
| SyncStatus GetDetailedStatus() const;
|
| @@ -476,7 +479,7 @@ class SyncManager {
|
| void StopSyncingForShutdown(const base::Closure& callback);
|
|
|
| // Issue a final SaveChanges, and close sqlite handles.
|
| - void ShutdownOnSyncThread();
|
| + virtual void ShutdownOnSyncThread();
|
|
|
| // May be called from any thread.
|
| UserShare* GetUserShare() const;
|
| @@ -493,8 +496,8 @@ class SyncManager {
|
| //
|
| // Note: opens a transaction, so must only be called after syncapi
|
| // has been initialized.
|
| - void RefreshNigori(const std::string& chrome_version,
|
| - const base::Closure& done_callback);
|
| + virtual void RefreshNigori(const std::string& chrome_version,
|
| + const base::Closure& done_callback);
|
|
|
| // Enable encryption of all sync data. Once enabled, it can never be
|
| // disabled without clearing the server data.
|
| @@ -516,7 +519,7 @@ class SyncManager {
|
| // Reads the nigori node to determine if any experimental features should
|
| // be enabled.
|
| // Note: opens a transaction. May be called on any thread.
|
| - bool ReceivedExperiment(syncer::Experiments* experiments) const;
|
| + virtual bool ReceivedExperiment(syncer::Experiments* experiments) const;
|
|
|
| // Uses a read-only transaction to determine if the directory being synced has
|
| // any remaining unsynced items. May be called on any thread.
|
| @@ -538,11 +541,17 @@ class SyncManager {
|
| static const FilePath::CharType kSyncDatabaseFilename[];
|
|
|
| private:
|
| + friend class SyncManagerTest;
|
| FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, NudgeDelayTest);
|
|
|
| // For unit tests.
|
| base::TimeDelta GetNudgeDelayTimeDelta(const syncer::ModelType& model_type);
|
|
|
| + // Set the internal scheduler for testing purposes.
|
| + // TODO(sync): Use dependency injection instead. crbug.com/133061
|
| + void SetSyncSchedulerForTest(
|
| + scoped_ptr<syncer::SyncScheduler> scheduler);
|
| +
|
| base::ThreadChecker thread_checker_;
|
|
|
| // An opaque pointer to the nested private class.
|
| @@ -553,10 +562,6 @@ class SyncManager {
|
|
|
| bool InitialSyncEndedForTypes(syncer::ModelTypeSet types, UserShare* share);
|
|
|
| -syncer::ModelTypeSet GetTypesWithEmptyProgressMarkerToken(
|
| - syncer::ModelTypeSet types,
|
| - syncer::UserShare* share);
|
| -
|
| const char* ConnectionStatusToString(ConnectionStatus status);
|
|
|
| // Returns the string representation of a PassphraseRequiredReason value.
|
|
|