| 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 "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 struct DoInitializeOptions { | 27 struct DoInitializeOptions { |
| 28 DoInitializeOptions( | 28 DoInitializeOptions( |
| 29 base::MessageLoop* sync_loop, | 29 base::MessageLoop* sync_loop, |
| 30 SyncBackendRegistrar* registrar, | 30 SyncBackendRegistrar* registrar, |
| 31 const syncer::ModelSafeRoutingInfo& routing_info, | 31 const syncer::ModelSafeRoutingInfo& routing_info, |
| 32 const std::vector<scoped_refptr<syncer::ModelSafeWorker>>& workers, | 32 const std::vector<scoped_refptr<syncer::ModelSafeWorker>>& workers, |
| 33 const scoped_refptr<syncer::ExtensionsActivity>& extensions_activity, | 33 const scoped_refptr<syncer::ExtensionsActivity>& extensions_activity, |
| 34 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, | 34 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, |
| 35 const GURL& service_url, | 35 const GURL& service_url, |
| 36 const std::string& sync_user_agent, | 36 const std::string& sync_user_agent, |
| 37 scoped_ptr<syncer::HttpPostProviderFactory> http_bridge_factory, | 37 std::unique_ptr<syncer::HttpPostProviderFactory> http_bridge_factory, |
| 38 const syncer::SyncCredentials& credentials, | 38 const syncer::SyncCredentials& credentials, |
| 39 const std::string& invalidator_client_id, | 39 const std::string& invalidator_client_id, |
| 40 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory, | 40 std::unique_ptr<syncer::SyncManagerFactory> sync_manager_factory, |
| 41 bool delete_sync_data_folder, | 41 bool delete_sync_data_folder, |
| 42 const std::string& restored_key_for_bootstrapping, | 42 const std::string& restored_key_for_bootstrapping, |
| 43 const std::string& restored_keystore_key_for_bootstrapping, | 43 const std::string& restored_keystore_key_for_bootstrapping, |
| 44 scoped_ptr<syncer::InternalComponentsFactory> internal_components_factory, | 44 std::unique_ptr<syncer::InternalComponentsFactory> |
| 45 internal_components_factory, |
| 45 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& | 46 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& |
| 46 unrecoverable_error_handler, | 47 unrecoverable_error_handler, |
| 47 const base::Closure& report_unrecoverable_error_function, | 48 const base::Closure& report_unrecoverable_error_function, |
| 48 scoped_ptr<syncer::SyncEncryptionHandler::NigoriState> saved_nigori_state, | 49 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> |
| 50 saved_nigori_state, |
| 49 syncer::PassphraseTransitionClearDataOption clear_data_option, | 51 syncer::PassphraseTransitionClearDataOption clear_data_option, |
| 50 const std::map<syncer::ModelType, int64_t>& invalidation_versions); | 52 const std::map<syncer::ModelType, int64_t>& invalidation_versions); |
| 51 ~DoInitializeOptions(); | 53 ~DoInitializeOptions(); |
| 52 | 54 |
| 53 base::MessageLoop* sync_loop; | 55 base::MessageLoop* sync_loop; |
| 54 SyncBackendRegistrar* registrar; | 56 SyncBackendRegistrar* registrar; |
| 55 syncer::ModelSafeRoutingInfo routing_info; | 57 syncer::ModelSafeRoutingInfo routing_info; |
| 56 std::vector<scoped_refptr<syncer::ModelSafeWorker> > workers; | 58 std::vector<scoped_refptr<syncer::ModelSafeWorker> > workers; |
| 57 scoped_refptr<syncer::ExtensionsActivity> extensions_activity; | 59 scoped_refptr<syncer::ExtensionsActivity> extensions_activity; |
| 58 syncer::WeakHandle<syncer::JsEventHandler> event_handler; | 60 syncer::WeakHandle<syncer::JsEventHandler> event_handler; |
| 59 GURL service_url; | 61 GURL service_url; |
| 60 std::string sync_user_agent; | 62 std::string sync_user_agent; |
| 61 // Overridden by tests. | 63 // Overridden by tests. |
| 62 scoped_ptr<syncer::HttpPostProviderFactory> http_bridge_factory; | 64 std::unique_ptr<syncer::HttpPostProviderFactory> http_bridge_factory; |
| 63 syncer::SyncCredentials credentials; | 65 syncer::SyncCredentials credentials; |
| 64 const std::string invalidator_client_id; | 66 const std::string invalidator_client_id; |
| 65 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory; | 67 std::unique_ptr<syncer::SyncManagerFactory> sync_manager_factory; |
| 66 std::string lsid; | 68 std::string lsid; |
| 67 bool delete_sync_data_folder; | 69 bool delete_sync_data_folder; |
| 68 std::string restored_key_for_bootstrapping; | 70 std::string restored_key_for_bootstrapping; |
| 69 std::string restored_keystore_key_for_bootstrapping; | 71 std::string restored_keystore_key_for_bootstrapping; |
| 70 scoped_ptr<syncer::InternalComponentsFactory> internal_components_factory; | 72 std::unique_ptr<syncer::InternalComponentsFactory> |
| 73 internal_components_factory; |
| 71 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler> | 74 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler> |
| 72 unrecoverable_error_handler; | 75 unrecoverable_error_handler; |
| 73 base::Closure report_unrecoverable_error_function; | 76 base::Closure report_unrecoverable_error_function; |
| 74 scoped_ptr<syncer::SyncEncryptionHandler::NigoriState> saved_nigori_state; | 77 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> |
| 78 saved_nigori_state; |
| 75 const syncer::PassphraseTransitionClearDataOption clear_data_option; | 79 const syncer::PassphraseTransitionClearDataOption clear_data_option; |
| 76 const std::map<syncer::ModelType, int64_t> invalidation_versions; | 80 const std::map<syncer::ModelType, int64_t> invalidation_versions; |
| 77 }; | 81 }; |
| 78 | 82 |
| 79 // Helper struct to handle currying params to | 83 // Helper struct to handle currying params to |
| 80 // SyncBackendHost::Core::DoConfigureSyncer. | 84 // SyncBackendHost::Core::DoConfigureSyncer. |
| 81 struct DoConfigureSyncerTypes { | 85 struct DoConfigureSyncerTypes { |
| 82 DoConfigureSyncerTypes(); | 86 DoConfigureSyncerTypes(); |
| 83 DoConfigureSyncerTypes(const DoConfigureSyncerTypes& other); | 87 DoConfigureSyncerTypes(const DoConfigureSyncerTypes& other); |
| 84 ~DoConfigureSyncerTypes(); | 88 ~DoConfigureSyncerTypes(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 153 |
| 150 // Note: | 154 // Note: |
| 151 // | 155 // |
| 152 // The Do* methods are the various entry points from our | 156 // The Do* methods are the various entry points from our |
| 153 // SyncBackendHost. They are all called on the sync thread to | 157 // SyncBackendHost. They are all called on the sync thread to |
| 154 // actually perform synchronous (and potentially blocking) syncapi | 158 // actually perform synchronous (and potentially blocking) syncapi |
| 155 // operations. | 159 // operations. |
| 156 // | 160 // |
| 157 // Called to perform initialization of the syncapi on behalf of | 161 // Called to perform initialization of the syncapi on behalf of |
| 158 // SyncBackendHost::Initialize. | 162 // SyncBackendHost::Initialize. |
| 159 void DoInitialize(scoped_ptr<DoInitializeOptions> options); | 163 void DoInitialize(std::unique_ptr<DoInitializeOptions> options); |
| 160 | 164 |
| 161 // Called to perform credential update on behalf of | 165 // Called to perform credential update on behalf of |
| 162 // SyncBackendHost::UpdateCredentials. | 166 // SyncBackendHost::UpdateCredentials. |
| 163 void DoUpdateCredentials(const syncer::SyncCredentials& credentials); | 167 void DoUpdateCredentials(const syncer::SyncCredentials& credentials); |
| 164 | 168 |
| 165 // Called to tell the syncapi to start syncing (generally after | 169 // Called to tell the syncapi to start syncing (generally after |
| 166 // initialization and authentication). | 170 // initialization and authentication). |
| 167 void DoStartSyncing(const syncer::ModelSafeRoutingInfo& routing_info, | 171 void DoStartSyncing(const syncer::ModelSafeRoutingInfo& routing_info, |
| 168 base::Time last_poll_time); | 172 base::Time last_poll_time); |
| 169 | 173 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 | 287 |
| 284 // The loop where all the sync backend operations happen. | 288 // The loop where all the sync backend operations happen. |
| 285 // Non-NULL only between calls to DoInitialize() and ~Core(). | 289 // Non-NULL only between calls to DoInitialize() and ~Core(). |
| 286 base::MessageLoop* sync_loop_; | 290 base::MessageLoop* sync_loop_; |
| 287 | 291 |
| 288 // Our parent's registrar (not owned). Non-NULL only between | 292 // Our parent's registrar (not owned). Non-NULL only between |
| 289 // calls to DoInitialize() and DoShutdown(). | 293 // calls to DoInitialize() and DoShutdown(). |
| 290 SyncBackendRegistrar* registrar_; | 294 SyncBackendRegistrar* registrar_; |
| 291 | 295 |
| 292 // The timer used to periodically call SaveChanges. | 296 // The timer used to periodically call SaveChanges. |
| 293 scoped_ptr<base::RepeatingTimer> save_changes_timer_; | 297 std::unique_ptr<base::RepeatingTimer> save_changes_timer_; |
| 294 | 298 |
| 295 // Our encryptor, which uses Chrome's encryption functions. | 299 // Our encryptor, which uses Chrome's encryption functions. |
| 296 sync_driver::SystemEncryptor encryptor_; | 300 sync_driver::SystemEncryptor encryptor_; |
| 297 | 301 |
| 298 // The top-level syncapi entry point. Lives on the sync thread. | 302 // The top-level syncapi entry point. Lives on the sync thread. |
| 299 scoped_ptr<syncer::SyncManager> sync_manager_; | 303 std::unique_ptr<syncer::SyncManager> sync_manager_; |
| 300 | 304 |
| 301 // Temporary holder of sync manager's initialization results. Set by | 305 // Temporary holder of sync manager's initialization results. Set by |
| 302 // OnInitializeComplete, and consumed when we pass it via OnBackendInitialized | 306 // OnInitializeComplete, and consumed when we pass it via OnBackendInitialized |
| 303 // in the final state of HandleInitializationSuccessOnFrontendLoop. | 307 // in the final state of HandleInitializationSuccessOnFrontendLoop. |
| 304 syncer::WeakHandle<syncer::JsBackend> js_backend_; | 308 syncer::WeakHandle<syncer::JsBackend> js_backend_; |
| 305 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; | 309 syncer::WeakHandle<syncer::DataTypeDebugInfoListener> debug_info_listener_; |
| 306 | 310 |
| 307 // These signals allow us to send requests to shut down the HttpBridgeFactory | 311 // These signals allow us to send requests to shut down the HttpBridgeFactory |
| 308 // and ServerConnectionManager without having to wait for those classes to | 312 // and ServerConnectionManager without having to wait for those classes to |
| 309 // finish initializing first. | 313 // finish initializing first. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 329 std::map<syncer::ModelType, int64_t> last_invalidation_versions_; | 333 std::map<syncer::ModelType, int64_t> last_invalidation_versions_; |
| 330 | 334 |
| 331 base::WeakPtrFactory<SyncBackendHostCore> weak_ptr_factory_; | 335 base::WeakPtrFactory<SyncBackendHostCore> weak_ptr_factory_; |
| 332 | 336 |
| 333 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostCore); | 337 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostCore); |
| 334 }; | 338 }; |
| 335 | 339 |
| 336 } // namespace browser_sync | 340 } // namespace browser_sync |
| 337 | 341 |
| 338 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_ | 342 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_ |
| OLD | NEW |