| 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> |
| 11 #include <memory> |
| 11 #include <string> | 12 #include <string> |
| 12 #include <vector> | 13 #include <vector> |
| 13 | 14 |
| 14 #include "base/callback.h" | 15 #include "base/callback.h" |
| 15 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 17 #include "base/memory/scoped_ptr.h" | |
| 18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 20 #include "components/invalidation/public/invalidation_handler.h" | 20 #include "components/invalidation/public/invalidation_handler.h" |
| 21 #include "components/sync_driver/backend_data_type_configurer.h" | 21 #include "components/sync_driver/backend_data_type_configurer.h" |
| 22 #include "components/sync_driver/glue/sync_backend_host.h" | 22 #include "components/sync_driver/glue/sync_backend_host.h" |
| 23 #include "sync/internal_api/public/base/model_type.h" | 23 #include "sync/internal_api/public/base/model_type.h" |
| 24 #include "sync/internal_api/public/configure_reason.h" | 24 #include "sync/internal_api/public/configure_reason.h" |
| 25 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" | 25 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" |
| 26 #include "sync/internal_api/public/sessions/type_debug_info_observer.h" | 26 #include "sync/internal_api/public/sessions/type_debug_info_observer.h" |
| 27 #include "sync/internal_api/public/sync_manager.h" | 27 #include "sync/internal_api/public/sync_manager.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 sync_driver::SyncClient* sync_client, | 74 sync_driver::SyncClient* sync_client, |
| 75 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, | 75 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, |
| 76 invalidation::InvalidationService* invalidator, | 76 invalidation::InvalidationService* invalidator, |
| 77 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, | 77 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, |
| 78 const base::FilePath& sync_folder); | 78 const base::FilePath& sync_folder); |
| 79 ~SyncBackendHostImpl() override; | 79 ~SyncBackendHostImpl() override; |
| 80 | 80 |
| 81 // SyncBackendHost implementation. | 81 // SyncBackendHost implementation. |
| 82 void Initialize( | 82 void Initialize( |
| 83 sync_driver::SyncFrontend* frontend, | 83 sync_driver::SyncFrontend* frontend, |
| 84 scoped_ptr<base::Thread> sync_thread, | 84 std::unique_ptr<base::Thread> sync_thread, |
| 85 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, | 85 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, |
| 86 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread, | 86 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread, |
| 87 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, | 87 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, |
| 88 const GURL& service_url, | 88 const GURL& service_url, |
| 89 const std::string& sync_user_agent, | 89 const std::string& sync_user_agent, |
| 90 const syncer::SyncCredentials& credentials, | 90 const syncer::SyncCredentials& credentials, |
| 91 bool delete_sync_data_folder, | 91 bool delete_sync_data_folder, |
| 92 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory, | 92 std::unique_ptr<syncer::SyncManagerFactory> sync_manager_factory, |
| 93 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& | 93 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& |
| 94 unrecoverable_error_handler, | 94 unrecoverable_error_handler, |
| 95 const base::Closure& report_unrecoverable_error_function, | 95 const base::Closure& report_unrecoverable_error_function, |
| 96 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, | 96 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, |
| 97 scoped_ptr<syncer::SyncEncryptionHandler::NigoriState> saved_nigori_state) | 97 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> |
| 98 override; | 98 saved_nigori_state) override; |
| 99 void TriggerRefresh(const syncer::ModelTypeSet& types) override; | 99 void TriggerRefresh(const syncer::ModelTypeSet& types) override; |
| 100 void UpdateCredentials(const syncer::SyncCredentials& credentials) override; | 100 void UpdateCredentials(const syncer::SyncCredentials& credentials) override; |
| 101 void StartSyncingWithServer() override; | 101 void StartSyncingWithServer() override; |
| 102 void SetEncryptionPassphrase(const std::string& passphrase, | 102 void SetEncryptionPassphrase(const std::string& passphrase, |
| 103 bool is_explicit) override; | 103 bool is_explicit) override; |
| 104 bool SetDecryptionPassphrase(const std::string& passphrase) override | 104 bool SetDecryptionPassphrase(const std::string& passphrase) override |
| 105 WARN_UNUSED_RESULT; | 105 WARN_UNUSED_RESULT; |
| 106 void StopSyncingForShutdown() override; | 106 void StopSyncingForShutdown() override; |
| 107 scoped_ptr<base::Thread> Shutdown(syncer::ShutdownReason reason) override; | 107 std::unique_ptr<base::Thread> Shutdown( |
| 108 syncer::ShutdownReason reason) override; |
| 108 void UnregisterInvalidationIds() override; | 109 void UnregisterInvalidationIds() override; |
| 109 syncer::ModelTypeSet ConfigureDataTypes( | 110 syncer::ModelTypeSet ConfigureDataTypes( |
| 110 syncer::ConfigureReason reason, | 111 syncer::ConfigureReason reason, |
| 111 const DataTypeConfigStateMap& config_state_map, | 112 const DataTypeConfigStateMap& config_state_map, |
| 112 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>& | 113 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>& |
| 113 ready_task, | 114 ready_task, |
| 114 const base::Callback<void()>& retry_callback) override; | 115 const base::Callback<void()>& retry_callback) override; |
| 115 void ActivateDirectoryDataType( | 116 void ActivateDirectoryDataType( |
| 116 syncer::ModelType type, | 117 syncer::ModelType type, |
| 117 syncer::ModelSafeGroup group, | 118 syncer::ModelSafeGroup group, |
| 118 sync_driver::ChangeProcessor* change_processor) override; | 119 sync_driver::ChangeProcessor* change_processor) override; |
| 119 void DeactivateDirectoryDataType(syncer::ModelType type) override; | 120 void DeactivateDirectoryDataType(syncer::ModelType type) override; |
| 120 void ActivateNonBlockingDataType( | 121 void ActivateNonBlockingDataType( |
| 121 syncer::ModelType type, | 122 syncer::ModelType type, |
| 122 scoped_ptr<syncer_v2::ActivationContext>) override; | 123 std::unique_ptr<syncer_v2::ActivationContext>) override; |
| 123 void DeactivateNonBlockingDataType(syncer::ModelType type) override; | 124 void DeactivateNonBlockingDataType(syncer::ModelType type) override; |
| 124 void EnableEncryptEverything() override; | 125 void EnableEncryptEverything() override; |
| 125 syncer::UserShare* GetUserShare() const override; | 126 syncer::UserShare* GetUserShare() const override; |
| 126 Status GetDetailedStatus() override; | 127 Status GetDetailedStatus() override; |
| 127 syncer::sessions::SyncSessionSnapshot GetLastSessionSnapshot() const override; | 128 syncer::sessions::SyncSessionSnapshot GetLastSessionSnapshot() const override; |
| 128 bool HasUnsyncedItems() const override; | 129 bool HasUnsyncedItems() const override; |
| 129 bool IsNigoriEnabled() const override; | 130 bool IsNigoriEnabled() const override; |
| 130 syncer::PassphraseType GetPassphraseType() const override; | 131 syncer::PassphraseType GetPassphraseType() const override; |
| 131 base::Time GetExplicitPassphraseTime() const override; | 132 base::Time GetExplicitPassphraseTime() const override; |
| 132 bool IsCryptographerReady( | 133 bool IsCryptographerReady( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 152 void OnInvalidatorStateChange(syncer::InvalidatorState state) override; | 153 void OnInvalidatorStateChange(syncer::InvalidatorState state) override; |
| 153 void OnIncomingInvalidation( | 154 void OnIncomingInvalidation( |
| 154 const syncer::ObjectIdInvalidationMap& invalidation_map) override; | 155 const syncer::ObjectIdInvalidationMap& invalidation_map) override; |
| 155 std::string GetOwnerName() const override; | 156 std::string GetOwnerName() const override; |
| 156 | 157 |
| 157 protected: | 158 protected: |
| 158 // The types and functions below are protected so that test | 159 // The types and functions below are protected so that test |
| 159 // subclasses can use them. | 160 // subclasses can use them. |
| 160 | 161 |
| 161 // Allows tests to perform alternate core initialization work. | 162 // Allows tests to perform alternate core initialization work. |
| 162 virtual void InitCore(scoped_ptr<DoInitializeOptions> options); | 163 virtual void InitCore(std::unique_ptr<DoInitializeOptions> options); |
| 163 | 164 |
| 164 // Request the syncer to reconfigure with the specfied params. | 165 // Request the syncer to reconfigure with the specfied params. |
| 165 // Virtual for testing. | 166 // Virtual for testing. |
| 166 virtual void RequestConfigureSyncer( | 167 virtual void RequestConfigureSyncer( |
| 167 syncer::ConfigureReason reason, | 168 syncer::ConfigureReason reason, |
| 168 syncer::ModelTypeSet to_download, | 169 syncer::ModelTypeSet to_download, |
| 169 syncer::ModelTypeSet to_purge, | 170 syncer::ModelTypeSet to_purge, |
| 170 syncer::ModelTypeSet to_journal, | 171 syncer::ModelTypeSet to_journal, |
| 171 syncer::ModelTypeSet to_unapply, | 172 syncer::ModelTypeSet to_unapply, |
| 172 syncer::ModelTypeSet to_ignore, | 173 syncer::ModelTypeSet to_ignore, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 185 | 186 |
| 186 // Reports backend initialization success. Includes some objects from sync | 187 // Reports backend initialization success. Includes some objects from sync |
| 187 // manager initialization to be passed back to the UI thread. | 188 // manager initialization to be passed back to the UI thread. |
| 188 // | 189 // |
| 189 // |model_type_connector| is our ModelTypeConnector, which is owned because in | 190 // |model_type_connector| is our ModelTypeConnector, which is owned because in |
| 190 // production it is a proxy object to the real ModelTypeConnector. | 191 // production it is a proxy object to the real ModelTypeConnector. |
| 191 virtual void HandleInitializationSuccessOnFrontendLoop( | 192 virtual void HandleInitializationSuccessOnFrontendLoop( |
| 192 const syncer::WeakHandle<syncer::JsBackend> js_backend, | 193 const syncer::WeakHandle<syncer::JsBackend> js_backend, |
| 193 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener> | 194 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener> |
| 194 debug_info_listener, | 195 debug_info_listener, |
| 195 scoped_ptr<syncer_v2::ModelTypeConnector> model_type_connector, | 196 std::unique_ptr<syncer_v2::ModelTypeConnector> model_type_connector, |
| 196 const std::string& cache_guid); | 197 const std::string& cache_guid); |
| 197 | 198 |
| 198 // Forwards a ProtocolEvent to the frontend. Will not be called unless a | 199 // Forwards a ProtocolEvent to the frontend. Will not be called unless a |
| 199 // call to SetForwardProtocolEvents() explicitly requested that we start | 200 // call to SetForwardProtocolEvents() explicitly requested that we start |
| 200 // forwarding these events. | 201 // forwarding these events. |
| 201 void HandleProtocolEventOnFrontendLoop(syncer::ProtocolEvent* event); | 202 void HandleProtocolEventOnFrontendLoop(syncer::ProtocolEvent* event); |
| 202 | 203 |
| 203 // Forwards a directory commit counter update to the frontend loop. Will not | 204 // Forwards a directory commit counter update to the frontend loop. Will not |
| 204 // be called unless a call to EnableDirectoryTypeDebugInfoForwarding() | 205 // be called unless a call to EnableDirectoryTypeDebugInfoForwarding() |
| 205 // explicitly requested that we start forwarding these events. | 206 // explicitly requested that we start forwarding these events. |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 // Name used for debugging (set from profile_->GetDebugName()). | 330 // Name used for debugging (set from profile_->GetDebugName()). |
| 330 const std::string name_; | 331 const std::string name_; |
| 331 | 332 |
| 332 // Our core, which communicates directly to the syncapi. Use refptr instead | 333 // Our core, which communicates directly to the syncapi. Use refptr instead |
| 333 // of WeakHandle because |core_| is created on UI loop but released on | 334 // of WeakHandle because |core_| is created on UI loop but released on |
| 334 // sync loop. | 335 // sync loop. |
| 335 scoped_refptr<SyncBackendHostCore> core_; | 336 scoped_refptr<SyncBackendHostCore> core_; |
| 336 | 337 |
| 337 // A handle referencing the main interface for non-blocking sync types. This | 338 // A handle referencing the main interface for non-blocking sync types. This |
| 338 // object is owned because in production code it is a proxy object. | 339 // object is owned because in production code it is a proxy object. |
| 339 scoped_ptr<syncer_v2::ModelTypeConnector> model_type_connector_; | 340 std::unique_ptr<syncer_v2::ModelTypeConnector> model_type_connector_; |
| 340 | 341 |
| 341 bool initialized_; | 342 bool initialized_; |
| 342 | 343 |
| 343 const base::WeakPtr<sync_driver::SyncPrefs> sync_prefs_; | 344 const base::WeakPtr<sync_driver::SyncPrefs> sync_prefs_; |
| 344 | 345 |
| 345 scoped_ptr<SyncBackendRegistrar> registrar_; | 346 std::unique_ptr<SyncBackendRegistrar> registrar_; |
| 346 | 347 |
| 347 // The frontend which we serve (and are owned by). | 348 // The frontend which we serve (and are owned by). |
| 348 sync_driver::SyncFrontend* frontend_; | 349 sync_driver::SyncFrontend* frontend_; |
| 349 | 350 |
| 350 // We cache the cryptographer's pending keys whenever NotifyPassphraseRequired | 351 // We cache the cryptographer's pending keys whenever NotifyPassphraseRequired |
| 351 // is called. This way, before the UI calls SetDecryptionPassphrase on the | 352 // is called. This way, before the UI calls SetDecryptionPassphrase on the |
| 352 // syncer, it can avoid the overhead of an asynchronous decryption call and | 353 // syncer, it can avoid the overhead of an asynchronous decryption call and |
| 353 // give the user immediate feedback about the passphrase entered by first | 354 // give the user immediate feedback about the passphrase entered by first |
| 354 // trying to decrypt the cached pending keys on the UI thread. Note that | 355 // trying to decrypt the cached pending keys on the UI thread. Note that |
| 355 // SetDecryptionPassphrase can still fail after the cached pending keys are | 356 // SetDecryptionPassphrase can still fail after the cached pending keys are |
| (...skipping 18 matching lines...) Expand all Loading... |
| 374 bool invalidation_handler_registered_; | 375 bool invalidation_handler_registered_; |
| 375 | 376 |
| 376 base::WeakPtrFactory<SyncBackendHostImpl> weak_ptr_factory_; | 377 base::WeakPtrFactory<SyncBackendHostImpl> weak_ptr_factory_; |
| 377 | 378 |
| 378 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostImpl); | 379 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostImpl); |
| 379 }; | 380 }; |
| 380 | 381 |
| 381 } // namespace browser_sync | 382 } // namespace browser_sync |
| 382 | 383 |
| 383 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_ | 384 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_IMPL_H_ |
| OLD | NEW |