| 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_IMPL_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_ |
| 6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_ | 6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 public: | 55 public: |
| 56 typedef SyncStatus Status; | 56 typedef SyncStatus Status; |
| 57 | 57 |
| 58 // Create a SyncBackendHost with a reference to the |frontend| that | 58 // Create a SyncBackendHost with a reference to the |frontend| that |
| 59 // it serves and communicates to via the SyncFrontend interface (on | 59 // it serves and communicates to via the SyncFrontend interface (on |
| 60 // the same thread it used to call the constructor). Must outlive | 60 // the same thread it used to call the constructor). Must outlive |
| 61 // |sync_prefs|. | 61 // |sync_prefs|. |
| 62 SyncBackendHostImpl( | 62 SyncBackendHostImpl( |
| 63 const std::string& name, | 63 const std::string& name, |
| 64 SyncClient* sync_client, | 64 SyncClient* sync_client, |
| 65 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, | |
| 66 invalidation::InvalidationService* invalidator, | 65 invalidation::InvalidationService* invalidator, |
| 67 const base::WeakPtr<SyncPrefs>& sync_prefs, | 66 const base::WeakPtr<SyncPrefs>& sync_prefs, |
| 68 const base::FilePath& sync_folder); | 67 const base::FilePath& sync_folder); |
| 69 ~SyncBackendHostImpl() override; | 68 ~SyncBackendHostImpl() override; |
| 70 | 69 |
| 71 // SyncBackendHost implementation. | 70 // SyncBackendHost implementation. |
| 72 void Initialize( | 71 void Initialize( |
| 73 SyncFrontend* frontend, | 72 SyncFrontend* frontend, |
| 74 base::Thread* sync_thread, | 73 scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner, |
| 75 const WeakHandle<JsEventHandler>& event_handler, | 74 const WeakHandle<JsEventHandler>& event_handler, |
| 76 const GURL& service_url, | 75 const GURL& service_url, |
| 77 const std::string& sync_user_agent, | 76 const std::string& sync_user_agent, |
| 78 const SyncCredentials& credentials, | 77 const SyncCredentials& credentials, |
| 79 bool delete_sync_data_folder, | 78 bool delete_sync_data_folder, |
| 80 bool enable_local_sync_backend, | 79 bool enable_local_sync_backend, |
| 81 const base::FilePath& local_sync_backend_folder, | 80 const base::FilePath& local_sync_backend_folder, |
| 82 std::unique_ptr<SyncManagerFactory> sync_manager_factory, | 81 std::unique_ptr<SyncManagerFactory> sync_manager_factory, |
| 83 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, | 82 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, |
| 84 const base::Closure& report_unrecoverable_error_function, | 83 const base::Closure& report_unrecoverable_error_function, |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 void HandleLocalSetPassphraseEncryptionOnFrontendLoop( | 280 void HandleLocalSetPassphraseEncryptionOnFrontendLoop( |
| 282 const SyncEncryptionHandler::NigoriState& nigori_state); | 281 const SyncEncryptionHandler::NigoriState& nigori_state); |
| 283 | 282 |
| 284 // Dispatched to from OnConnectionStatusChange to handle updating | 283 // Dispatched to from OnConnectionStatusChange to handle updating |
| 285 // frontend UI components. | 284 // frontend UI components. |
| 286 void HandleConnectionStatusChangeOnFrontendLoop(ConnectionStatus status); | 285 void HandleConnectionStatusChangeOnFrontendLoop(ConnectionStatus status); |
| 287 | 286 |
| 288 void ClearServerDataDoneOnFrontendLoop( | 287 void ClearServerDataDoneOnFrontendLoop( |
| 289 const SyncManager::ClearServerDataCallback& frontend_callback); | 288 const SyncManager::ClearServerDataCallback& frontend_callback); |
| 290 | 289 |
| 291 // A reference to the TaskRUnner used to construct |this|, so we know how to | |
| 292 // safely talk back to the SyncFrontend. | |
| 293 scoped_refptr<base::SingleThreadTaskRunner> const frontend_task_runner_; | |
| 294 | |
| 295 SyncClient* const sync_client_; | 290 SyncClient* const sync_client_; |
| 296 | 291 |
| 297 // A pointer to the sync thread. | 292 // The task runner where all the sync engine operations happen. |
| 298 base::Thread* sync_thread_; | 293 scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner_; |
| 299 | |
| 300 // The UI thread's task runner. | |
| 301 const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_; | |
| 302 | 294 |
| 303 // Name used for debugging (set from profile_->GetDebugName()). | 295 // Name used for debugging (set from profile_->GetDebugName()). |
| 304 const std::string name_; | 296 const std::string name_; |
| 305 | 297 |
| 306 // Our core, which communicates directly to the syncapi. Use refptr instead | 298 // Our core, which communicates directly to the syncapi. Use refptr instead |
| 307 // of WeakHandle because |core_| is created on UI loop but released on | 299 // of WeakHandle because |core_| is created on UI loop but released on |
| 308 // sync loop. | 300 // sync loop. |
| 309 scoped_refptr<SyncBackendHostCore> core_; | 301 scoped_refptr<SyncBackendHostCore> core_; |
| 310 | 302 |
| 311 // A handle referencing the main interface for non-blocking sync types. This | 303 // A handle referencing the main interface for non-blocking sync types. This |
| (...skipping 28 matching lines...) Expand all Loading... |
| 340 // If an explicit passphrase is in use, the time at which the passphrase was | 332 // If an explicit passphrase is in use, the time at which the passphrase was |
| 341 // first set (if available). | 333 // first set (if available). |
| 342 base::Time cached_explicit_passphrase_time_; | 334 base::Time cached_explicit_passphrase_time_; |
| 343 | 335 |
| 344 // UI-thread cache of the last SyncCycleSnapshot received from syncapi. | 336 // UI-thread cache of the last SyncCycleSnapshot received from syncapi. |
| 345 SyncCycleSnapshot last_snapshot_; | 337 SyncCycleSnapshot last_snapshot_; |
| 346 | 338 |
| 347 invalidation::InvalidationService* invalidator_; | 339 invalidation::InvalidationService* invalidator_; |
| 348 bool invalidation_handler_registered_; | 340 bool invalidation_handler_registered_; |
| 349 | 341 |
| 342 // Checks that we're on the same thread this was constructed on (UI thread). |
| 343 base::ThreadChecker thread_checker_; |
| 344 |
| 350 base::WeakPtrFactory<SyncBackendHostImpl> weak_ptr_factory_; | 345 base::WeakPtrFactory<SyncBackendHostImpl> weak_ptr_factory_; |
| 351 | 346 |
| 352 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostImpl); | 347 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostImpl); |
| 353 }; | 348 }; |
| 354 | 349 |
| 355 } // namespace syncer | 350 } // namespace syncer |
| 356 | 351 |
| 357 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_ | 352 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_ |
| OLD | NEW |