OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SYNC_BACKUP_ROLLBACK_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_BACKUP_ROLLBACK_CONTROLLER_H_ |
6 #define CHROME_BROWSER_SYNC_BACKUP_ROLLBACK_CONTROLLER_H_ | 6 #define CHROME_BROWSER_SYNC_BACKUP_ROLLBACK_CONTROLLER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 | 10 |
11 class ManagedUserSigninManagerWrapper; | 11 class SupervisedUserSigninManagerWrapper; |
12 | 12 |
13 namespace sync_driver { | 13 namespace sync_driver { |
14 class SyncPrefs; | 14 class SyncPrefs; |
15 } | 15 } |
16 | 16 |
17 namespace browser_sync { | 17 namespace browser_sync { |
18 | 18 |
19 // BackupRollbackController takes two closures for starting backup/rollback | 19 // BackupRollbackController takes two closures for starting backup/rollback |
20 // process. It calls the closures according to user's signin status or | 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 | 21 // received rollback command. Backup is not run when user signed in, even when |
22 // sync is not running. | 22 // sync is not running. |
23 class BackupRollbackController { | 23 class BackupRollbackController { |
24 public: | 24 public: |
25 BackupRollbackController(sync_driver::SyncPrefs* sync_prefs, | 25 BackupRollbackController(sync_driver::SyncPrefs* sync_prefs, |
26 const ManagedUserSigninManagerWrapper* signin, | 26 const SupervisedUserSigninManagerWrapper* signin, |
27 base::Closure start_backup, | 27 base::Closure start_backup, |
28 base::Closure start_rollback); | 28 base::Closure start_rollback); |
29 ~BackupRollbackController(); | 29 ~BackupRollbackController(); |
30 | 30 |
31 // Check to see whether to start backup/rollback. |delay| specifies the time | 31 // Check to see whether to start backup/rollback. |delay| specifies the time |
32 // to wait before checking. | 32 // to wait before checking. |
33 void Start(base::TimeDelta delay); | 33 void Start(base::TimeDelta delay); |
34 | 34 |
35 // Update rollback preference to indicate rollback is needed. | 35 // Update rollback preference to indicate rollback is needed. |
36 void OnRollbackReceived(); | 36 void OnRollbackReceived(); |
37 | 37 |
38 // Update rollback preference to indicate rollback is finished. | 38 // Update rollback preference to indicate rollback is finished. |
39 void OnRollbackDone(); | 39 void OnRollbackDone(); |
40 | 40 |
41 private: | 41 private: |
42 // Check signin status and rollback preference and start backup/rollback | 42 // Check signin status and rollback preference and start backup/rollback |
43 // accordingly. | 43 // accordingly. |
44 void TryStart(); | 44 void TryStart(); |
45 | 45 |
46 sync_driver::SyncPrefs* sync_prefs_; | 46 sync_driver::SyncPrefs* sync_prefs_; |
47 | 47 |
48 // Use ManagedUserSigninManagerWrapper instead of SigninManagerBase because | 48 // Use SupervisedUserSigninManagerWrapper instead of SigninManagerBase because |
49 // SigninManagerBase could return non-empty user name for managed user, which | 49 // SigninManagerBase could return non-empty user name for supervised user, |
50 // would cause backup to trumpet normal sync for managed user. | 50 // which would cause backup to trumpet normal sync for supervised user. |
51 const ManagedUserSigninManagerWrapper* signin_; | 51 const SupervisedUserSigninManagerWrapper* signin_; |
52 | 52 |
53 base::Closure start_backup_; | 53 base::Closure start_backup_; |
54 base::Closure start_rollback_; | 54 base::Closure start_rollback_; |
55 base::WeakPtrFactory<BackupRollbackController> weak_ptr_factory_; | 55 base::WeakPtrFactory<BackupRollbackController> weak_ptr_factory_; |
56 | 56 |
57 DISALLOW_COPY_AND_ASSIGN(BackupRollbackController); | 57 DISALLOW_COPY_AND_ASSIGN(BackupRollbackController); |
58 }; | 58 }; |
59 | 59 |
60 } // namespace browser_sync | 60 } // namespace browser_sync |
61 | 61 |
62 #endif // CHROME_BROWSER_SYNC_BACKUP_ROLLBACK_CONTROLLER_H_ | 62 #endif // CHROME_BROWSER_SYNC_BACKUP_ROLLBACK_CONTROLLER_H_ |
OLD | NEW |