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 COMPONENTS_SYNC_DRIVER_BACKUP_ROLLBACK_CONTROLLER_H_
6 #define COMPONENTS_SYNC_DRIVER_BACKUP_ROLLBACK_CONTROLLER_H_
8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h"
11 class SigninManagerWrapper
;
13 namespace sync_driver
{
17 // BackupRollbackController takes two closures for starting backup/rollback
18 // process. It calls the closures according to user's signin status or
19 // received rollback command. Backup is not run when user signed in, even when
20 // sync is not running.
21 class BackupRollbackController
{
23 BackupRollbackController(sync_driver::SyncPrefs
* sync_prefs
,
24 const SigninManagerWrapper
* signin
,
25 base::Closure start_backup
,
26 base::Closure start_rollback
);
27 ~BackupRollbackController();
29 // Post task to run |start_backup_| if conditions are met. Return true if
30 // task is posted, false otherwise.
33 // Post task to run |start_rollback_| if conditions are met. Return true if
34 // task is posted, false otherwise.
37 // Update rollback preference to indicate rollback is needed.
38 void OnRollbackReceived();
40 // Update rollback preference to indicate rollback is finished.
41 void OnRollbackDone();
43 // Return true if platform supports backup and backup is enabled.
44 static bool IsBackupEnabled();
47 sync_driver::SyncPrefs
* sync_prefs_
;
49 // Use SigninManagerWrapper instead of SigninManagerBase so that
50 // supervised users are treated like regular signed-in users.
51 const SigninManagerWrapper
* signin_
;
53 base::Closure start_backup_
;
54 base::Closure start_rollback_
;
56 DISALLOW_COPY_AND_ASSIGN(BackupRollbackController
);
59 } // namespace sync_driver
61 #endif // COMPONENTS_SYNC_DRIVER_BACKUP_ROLLBACK_CONTROLLER_H_