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

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

Issue 2559123002: [Sync] SyncEngine refactor part 2: SyncServiceBase. (Closed)
Patch Set: Self-review (added 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..d2d5ce58f1ff8640c856af4eb998436dcb42beda
--- /dev/null
+++ b/components/sync/driver/sync_service_base.h
@@ -0,0 +1,104 @@
+// 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.
skym 2016/12/14 19:02:35 Common functionality? Between who? Me, myself, and
maxbogue 2016/12/14 19:38:09 I updated the comment. Anything that can be inside
+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_

Powered by Google App Engine
This is Rietveld 408576698