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

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

Issue 2663783002: [Sync] Split encryption state and logic out of PSS and SBHI. (Closed)
Patch Set: Tweak comment. Created 3 years, 11 months 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
« no previous file with comments | « components/sync/driver/sync_service.h ('k') | components/sync/driver/sync_service_base.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index 736c5277ea403f94e7ac35c31b953a28e647a958..96a63055a15bd6dc25fca3f2d0787481189b8e63 100644
--- a/components/sync/driver/sync_service_base.h
+++ b/components/sync/driver/sync_service_base.h
@@ -9,14 +9,18 @@
#include <string>
#include "base/files/file_path.h"
+#include "base/macros.h"
#include "base/memory/weak_ptr.h"
+#include "base/observer_list.h"
#include "base/threading/thread.h"
+#include "base/threading/thread_checker.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/driver/sync_service_crypto.h"
#include "components/sync/engine/sync_engine.h"
#include "components/sync/engine/sync_engine_host.h"
#include "components/sync/engine/sync_manager.h"
@@ -39,10 +43,21 @@ class SyncServiceBase : public SyncService, public SyncEngineHost {
const std::string& debug_identifier);
~SyncServiceBase() override;
+ // SyncService partial implementation.
+ void AddObserver(SyncServiceObserver* observer) override;
+ void RemoveObserver(SyncServiceObserver* observer) override;
+ bool HasObserver(const SyncServiceObserver* observer) const override;
+
protected:
+ // Notify all observers that a change has occurred.
+ void NotifyObservers();
+
// Kicks off asynchronous initialization of the SyncEngine.
void InitializeEngine();
+ // Destroys the |crypto_| object and creates a new one with fresh state.
+ void ResetCryptoState();
+
// Returns SyncCredentials from the OAuth2TokenService.
virtual SyncCredentials GetCredentials() = 0;
@@ -53,10 +68,6 @@ class SyncServiceBase : public SyncService, public SyncEngineHost {
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;
@@ -88,6 +99,10 @@ class SyncServiceBase : public SyncService, public SyncEngineHost {
// preferences.
SyncPrefs sync_prefs_;
+ // A utility object containing logic and state relating to encryption. It is
+ // never null.
+ std::unique_ptr<SyncServiceCrypto> crypto_;
+
// 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
@@ -98,6 +113,13 @@ class SyncServiceBase : public SyncService, public SyncEngineHost {
// other threads.
std::unique_ptr<SyncEngine> engine_;
+ // The list of observers of the SyncService state.
+ base::ObserverList<SyncServiceObserver> observers_;
+
+ // Used to ensure that certain operations are performed on the thread that
+ // this object was created on.
+ base::ThreadChecker thread_checker_;
+
private:
bool GetLocalSyncConfig(base::FilePath* local_sync_backend_folder) const;
« no previous file with comments | « components/sync/driver/sync_service.h ('k') | components/sync/driver/sync_service_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698