[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / sync / internal_api / sync_backup_manager.h
blobaba58e2c4268cf8674c04d21029a91a352fa1c36
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef SYNC_INTERNAL_API_SYNC_BACKUP_MANAGER_H_
6 #define SYNC_INTERNAL_API_SYNC_BACKUP_MANAGER_H_
8 #include <set>
10 #include "sync/internal_api/sync_rollback_manager_base.h"
12 namespace syncer {
14 // SyncBackupManager runs before user signs in to sync to back up user's data
15 // before sync starts. The data that's backed up can be used to restore user's
16 // settings to pre-sync state.
17 class SYNC_EXPORT_PRIVATE SyncBackupManager : public SyncRollbackManagerBase {
18 public:
19 SyncBackupManager();
20 virtual ~SyncBackupManager();
22 // SyncManager implementation.
23 virtual void Init(
24 const base::FilePath& database_location,
25 const WeakHandle<JsEventHandler>& event_handler,
26 const std::string& sync_server_and_path,
27 int sync_server_port,
28 bool use_ssl,
29 scoped_ptr<HttpPostProviderFactory> post_factory,
30 const std::vector<scoped_refptr<ModelSafeWorker> >& workers,
31 ExtensionsActivity* extensions_activity,
32 SyncManager::ChangeDelegate* change_delegate,
33 const SyncCredentials& credentials,
34 const std::string& invalidator_client_id,
35 const std::string& restored_key_for_bootstrapping,
36 const std::string& restored_keystore_key_for_bootstrapping,
37 InternalComponentsFactory* internal_components_factory,
38 Encryptor* encryptor,
39 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler,
40 ReportUnrecoverableErrorFunction
41 report_unrecoverable_error_function,
42 CancelationSignal* cancelation_signal) OVERRIDE;
43 virtual void SaveChanges() OVERRIDE;
44 virtual SyncStatus GetDetailedStatus() const OVERRIDE;
46 // DirectoryChangeDelegate implementation.
47 virtual ModelTypeSet HandleTransactionEndingChangeEvent(
48 const syncable::ImmutableWriteTransactionInfo& write_transaction_info,
49 syncable::BaseTransaction* trans) OVERRIDE;
51 virtual void RegisterDirectoryTypeDebugInfoObserver(
52 syncer::TypeDebugInfoObserver* observer) OVERRIDE;
53 virtual void UnregisterDirectoryTypeDebugInfoObserver(
54 syncer::TypeDebugInfoObserver* observer) OVERRIDE;
55 virtual bool HasDirectoryTypeDebugInfoObserver(
56 syncer::TypeDebugInfoObserver* observer) OVERRIDE;
57 virtual void RequestEmitDebugInfo() OVERRIDE;
59 private:
60 // Replaces local IDs with server IDs and clear unsynced bit of modified
61 // entries.
62 void NormalizeEntries();
64 // Manipulate preference nodes so that they'll be overwritten by local
65 // preference values during model association, i.e. local wins instead of
66 // server wins. This is for preventing backup from changing preferences in
67 // case backup DB has hijacked preferences.
68 void HideSyncPreference(ModelType pref_type);
70 // Handles of unsynced entries caused by local model changes.
71 std::set<int64> unsynced_;
73 // True if NormalizeEntries() is being called.
74 bool in_normalization_;
76 SyncStatus status_;
78 DISALLOW_COPY_AND_ASSIGN(SyncBackupManager);
81 } // namespace syncer
83 #endif // SYNC_INTERNAL_API_SYNC_BACKUP_MANAGER_H_