| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_H_ |
| 6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_H_ | 6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/callback.h" | 11 #include "base/callback.h" |
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 15 #include "components/sync_driver/backend_data_type_configurer.h" | 15 #include "components/sync_driver/backend_data_type_configurer.h" |
| 16 #include "sync/internal_api/public/base/model_type.h" | 16 #include "sync/internal_api/public/base/model_type.h" |
| 17 #include "sync/internal_api/public/configure_reason.h" | 17 #include "sync/internal_api/public/configure_reason.h" |
| 18 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" | 18 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" |
| 19 #include "sync/internal_api/public/shutdown_reason.h" | 19 #include "sync/internal_api/public/shutdown_reason.h" |
| 20 #include "sync/internal_api/public/sync_manager.h" | 20 #include "sync/internal_api/public/sync_manager.h" |
| 21 #include "sync/internal_api/public/sync_manager_factory.h" | 21 #include "sync/internal_api/public/sync_manager_factory.h" |
| 22 #include "sync/internal_api/public/util/weak_handle.h" | 22 #include "sync/internal_api/public/util/weak_handle.h" |
| 23 | 23 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 namespace browser_sync { | 42 namespace browser_sync { |
| 43 | 43 |
| 44 // An API to "host" the top level SyncAPI element. | 44 // An API to "host" the top level SyncAPI element. |
| 45 // | 45 // |
| 46 // This class handles dispatch of potentially blocking calls to appropriate | 46 // This class handles dispatch of potentially blocking calls to appropriate |
| 47 // threads and ensures that the SyncFrontend is only accessed on the UI loop. | 47 // threads and ensures that the SyncFrontend is only accessed on the UI loop. |
| 48 class SyncBackendHost : public sync_driver::BackendDataTypeConfigurer { | 48 class SyncBackendHost : public sync_driver::BackendDataTypeConfigurer { |
| 49 public: | 49 public: |
| 50 typedef syncer::SyncStatus Status; | 50 typedef syncer::SyncStatus Status; |
| 51 typedef base::Callback<scoped_ptr<syncer::HttpPostProviderFactory>( | 51 typedef base::Callback<std::unique_ptr<syncer::HttpPostProviderFactory>( |
| 52 syncer::CancelationSignal*)> HttpPostProviderFactoryGetter; | 52 syncer::CancelationSignal*)> |
| 53 HttpPostProviderFactoryGetter; |
| 53 | 54 |
| 54 // Stubs used by implementing classes. | 55 // Stubs used by implementing classes. |
| 55 SyncBackendHost(); | 56 SyncBackendHost(); |
| 56 ~SyncBackendHost() override; | 57 ~SyncBackendHost() override; |
| 57 | 58 |
| 58 // Called on the frontend's thread to kick off asynchronous initialization. | 59 // Called on the frontend's thread to kick off asynchronous initialization. |
| 59 // Optionally deletes the "Sync Data" folder during init in order to make | 60 // Optionally deletes the "Sync Data" folder during init in order to make |
| 60 // sure we're starting fresh. | 61 // sure we're starting fresh. |
| 61 // | 62 // |
| 62 // |saved_nigori_state| is optional nigori state to restore from a previous | 63 // |saved_nigori_state| is optional nigori state to restore from a previous |
| 63 // backend instance. May be null. | 64 // backend instance. May be null. |
| 64 virtual void Initialize( | 65 virtual void Initialize( |
| 65 sync_driver::SyncFrontend* frontend, | 66 sync_driver::SyncFrontend* frontend, |
| 66 scoped_ptr<base::Thread> sync_thread, | 67 std::unique_ptr<base::Thread> sync_thread, |
| 67 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, | 68 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, |
| 68 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread, | 69 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread, |
| 69 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, | 70 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, |
| 70 const GURL& service_url, | 71 const GURL& service_url, |
| 71 const std::string& sync_user_agent, | 72 const std::string& sync_user_agent, |
| 72 const syncer::SyncCredentials& credentials, | 73 const syncer::SyncCredentials& credentials, |
| 73 bool delete_sync_data_folder, | 74 bool delete_sync_data_folder, |
| 74 scoped_ptr<syncer::SyncManagerFactory> sync_manager_factory, | 75 std::unique_ptr<syncer::SyncManagerFactory> sync_manager_factory, |
| 75 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& | 76 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& |
| 76 unrecoverable_error_handler, | 77 unrecoverable_error_handler, |
| 77 const base::Closure& report_unrecoverable_error_function, | 78 const base::Closure& report_unrecoverable_error_function, |
| 78 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, | 79 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, |
| 79 scoped_ptr<syncer::SyncEncryptionHandler::NigoriState> | 80 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> |
| 80 saved_nigori_state) = 0; | 81 saved_nigori_state) = 0; |
| 81 | 82 |
| 82 // Called on the frontend's thread to trigger a refresh. | 83 // Called on the frontend's thread to trigger a refresh. |
| 83 virtual void TriggerRefresh(const syncer::ModelTypeSet& types) = 0; | 84 virtual void TriggerRefresh(const syncer::ModelTypeSet& types) = 0; |
| 84 | 85 |
| 85 // Called on the frontend's thread to update SyncCredentials. | 86 // Called on the frontend's thread to update SyncCredentials. |
| 86 virtual void UpdateCredentials( | 87 virtual void UpdateCredentials( |
| 87 const syncer::SyncCredentials& credentials) = 0; | 88 const syncer::SyncCredentials& credentials) = 0; |
| 88 | 89 |
| 89 // This starts the SyncerThread running a Syncer object to communicate with | 90 // This starts the SyncerThread running a Syncer object to communicate with |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // See the implementation and Core::DoShutdown for details. | 126 // See the implementation and Core::DoShutdown for details. |
| 126 // Must be called *after* StopSyncingForShutdown. | 127 // Must be called *after* StopSyncingForShutdown. |
| 127 // For any reason other than BROWSER_SHUTDOWN, caller should claim sync | 128 // For any reason other than BROWSER_SHUTDOWN, caller should claim sync |
| 128 // thread because: | 129 // thread because: |
| 129 // * during browser shutdown sync thread is not claimed to avoid blocking | 130 // * during browser shutdown sync thread is not claimed to avoid blocking |
| 130 // browser shutdown on sync shutdown. | 131 // browser shutdown on sync shutdown. |
| 131 // * otherwise sync thread is claimed so that if sync backend is recreated | 132 // * otherwise sync thread is claimed so that if sync backend is recreated |
| 132 // later, initialization of new backend is serialized on previous sync | 133 // later, initialization of new backend is serialized on previous sync |
| 133 // thread after cleanup of previous backend to avoid old/new backends | 134 // thread after cleanup of previous backend to avoid old/new backends |
| 134 // interfere with each other. | 135 // interfere with each other. |
| 135 virtual scoped_ptr<base::Thread> Shutdown(syncer::ShutdownReason reason) = 0; | 136 virtual std::unique_ptr<base::Thread> Shutdown( |
| 137 syncer::ShutdownReason reason) = 0; |
| 136 | 138 |
| 137 // Removes all current registrations from the backend on the | 139 // Removes all current registrations from the backend on the |
| 138 // InvalidationService. | 140 // InvalidationService. |
| 139 virtual void UnregisterInvalidationIds() = 0; | 141 virtual void UnregisterInvalidationIds() = 0; |
| 140 | 142 |
| 141 // Changes the set of data types that are currently being synced. | 143 // Changes the set of data types that are currently being synced. |
| 142 // The ready_task will be run when configuration is done with the | 144 // The ready_task will be run when configuration is done with the |
| 143 // set of all types that failed configuration (i.e., if its argument | 145 // set of all types that failed configuration (i.e., if its argument |
| 144 // is non-empty, then an error was encountered). | 146 // is non-empty, then an error was encountered). |
| 145 // Returns the set of types that are ready to start without needing any | 147 // Returns the set of types that are ready to start without needing any |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 // See SyncManager::OnCookieJarChanged. | 233 // See SyncManager::OnCookieJarChanged. |
| 232 virtual void OnCookieJarChanged(bool account_mismatch) = 0; | 234 virtual void OnCookieJarChanged(bool account_mismatch) = 0; |
| 233 | 235 |
| 234 private: | 236 private: |
| 235 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); | 237 DISALLOW_COPY_AND_ASSIGN(SyncBackendHost); |
| 236 }; | 238 }; |
| 237 | 239 |
| 238 } // namespace browser_sync | 240 } // namespace browser_sync |
| 239 | 241 |
| 240 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_H_ | 242 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_H_ |
| OLD | NEW |