• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef SYNC_INTERNAL_API_SYNC_ROLLBACK_MANAGER_H_
6 #define SYNC_INTERNAL_API_SYNC_ROLLBACK_MANAGER_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "sync/internal_api/sync_rollback_manager_base.h"
12 
13 namespace syncer {
14 
15 // SyncRollbackManager restores user's data to pre-sync state using backup
16 // DB created by SyncBackupManager.
17 class SYNC_EXPORT_PRIVATE SyncRollbackManager : public SyncRollbackManagerBase {
18  public:
19   SyncRollbackManager();
20   virtual ~SyncRollbackManager();
21 
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 StartSyncingNormally(
44       const ModelSafeRoutingInfo& routing_info) OVERRIDE;
45 
46  private:
47   // Deletes specified entries in local model.
48   SyncerError DeleteOnWorkerThread(ModelType type, std::vector<int64> handles);
49 
50   void NotifyRollbackDone();
51 
52   std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> > workers_;
53 
54   SyncManager::ChangeDelegate* change_delegate_;
55 
56   // Types that can be rolled back.
57   ModelTypeSet rollback_ready_types_;
58 
59   DISALLOW_COPY_AND_ASSIGN(SyncRollbackManager);
60 };
61 
62 }  // namespace syncer
63 
64 #endif  // SYNC_INTERNAL_API_SYNC_ROLLBACK_MANAGER_H_
65