Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / sync / backup_rollback_controller.h
blob00b6329313262035a42a5eb7a4315f5fedfe2145
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 CHROME_BROWSER_SYNC_BACKUP_ROLLBACK_CONTROLLER_H_
6 #define CHROME_BROWSER_SYNC_BACKUP_ROLLBACK_CONTROLLER_H_
8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h"
11 class SigninManagerWrapper;
13 namespace sync_driver {
14 class SyncPrefs;
17 namespace browser_sync {
19 // BackupRollbackController takes two closures for starting backup/rollback
20 // process. It calls the closures according to user's signin status or
21 // received rollback command. Backup is not run when user signed in, even when
22 // sync is not running.
23 class BackupRollbackController {
24 public:
25 BackupRollbackController(sync_driver::SyncPrefs* sync_prefs,
26 const SigninManagerWrapper* signin,
27 base::Closure start_backup,
28 base::Closure start_rollback);
29 ~BackupRollbackController();
31 // Post task to run |start_backup_| if conditions are met. Return true if
32 // task is posted, false otherwise.
33 bool StartBackup();
35 // Post task to run |start_rollback_| if conditions are met. Return true if
36 // task is posted, false otherwise.
37 bool StartRollback();
39 // Update rollback preference to indicate rollback is needed.
40 void OnRollbackReceived();
42 // Update rollback preference to indicate rollback is finished.
43 void OnRollbackDone();
45 // Return true if platform supports backup and backup is enabled.
46 static bool IsBackupEnabled();
48 private:
49 sync_driver::SyncPrefs* sync_prefs_;
51 // Use SigninManagerWrapper instead of SigninManagerBase so that
52 // supervised users are treated like regular signed-in users.
53 const SigninManagerWrapper* signin_;
55 base::Closure start_backup_;
56 base::Closure start_rollback_;
58 DISALLOW_COPY_AND_ASSIGN(BackupRollbackController);
61 } // namespace browser_sync
63 #endif // CHROME_BROWSER_SYNC_BACKUP_ROLLBACK_CONTROLLER_H_