OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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 CHROME_BROWSER_SYNC_BACKUP_ROLLBACK_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_SYNC_BACKUP_ROLLBACK_CONTROLLER_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 10 |
| 11 class ManagedUserSigninManagerWrapper; |
| 12 |
| 13 namespace sync_driver { |
| 14 class SyncPrefs; |
| 15 } |
| 16 |
| 17 namespace browser_sync { |
| 18 |
| 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. |
| 22 class BackupRollbackController { |
| 23 public: |
| 24 BackupRollbackController(sync_driver::SyncPrefs* sync_prefs, |
| 25 const ManagedUserSigninManagerWrapper* signin, |
| 26 base::Closure start_backup, |
| 27 base::Closure start_rollback); |
| 28 ~BackupRollbackController(); |
| 29 |
| 30 // Check to see whether to start backup/rollback. |delay| specifies the time |
| 31 // to wait before checking. |
| 32 void Start(base::TimeDelta delay); |
| 33 |
| 34 // Update rollback preference to indicate rollback is needed. |
| 35 void OnRollbackReceived(); |
| 36 |
| 37 // Update rollback preference to indicate rollback is finished. |
| 38 void OnRollbackDone(); |
| 39 |
| 40 private: |
| 41 // Check signin status and rollback preference and start backup/rollback |
| 42 // accordingly. |
| 43 void TryStart(); |
| 44 |
| 45 sync_driver::SyncPrefs* sync_prefs_; |
| 46 |
| 47 // Use ManagedUserSigninManagerWrapper instead of SigninManagerBase because |
| 48 // SigninManagerBase could return non-empty user name for managed user, which |
| 49 // would cause backup to trumpet normal sync for managed user. |
| 50 const ManagedUserSigninManagerWrapper* signin_; |
| 51 |
| 52 base::Closure start_backup_; |
| 53 base::Closure start_rollback_; |
| 54 base::WeakPtrFactory<BackupRollbackController> weak_ptr_factory_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(BackupRollbackController); |
| 57 }; |
| 58 |
| 59 } // namespace browser_sync |
| 60 |
| 61 #endif // CHROME_BROWSER_SYNC_BACKUP_ROLLBACK_CONTROLLER_H_ |
OLD | NEW |