| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SYNC_INTERNAL_API_SYNC_MANAGER_H_ | 5 #ifndef SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
| 6 #define SYNC_INTERNAL_API_SYNC_MANAGER_H_ | 6 #define SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // internal types from clients of the interface. | 26 // internal types from clients of the interface. |
| 27 class SyncInternal; | 27 class SyncInternal; |
| 28 | 28 |
| 29 // Create an uninitialized SyncManager. Callers must Init() before using. | 29 // Create an uninitialized SyncManager. Callers must Init() before using. |
| 30 explicit SyncManagerImpl(const std::string& name); | 30 explicit SyncManagerImpl(const std::string& name); |
| 31 virtual ~SyncManagerImpl(); | 31 virtual ~SyncManagerImpl(); |
| 32 | 32 |
| 33 // SyncManager implementation. | 33 // SyncManager implementation. |
| 34 virtual bool Init( | 34 virtual bool Init( |
| 35 const FilePath& database_location, | 35 const FilePath& database_location, |
| 36 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, | 36 const WeakHandle<JsEventHandler>& event_handler, |
| 37 const std::string& sync_server_and_path, | 37 const std::string& sync_server_and_path, |
| 38 int sync_server_port, | 38 int sync_server_port, |
| 39 bool use_ssl, | 39 bool use_ssl, |
| 40 const scoped_refptr<base::TaskRunner>& blocking_task_runner, | 40 const scoped_refptr<base::TaskRunner>& blocking_task_runner, |
| 41 scoped_ptr<HttpPostProviderFactory> post_factory, | 41 scoped_ptr<HttpPostProviderFactory> post_factory, |
| 42 const syncer::ModelSafeRoutingInfo& model_safe_routing_info, | 42 const ModelSafeRoutingInfo& model_safe_routing_info, |
| 43 const std::vector<syncer::ModelSafeWorker*>& workers, | 43 const std::vector<ModelSafeWorker*>& workers, |
| 44 syncer::ExtensionsActivityMonitor* extensions_activity_monitor, | 44 ExtensionsActivityMonitor* extensions_activity_monitor, |
| 45 SyncManager::ChangeDelegate* change_delegate, | 45 SyncManager::ChangeDelegate* change_delegate, |
| 46 const SyncCredentials& credentials, | 46 const SyncCredentials& credentials, |
| 47 scoped_ptr<syncer::SyncNotifier> sync_notifier, | 47 scoped_ptr<SyncNotifier> sync_notifier, |
| 48 const std::string& restored_key_for_bootstrapping, | 48 const std::string& restored_key_for_bootstrapping, |
| 49 TestingMode testing_mode, | 49 TestingMode testing_mode, |
| 50 syncer::Encryptor* encryptor, | 50 Encryptor* encryptor, |
| 51 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler, | 51 UnrecoverableErrorHandler* unrecoverable_error_handler, |
| 52 syncer::ReportUnrecoverableErrorFunction | 52 ReportUnrecoverableErrorFunction |
| 53 report_unrecoverable_error_function) OVERRIDE; | 53 report_unrecoverable_error_function) OVERRIDE; |
| 54 virtual void ThrowUnrecoverableError() OVERRIDE; | 54 virtual void ThrowUnrecoverableError() OVERRIDE; |
| 55 virtual syncer::ModelTypeSet InitialSyncEndedTypes() OVERRIDE; | 55 virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE; |
| 56 virtual syncer::ModelTypeSet GetTypesWithEmptyProgressMarkerToken( | 56 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( |
| 57 syncer::ModelTypeSet types) OVERRIDE; | 57 ModelTypeSet types) OVERRIDE; |
| 58 virtual bool PurgePartiallySyncedTypes() OVERRIDE; | 58 virtual bool PurgePartiallySyncedTypes() OVERRIDE; |
| 59 virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE; | 59 virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE; |
| 60 virtual void UpdateEnabledTypes( | 60 virtual void UpdateEnabledTypes( |
| 61 const syncer::ModelTypeSet& enabled_types) OVERRIDE; | 61 const ModelTypeSet& enabled_types) OVERRIDE; |
| 62 virtual void StartSyncingNormally( | 62 virtual void StartSyncingNormally( |
| 63 const syncer::ModelSafeRoutingInfo& routing_info) OVERRIDE; | 63 const ModelSafeRoutingInfo& routing_info) OVERRIDE; |
| 64 virtual void SetEncryptionPassphrase(const std::string& passphrase, | 64 virtual void SetEncryptionPassphrase(const std::string& passphrase, |
| 65 bool is_explicit) OVERRIDE; | 65 bool is_explicit) OVERRIDE; |
| 66 virtual void SetDecryptionPassphrase(const std::string& passphrase) OVERRIDE; | 66 virtual void SetDecryptionPassphrase(const std::string& passphrase) OVERRIDE; |
| 67 virtual void ConfigureSyncer( | 67 virtual void ConfigureSyncer( |
| 68 ConfigureReason reason, | 68 ConfigureReason reason, |
| 69 const syncer::ModelTypeSet& types_to_config, | 69 const ModelTypeSet& types_to_config, |
| 70 const syncer::ModelSafeRoutingInfo& new_routing_info, | 70 const ModelSafeRoutingInfo& new_routing_info, |
| 71 const base::Closure& ready_task, | 71 const base::Closure& ready_task, |
| 72 const base::Closure& retry_task) OVERRIDE; | 72 const base::Closure& retry_task) OVERRIDE; |
| 73 virtual void AddObserver(Observer* observer) OVERRIDE; | 73 virtual void AddObserver(Observer* observer) OVERRIDE; |
| 74 virtual void RemoveObserver(Observer* observer) OVERRIDE; | 74 virtual void RemoveObserver(Observer* observer) OVERRIDE; |
| 75 virtual SyncStatus GetDetailedStatus() const OVERRIDE; | 75 virtual SyncStatus GetDetailedStatus() const OVERRIDE; |
| 76 virtual bool IsUsingExplicitPassphrase() OVERRIDE; | 76 virtual bool IsUsingExplicitPassphrase() OVERRIDE; |
| 77 virtual void SaveChanges() OVERRIDE; | 77 virtual void SaveChanges() OVERRIDE; |
| 78 virtual void StopSyncingForShutdown(const base::Closure& callback) OVERRIDE; | 78 virtual void StopSyncingForShutdown(const base::Closure& callback) OVERRIDE; |
| 79 virtual void ShutdownOnSyncThread() OVERRIDE; | 79 virtual void ShutdownOnSyncThread() OVERRIDE; |
| 80 virtual UserShare* GetUserShare() const OVERRIDE; | 80 virtual UserShare* GetUserShare() const OVERRIDE; |
| 81 virtual void RefreshNigori(const std::string& chrome_version, | 81 virtual void RefreshNigori(const std::string& chrome_version, |
| 82 const base::Closure& done_callback) OVERRIDE; | 82 const base::Closure& done_callback) OVERRIDE; |
| 83 virtual void EnableEncryptEverything() OVERRIDE; | 83 virtual void EnableEncryptEverything() OVERRIDE; |
| 84 virtual bool ReceivedExperiment( | 84 virtual bool ReceivedExperiment(Experiments* experiments) const OVERRIDE; |
| 85 syncer::Experiments* experiments) const OVERRIDE; | |
| 86 virtual bool HasUnsyncedItems() const OVERRIDE; | 85 virtual bool HasUnsyncedItems() const OVERRIDE; |
| 87 | 86 |
| 88 // Functions used for testing. | 87 // Functions used for testing. |
| 89 | 88 |
| 90 // Returns true if we are currently encrypting all sync data. May | 89 // Returns true if we are currently encrypting all sync data. May |
| 91 // be called on any thread. | 90 // be called on any thread. |
| 92 bool EncryptEverythingEnabledForTest() const; | 91 bool EncryptEverythingEnabledForTest() const; |
| 93 | 92 |
| 94 // Gets the set of encrypted types from the cryptographer | 93 // Gets the set of encrypted types from the cryptographer |
| 95 // Note: opens a transaction. May be called from any thread. | 94 // Note: opens a transaction. May be called from any thread. |
| 96 syncer::ModelTypeSet GetEncryptedDataTypesForTest() const; | 95 ModelTypeSet GetEncryptedDataTypesForTest() const; |
| 97 | 96 |
| 98 void SimulateEnableNotificationsForTest(); | 97 void SimulateEnableNotificationsForTest(); |
| 99 void SimulateDisableNotificationsForTest(int reason); | 98 void SimulateDisableNotificationsForTest(int reason); |
| 100 void TriggerOnIncomingNotificationForTest(syncer::ModelTypeSet model_types); | 99 void TriggerOnIncomingNotificationForTest(ModelTypeSet model_types); |
| 101 | 100 |
| 102 static int GetDefaultNudgeDelay(); | 101 static int GetDefaultNudgeDelay(); |
| 103 static int GetPreferencesNudgeDelay(); | 102 static int GetPreferencesNudgeDelay(); |
| 104 | 103 |
| 105 private: | 104 private: |
| 106 friend class SyncManagerTest; | 105 friend class SyncManagerTest; |
| 107 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, NudgeDelayTest); | 106 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, NudgeDelayTest); |
| 108 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, OnNotificationStateChange); | 107 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, OnNotificationStateChange); |
| 109 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, OnIncomingNotification); | 108 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, OnIncomingNotification); |
| 110 | 109 |
| 111 base::TimeDelta GetNudgeDelayTimeDelta(const syncer::ModelType& model_type); | 110 base::TimeDelta GetNudgeDelayTimeDelta(const ModelType& model_type); |
| 112 | 111 |
| 113 // Set the internal scheduler for testing purposes. | 112 // Set the internal scheduler for testing purposes. |
| 114 // TODO(sync): Use dependency injection instead. crbug.com/133061 | 113 // TODO(sync): Use dependency injection instead. crbug.com/133061 |
| 115 void SetSyncSchedulerForTest( | 114 void SetSyncSchedulerForTest(scoped_ptr<SyncScheduler> scheduler); |
| 116 scoped_ptr<syncer::SyncScheduler> scheduler); | |
| 117 | 115 |
| 118 base::ThreadChecker thread_checker_; | 116 base::ThreadChecker thread_checker_; |
| 119 | 117 |
| 120 // An opaque pointer to the nested private class. | 118 // An opaque pointer to the nested private class. |
| 121 SyncInternal* data_; | 119 SyncInternal* data_; |
| 122 | 120 |
| 123 DISALLOW_COPY_AND_ASSIGN(SyncManagerImpl); | 121 DISALLOW_COPY_AND_ASSIGN(SyncManagerImpl); |
| 124 }; | 122 }; |
| 125 | 123 |
| 126 } // namespace syncer | 124 } // namespace syncer |
| 127 | 125 |
| 128 #endif // SYNC_INTERNAL_API_SYNC_MANAGER_H_ | 126 #endif // SYNC_INTERNAL_API_SYNC_MANAGER_H_ |
| OLD | NEW |