#ifndef SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_
#define SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_
#include <string>
#include "base/memory/ref_counted.h"
#include "base/observer_list.h"
#include "sync/internal_api/public/sync_manager.h"
#include "sync/notifier/invalidator_registrar.h"
namespace base {
class SequencedTaskRunner;
}
namespace syncer {
class FakeSyncEncryptionHandler;
class FakeSyncManager : public SyncManager {
public:
FakeSyncManager(ModelTypeSet initial_sync_ended_types,
ModelTypeSet progress_marker_types,
ModelTypeSet configure_fail_types);
virtual ~FakeSyncManager();
ModelTypeSet GetAndResetCleanedTypes();
ModelTypeSet GetAndResetDownloadedTypes();
ModelTypeSet GetAndResetEnabledTypes();
void Invalidate(const ObjectIdStateMap& id_state_map,
IncomingInvalidationSource source);
void UpdateInvalidatorState(InvalidatorState state);
void WaitForSyncThread();
virtual void Init(
const FilePath& database_location,
const WeakHandle<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 std::vector<ModelSafeWorker*>& workers,
ExtensionsActivityMonitor* extensions_activity_monitor,
ChangeDelegate* change_delegate,
const SyncCredentials& credentials,
scoped_ptr<Invalidator> invalidator,
const std::string& restored_key_for_bootstrapping,
const std::string& restored_keystore_key_for_bootstrapping,
scoped_ptr<InternalComponentsFactory> internal_components_factory,
Encryptor* encryptor,
UnrecoverableErrorHandler* unrecoverable_error_handler,
ReportUnrecoverableErrorFunction
report_unrecoverable_error_function) OVERRIDE;
virtual void ThrowUnrecoverableError() OVERRIDE;
virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE;
virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken(
ModelTypeSet types) OVERRIDE;
virtual bool PurgePartiallySyncedTypes() OVERRIDE;
virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE;
virtual void UpdateEnabledTypes(ModelTypeSet types) OVERRIDE;
virtual void RegisterInvalidationHandler(
InvalidationHandler* handler) OVERRIDE;
virtual void UpdateRegisteredInvalidationIds(
InvalidationHandler* handler,
const ObjectIdSet& ids) OVERRIDE;
virtual void UnregisterInvalidationHandler(
InvalidationHandler* handler) OVERRIDE;
virtual void StartSyncingNormally(
const ModelSafeRoutingInfo& routing_info) OVERRIDE;
virtual void ConfigureSyncer(
ConfigureReason reason,
ModelTypeSet types_to_config,
const ModelSafeRoutingInfo& new_routing_info,
const base::Closure& ready_task,
const base::Closure& retry_task) OVERRIDE;
virtual void AddObserver(Observer* observer) OVERRIDE;
virtual void RemoveObserver(Observer* observer) OVERRIDE;
virtual SyncStatus GetDetailedStatus() const OVERRIDE;
virtual void SaveChanges() OVERRIDE;
virtual void StopSyncingForShutdown(const base::Closure& callback) OVERRIDE;
virtual void ShutdownOnSyncThread() OVERRIDE;
virtual UserShare* GetUserShare() OVERRIDE;
virtual bool ReceivedExperiment(Experiments* experiments) OVERRIDE;
virtual bool HasUnsyncedItems() OVERRIDE;
virtual SyncEncryptionHandler* GetEncryptionHandler() OVERRIDE;
private:
void InvalidateOnSyncThread(
const ObjectIdStateMap& id_state_map,
IncomingInvalidationSource source);
void UpdateInvalidatorStateOnSyncThread(InvalidatorState state);
scoped_refptr<base::SequencedTaskRunner> sync_task_runner_;
ObserverList<SyncManager::Observer> observers_;
ModelTypeSet initial_sync_ended_types_;
ModelTypeSet progress_marker_types_;
ModelTypeSet configure_fail_types_;
ModelTypeSet cleaned_types_;
ModelTypeSet downloaded_types_;
ModelTypeSet enabled_types_;
InvalidatorRegistrar registrar_;
scoped_ptr<FakeSyncEncryptionHandler> fake_encryption_handler_;
DISALLOW_COPY_AND_ASSIGN(FakeSyncManager);
};
}
#endif