| 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_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_ |
| 6 #define SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "sync/internal_api/public/sync_manager.h" | 12 #include "sync/internal_api/public/sync_manager.h" |
| 13 #include "sync/notifier/sync_notifier_helper.h" | 13 #include "sync/notifier/sync_notifier_registrar.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class SequencedTaskRunner; | 16 class SequencedTaskRunner; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace syncer { | 19 namespace syncer { |
| 20 | 20 |
| 21 class FakeSyncManager : public SyncManager { | 21 class FakeSyncManager : public SyncManager { |
| 22 public: | 22 public: |
| 23 explicit FakeSyncManager(); | 23 // |initial_sync_ended_types|: The set of types that have initial_sync_ended |
| 24 // set to true. This value will be used by InitialSyncEndedTypes() until the |
| 25 // next configuration is performed. |
| 26 // |
| 27 // |progress_marker_types|: The set of types that have valid progress |
| 28 // markers. This will be used by GetTypesWithEmptyProgressMarkerToken() until |
| 29 // the next configuration is performed. |
| 30 // |
| 31 // |configure_fail_types|: The set of types that will fail |
| 32 // configuration. Once ConfigureSyncer is called, the |
| 33 // |initial_sync_ended_types_| and |progress_marker_types_| will be updated |
| 34 // to include those types that didn't fail. |
| 35 FakeSyncManager(ModelTypeSet initial_sync_ended_types, |
| 36 ModelTypeSet progress_marker_types, |
| 37 ModelTypeSet configure_fail_types); |
| 24 virtual ~FakeSyncManager(); | 38 virtual ~FakeSyncManager(); |
| 25 | 39 |
| 26 // The set of types that have initial_sync_ended set to true. This value will | |
| 27 // be used by InitialSyncEndedTypes() until the next configuration is | |
| 28 // performed. | |
| 29 void set_initial_sync_ended_types(ModelTypeSet types); | |
| 30 | |
| 31 // The set of types that have valid progress markers. This will be used by | |
| 32 // GetTypesWithEmptyProgressMarkerToken() until the next configuration is | |
| 33 // performed. | |
| 34 void set_progress_marker_types(ModelTypeSet types); | |
| 35 | |
| 36 // The set of types that will fail configuration. Once ConfigureSyncer is | |
| 37 // called, the |initial_sync_ended_types_| and | |
| 38 // |progress_marker_types_| will be updated to include those types | |
| 39 // that didn't fail. | |
| 40 void set_configure_fail_types(ModelTypeSet types); | |
| 41 | |
| 42 // Returns those types that have been cleaned (purged from the directory) | 40 // Returns those types that have been cleaned (purged from the directory) |
| 43 // since the last call to GetAndResetCleanedTypes(), or since startup if never | 41 // since the last call to GetAndResetCleanedTypes(), or since startup if never |
| 44 // called. | 42 // called. |
| 45 ModelTypeSet GetAndResetCleanedTypes(); | 43 ModelTypeSet GetAndResetCleanedTypes(); |
| 46 | 44 |
| 47 // Returns those types that have been downloaded since the last call to | 45 // Returns those types that have been downloaded since the last call to |
| 48 // GetAndResetDownloadedTypes(), or since startup if never called. | 46 // GetAndResetDownloadedTypes(), or since startup if never called. |
| 49 ModelTypeSet GetAndResetDownloadedTypes(); | 47 ModelTypeSet GetAndResetDownloadedTypes(); |
| 50 | 48 |
| 51 // Returns those types that have been marked as enabled since the | 49 // Returns those types that have been marked as enabled since the |
| 52 // last call to GetAndResetEnabledTypes(), or since startup if never | 50 // last call to GetAndResetEnabledTypes(), or since startup if never |
| 53 // called. | 51 // called. |
| 54 ModelTypeSet GetAndResetEnabledTypes(); | 52 ModelTypeSet GetAndResetEnabledTypes(); |
| 55 | 53 |
| 56 // Posts a method to invalidate the given IDs on the sync thread. | 54 // Posts a method to invalidate the given IDs on the sync thread. |
| 57 void Invalidate(const ObjectIdPayloadMap& id_payloads, | 55 void Invalidate(const ObjectIdPayloadMap& id_payloads, |
| 58 IncomingNotificationSource source); | 56 IncomingNotificationSource source); |
| 59 | 57 |
| 60 // Posts a method to enable notifications on the sync thread. | 58 // Posts a method to enable notifications on the sync thread. |
| 61 void EnableNotifications(); | 59 void EnableNotifications(); |
| 62 | 60 |
| 63 // Posts a method to disable notifications on the sync thread. | 61 // Posts a method to disable notifications on the sync thread. |
| 64 void DisableNotifications(NotificationsDisabledReason reason); | 62 void DisableNotifications(NotificationsDisabledReason reason); |
| 65 | 63 |
| 64 // Block until the sync thread has finished processing any pending messages. |
| 65 void WaitForSyncThread(); |
| 66 |
| 66 // SyncManager implementation. | 67 // SyncManager implementation. |
| 67 // Note: we treat whatever message loop this is called from as the sync | 68 // Note: we treat whatever message loop this is called from as the sync |
| 68 // loop for purposes of callbacks. | 69 // loop for purposes of callbacks. |
| 69 virtual bool Init( | 70 virtual bool Init( |
| 70 const FilePath& database_location, | 71 const FilePath& database_location, |
| 71 const WeakHandle<JsEventHandler>& event_handler, | 72 const WeakHandle<JsEventHandler>& event_handler, |
| 72 const std::string& sync_server_and_path, | 73 const std::string& sync_server_and_path, |
| 73 int sync_server_port, | 74 int sync_server_port, |
| 74 bool use_ssl, | 75 bool use_ssl, |
| 75 const scoped_refptr<base::TaskRunner>& blocking_task_runner, | 76 const scoped_refptr<base::TaskRunner>& blocking_task_runner, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 87 UnrecoverableErrorHandler* unrecoverable_error_handler, | 88 UnrecoverableErrorHandler* unrecoverable_error_handler, |
| 88 ReportUnrecoverableErrorFunction | 89 ReportUnrecoverableErrorFunction |
| 89 report_unrecoverable_error_function) OVERRIDE; | 90 report_unrecoverable_error_function) OVERRIDE; |
| 90 virtual void ThrowUnrecoverableError() OVERRIDE; | 91 virtual void ThrowUnrecoverableError() OVERRIDE; |
| 91 virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE; | 92 virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE; |
| 92 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( | 93 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( |
| 93 ModelTypeSet types) OVERRIDE; | 94 ModelTypeSet types) OVERRIDE; |
| 94 virtual bool PurgePartiallySyncedTypes() OVERRIDE; | 95 virtual bool PurgePartiallySyncedTypes() OVERRIDE; |
| 95 virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE; | 96 virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE; |
| 96 virtual void UpdateEnabledTypes(const ModelTypeSet& types) OVERRIDE; | 97 virtual void UpdateEnabledTypes(const ModelTypeSet& types) OVERRIDE; |
| 98 virtual void RegisterInvalidationHandler( |
| 99 SyncNotifierObserver* handler) OVERRIDE; |
| 97 virtual void UpdateRegisteredInvalidationIds( | 100 virtual void UpdateRegisteredInvalidationIds( |
| 98 SyncNotifierObserver* handler, | 101 SyncNotifierObserver* handler, |
| 99 const ObjectIdSet& ids) OVERRIDE; | 102 const ObjectIdSet& ids) OVERRIDE; |
| 103 virtual void UnregisterInvalidationHandler( |
| 104 SyncNotifierObserver* handler) OVERRIDE; |
| 100 virtual void StartSyncingNormally( | 105 virtual void StartSyncingNormally( |
| 101 const ModelSafeRoutingInfo& routing_info) OVERRIDE; | 106 const ModelSafeRoutingInfo& routing_info) OVERRIDE; |
| 102 virtual void SetEncryptionPassphrase(const std::string& passphrase, | 107 virtual void SetEncryptionPassphrase(const std::string& passphrase, |
| 103 bool is_explicit) OVERRIDE; | 108 bool is_explicit) OVERRIDE; |
| 104 virtual void SetDecryptionPassphrase(const std::string& passphrase) OVERRIDE; | 109 virtual void SetDecryptionPassphrase(const std::string& passphrase) OVERRIDE; |
| 105 virtual void ConfigureSyncer( | 110 virtual void ConfigureSyncer( |
| 106 ConfigureReason reason, | 111 ConfigureReason reason, |
| 107 const ModelTypeSet& types_to_config, | 112 const ModelTypeSet& types_to_config, |
| 108 const ModelSafeRoutingInfo& new_routing_info, | 113 const ModelSafeRoutingInfo& new_routing_info, |
| 109 const base::Closure& ready_task, | 114 const base::Closure& ready_task, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 // have their progress markers or initial_sync_ended bits set. | 148 // have their progress markers or initial_sync_ended bits set. |
| 144 ModelTypeSet configure_fail_types_; | 149 ModelTypeSet configure_fail_types_; |
| 145 // The set of types that have been cleaned up. | 150 // The set of types that have been cleaned up. |
| 146 ModelTypeSet cleaned_types_; | 151 ModelTypeSet cleaned_types_; |
| 147 // The set of types that have been downloaded. | 152 // The set of types that have been downloaded. |
| 148 ModelTypeSet downloaded_types_; | 153 ModelTypeSet downloaded_types_; |
| 149 // The set of types that have been enabled. | 154 // The set of types that have been enabled. |
| 150 ModelTypeSet enabled_types_; | 155 ModelTypeSet enabled_types_; |
| 151 | 156 |
| 152 // Faked notifier state. | 157 // Faked notifier state. |
| 153 SyncNotifierHelper notifier_helper_; | 158 SyncNotifierRegistrar registrar_; |
| 154 | 159 |
| 155 DISALLOW_COPY_AND_ASSIGN(FakeSyncManager); | 160 DISALLOW_COPY_AND_ASSIGN(FakeSyncManager); |
| 156 }; | 161 }; |
| 157 | 162 |
| 158 } // namespace syncer | 163 } // namespace syncer |
| 159 | 164 |
| 160 #endif // SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_ | 165 #endif // SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_ |
| OLD | NEW |