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 CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_CORE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_CORE_H_ |
6 #define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_CORE_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_CORE_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 | 9 |
10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 scoped_ptr<syncer::HttpPostProviderFactory> http_bridge_factory, | 33 scoped_ptr<syncer::HttpPostProviderFactory> http_bridge_factory, |
34 const syncer::SyncCredentials& credentials, | 34 const syncer::SyncCredentials& credentials, |
35 const std::string& invalidator_client_id, | 35 const std::string& invalidator_client_id, |
36 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory, | 36 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory, |
37 bool delete_sync_data_folder, | 37 bool delete_sync_data_folder, |
38 const std::string& restored_key_for_bootstrapping, | 38 const std::string& restored_key_for_bootstrapping, |
39 const std::string& restored_keystore_key_for_bootstrapping, | 39 const std::string& restored_keystore_key_for_bootstrapping, |
40 scoped_ptr<syncer::InternalComponentsFactory> internal_components_factory, | 40 scoped_ptr<syncer::InternalComponentsFactory> internal_components_factory, |
41 scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler, | 41 scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler, |
42 syncer::ReportUnrecoverableErrorFunction | 42 syncer::ReportUnrecoverableErrorFunction |
43 report_unrecoverable_error_function, | 43 report_unrecoverable_error_function); |
44 const std::string& signin_scoped_device_id); | |
45 ~DoInitializeOptions(); | 44 ~DoInitializeOptions(); |
46 | 45 |
47 base::MessageLoop* sync_loop; | 46 base::MessageLoop* sync_loop; |
48 SyncBackendRegistrar* registrar; | 47 SyncBackendRegistrar* registrar; |
49 syncer::ModelSafeRoutingInfo routing_info; | 48 syncer::ModelSafeRoutingInfo routing_info; |
50 std::vector<scoped_refptr<syncer::ModelSafeWorker> > workers; | 49 std::vector<scoped_refptr<syncer::ModelSafeWorker> > workers; |
51 scoped_refptr<syncer::ExtensionsActivity> extensions_activity; | 50 scoped_refptr<syncer::ExtensionsActivity> extensions_activity; |
52 syncer::WeakHandle<syncer::JsEventHandler> event_handler; | 51 syncer::WeakHandle<syncer::JsEventHandler> event_handler; |
53 GURL service_url; | 52 GURL service_url; |
54 // Overridden by tests. | 53 // Overridden by tests. |
55 scoped_ptr<syncer::HttpPostProviderFactory> http_bridge_factory; | 54 scoped_ptr<syncer::HttpPostProviderFactory> http_bridge_factory; |
56 syncer::SyncCredentials credentials; | 55 syncer::SyncCredentials credentials; |
57 const std::string invalidator_client_id; | 56 const std::string invalidator_client_id; |
58 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory; | 57 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory; |
59 std::string lsid; | 58 std::string lsid; |
60 bool delete_sync_data_folder; | 59 bool delete_sync_data_folder; |
61 std::string restored_key_for_bootstrapping; | 60 std::string restored_key_for_bootstrapping; |
62 std::string restored_keystore_key_for_bootstrapping; | 61 std::string restored_keystore_key_for_bootstrapping; |
63 scoped_ptr<syncer::InternalComponentsFactory> internal_components_factory; | 62 scoped_ptr<syncer::InternalComponentsFactory> internal_components_factory; |
64 scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler; | 63 scoped_ptr<syncer::UnrecoverableErrorHandler> unrecoverable_error_handler; |
65 syncer::ReportUnrecoverableErrorFunction | 64 syncer::ReportUnrecoverableErrorFunction |
66 report_unrecoverable_error_function; | 65 report_unrecoverable_error_function; |
67 std::string signin_scoped_device_id; | |
68 }; | 66 }; |
69 | 67 |
70 // Helper struct to handle currying params to | 68 // Helper struct to handle currying params to |
71 // SyncBackendHost::Core::DoConfigureSyncer. | 69 // SyncBackendHost::Core::DoConfigureSyncer. |
72 struct DoConfigureSyncerTypes { | 70 struct DoConfigureSyncerTypes { |
73 DoConfigureSyncerTypes(); | 71 DoConfigureSyncerTypes(); |
74 ~DoConfigureSyncerTypes(); | 72 ~DoConfigureSyncerTypes(); |
75 syncer::ModelTypeSet to_download; | 73 syncer::ModelTypeSet to_download; |
76 syncer::ModelTypeSet to_purge; | 74 syncer::ModelTypeSet to_purge; |
77 syncer::ModelTypeSet to_journal; | 75 syncer::ModelTypeSet to_journal; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 void DoEnableEncryptEverything(); | 171 void DoEnableEncryptEverything(); |
174 | 172 |
175 // Ask the syncer to check for updates for the specified types. | 173 // Ask the syncer to check for updates for the specified types. |
176 void DoRefreshTypes(syncer::ModelTypeSet types); | 174 void DoRefreshTypes(syncer::ModelTypeSet types); |
177 | 175 |
178 // Invoked if we failed to download the necessary control types at startup. | 176 // Invoked if we failed to download the necessary control types at startup. |
179 // Invokes SyncBackendHost::HandleControlTypesDownloadRetry. | 177 // Invokes SyncBackendHost::HandleControlTypesDownloadRetry. |
180 void OnControlTypesDownloadRetry(); | 178 void OnControlTypesDownloadRetry(); |
181 | 179 |
182 // Called to perform tasks which require the control data to be downloaded. | 180 // Called to perform tasks which require the control data to be downloaded. |
183 // This includes refreshing encryption, setting up the device info change | 181 // This includes refreshing encryption, etc. |
184 // processor, etc. | |
185 void DoInitialProcessControlTypes(); | 182 void DoInitialProcessControlTypes(); |
186 | 183 |
187 // Some parts of DoInitialProcessControlTypes() may be executed on a different | |
188 // thread. This function asynchronously continues the work started in | |
189 // DoInitialProcessControlTypes() once that other thread gets back to us. | |
190 void DoFinishInitialProcessControlTypes(); | |
191 | |
192 // The shutdown order is a bit complicated: | 184 // The shutdown order is a bit complicated: |
193 // 1) Call ShutdownOnUIThread() from |frontend_loop_| to request sync manager | 185 // 1) Call ShutdownOnUIThread() from |frontend_loop_| to request sync manager |
194 // to stop as soon as possible. | 186 // to stop as soon as possible. |
195 // 2) Post DoShutdown() to sync loop to clean up backend state, save | 187 // 2) Post DoShutdown() to sync loop to clean up backend state, save |
196 // directory and destroy sync manager. | 188 // directory and destroy sync manager. |
197 void ShutdownOnUIThread(); | 189 void ShutdownOnUIThread(); |
198 void DoShutdown(syncer::ShutdownReason reason); | 190 void DoShutdown(syncer::ShutdownReason reason); |
199 void DoDestroySyncManager(syncer::ShutdownReason reason); | 191 void DoDestroySyncManager(syncer::ShutdownReason reason); |
200 | 192 |
201 // Configuration methods that must execute on sync loop. | 193 // Configuration methods that must execute on sync loop. |
(...skipping 10 matching lines...) Expand all Loading... |
212 syncer::ModelTypeSet)>& ready_task); | 204 syncer::ModelTypeSet)>& ready_task); |
213 void DoRetryConfiguration( | 205 void DoRetryConfiguration( |
214 const base::Closure& retry_callback); | 206 const base::Closure& retry_callback); |
215 | 207 |
216 // Set the base request context to use when making HTTP calls. | 208 // Set the base request context to use when making HTTP calls. |
217 // 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 |
218 // on the IO thread. Must be removed from IO thread. | 210 // on the IO thread. Must be removed from IO thread. |
219 | 211 |
220 syncer::SyncManager* sync_manager() { return sync_manager_.get(); } | 212 syncer::SyncManager* sync_manager() { return sync_manager_.get(); } |
221 | 213 |
222 SyncedDeviceTracker* synced_device_tracker() { | |
223 return synced_device_tracker_.get(); | |
224 } | |
225 | |
226 void SendBufferedProtocolEventsAndEnableForwarding(); | 214 void SendBufferedProtocolEventsAndEnableForwarding(); |
227 void DisableProtocolEventForwarding(); | 215 void DisableProtocolEventForwarding(); |
228 | 216 |
229 // Enables the forwarding of directory type debug counters to the | 217 // Enables the forwarding of directory type debug counters to the |
230 // SyncBackendHost. Also requests that updates to all counters be | 218 // SyncBackendHost. Also requests that updates to all counters be |
231 // emitted right away to initialize any new listeners' states. | 219 // emitted right away to initialize any new listeners' states. |
232 void EnableDirectoryTypeDebugInfoForwarding(); | 220 void EnableDirectoryTypeDebugInfoForwarding(); |
233 | 221 |
234 // Disables forwarding of directory type debug counters. | 222 // Disables forwarding of directory type debug counters. |
235 void DisableDirectoryTypeDebugInfoForwarding(); | 223 void DisableDirectoryTypeDebugInfoForwarding(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 // Our parent's registrar (not owned). Non-NULL only between | 274 // Our parent's registrar (not owned). Non-NULL only between |
287 // calls to DoInitialize() and DoShutdown(). | 275 // calls to DoInitialize() and DoShutdown(). |
288 SyncBackendRegistrar* registrar_; | 276 SyncBackendRegistrar* registrar_; |
289 | 277 |
290 // The timer used to periodically call SaveChanges. | 278 // The timer used to periodically call SaveChanges. |
291 scoped_ptr<base::RepeatingTimer<SyncBackendHostCore> > save_changes_timer_; | 279 scoped_ptr<base::RepeatingTimer<SyncBackendHostCore> > save_changes_timer_; |
292 | 280 |
293 // Our encryptor, which uses Chrome's encryption functions. | 281 // Our encryptor, which uses Chrome's encryption functions. |
294 sync_driver::SystemEncryptor encryptor_; | 282 sync_driver::SystemEncryptor encryptor_; |
295 | 283 |
296 // A special ChangeProcessor that tracks the DEVICE_INFO type for us. | |
297 scoped_ptr<SyncedDeviceTracker> synced_device_tracker_; | |
298 | |
299 // The top-level syncapi entry point. Lives on the sync thread. | 284 // The top-level syncapi entry point. Lives on the sync thread. |
300 scoped_ptr<syncer::SyncManager> sync_manager_; | 285 scoped_ptr<syncer::SyncManager> sync_manager_; |
301 | 286 |
302 // Temporary holder of sync manager's initialization results. Set by | 287 // Temporary holder of sync manager's initialization results. Set by |
303 // OnInitializeComplete, and consumed when we pass it via OnBackendInitialized | 288 // OnInitializeComplete, and consumed when we pass it via OnBackendInitialized |
304 // in the final state of HandleInitializationSuccessOnFrontendLoop. | 289 // in the final state of HandleInitializationSuccessOnFrontendLoop. |
305 syncer::WeakHandle<syncer::JsBackend> js_backend_; | 290 syncer::WeakHandle<syncer::JsBackend> js_backend_; |
306 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; | 291 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; |
307 | 292 |
308 // These signals allow us to send requests to shut down the HttpBridgeFactory | 293 // These signals allow us to send requests to shut down the HttpBridgeFactory |
309 // and ServerConnectionManager without having to wait for those classes to | 294 // and ServerConnectionManager without having to wait for those classes to |
310 // finish initializing first. | 295 // finish initializing first. |
311 // | 296 // |
312 // See comments in SyncBackendHostCore::ShutdownOnUIThread() for more details. | 297 // See comments in SyncBackendHostCore::ShutdownOnUIThread() for more details. |
313 syncer::CancelationSignal release_request_context_signal_; | 298 syncer::CancelationSignal release_request_context_signal_; |
314 syncer::CancelationSignal stop_syncing_signal_; | 299 syncer::CancelationSignal stop_syncing_signal_; |
315 | 300 |
316 // Matches the value of SyncPref's HasSyncSetupCompleted() flag at init time. | 301 // Matches the value of SyncPref's HasSyncSetupCompleted() flag at init time. |
317 // Should not be used for anything except for UMAs and logging. | 302 // Should not be used for anything except for UMAs and logging. |
318 const bool has_sync_setup_completed_; | 303 const bool has_sync_setup_completed_; |
319 | 304 |
320 // Set when we've been asked to forward sync protocol events to the frontend. | 305 // Set when we've been asked to forward sync protocol events to the frontend. |
321 bool forward_protocol_events_; | 306 bool forward_protocol_events_; |
322 | 307 |
323 // Set when the forwarding of per-type debug counters is enabled. | 308 // Set when the forwarding of per-type debug counters is enabled. |
324 bool forward_type_info_; | 309 bool forward_type_info_; |
325 | 310 |
326 // Obtained from SigninClient::GetSigninScopedDeviceId(). Stored here just to | |
327 // pass from SyncBackendHostImpl to SyncedDeviceTracker. | |
328 std::string signin_scoped_device_id_; | |
329 | |
330 base::WeakPtrFactory<SyncBackendHostCore> weak_ptr_factory_; | 311 base::WeakPtrFactory<SyncBackendHostCore> weak_ptr_factory_; |
331 | 312 |
332 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostCore); | 313 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostCore); |
333 }; | 314 }; |
334 | 315 |
335 } // namespace browser_sync | 316 } // namespace browser_sync |
336 | 317 |
337 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_CORE_H_ | 318 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_BACKEND_HOST_CORE_H_ |
OLD | NEW |