| 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_ENGINE_SYNC_ENGINE_H_ | 5 #ifndef COMPONENTS_SYNC_ENGINE_SYNC_ENGINE_H_ |
| 6 #define COMPONENTS_SYNC_ENGINE_SYNC_ENGINE_H_ | 6 #define COMPONENTS_SYNC_ENGINE_SYNC_ENGINE_H_ |
| 7 | 7 |
| 8 #include <map> |
| 8 #include <memory> | 9 #include <memory> |
| 9 #include <string> | 10 #include <string> |
| 10 | 11 |
| 11 #include "base/callback.h" | 12 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/files/file_path.h" |
| 13 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" |
| 14 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 18 #include "components/sync/base/extensions_activity.h" |
| 15 #include "components/sync/base/model_type.h" | 19 #include "components/sync/base/model_type.h" |
| 16 #include "components/sync/base/weak_handle.h" | 20 #include "components/sync/base/weak_handle.h" |
| 17 #include "components/sync/engine/configure_reason.h" | 21 #include "components/sync/engine/configure_reason.h" |
| 18 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" | 22 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" |
| 19 #include "components/sync/engine/model_type_configurer.h" | 23 #include "components/sync/engine/model_type_configurer.h" |
| 20 #include "components/sync/engine/shutdown_reason.h" | 24 #include "components/sync/engine/shutdown_reason.h" |
| 25 #include "components/sync/engine/sync_backend_registrar.h" |
| 21 #include "components/sync/engine/sync_manager.h" | 26 #include "components/sync/engine/sync_manager.h" |
| 22 #include "components/sync/engine/sync_manager_factory.h" | 27 #include "components/sync/engine/sync_manager_factory.h" |
| 23 | 28 |
| 24 class GURL; | 29 class GURL; |
| 25 | 30 |
| 26 namespace syncer { | 31 namespace syncer { |
| 27 | 32 |
| 28 class CancelationSignal; | 33 class CancelationSignal; |
| 29 class HttpPostProviderFactory; | 34 class HttpPostProviderFactory; |
| 30 class SyncEngineHost; | 35 class SyncEngineHost; |
| 31 class SyncManagerFactory; | 36 class SyncManagerFactory; |
| 32 class UnrecoverableErrorHandler; | 37 class UnrecoverableErrorHandler; |
| 33 | 38 |
| 34 // The interface into the sync engine, which is the part of sync that performs | 39 // The interface into the sync engine, which is the part of sync that performs |
| 35 // communication between model types and the sync server. In prod the engine | 40 // communication between model types and the sync server. In prod the engine |
| 36 // will always live on the sync thread and the object implementing this | 41 // will always live on the sync thread and the object implementing this |
| 37 // interface will handle crossing threads if necessary. | 42 // interface will handle crossing threads if necessary. |
| 38 class SyncEngine : public ModelTypeConfigurer { | 43 class SyncEngine : public ModelTypeConfigurer { |
| 39 public: | 44 public: |
| 40 typedef SyncStatus Status; | 45 typedef SyncStatus Status; |
| 41 typedef base::Callback<std::unique_ptr<HttpPostProviderFactory>( | 46 typedef base::Callback<std::unique_ptr<HttpPostProviderFactory>( |
| 42 CancelationSignal*)> | 47 CancelationSignal*)> |
| 43 HttpPostProviderFactoryGetter; | 48 HttpPostProviderFactoryGetter; |
| 44 | 49 |
| 45 // Stubs used by implementing classes. | 50 // Utility struct for holding initialization options. |
| 51 struct InitParams { |
| 52 InitParams(); |
| 53 InitParams(InitParams&& other); |
| 54 ~InitParams(); |
| 55 |
| 56 scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner; |
| 57 SyncEngineHost* host = nullptr; |
| 58 std::unique_ptr<SyncBackendRegistrar> registrar; |
| 59 scoped_refptr<ExtensionsActivity> extensions_activity; |
| 60 WeakHandle<JsEventHandler> event_handler; |
| 61 GURL service_url; |
| 62 std::string sync_user_agent; |
| 63 SyncEngine::HttpPostProviderFactoryGetter http_factory_getter; |
| 64 SyncCredentials credentials; |
| 65 std::string invalidator_client_id; |
| 66 std::unique_ptr<SyncManagerFactory> sync_manager_factory; |
| 67 bool delete_sync_data_folder = false; |
| 68 bool enable_local_sync_backend = false; |
| 69 base::FilePath local_sync_backend_folder; |
| 70 std::string restored_key_for_bootstrapping; |
| 71 std::string restored_keystore_key_for_bootstrapping; |
| 72 std::unique_ptr<EngineComponentsFactory> engine_components_factory; |
| 73 WeakHandle<UnrecoverableErrorHandler> unrecoverable_error_handler; |
| 74 base::Closure report_unrecoverable_error_function; |
| 75 std::unique_ptr<SyncEncryptionHandler::NigoriState> saved_nigori_state; |
| 76 std::map<ModelType, int64_t> invalidation_versions; |
| 77 |
| 78 private: |
| 79 DISALLOW_COPY_AND_ASSIGN(InitParams); |
| 80 }; |
| 81 |
| 46 SyncEngine(); | 82 SyncEngine(); |
| 47 ~SyncEngine() override; | 83 ~SyncEngine() override; |
| 48 | 84 |
| 49 // Kicks off asynchronous initialization. Optionally deletes sync data during | 85 // Kicks off asynchronous initialization. Optionally deletes sync data during |
| 50 // init in order to make sure we're starting fresh. | 86 // init in order to make sure we're starting fresh. |
| 51 // | 87 // |
| 52 // |saved_nigori_state| is optional nigori state to restore from a previous | 88 // |saved_nigori_state| is optional nigori state to restore from a previous |
| 53 // engine instance. May be null. | 89 // engine instance. May be null. |
| 54 virtual void Initialize( | 90 virtual void Initialize(InitParams params) = 0; |
| 55 SyncEngineHost* host, | |
| 56 scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner, | |
| 57 const WeakHandle<JsEventHandler>& event_handler, | |
| 58 const GURL& service_url, | |
| 59 const std::string& sync_user_agent, | |
| 60 const SyncCredentials& credentials, | |
| 61 bool delete_sync_data_folder, | |
| 62 bool enable_local_sync_backend, | |
| 63 const base::FilePath& local_sync_backend_folder, | |
| 64 std::unique_ptr<SyncManagerFactory> sync_manager_factory, | |
| 65 const WeakHandle<UnrecoverableErrorHandler>& unrecoverable_error_handler, | |
| 66 const base::Closure& report_unrecoverable_error_function, | |
| 67 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, | |
| 68 std::unique_ptr<SyncEncryptionHandler::NigoriState> | |
| 69 saved_nigori_state) = 0; | |
| 70 | 91 |
| 71 // Inform the engine to trigger a sync cycle for |types|. | 92 // Inform the engine to trigger a sync cycle for |types|. |
| 72 virtual void TriggerRefresh(const ModelTypeSet& types) = 0; | 93 virtual void TriggerRefresh(const ModelTypeSet& types) = 0; |
| 73 | 94 |
| 74 // Updates the engine's SyncCredentials. | 95 // Updates the engine's SyncCredentials. |
| 75 virtual void UpdateCredentials(const SyncCredentials& credentials) = 0; | 96 virtual void UpdateCredentials(const SyncCredentials& credentials) = 0; |
| 76 | 97 |
| 77 // This starts the sync engine running a Syncer object to communicate with | 98 // This starts the sync engine running a Syncer object to communicate with |
| 78 // sync servers. Until this is called, no changes will leave or enter this | 99 // sync servers. Until this is called, no changes will leave or enter this |
| 79 // browser from the cloud / sync servers. | 100 // browser from the cloud / sync servers. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 // See SyncManager::OnCookieJarChanged. | 215 // See SyncManager::OnCookieJarChanged. |
| 195 virtual void OnCookieJarChanged(bool account_mismatch, bool empty_jar) = 0; | 216 virtual void OnCookieJarChanged(bool account_mismatch, bool empty_jar) = 0; |
| 196 | 217 |
| 197 private: | 218 private: |
| 198 DISALLOW_COPY_AND_ASSIGN(SyncEngine); | 219 DISALLOW_COPY_AND_ASSIGN(SyncEngine); |
| 199 }; | 220 }; |
| 200 | 221 |
| 201 } // namespace syncer | 222 } // namespace syncer |
| 202 | 223 |
| 203 #endif // COMPONENTS_SYNC_ENGINE_SYNC_ENGINE_H_ | 224 #endif // COMPONENTS_SYNC_ENGINE_SYNC_ENGINE_H_ |
| OLD | NEW |