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" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 ModelTypeSet GetAndResetEnabledTypes(); | 55 ModelTypeSet GetAndResetEnabledTypes(); |
56 | 56 |
57 // Returns the types that have most recently received a refresh request. | 57 // Returns the types that have most recently received a refresh request. |
58 ModelTypeSet GetLastRefreshRequestTypes(); | 58 ModelTypeSet GetLastRefreshRequestTypes(); |
59 | 59 |
60 // Returns the most recent configuration reason since the last call to | 60 // Returns the most recent configuration reason since the last call to |
61 // GetAndResetConfigureReason, or since startup if never called. | 61 // GetAndResetConfigureReason, or since startup if never called. |
62 ConfigureReason GetAndResetConfigureReason(); | 62 ConfigureReason GetAndResetConfigureReason(); |
63 | 63 |
64 // Posts a method to invalidate the given IDs on the sync thread. | 64 // Posts a method to invalidate the given IDs on the sync thread. |
65 virtual void OnIncomingInvalidation( | 65 void Invalidate(const ObjectIdInvalidationMap& invalidation_map); |
66 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; | |
67 | 66 |
68 // Posts a method to update the invalidator state on the sync thread. | 67 // Posts a method to update the invalidator state on the sync thread. |
69 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE; | 68 void UpdateInvalidatorState(InvalidatorState state); |
70 | 69 |
71 // Block until the sync thread has finished processing any pending messages. | 70 // Block until the sync thread has finished processing any pending messages. |
72 void WaitForSyncThread(); | 71 void WaitForSyncThread(); |
73 | 72 |
74 // SyncManager implementation. | 73 // SyncManager implementation. |
75 // 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 |
76 // loop for purposes of callbacks. | 75 // loop for purposes of callbacks. |
77 virtual void Init( | 76 virtual void Init( |
78 const base::FilePath& database_location, | 77 const base::FilePath& database_location, |
79 const WeakHandle<JsEventHandler>& event_handler, | 78 const WeakHandle<JsEventHandler>& event_handler, |
80 const std::string& sync_server_and_path, | 79 const std::string& sync_server_and_path, |
81 int sync_server_port, | 80 int sync_server_port, |
82 bool use_ssl, | 81 bool use_ssl, |
83 scoped_ptr<HttpPostProviderFactory> post_factory, | 82 scoped_ptr<HttpPostProviderFactory> post_factory, |
84 const std::vector<ModelSafeWorker*>& workers, | 83 const std::vector<ModelSafeWorker*>& workers, |
85 ExtensionsActivityMonitor* extensions_activity_monitor, | 84 ExtensionsActivityMonitor* extensions_activity_monitor, |
86 ChangeDelegate* change_delegate, | 85 ChangeDelegate* change_delegate, |
87 const SyncCredentials& credentials, | 86 const SyncCredentials& credentials, |
| 87 scoped_ptr<Invalidator> invalidator, |
88 const std::string& invalidator_client_id, | 88 const std::string& invalidator_client_id, |
89 const std::string& restored_key_for_bootstrapping, | 89 const std::string& restored_key_for_bootstrapping, |
90 const std::string& restored_keystore_key_for_bootstrapping, | 90 const std::string& restored_keystore_key_for_bootstrapping, |
91 scoped_ptr<InternalComponentsFactory> internal_components_factory, | 91 scoped_ptr<InternalComponentsFactory> internal_components_factory, |
92 Encryptor* encryptor, | 92 Encryptor* encryptor, |
93 UnrecoverableErrorHandler* unrecoverable_error_handler, | 93 UnrecoverableErrorHandler* unrecoverable_error_handler, |
94 ReportUnrecoverableErrorFunction | 94 ReportUnrecoverableErrorFunction |
95 report_unrecoverable_error_function, | 95 report_unrecoverable_error_function, |
96 bool use_oauth2_token) OVERRIDE; | 96 bool use_oauth2_token) OVERRIDE; |
97 virtual void ThrowUnrecoverableError() OVERRIDE; | 97 virtual void ThrowUnrecoverableError() OVERRIDE; |
98 virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE; | 98 virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE; |
99 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( | 99 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( |
100 ModelTypeSet types) OVERRIDE; | 100 ModelTypeSet types) OVERRIDE; |
101 virtual bool PurgePartiallySyncedTypes() OVERRIDE; | 101 virtual bool PurgePartiallySyncedTypes() OVERRIDE; |
102 virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE; | 102 virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE; |
| 103 virtual void UpdateEnabledTypes(ModelTypeSet types) OVERRIDE; |
| 104 virtual void RegisterInvalidationHandler( |
| 105 InvalidationHandler* handler) OVERRIDE; |
| 106 virtual void UpdateRegisteredInvalidationIds( |
| 107 InvalidationHandler* handler, |
| 108 const ObjectIdSet& ids) OVERRIDE; |
| 109 virtual void UnregisterInvalidationHandler( |
| 110 InvalidationHandler* handler) OVERRIDE; |
| 111 virtual void AcknowledgeInvalidation( |
| 112 const invalidation::ObjectId& id, |
| 113 const syncer::AckHandle& ack_handle) OVERRIDE; |
103 virtual void StartSyncingNormally( | 114 virtual void StartSyncingNormally( |
104 const ModelSafeRoutingInfo& routing_info) OVERRIDE; | 115 const ModelSafeRoutingInfo& routing_info) OVERRIDE; |
105 virtual void ConfigureSyncer( | 116 virtual void ConfigureSyncer( |
106 ConfigureReason reason, | 117 ConfigureReason reason, |
107 ModelTypeSet to_download, | 118 ModelTypeSet to_download, |
108 ModelTypeSet to_purge, | 119 ModelTypeSet to_purge, |
109 ModelTypeSet to_journal, | 120 ModelTypeSet to_journal, |
110 ModelTypeSet to_unapply, | 121 ModelTypeSet to_unapply, |
111 const ModelSafeRoutingInfo& new_routing_info, | 122 const ModelSafeRoutingInfo& new_routing_info, |
112 const base::Closure& ready_task, | 123 const base::Closure& ready_task, |
113 const base::Closure& retry_task) OVERRIDE; | 124 const base::Closure& retry_task) OVERRIDE; |
114 virtual void AddObserver(Observer* observer) OVERRIDE; | 125 virtual void AddObserver(Observer* observer) OVERRIDE; |
115 virtual void RemoveObserver(Observer* observer) OVERRIDE; | 126 virtual void RemoveObserver(Observer* observer) OVERRIDE; |
116 virtual SyncStatus GetDetailedStatus() const OVERRIDE; | 127 virtual SyncStatus GetDetailedStatus() const OVERRIDE; |
117 virtual void SaveChanges() OVERRIDE; | 128 virtual void SaveChanges() OVERRIDE; |
118 virtual void StopSyncingForShutdown(const base::Closure& callback) OVERRIDE; | 129 virtual void StopSyncingForShutdown(const base::Closure& callback) OVERRIDE; |
119 virtual void ShutdownOnSyncThread() OVERRIDE; | 130 virtual void ShutdownOnSyncThread() OVERRIDE; |
120 virtual UserShare* GetUserShare() OVERRIDE; | 131 virtual UserShare* GetUserShare() OVERRIDE; |
121 virtual const std::string cache_guid() OVERRIDE; | 132 virtual const std::string cache_guid() OVERRIDE; |
122 virtual bool ReceivedExperiment(Experiments* experiments) OVERRIDE; | 133 virtual bool ReceivedExperiment(Experiments* experiments) OVERRIDE; |
123 virtual bool HasUnsyncedItems() OVERRIDE; | 134 virtual bool HasUnsyncedItems() OVERRIDE; |
124 virtual SyncEncryptionHandler* GetEncryptionHandler() OVERRIDE; | 135 virtual SyncEncryptionHandler* GetEncryptionHandler() OVERRIDE; |
125 virtual void RefreshTypes(ModelTypeSet types) OVERRIDE; | 136 virtual void RefreshTypes(ModelTypeSet types) OVERRIDE; |
126 | 137 |
127 private: | 138 private: |
| 139 void InvalidateOnSyncThread( |
| 140 const ObjectIdInvalidationMap& invalidation_map); |
| 141 void UpdateInvalidatorStateOnSyncThread(InvalidatorState state); |
| 142 |
128 scoped_refptr<base::SequencedTaskRunner> sync_task_runner_; | 143 scoped_refptr<base::SequencedTaskRunner> sync_task_runner_; |
129 | 144 |
130 ObserverList<SyncManager::Observer> observers_; | 145 ObserverList<SyncManager::Observer> observers_; |
131 | 146 |
132 // Faked directory state. | 147 // Faked directory state. |
133 ModelTypeSet initial_sync_ended_types_; | 148 ModelTypeSet initial_sync_ended_types_; |
134 ModelTypeSet progress_marker_types_; | 149 ModelTypeSet progress_marker_types_; |
135 | 150 |
136 // Test specific state. | 151 // Test specific state. |
137 // The types that should fail configuration attempts. These types will not | 152 // The types that should fail configuration attempts. These types will not |
(...skipping 18 matching lines...) Expand all Loading... |
156 scoped_ptr<FakeSyncEncryptionHandler> fake_encryption_handler_; | 171 scoped_ptr<FakeSyncEncryptionHandler> fake_encryption_handler_; |
157 | 172 |
158 TestUserShare test_user_share_; | 173 TestUserShare test_user_share_; |
159 | 174 |
160 DISALLOW_COPY_AND_ASSIGN(FakeSyncManager); | 175 DISALLOW_COPY_AND_ASSIGN(FakeSyncManager); |
161 }; | 176 }; |
162 | 177 |
163 } // namespace syncer | 178 } // namespace syncer |
164 | 179 |
165 #endif // SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_ | 180 #endif // SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_MANAGER_H_ |
OLD | NEW |