Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: components/sync/driver/sync_service_base.h

Issue 2559123002: [Sync] SyncEngine refactor part 2: SyncServiceBase. (Closed)
Patch Set: Address comments. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/sync/driver/sync_service_base.h
diff --git a/components/sync/driver/sync_service_base.h b/components/sync/driver/sync_service_base.h
new file mode 100644
index 0000000000000000000000000000000000000000..1f068b1afb6775ab58ffa53e71a3fdeed610c358
--- /dev/null
+++ b/components/sync/driver/sync_service_base.h
@@ -0,0 +1,107 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_BASE_H_
+#define COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_BASE_H_
+
+#include <memory>
+#include <string>
+
+#include "base/files/file_path.h"
+#include "base/memory/weak_ptr.h"
+#include "base/threading/thread.h"
+#include "components/sync/base/sync_prefs.h"
+#include "components/sync/base/unrecoverable_error_handler.h"
+#include "components/sync/base/weak_handle.h"
+#include "components/sync/driver/signin_manager_wrapper.h"
+#include "components/sync/driver/sync_client.h"
+#include "components/sync/driver/sync_service.h"
+#include "components/sync/engine/sync_engine.h"
+#include "components/sync/engine/sync_engine_host.h"
+#include "components/sync/engine/sync_manager.h"
+#include "components/sync/js/sync_js_controller.h"
+#include "components/version_info/version_info.h"
+
+namespace syncer {
+
+// This is a base class for implementations of SyncService that contains some
+// common functionality and member variables. Anything that can live inside the
+// sync component should eventually live here instead of a concrete
+// implementation. This is set up as a base class so things can be transferred
+// piece by piece as easily as possible.
+class SyncServiceBase : public SyncService, public SyncEngineHost {
+ public:
+ SyncServiceBase(std::unique_ptr<SyncClient> sync_client,
+ std::unique_ptr<SigninManagerWrapper> signin,
+ const version_info::Channel& channel,
+ const base::FilePath& base_directory,
+ const std::string& debug_identifier);
+ ~SyncServiceBase() override;
+
+ protected:
+ // Kicks off asynchronous initialization of the SyncEngine.
+ void InitializeEngine();
+
+ // Returns SyncCredentials from the OAuth2TokenService.
+ virtual SyncCredentials GetCredentials() = 0;
+
+ // Returns a weak handle to the JsEventHandler.
+ virtual WeakHandle<JsEventHandler> GetJsEventHandler() = 0;
+
+ // Returns a callback that makes an HttpPostProviderFactory.
+ virtual SyncEngine::HttpPostProviderFactoryGetter
+ MakeHttpPostProviderFactoryGetter() = 0;
+
+ // Takes the previously saved nigori state; null if there isn't any.
+ virtual std::unique_ptr<SyncEncryptionHandler::NigoriState>
+ MoveSavedNigoriState() = 0;
+
+ // Returns a weak handle to an UnrecoverableErrorHandler (may be |this|).
+ virtual WeakHandle<UnrecoverableErrorHandler>
+ GetUnrecoverableErrorHandler() = 0;
+
+ // This profile's SyncClient, which abstracts away non-Sync dependencies and
+ // the Sync API component factory.
+ const std::unique_ptr<SyncClient> sync_client_;
+
+ // Encapsulates user signin - used to set/get the user's authenticated
+ // email address.
+ const std::unique_ptr<SigninManagerWrapper> signin_;
+
+ // The product channel of the embedder.
+ const version_info::Channel channel_;
+
+ // The path to the base directory under which sync should store its
+ // information.
+ const base::FilePath base_directory_;
+
+ // The full path to the sync data directory.
+ const base::FilePath directory_path_;
+
+ // An identifier representing this instance for debugging purposes.
+ const std::string debug_identifier_;
+
+ // The class that handles getting, setting, and persisting sync
+ // preferences.
+ SyncPrefs sync_prefs_;
+
+ // The thread where all the sync operations happen. This thread is kept alive
+ // until browser shutdown and reused if sync is turned off and on again. It is
+ // joined during the shutdown process, but there is an abort mechanism in
+ // place to prevent slow HTTP requests from blocking browser shutdown.
+ std::unique_ptr<base::Thread> sync_thread_;
+
+ // Our asynchronous engine to communicate with sync components living on
+ // other threads.
+ std::unique_ptr<SyncEngine> engine_;
+
+ private:
+ bool GetLocalSyncConfig(base::FilePath* local_sync_backend_folder) const;
+
+ DISALLOW_COPY_AND_ASSIGN(SyncServiceBase);
+};
+
+} // namespace syncer
+
+#endif // COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_BASE_H_
« no previous file with comments | « components/sync/driver/glue/sync_backend_host_impl_unittest.cc ('k') | components/sync/driver/sync_service_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698