| 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" |
| 22 #include "components/sync/driver/system_encryptor.h" |
| 21 #include "components/sync/sessions/type_debug_info_observer.h" | 23 #include "components/sync/sessions/type_debug_info_observer.h" |
| 22 #include "components/sync_driver/glue/sync_backend_host_impl.h" | |
| 23 #include "components/sync_driver/system_encryptor.h" | |
| 24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 25 | 25 |
| 26 namespace browser_sync { | 26 namespace browser_sync { |
| 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, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 49 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& | 49 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& |
| 50 unrecoverable_error_handler, | 50 unrecoverable_error_handler, |
| 51 const base::Closure& report_unrecoverable_error_function, | 51 const base::Closure& report_unrecoverable_error_function, |
| 52 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> | 52 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> |
| 53 saved_nigori_state, | 53 saved_nigori_state, |
| 54 const std::map<syncer::ModelType, int64_t>& invalidation_versions); | 54 const std::map<syncer::ModelType, int64_t>& invalidation_versions); |
| 55 ~DoInitializeOptions(); | 55 ~DoInitializeOptions(); |
| 56 | 56 |
| 57 base::MessageLoop* sync_loop; | 57 base::MessageLoop* sync_loop; |
| 58 SyncBackendRegistrar* registrar; | 58 SyncBackendRegistrar* registrar; |
| 59 std::vector<scoped_refptr<syncer::ModelSafeWorker> > workers; | 59 std::vector<scoped_refptr<syncer::ModelSafeWorker>> workers; |
| 60 scoped_refptr<syncer::ExtensionsActivity> extensions_activity; | 60 scoped_refptr<syncer::ExtensionsActivity> extensions_activity; |
| 61 syncer::WeakHandle<syncer::JsEventHandler> event_handler; | 61 syncer::WeakHandle<syncer::JsEventHandler> event_handler; |
| 62 GURL service_url; | 62 GURL service_url; |
| 63 std::string sync_user_agent; | 63 std::string sync_user_agent; |
| 64 // Overridden by tests. | 64 // Overridden by tests. |
| 65 std::unique_ptr<syncer::HttpPostProviderFactory> http_bridge_factory; | 65 std::unique_ptr<syncer::HttpPostProviderFactory> http_bridge_factory; |
| 66 syncer::SyncCredentials credentials; | 66 syncer::SyncCredentials credentials; |
| 67 const std::string invalidator_client_id; | 67 const std::string invalidator_client_id; |
| 68 std::unique_ptr<syncer::SyncManagerFactory> sync_manager_factory; | 68 std::unique_ptr<syncer::SyncManagerFactory> sync_manager_factory; |
| 69 std::string lsid; | 69 std::string lsid; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 92 syncer::ModelTypeSet to_unapply; | 92 syncer::ModelTypeSet to_unapply; |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 class SyncBackendHostCore | 95 class SyncBackendHostCore |
| 96 : public base::RefCountedThreadSafe<SyncBackendHostCore>, | 96 : public base::RefCountedThreadSafe<SyncBackendHostCore>, |
| 97 public syncer::SyncEncryptionHandler::Observer, | 97 public syncer::SyncEncryptionHandler::Observer, |
| 98 public syncer::SyncManager::Observer, | 98 public syncer::SyncManager::Observer, |
| 99 public syncer::TypeDebugInfoObserver { | 99 public syncer::TypeDebugInfoObserver { |
| 100 public: | 100 public: |
| 101 SyncBackendHostCore(const std::string& name, | 101 SyncBackendHostCore(const std::string& name, |
| 102 const base::FilePath& sync_data_folder_path, | 102 const base::FilePath& sync_data_folder_path, |
| 103 bool has_sync_setup_completed, | 103 bool has_sync_setup_completed, |
| 104 const base::WeakPtr<SyncBackendHostImpl>& backend); | 104 const base::WeakPtr<SyncBackendHostImpl>& backend); |
| 105 | 105 |
| 106 // SyncManager::Observer implementation. The Core just acts like an air | 106 // SyncManager::Observer implementation. The Core just acts like an air |
| 107 // traffic controller here, forwarding incoming messages to appropriate | 107 // traffic controller here, forwarding incoming messages to appropriate |
| 108 // landing threads. | 108 // landing threads. |
| 109 void OnSyncCycleCompleted( | 109 void OnSyncCycleCompleted( |
| 110 const syncer::sessions::SyncSessionSnapshot& snapshot) override; | 110 const syncer::sessions::SyncSessionSnapshot& snapshot) override; |
| 111 void OnInitializationComplete( | 111 void OnInitializationComplete( |
| 112 const syncer::WeakHandle<syncer::JsBackend>& js_backend, | 112 const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
| 113 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& | 113 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& |
| 114 debug_info_listener, | 114 debug_info_listener, |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 // directory and destroy sync manager. | 200 // directory and destroy sync manager. |
| 201 void ShutdownOnUIThread(); | 201 void ShutdownOnUIThread(); |
| 202 void DoShutdown(syncer::ShutdownReason reason); | 202 void DoShutdown(syncer::ShutdownReason reason); |
| 203 void DoDestroySyncManager(syncer::ShutdownReason reason); | 203 void DoDestroySyncManager(syncer::ShutdownReason reason); |
| 204 | 204 |
| 205 // Configuration methods that must execute on sync loop. | 205 // Configuration methods that must execute on sync loop. |
| 206 void DoConfigureSyncer( | 206 void DoConfigureSyncer( |
| 207 syncer::ConfigureReason reason, | 207 syncer::ConfigureReason reason, |
| 208 const DoConfigureSyncerTypes& config_types, | 208 const DoConfigureSyncerTypes& config_types, |
| 209 const syncer::ModelSafeRoutingInfo routing_info, | 209 const syncer::ModelSafeRoutingInfo routing_info, |
| 210 const base::Callback<void(syncer::ModelTypeSet, | 210 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>& |
| 211 syncer::ModelTypeSet)>& ready_task, | 211 ready_task, |
| 212 const base::Closure& retry_callback); | 212 const base::Closure& retry_callback); |
| 213 void DoFinishConfigureDataTypes( | 213 void DoFinishConfigureDataTypes( |
| 214 syncer::ModelTypeSet types_to_config, | 214 syncer::ModelTypeSet types_to_config, |
| 215 const base::Callback<void(syncer::ModelTypeSet, | 215 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>& |
| 216 syncer::ModelTypeSet)>& ready_task); | 216 ready_task); |
| 217 void DoRetryConfiguration( | 217 void DoRetryConfiguration(const base::Closure& retry_callback); |
| 218 const base::Closure& retry_callback); | |
| 219 | 218 |
| 220 // Set the base request context to use when making HTTP calls. | 219 // Set the base request context to use when making HTTP calls. |
| 221 // This method will add a reference to the context to persist it | 220 // This method will add a reference to the context to persist it |
| 222 // on the IO thread. Must be removed from IO thread. | 221 // on the IO thread. Must be removed from IO thread. |
| 223 | 222 |
| 224 syncer::SyncManager* sync_manager() { return sync_manager_.get(); } | 223 syncer::SyncManager* sync_manager() { return sync_manager_.get(); } |
| 225 | 224 |
| 226 void SendBufferedProtocolEventsAndEnableForwarding(); | 225 void SendBufferedProtocolEventsAndEnableForwarding(); |
| 227 void DisableProtocolEventForwarding(); | 226 void DisableProtocolEventForwarding(); |
| 228 | 227 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 242 // We expose this member because it's required in the construction of the | 241 // We expose this member because it's required in the construction of the |
| 243 // HttpBridgeFactory. | 242 // HttpBridgeFactory. |
| 244 syncer::CancelationSignal* GetRequestContextCancelationSignal() { | 243 syncer::CancelationSignal* GetRequestContextCancelationSignal() { |
| 245 return &release_request_context_signal_; | 244 return &release_request_context_signal_; |
| 246 } | 245 } |
| 247 | 246 |
| 248 void GetAllNodesForTypes( | 247 void GetAllNodesForTypes( |
| 249 syncer::ModelTypeSet types, | 248 syncer::ModelTypeSet types, |
| 250 scoped_refptr<base::SequencedTaskRunner> task_runner, | 249 scoped_refptr<base::SequencedTaskRunner> task_runner, |
| 251 base::Callback<void(const std::vector<syncer::ModelType>& type, | 250 base::Callback<void(const std::vector<syncer::ModelType>& type, |
| 252 ScopedVector<base::ListValue>) > callback); | 251 ScopedVector<base::ListValue>)> callback); |
| 253 | 252 |
| 254 // Tell the sync manager to persist its state by writing to disk. | 253 // Tell the sync manager to persist its state by writing to disk. |
| 255 // Called on the sync thread, both by a timer and, on Android, when the | 254 // Called on the sync thread, both by a timer and, on Android, when the |
| 256 // application is backgrounded. | 255 // application is backgrounded. |
| 257 void SaveChanges(); | 256 void SaveChanges(); |
| 258 | 257 |
| 259 void DoClearServerData( | 258 void DoClearServerData( |
| 260 const syncer::SyncManager::ClearServerDataCallback& frontend_callback); | 259 const syncer::SyncManager::ClearServerDataCallback& frontend_callback); |
| 261 | 260 |
| 262 // Notify the syncer that the cookie jar has changed. | 261 // Notify the syncer that the cookie jar has changed. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 std::map<syncer::ModelType, int64_t> last_invalidation_versions_; | 332 std::map<syncer::ModelType, int64_t> last_invalidation_versions_; |
| 334 | 333 |
| 335 base::WeakPtrFactory<SyncBackendHostCore> weak_ptr_factory_; | 334 base::WeakPtrFactory<SyncBackendHostCore> weak_ptr_factory_; |
| 336 | 335 |
| 337 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostCore); | 336 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostCore); |
| 338 }; | 337 }; |
| 339 | 338 |
| 340 } // namespace browser_sync | 339 } // namespace browser_sync |
| 341 | 340 |
| 342 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_ | 341 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_ |
| OLD | NEW |