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

Unified Diff: sync/internal_api/sync_rollback_manager_base.h

Issue 235053006: Add sync manager classes for backup/rollback: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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
Index: sync/internal_api/sync_rollback_manager_base.h
diff --git a/sync/internal_api/sync_rollback_manager_base.h b/sync/internal_api/sync_rollback_manager_base.h
new file mode 100644
index 0000000000000000000000000000000000000000..646d3bd3b66bd01c269ae7124e3c87d80c60c915
--- /dev/null
+++ b/sync/internal_api/sync_rollback_manager_base.h
@@ -0,0 +1,143 @@
+// 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_ROLLBACK_MANAGER_BASE_H_
+#define SYNC_INTERNAL_API_SYNC_ROLLBACK_MANAGER_BASE_H_
+
+#include <string>
+#include <vector>
+
+#include "sync/internal_api/public/http_post_provider_factory.h"
+#include "sync/internal_api/public/sync_manager.h"
+#include "sync/internal_api/public/user_share.h"
+#include "sync/js/js_backend.h"
+#include "sync/syncable/directory_change_delegate.h"
+#include "sync/syncable/transaction_observer.h"
+
+namespace syncer {
+
+class WriteTransaction;
+
+// Base class of sync managers used for backup and rollback. Initialize sync
+// DB for backup types as needed. Most of functions are no ops.
Nicolas Zea 2014/04/14 21:36:31 I think this would be a good place to go into more
haitaol1 2014/04/15 00:19:06 Done.
+class SyncRollbackManagerBase :
+ public SyncManager,
+ public JsBackend,
Nicolas Zea 2014/04/14 21:36:31 Why do we need the JsBackend?
haitaol1 2014/04/15 00:19:06 This was used to query directory stats, but it may
+ public syncable::DirectoryChangeDelegate,
+ public syncable::TransactionObserver {
Nicolas Zea 2014/04/14 21:36:31 transaction observer doesn't seem necessary either
haitaol1 2014/04/15 00:19:06 There's a DCHECK(transaction_observer.IsInitialize
+ public:
+ SyncRollbackManagerBase();
+ virtual ~SyncRollbackManagerBase();
+
+ // 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 ThrowUnrecoverableError() OVERRIDE;
+ virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE;
+ virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken(
+ ModelTypeSet types) OVERRIDE;
+ virtual bool PurgePartiallySyncedTypes() OVERRIDE;
+ virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE;
+ virtual void StartSyncingNormally(const ModelSafeRoutingInfo& routing_info)
+ OVERRIDE;
+ virtual void ConfigureSyncer(
+ ConfigureReason reason,
+ ModelTypeSet to_download,
+ ModelTypeSet to_purge,
+ ModelTypeSet to_journal,
+ ModelTypeSet to_unapply,
+ const ModelSafeRoutingInfo& new_routing_info,
+ const base::Closure& ready_task,
+ const base::Closure& retry_task) OVERRIDE;
+ virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE;
+ virtual void OnIncomingInvalidation(
+ const ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
+ virtual void AddObserver(SyncManager::Observer* observer) OVERRIDE;
+ virtual void RemoveObserver(SyncManager::Observer* observer) OVERRIDE;
+ virtual SyncStatus GetDetailedStatus() const OVERRIDE;
+ virtual void SaveChanges() OVERRIDE;
+ virtual void ShutdownOnSyncThread() OVERRIDE;
+ virtual UserShare* GetUserShare() OVERRIDE;
+ virtual const std::string cache_guid() OVERRIDE;
+ virtual bool ReceivedExperiment(Experiments* experiments) OVERRIDE;
+ virtual bool HasUnsyncedItems() OVERRIDE;
+ virtual SyncEncryptionHandler* GetEncryptionHandler() OVERRIDE;
+ virtual void RefreshTypes(ModelTypeSet types) OVERRIDE;
+ virtual std::string GetOwnerName() const OVERRIDE;
+ virtual base::WeakPtr<syncer::SyncCore> GetSyncCore() OVERRIDE;
+ virtual ScopedVector<syncer::ProtocolEvent> GetBufferedProtocolEvents()
+ OVERRIDE;
+ virtual scoped_ptr<base::ListValue> GetAllNodesForType(
+ syncer::ModelType type) OVERRIDE;
+
+ // JsBackend implementation.
+ virtual void SetJsEventHandler(
+ const WeakHandle<JsEventHandler>& event_handler) OVERRIDE;
+ virtual void ProcessJsMessage(
+ const std::string& name, const JsArgList& args,
+ const WeakHandle<JsReplyHandler>& reply_handler) OVERRIDE;
+
+ // DirectoryChangeDelegate implementation.
+ virtual void HandleTransactionCompleteChangeEvent(
+ ModelTypeSet models_with_changes) OVERRIDE;
+ virtual ModelTypeSet HandleTransactionEndingChangeEvent(
+ const syncable::ImmutableWriteTransactionInfo& write_transaction_info,
+ syncable::BaseTransaction* trans) OVERRIDE;
+ virtual void HandleCalculateChangesChangeEventFromSyncApi(
+ const syncable::ImmutableWriteTransactionInfo& write_transaction_info,
+ syncable::BaseTransaction* trans,
+ std::vector<int64>* entries_changed) OVERRIDE;
+ virtual void HandleCalculateChangesChangeEventFromSyncer(
+ const syncable::ImmutableWriteTransactionInfo& write_transaction_info,
+ syncable::BaseTransaction* trans,
+ std::vector<int64>* entries_changed) OVERRIDE;
+
+ // syncable::TransactionObserver implementation.
+ virtual void OnTransactionWrite(
+ const syncable::ImmutableWriteTransactionInfo& write_transaction_info,
+ ModelTypeSet models_with_changes) OVERRIDE;
+
+ protected:
+ UserShare share_;
+ SyncStatus status_;
+ ObserverList<SyncManager::Observer> observers_;
+
+ private:
+ void NotifyInitializationSuccess();
+ void NotifyInitializationFailure();
+
+ bool InitBackupDB(
+ const base::FilePath& sync_folder,
+ InternalComponentsFactory* internal_components_factory);
+
+ bool InitTypeRootNode(ModelType type);
+ void InitBookmarkFolder(const std::string& folder);
+
+ scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler_;
+ ReportUnrecoverableErrorFunction report_unrecoverable_error_function_;
+
+ base::WeakPtrFactory<SyncRollbackManagerBase> weak_ptr_factory_;
+};
+
+} // namespace syncer
+
+#endif // SYNC_INTERNAL_API_SYNC_ROLLBACK_MANAGER_BASE_H_

Powered by Google App Engine
This is Rietveld 408576698