OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_ |
6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_ | 6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
17 #include "components/invalidation/public/invalidation.h" | 17 #include "components/invalidation/public/invalidation.h" |
18 #include "components/sync/base/cancelation_signal.h" | 18 #include "components/sync/base/cancelation_signal.h" |
19 #include "components/sync/core/shutdown_reason.h" | 19 #include "components/sync/core/shutdown_reason.h" |
20 #include "components/sync/core/sync_encryption_handler.h" | 20 #include "components/sync/core/sync_encryption_handler.h" |
21 #include "components/sync/driver/glue/sync_backend_host_impl.h" | 21 #include "components/sync/driver/glue/sync_backend_host_impl.h" |
22 #include "components/sync/driver/system_encryptor.h" | 22 #include "components/sync/driver/system_encryptor.h" |
23 #include "components/sync/engine/cycle/type_debug_info_observer.h" | 23 #include "components/sync/engine/cycle/type_debug_info_observer.h" |
24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
25 | 25 |
26 namespace browser_sync { | 26 namespace syncer { |
27 | 27 |
28 class SyncBackendHostImpl; | 28 class SyncBackendHostImpl; |
29 | 29 |
30 // Utility struct for holding initialization options. | 30 // Utility struct for holding initialization options. |
31 struct DoInitializeOptions { | 31 struct DoInitializeOptions { |
32 DoInitializeOptions( | 32 DoInitializeOptions( |
33 base::MessageLoop* sync_loop, | 33 base::MessageLoop* sync_loop, |
34 SyncBackendRegistrar* registrar, | 34 SyncBackendRegistrar* registrar, |
35 const std::vector<scoped_refptr<syncer::ModelSafeWorker>>& workers, | 35 const std::vector<scoped_refptr<ModelSafeWorker>>& workers, |
36 const scoped_refptr<syncer::ExtensionsActivity>& extensions_activity, | 36 const scoped_refptr<ExtensionsActivity>& extensions_activity, |
37 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, | 37 const WeakHandle<JsEventHandler>& event_handler, |
38 const GURL& service_url, | 38 const GURL& service_url, |
39 const std::string& sync_user_agent, | 39 const std::string& sync_user_agent, |
40 std::unique_ptr<syncer::HttpPostProviderFactory> http_bridge_factory, | 40 std::unique_ptr<HttpPostProviderFactory> http_bridge_factory, |
41 const syncer::SyncCredentials& credentials, | 41 const SyncCredentials& credentials, |
42 const std::string& invalidator_client_id, | 42 const std::string& invalidator_client_id, |
43 std::unique_ptr<syncer::SyncManagerFactory> sync_manager_factory, | 43 std::unique_ptr<SyncManagerFactory> sync_manager_factory, |
44 bool delete_sync_data_folder, | 44 bool delete_sync_data_folder, |
45 const std::string& restored_key_for_bootstrapping, | 45 const std::string& restored_key_for_bootstrapping, |
46 const std::string& restored_keystore_key_for_bootstrapping, | 46 const std::string& restored_keystore_key_for_bootstrapping, |
47 std::unique_ptr<syncer::InternalComponentsFactory> | 47 std::unique_ptr<InternalComponentsFactory> internal_components_factory, |
48 internal_components_factory, | 48 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, |
49 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& | |
50 unrecoverable_error_handler, | |
51 const base::Closure& report_unrecoverable_error_function, | 49 const base::Closure& report_unrecoverable_error_function, |
52 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> | 50 std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state, |
53 saved_nigori_state, | 51 const std::map<ModelType, int64_t>& invalidation_versions); |
54 const std::map<syncer::ModelType, int64_t>& invalidation_versions); | |
55 ~DoInitializeOptions(); | 52 ~DoInitializeOptions(); |
56 | 53 |
57 base::MessageLoop* sync_loop; | 54 base::MessageLoop* sync_loop; |
58 SyncBackendRegistrar* registrar; | 55 SyncBackendRegistrar* registrar; |
59 std::vector<scoped_refptr<syncer::ModelSafeWorker>> workers; | 56 std::vector<scoped_refptr<ModelSafeWorker>> workers; |
60 scoped_refptr<syncer::ExtensionsActivity> extensions_activity; | 57 scoped_refptr<ExtensionsActivity> extensions_activity; |
61 syncer::WeakHandle<syncer::JsEventHandler> event_handler; | 58 WeakHandle<JsEventHandler> event_handler; |
62 GURL service_url; | 59 GURL service_url; |
63 std::string sync_user_agent; | 60 std::string sync_user_agent; |
64 // Overridden by tests. | 61 // Overridden by tests. |
65 std::unique_ptr<syncer::HttpPostProviderFactory> http_bridge_factory; | 62 std::unique_ptr<HttpPostProviderFactory> http_bridge_factory; |
66 syncer::SyncCredentials credentials; | 63 SyncCredentials credentials; |
67 const std::string invalidator_client_id; | 64 const std::string invalidator_client_id; |
68 std::unique_ptr<syncer::SyncManagerFactory> sync_manager_factory; | 65 std::unique_ptr<SyncManagerFactory> sync_manager_factory; |
69 std::string lsid; | 66 std::string lsid; |
70 bool delete_sync_data_folder; | 67 bool delete_sync_data_folder; |
71 std::string restored_key_for_bootstrapping; | 68 std::string restored_key_for_bootstrapping; |
72 std::string restored_keystore_key_for_bootstrapping; | 69 std::string restored_keystore_key_for_bootstrapping; |
73 std::unique_ptr<syncer::InternalComponentsFactory> | 70 std::unique_ptr<InternalComponentsFactory> internal_components_factory; |
74 internal_components_factory; | 71 const WeakHandle<UnrecoverableErrorHandler> unrecoverable_error_handler; |
75 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler> | |
76 unrecoverable_error_handler; | |
77 base::Closure report_unrecoverable_error_function; | 72 base::Closure report_unrecoverable_error_function; |
78 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> | 73 std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state; |
79 saved_nigori_state; | 74 const std::map<ModelType, int64_t> invalidation_versions; |
80 const std::map<syncer::ModelType, int64_t> invalidation_versions; | |
81 }; | 75 }; |
82 | 76 |
83 // Helper struct to handle currying params to | 77 // Helper struct to handle currying params to |
84 // SyncBackendHost::Core::DoConfigureSyncer. | 78 // SyncBackendHost::Core::DoConfigureSyncer. |
85 struct DoConfigureSyncerTypes { | 79 struct DoConfigureSyncerTypes { |
86 DoConfigureSyncerTypes(); | 80 DoConfigureSyncerTypes(); |
87 DoConfigureSyncerTypes(const DoConfigureSyncerTypes& other); | 81 DoConfigureSyncerTypes(const DoConfigureSyncerTypes& other); |
88 ~DoConfigureSyncerTypes(); | 82 ~DoConfigureSyncerTypes(); |
89 syncer::ModelTypeSet to_download; | 83 ModelTypeSet to_download; |
90 syncer::ModelTypeSet to_purge; | 84 ModelTypeSet to_purge; |
91 syncer::ModelTypeSet to_journal; | 85 ModelTypeSet to_journal; |
92 syncer::ModelTypeSet to_unapply; | 86 ModelTypeSet to_unapply; |
93 }; | 87 }; |
94 | 88 |
95 class SyncBackendHostCore | 89 class SyncBackendHostCore |
96 : public base::RefCountedThreadSafe<SyncBackendHostCore>, | 90 : public base::RefCountedThreadSafe<SyncBackendHostCore>, |
97 public syncer::SyncEncryptionHandler::Observer, | 91 public SyncEncryptionHandler::Observer, |
98 public syncer::SyncManager::Observer, | 92 public SyncManager::Observer, |
99 public syncer::TypeDebugInfoObserver { | 93 public TypeDebugInfoObserver { |
100 public: | 94 public: |
101 SyncBackendHostCore(const std::string& name, | 95 SyncBackendHostCore(const std::string& name, |
102 const base::FilePath& sync_data_folder_path, | 96 const base::FilePath& sync_data_folder_path, |
103 bool has_sync_setup_completed, | 97 bool has_sync_setup_completed, |
104 const base::WeakPtr<SyncBackendHostImpl>& backend); | 98 const base::WeakPtr<SyncBackendHostImpl>& backend); |
105 | 99 |
106 // SyncManager::Observer implementation. The Core just acts like an air | 100 // SyncManager::Observer implementation. The Core just acts like an air |
107 // traffic controller here, forwarding incoming messages to appropriate | 101 // traffic controller here, forwarding incoming messages to appropriate |
108 // landing threads. | 102 // landing threads. |
109 void OnSyncCycleCompleted(const syncer::SyncCycleSnapshot& snapshot) override; | 103 void OnSyncCycleCompleted(const SyncCycleSnapshot& snapshot) override; |
110 void OnInitializationComplete( | 104 void OnInitializationComplete( |
111 const syncer::WeakHandle<syncer::JsBackend>& js_backend, | 105 const WeakHandle<JsBackend>& js_backend, |
112 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& | 106 const WeakHandle<DataTypeDebugInfoListener>& debug_info_listener, |
113 debug_info_listener, | |
114 bool success, | 107 bool success, |
115 syncer::ModelTypeSet restored_types) override; | 108 ModelTypeSet restored_types) override; |
116 void OnConnectionStatusChange(syncer::ConnectionStatus status) override; | 109 void OnConnectionStatusChange(ConnectionStatus status) override; |
117 void OnActionableError(const syncer::SyncProtocolError& sync_error) override; | 110 void OnActionableError(const SyncProtocolError& sync_error) override; |
118 void OnMigrationRequested(syncer::ModelTypeSet types) override; | 111 void OnMigrationRequested(ModelTypeSet types) override; |
119 void OnProtocolEvent(const syncer::ProtocolEvent& event) override; | 112 void OnProtocolEvent(const ProtocolEvent& event) override; |
120 | 113 |
121 // SyncEncryptionHandler::Observer implementation. | 114 // SyncEncryptionHandler::Observer implementation. |
122 void OnPassphraseRequired( | 115 void OnPassphraseRequired( |
123 syncer::PassphraseRequiredReason reason, | 116 PassphraseRequiredReason reason, |
124 const sync_pb::EncryptedData& pending_keys) override; | 117 const sync_pb::EncryptedData& pending_keys) override; |
125 void OnPassphraseAccepted() override; | 118 void OnPassphraseAccepted() override; |
126 void OnBootstrapTokenUpdated(const std::string& bootstrap_token, | 119 void OnBootstrapTokenUpdated(const std::string& bootstrap_token, |
127 syncer::BootstrapTokenType type) override; | 120 BootstrapTokenType type) override; |
128 void OnEncryptedTypesChanged(syncer::ModelTypeSet encrypted_types, | 121 void OnEncryptedTypesChanged(ModelTypeSet encrypted_types, |
129 bool encrypt_everything) override; | 122 bool encrypt_everything) override; |
130 void OnEncryptionComplete() override; | 123 void OnEncryptionComplete() override; |
131 void OnCryptographerStateChanged( | 124 void OnCryptographerStateChanged(Cryptographer* cryptographer) override; |
132 syncer::Cryptographer* cryptographer) override; | 125 void OnPassphraseTypeChanged(PassphraseType type, |
133 void OnPassphraseTypeChanged(syncer::PassphraseType type, | |
134 base::Time passphrase_time) override; | 126 base::Time passphrase_time) override; |
135 void OnLocalSetPassphraseEncryption( | 127 void OnLocalSetPassphraseEncryption( |
136 const syncer::SyncEncryptionHandler::NigoriState& nigori_state) override; | 128 const SyncEncryptionHandler::NigoriState& nigori_state) override; |
137 | 129 |
138 // TypeDebugInfoObserver implementation | 130 // TypeDebugInfoObserver implementation |
139 void OnCommitCountersUpdated(syncer::ModelType type, | 131 void OnCommitCountersUpdated(ModelType type, |
140 const syncer::CommitCounters& counters) override; | 132 const CommitCounters& counters) override; |
141 void OnUpdateCountersUpdated(syncer::ModelType type, | 133 void OnUpdateCountersUpdated(ModelType type, |
142 const syncer::UpdateCounters& counters) override; | 134 const UpdateCounters& counters) override; |
143 void OnStatusCountersUpdated(syncer::ModelType type, | 135 void OnStatusCountersUpdated(ModelType type, |
144 const syncer::StatusCounters& counters) override; | 136 const StatusCounters& counters) override; |
145 | 137 |
146 // Forwards an invalidation state change to the sync manager. | 138 // Forwards an invalidation state change to the sync manager. |
147 void DoOnInvalidatorStateChange(syncer::InvalidatorState state); | 139 void DoOnInvalidatorStateChange(InvalidatorState state); |
148 | 140 |
149 // Forwards an invalidation to the sync manager. | 141 // Forwards an invalidation to the sync manager. |
150 void DoOnIncomingInvalidation( | 142 void DoOnIncomingInvalidation( |
151 const syncer::ObjectIdInvalidationMap& invalidation_map); | 143 const ObjectIdInvalidationMap& invalidation_map); |
152 | 144 |
153 // Note: | 145 // Note: |
154 // | 146 // |
155 // The Do* methods are the various entry points from our | 147 // The Do* methods are the various entry points from our |
156 // SyncBackendHost. They are all called on the sync thread to | 148 // SyncBackendHost. They are all called on the sync thread to |
157 // actually perform synchronous (and potentially blocking) syncapi | 149 // actually perform synchronous (and potentially blocking) syncapi |
158 // operations. | 150 // operations. |
159 // | 151 // |
160 // Called to perform initialization of the syncapi on behalf of | 152 // Called to perform initialization of the syncapi on behalf of |
161 // SyncBackendHost::Initialize. | 153 // SyncBackendHost::Initialize. |
162 void DoInitialize(std::unique_ptr<DoInitializeOptions> options); | 154 void DoInitialize(std::unique_ptr<DoInitializeOptions> options); |
163 | 155 |
164 // Called to perform credential update on behalf of | 156 // Called to perform credential update on behalf of |
165 // SyncBackendHost::UpdateCredentials. | 157 // SyncBackendHost::UpdateCredentials. |
166 void DoUpdateCredentials(const syncer::SyncCredentials& credentials); | 158 void DoUpdateCredentials(const SyncCredentials& credentials); |
167 | 159 |
168 // Called to tell the syncapi to start syncing (generally after | 160 // Called to tell the syncapi to start syncing (generally after |
169 // initialization and authentication). | 161 // initialization and authentication). |
170 void DoStartSyncing(const syncer::ModelSafeRoutingInfo& routing_info, | 162 void DoStartSyncing(const ModelSafeRoutingInfo& routing_info, |
171 base::Time last_poll_time); | 163 base::Time last_poll_time); |
172 | 164 |
173 // Called to set the passphrase for encryption. | 165 // Called to set the passphrase for encryption. |
174 void DoSetEncryptionPassphrase(const std::string& passphrase, | 166 void DoSetEncryptionPassphrase(const std::string& passphrase, |
175 bool is_explicit); | 167 bool is_explicit); |
176 | 168 |
177 // Called to decrypt the pending keys. | 169 // Called to decrypt the pending keys. |
178 void DoSetDecryptionPassphrase(const std::string& passphrase); | 170 void DoSetDecryptionPassphrase(const std::string& passphrase); |
179 | 171 |
180 // Called to turn on encryption of all sync data as well as | 172 // Called to turn on encryption of all sync data as well as |
181 // reencrypt everything. | 173 // reencrypt everything. |
182 void DoEnableEncryptEverything(); | 174 void DoEnableEncryptEverything(); |
183 | 175 |
184 // Ask the syncer to check for updates for the specified types. | 176 // Ask the syncer to check for updates for the specified types. |
185 void DoRefreshTypes(syncer::ModelTypeSet types); | 177 void DoRefreshTypes(ModelTypeSet types); |
186 | 178 |
187 // Invoked if we failed to download the necessary control types at startup. | 179 // Invoked if we failed to download the necessary control types at startup. |
188 // Invokes SyncBackendHost::HandleControlTypesDownloadRetry. | 180 // Invokes SyncBackendHost::HandleControlTypesDownloadRetry. |
189 void OnControlTypesDownloadRetry(); | 181 void OnControlTypesDownloadRetry(); |
190 | 182 |
191 // Called to perform tasks which require the control data to be downloaded. | 183 // Called to perform tasks which require the control data to be downloaded. |
192 // This includes refreshing encryption, etc. | 184 // This includes refreshing encryption, etc. |
193 void DoInitialProcessControlTypes(); | 185 void DoInitialProcessControlTypes(); |
194 | 186 |
195 // The shutdown order is a bit complicated: | 187 // The shutdown order is a bit complicated: |
196 // 1) Call ShutdownOnUIThread() from |frontend_loop_| to request sync manager | 188 // 1) Call ShutdownOnUIThread() from |frontend_loop_| to request sync manager |
197 // to stop as soon as possible. | 189 // to stop as soon as possible. |
198 // 2) Post DoShutdown() to sync loop to clean up backend state, save | 190 // 2) Post DoShutdown() to sync loop to clean up backend state, save |
199 // directory and destroy sync manager. | 191 // directory and destroy sync manager. |
200 void ShutdownOnUIThread(); | 192 void ShutdownOnUIThread(); |
201 void DoShutdown(syncer::ShutdownReason reason); | 193 void DoShutdown(ShutdownReason reason); |
202 void DoDestroySyncManager(syncer::ShutdownReason reason); | 194 void DoDestroySyncManager(ShutdownReason reason); |
203 | 195 |
204 // Configuration methods that must execute on sync loop. | 196 // Configuration methods that must execute on sync loop. |
205 void DoConfigureSyncer( | 197 void DoConfigureSyncer( |
206 syncer::ConfigureReason reason, | 198 ConfigureReason reason, |
207 const DoConfigureSyncerTypes& config_types, | 199 const DoConfigureSyncerTypes& config_types, |
208 const syncer::ModelSafeRoutingInfo routing_info, | 200 const ModelSafeRoutingInfo routing_info, |
209 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>& | 201 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task, |
210 ready_task, | |
211 const base::Closure& retry_callback); | 202 const base::Closure& retry_callback); |
212 void DoFinishConfigureDataTypes( | 203 void DoFinishConfigureDataTypes( |
213 syncer::ModelTypeSet types_to_config, | 204 ModelTypeSet types_to_config, |
214 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>& | 205 const base::Callback<void(ModelTypeSet, ModelTypeSet)>& ready_task); |
215 ready_task); | |
216 void DoRetryConfiguration(const base::Closure& retry_callback); | 206 void DoRetryConfiguration(const base::Closure& retry_callback); |
217 | 207 |
218 // Set the base request context to use when making HTTP calls. | 208 // Set the base request context to use when making HTTP calls. |
219 // This method will add a reference to the context to persist it | 209 // This method will add a reference to the context to persist it |
220 // on the IO thread. Must be removed from IO thread. | 210 // on the IO thread. Must be removed from IO thread. |
221 | 211 |
222 syncer::SyncManager* sync_manager() { return sync_manager_.get(); } | 212 SyncManager* sync_manager() { return sync_manager_.get(); } |
223 | 213 |
224 void SendBufferedProtocolEventsAndEnableForwarding(); | 214 void SendBufferedProtocolEventsAndEnableForwarding(); |
225 void DisableProtocolEventForwarding(); | 215 void DisableProtocolEventForwarding(); |
226 | 216 |
227 // Enables the forwarding of directory type debug counters to the | 217 // Enables the forwarding of directory type debug counters to the |
228 // SyncBackendHost. Also requests that updates to all counters be | 218 // SyncBackendHost. Also requests that updates to all counters be |
229 // emitted right away to initialize any new listeners' states. | 219 // emitted right away to initialize any new listeners' states. |
230 void EnableDirectoryTypeDebugInfoForwarding(); | 220 void EnableDirectoryTypeDebugInfoForwarding(); |
231 | 221 |
232 // Disables forwarding of directory type debug counters. | 222 // Disables forwarding of directory type debug counters. |
233 void DisableDirectoryTypeDebugInfoForwarding(); | 223 void DisableDirectoryTypeDebugInfoForwarding(); |
234 | 224 |
235 // Delete the sync data folder to cleanup backend data. Happens the first | 225 // Delete the sync data folder to cleanup backend data. Happens the first |
236 // time sync is enabled for a user (to prevent accidentally reusing old | 226 // time sync is enabled for a user (to prevent accidentally reusing old |
237 // sync databases), as well as shutdown when you're no longer syncing. | 227 // sync databases), as well as shutdown when you're no longer syncing. |
238 void DeleteSyncDataFolder(); | 228 void DeleteSyncDataFolder(); |
239 | 229 |
240 // We expose this member because it's required in the construction of the | 230 // We expose this member because it's required in the construction of the |
241 // HttpBridgeFactory. | 231 // HttpBridgeFactory. |
242 syncer::CancelationSignal* GetRequestContextCancelationSignal() { | 232 CancelationSignal* GetRequestContextCancelationSignal() { |
243 return &release_request_context_signal_; | 233 return &release_request_context_signal_; |
244 } | 234 } |
245 | 235 |
246 // Tell the sync manager to persist its state by writing to disk. | 236 // Tell the sync manager to persist its state by writing to disk. |
247 // Called on the sync thread, both by a timer and, on Android, when the | 237 // Called on the sync thread, both by a timer and, on Android, when the |
248 // application is backgrounded. | 238 // application is backgrounded. |
249 void SaveChanges(); | 239 void SaveChanges(); |
250 | 240 |
251 void DoClearServerData( | 241 void DoClearServerData( |
252 const syncer::SyncManager::ClearServerDataCallback& frontend_callback); | 242 const SyncManager::ClearServerDataCallback& frontend_callback); |
253 | 243 |
254 // Notify the syncer that the cookie jar has changed. | 244 // Notify the syncer that the cookie jar has changed. |
255 void DoOnCookieJarChanged(bool account_mismatch, bool empty_jar); | 245 void DoOnCookieJarChanged(bool account_mismatch, bool empty_jar); |
256 | 246 |
257 private: | 247 private: |
258 friend class base::RefCountedThreadSafe<SyncBackendHostCore>; | 248 friend class base::RefCountedThreadSafe<SyncBackendHostCore>; |
259 | 249 |
260 ~SyncBackendHostCore() override; | 250 ~SyncBackendHostCore() override; |
261 | 251 |
262 // Invoked when initialization of syncapi is complete and we can start | 252 // Invoked when initialization of syncapi is complete and we can start |
263 // our timer. | 253 // our timer. |
264 // This must be called from the thread on which SaveChanges is intended to | 254 // This must be called from the thread on which SaveChanges is intended to |
265 // be run on; the host's |registrar_->sync_thread()|. | 255 // be run on; the host's |registrar_->sync_thread()|. |
266 void StartSavingChanges(); | 256 void StartSavingChanges(); |
267 | 257 |
268 void ClearServerDataDone(const base::Closure& frontend_callback); | 258 void ClearServerDataDone(const base::Closure& frontend_callback); |
269 | 259 |
270 // Name used for debugging. | 260 // Name used for debugging. |
271 const std::string name_; | 261 const std::string name_; |
272 | 262 |
273 // Path of the folder that stores the sync data files. | 263 // Path of the folder that stores the sync data files. |
274 const base::FilePath sync_data_folder_path_; | 264 const base::FilePath sync_data_folder_path_; |
275 | 265 |
276 // Our parent SyncBackendHost. | 266 // Our parent SyncBackendHost. |
277 syncer::WeakHandle<SyncBackendHostImpl> host_; | 267 WeakHandle<SyncBackendHostImpl> host_; |
278 | 268 |
279 // The loop where all the sync backend operations happen. | 269 // The loop where all the sync backend operations happen. |
280 // Non-NULL only between calls to DoInitialize() and ~Core(). | 270 // Non-NULL only between calls to DoInitialize() and ~Core(). |
281 base::MessageLoop* sync_loop_; | 271 base::MessageLoop* sync_loop_; |
282 | 272 |
283 // Our parent's registrar (not owned). Non-NULL only between | 273 // Our parent's registrar (not owned). Non-NULL only between |
284 // calls to DoInitialize() and DoShutdown(). | 274 // calls to DoInitialize() and DoShutdown(). |
285 SyncBackendRegistrar* registrar_; | 275 SyncBackendRegistrar* registrar_; |
286 | 276 |
287 // The timer used to periodically call SaveChanges. | 277 // The timer used to periodically call SaveChanges. |
288 std::unique_ptr<base::RepeatingTimer> save_changes_timer_; | 278 std::unique_ptr<base::RepeatingTimer> save_changes_timer_; |
289 | 279 |
290 // Our encryptor, which uses Chrome's encryption functions. | 280 // Our encryptor, which uses Chrome's encryption functions. |
291 sync_driver::SystemEncryptor encryptor_; | 281 SystemEncryptor encryptor_; |
292 | 282 |
293 // The top-level syncapi entry point. Lives on the sync thread. | 283 // The top-level syncapi entry point. Lives on the sync thread. |
294 std::unique_ptr<syncer::SyncManager> sync_manager_; | 284 std::unique_ptr<SyncManager> sync_manager_; |
295 | 285 |
296 // Temporary holder of sync manager's initialization results. Set by | 286 // Temporary holder of sync manager's initialization results. Set by |
297 // OnInitializeComplete, and consumed when we pass it via OnBackendInitialized | 287 // OnInitializeComplete, and consumed when we pass it via OnBackendInitialized |
298 // in the final state of HandleInitializationSuccessOnFrontendLoop. | 288 // in the final state of HandleInitializationSuccessOnFrontendLoop. |
299 syncer::WeakHandle<syncer::JsBackend> js_backend_; | 289 WeakHandle<JsBackend> js_backend_; |
300 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; | 290 WeakHandle<DataTypeDebugInfoListener> debug_info_listener_; |
301 | 291 |
302 // These signals allow us to send requests to shut down the HttpBridgeFactory | 292 // These signals allow us to send requests to shut down the HttpBridgeFactory |
303 // and ServerConnectionManager without having to wait for those classes to | 293 // and ServerConnectionManager without having to wait for those classes to |
304 // finish initializing first. | 294 // finish initializing first. |
305 // | 295 // |
306 // See comments in SyncBackendHostCore::ShutdownOnUIThread() for more details. | 296 // See comments in SyncBackendHostCore::ShutdownOnUIThread() for more details. |
307 syncer::CancelationSignal release_request_context_signal_; | 297 CancelationSignal release_request_context_signal_; |
308 syncer::CancelationSignal stop_syncing_signal_; | 298 CancelationSignal stop_syncing_signal_; |
309 | 299 |
310 // Matches the value of SyncPref's IsFirstSetupComplete() flag at init time. | 300 // Matches the value of SyncPref's IsFirstSetupComplete() flag at init time. |
311 // Should not be used for anything except for UMAs and logging. | 301 // Should not be used for anything except for UMAs and logging. |
312 const bool has_sync_setup_completed_; | 302 const bool has_sync_setup_completed_; |
313 | 303 |
314 // Set when we've been asked to forward sync protocol events to the frontend. | 304 // Set when we've been asked to forward sync protocol events to the frontend. |
315 bool forward_protocol_events_; | 305 bool forward_protocol_events_; |
316 | 306 |
317 // Set when the forwarding of per-type debug counters is enabled. | 307 // Set when the forwarding of per-type debug counters is enabled. |
318 bool forward_type_info_; | 308 bool forward_type_info_; |
319 | 309 |
320 // A map of data type -> invalidation version to track the most recently | 310 // A map of data type -> invalidation version to track the most recently |
321 // received invalidation version for each type. | 311 // received invalidation version for each type. |
322 // This allows dropping any invalidations with versions older than those | 312 // This allows dropping any invalidations with versions older than those |
323 // most recently received for that data type. | 313 // most recently received for that data type. |
324 std::map<syncer::ModelType, int64_t> last_invalidation_versions_; | 314 std::map<ModelType, int64_t> last_invalidation_versions_; |
325 | 315 |
326 base::WeakPtrFactory<SyncBackendHostCore> weak_ptr_factory_; | 316 base::WeakPtrFactory<SyncBackendHostCore> weak_ptr_factory_; |
327 | 317 |
328 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostCore); | 318 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostCore); |
329 }; | 319 }; |
330 | 320 |
331 } // namespace browser_sync | 321 } // namespace syncer |
332 | 322 |
333 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_ | 323 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_ |
OLD | NEW |