summaryrefslogtreecommitdiffstats
path: root/sync/internal_api/sync_backup_manager.h
diff options
context:
space:
mode:
authorhaitaol@chromium.org <haitaol@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-21 18:35:44 +0000
committerhaitaol@chromium.org <haitaol@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-21 18:35:44 +0000
commitd50311f0a8785d61a806337d842e0a48bb3e75f4 (patch)
tree2568bafe3ee83322c1e646931516ccd41d8f7e3b /sync/internal_api/sync_backup_manager.h
parentbcae6b83ce10987bf5bca2fddfc9e2c058a5c4b5 (diff)
downloadchromium_src-d50311f0a8785d61a806337d842e0a48bb3e75f4.zip
chromium_src-d50311f0a8785d61a806337d842e0a48bb3e75f4.tar.gz
chromium_src-d50311f0a8785d61a806337d842e0a48bb3e75f4.tar.bz2
Add sync manager classes for backup/rollback:
* SyncBackupManager runs before first-sync to save local data in backup DB. * SyncRollbackManager deletes local data that's not found in backup DB. BUG=362679 Review URL: https://codereview.chromium.org/235053006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@265027 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/internal_api/sync_backup_manager.h')
-rw-r--r--sync/internal_api/sync_backup_manager.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/sync/internal_api/sync_backup_manager.h b/sync/internal_api/sync_backup_manager.h
new file mode 100644
index 0000000..1bee105
--- /dev/null
+++ b/sync/internal_api/sync_backup_manager.h
@@ -0,0 +1,69 @@
+// Copyright 2014 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 SYNC_INTERNAL_API_SYNC_BACKUP_MANAGER_H_
+#define SYNC_INTERNAL_API_SYNC_BACKUP_MANAGER_H_
+
+#include <set>
+
+#include "sync/internal_api/sync_rollback_manager_base.h"
+
+namespace syncer {
+
+// SyncBackupManager runs before user signs in to sync to back up user's data
+// before sync starts. The data that's backed up can be used to restore user's
+// settings to pre-sync state.
+class SYNC_EXPORT_PRIVATE SyncBackupManager : public SyncRollbackManagerBase {
+ public:
+ SyncBackupManager();
+ virtual ~SyncBackupManager();
+
+ // SyncManager implementation.
+ virtual void Init(
+ const base::FilePath& database_location,
+ const WeakHandle<JsEventHandler>& event_handler,
+ const std::string& sync_server_and_path,
+ int sync_server_port,
+ bool use_ssl,
+ scoped_ptr<HttpPostProviderFactory> post_factory,
+ const std::vector<scoped_refptr<ModelSafeWorker> >& workers,
+ ExtensionsActivity* extensions_activity,
+ SyncManager::ChangeDelegate* change_delegate,
+ const SyncCredentials& credentials,
+ const std::string& invalidator_client_id,
+ const std::string& restored_key_for_bootstrapping,
+ const std::string& restored_keystore_key_for_bootstrapping,
+ InternalComponentsFactory* internal_components_factory,
+ Encryptor* encryptor,
+ scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler,
+ ReportUnrecoverableErrorFunction
+ report_unrecoverable_error_function,
+ CancelationSignal* cancelation_signal) OVERRIDE;
+ virtual void SaveChanges() OVERRIDE;
+ virtual SyncStatus GetDetailedStatus() const OVERRIDE;
+
+ // DirectoryChangeDelegate implementation.
+ virtual ModelTypeSet HandleTransactionEndingChangeEvent(
+ const syncable::ImmutableWriteTransactionInfo& write_transaction_info,
+ syncable::BaseTransaction* trans) OVERRIDE;
+
+ private:
+ // Replaces local IDs with server IDs and clear unsynced bit of modified
+ // entries.
+ void NormalizeEntries();
+
+ // Handles of unsynced entries caused by local model changes.
+ std::set<int64> unsynced_;
+
+ // True if NormalizeEntries() is being called.
+ bool in_normalization_;
+
+ SyncStatus status_;
+
+ DISALLOW_COPY_AND_ASSIGN(SyncBackupManager);
+};
+
+} // namespace syncer
+
+#endif // SYNC_INTERNAL_API_SYNC_BACKUP_MANAGER_H_