| 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 COMPONENTS_SYNC_ENGINE_FAKE_SYNC_MANAGER_H_ | 5 #ifndef COMPONENTS_SYNC_ENGINE_FAKE_SYNC_MANAGER_H_ |
| 6 #define COMPONENTS_SYNC_ENGINE_FAKE_SYNC_MANAGER_H_ | 6 #define COMPONENTS_SYNC_ENGINE_FAKE_SYNC_MANAGER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "components/sync/engine/fake_model_type_connector.h" |
| 15 #include "components/sync/engine/sync_manager.h" | 16 #include "components/sync/engine/sync_manager.h" |
| 16 #include "components/sync/syncable/test_user_share.h" | 17 #include "components/sync/syncable/test_user_share.h" |
| 18 #include "components/sync/test/fake_sync_encryption_handler.h" |
| 17 | 19 |
| 18 namespace base { | 20 namespace base { |
| 19 class SequencedTaskRunner; | 21 class SequencedTaskRunner; |
| 20 } | 22 } |
| 21 | 23 |
| 22 namespace syncer { | 24 namespace syncer { |
| 23 | 25 |
| 24 class FakeSyncEncryptionHandler; | 26 class FakeSyncEncryptionHandler; |
| 25 | 27 |
| 26 class FakeSyncManager : public SyncManager { | 28 class FakeSyncManager : public SyncManager { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 48 | 50 |
| 49 // Returns those types that have been unapplied as part of purging disabled | 51 // Returns those types that have been unapplied as part of purging disabled |
| 50 // types since the last call to GetAndResetUnappliedTypes, or since startup if | 52 // types since the last call to GetAndResetUnappliedTypes, or since startup if |
| 51 // never called. | 53 // never called. |
| 52 ModelTypeSet GetAndResetUnappliedTypes(); | 54 ModelTypeSet GetAndResetUnappliedTypes(); |
| 53 | 55 |
| 54 // Returns those types that have been downloaded since the last call to | 56 // Returns those types that have been downloaded since the last call to |
| 55 // GetAndResetDownloadedTypes(), or since startup if never called. | 57 // GetAndResetDownloadedTypes(), or since startup if never called. |
| 56 ModelTypeSet GetAndResetDownloadedTypes(); | 58 ModelTypeSet GetAndResetDownloadedTypes(); |
| 57 | 59 |
| 58 // Returns those types that have been marked as enabled since the | |
| 59 // last call to GetAndResetEnabledTypes(), or since startup if never | |
| 60 // called. | |
| 61 ModelTypeSet GetAndResetEnabledTypes(); | |
| 62 | |
| 63 // Returns the types that have most recently received a refresh request. | 60 // Returns the types that have most recently received a refresh request. |
| 64 ModelTypeSet GetLastRefreshRequestTypes(); | 61 ModelTypeSet GetLastRefreshRequestTypes(); |
| 65 | 62 |
| 66 // Returns the most recent configuration reason since the last call to | 63 // Returns the most recent configuration reason since the last call to |
| 67 // GetAndResetConfigureReason, or since startup if never called. | 64 // GetAndResetConfigureReason, or since startup if never called. |
| 68 ConfigureReason GetAndResetConfigureReason(); | 65 ConfigureReason GetAndResetConfigureReason(); |
| 69 | 66 |
| 70 // Returns the number of invalidations received since startup. | 67 // Returns the number of invalidations received since startup. |
| 71 int GetInvalidationCount() const; | 68 int GetInvalidationCount() const; |
| 72 | 69 |
| 73 // Block until the sync thread has finished processing any pending messages. | 70 // Block until the sync thread has finished processing any pending messages. |
| 74 void WaitForSyncThread(); | 71 void WaitForSyncThread(); |
| 75 | 72 |
| 76 // SyncManager implementation. | 73 // SyncManager implementation. |
| 77 // Note: we treat whatever message loop this is called from as the sync | 74 // Note: we treat whatever message loop this is called from as the sync |
| 78 // loop for purposes of callbacks. | 75 // loop for purposes of callbacks. |
| 79 void Init(InitArgs* args) override; | 76 void Init(InitArgs* args) override; |
| 80 ModelTypeSet InitialSyncEndedTypes() override; | 77 ModelTypeSet InitialSyncEndedTypes() override; |
| 81 ModelTypeSet GetTypesWithEmptyProgressMarkerToken( | 78 ModelTypeSet GetTypesWithEmptyProgressMarkerToken( |
| 82 ModelTypeSet types) override; | 79 ModelTypeSet types) override; |
| 83 void PurgePartiallySyncedTypes() override; | 80 void PurgePartiallySyncedTypes() override; |
| 84 void PurgeDisabledTypes(ModelTypeSet to_purge, | 81 void PurgeDisabledTypes(ModelTypeSet to_purge, |
| 85 ModelTypeSet to_journal, | 82 ModelTypeSet to_journal, |
| 86 ModelTypeSet to_unapply) override; | 83 ModelTypeSet to_unapply) override; |
| 87 void UpdateCredentials(const SyncCredentials& credentials) override; | 84 void UpdateCredentials(const SyncCredentials& credentials) override; |
| 88 void StartSyncingNormally(const ModelSafeRoutingInfo& routing_info, | 85 void StartSyncingNormally(base::Time last_poll_time) override; |
| 89 base::Time last_poll_time) override; | 86 void StartConfiguration() override; |
| 90 void ConfigureSyncer(ConfigureReason reason, | 87 void ConfigureSyncer(ConfigureReason reason, |
| 91 ModelTypeSet to_download, | 88 ModelTypeSet to_download, |
| 92 const ModelSafeRoutingInfo& new_routing_info, | |
| 93 const base::Closure& ready_task, | 89 const base::Closure& ready_task, |
| 94 const base::Closure& retry_task) override; | 90 const base::Closure& retry_task) override; |
| 95 void OnIncomingInvalidation( | 91 void OnIncomingInvalidation( |
| 96 ModelType type, | 92 ModelType type, |
| 97 std::unique_ptr<InvalidationInterface> interface) override; | 93 std::unique_ptr<InvalidationInterface> interface) override; |
| 98 void SetInvalidatorEnabled(bool invalidator_enabled) override; | 94 void SetInvalidatorEnabled(bool invalidator_enabled) override; |
| 99 void AddObserver(Observer* observer) override; | 95 void AddObserver(Observer* observer) override; |
| 100 void RemoveObserver(Observer* observer) override; | 96 void RemoveObserver(Observer* observer) override; |
| 101 SyncStatus GetDetailedStatus() const override; | 97 SyncStatus GetDetailedStatus() const override; |
| 102 void SaveChanges() override; | 98 void SaveChanges() override; |
| 103 void ShutdownOnSyncThread(ShutdownReason reason) override; | 99 void ShutdownOnSyncThread(ShutdownReason reason) override; |
| 104 UserShare* GetUserShare() override; | 100 UserShare* GetUserShare() override; |
| 101 ModelTypeConnector* GetModelTypeConnector() override; |
| 105 std::unique_ptr<ModelTypeConnector> GetModelTypeConnectorProxy() override; | 102 std::unique_ptr<ModelTypeConnector> GetModelTypeConnectorProxy() override; |
| 106 const std::string cache_guid() override; | 103 const std::string cache_guid() override; |
| 107 bool ReceivedExperiment(Experiments* experiments) override; | 104 bool ReceivedExperiment(Experiments* experiments) override; |
| 108 bool HasUnsyncedItems() override; | 105 bool HasUnsyncedItems() override; |
| 109 SyncEncryptionHandler* GetEncryptionHandler() override; | 106 SyncEncryptionHandler* GetEncryptionHandler() override; |
| 110 std::vector<std::unique_ptr<ProtocolEvent>> GetBufferedProtocolEvents() | 107 std::vector<std::unique_ptr<ProtocolEvent>> GetBufferedProtocolEvents() |
| 111 override; | 108 override; |
| 112 void RefreshTypes(ModelTypeSet types) override; | 109 void RefreshTypes(ModelTypeSet types) override; |
| 113 void RegisterDirectoryTypeDebugInfoObserver( | 110 void RegisterDirectoryTypeDebugInfoObserver( |
| 114 TypeDebugInfoObserver* observer) override; | 111 TypeDebugInfoObserver* observer) override; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 133 // Test specific state. | 130 // Test specific state. |
| 134 // The types that should fail configuration attempts. These types will not | 131 // The types that should fail configuration attempts. These types will not |
| 135 // have their progress markers or initial_sync_ended bits set. | 132 // have their progress markers or initial_sync_ended bits set. |
| 136 ModelTypeSet configure_fail_types_; | 133 ModelTypeSet configure_fail_types_; |
| 137 // The set of types that have been purged. | 134 // The set of types that have been purged. |
| 138 ModelTypeSet purged_types_; | 135 ModelTypeSet purged_types_; |
| 139 // Subset of |purged_types_| that were unapplied. | 136 // Subset of |purged_types_| that were unapplied. |
| 140 ModelTypeSet unapplied_types_; | 137 ModelTypeSet unapplied_types_; |
| 141 // The set of types that have been downloaded. | 138 // The set of types that have been downloaded. |
| 142 ModelTypeSet downloaded_types_; | 139 ModelTypeSet downloaded_types_; |
| 143 // The set of types that have been enabled. | |
| 144 ModelTypeSet enabled_types_; | |
| 145 | 140 |
| 146 // The types for which a refresh was most recently requested. | 141 // The types for which a refresh was most recently requested. |
| 147 ModelTypeSet last_refresh_request_types_; | 142 ModelTypeSet last_refresh_request_types_; |
| 148 | 143 |
| 149 // The most recent configure reason. | 144 // The most recent configure reason. |
| 150 ConfigureReason last_configure_reason_; | 145 ConfigureReason last_configure_reason_; |
| 151 | 146 |
| 152 std::unique_ptr<FakeSyncEncryptionHandler> fake_encryption_handler_; | 147 FakeModelTypeConnector fake_model_type_connector_; |
| 148 |
| 149 FakeSyncEncryptionHandler fake_encryption_handler_; |
| 153 | 150 |
| 154 TestUserShare test_user_share_; | 151 TestUserShare test_user_share_; |
| 155 | 152 |
| 156 // Number of invalidations received since startup. | 153 // Number of invalidations received since startup. |
| 157 int num_invalidations_received_; | 154 int num_invalidations_received_; |
| 158 | 155 |
| 159 DISALLOW_COPY_AND_ASSIGN(FakeSyncManager); | 156 DISALLOW_COPY_AND_ASSIGN(FakeSyncManager); |
| 160 }; | 157 }; |
| 161 | 158 |
| 162 } // namespace syncer | 159 } // namespace syncer |
| 163 | 160 |
| 164 #endif // COMPONENTS_SYNC_ENGINE_FAKE_SYNC_MANAGER_H_ | 161 #endif // COMPONENTS_SYNC_ENGINE_FAKE_SYNC_MANAGER_H_ |
| OLD | NEW |