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 #include "components/sync_driver/backup_rollback_controller.h" | 5 #include "components/sync_driver/backup_rollback_controller.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
14 #include "components/sync_driver/signin_manager_wrapper.h" | 14 #include "components/sync_driver/signin_manager_wrapper.h" |
| 15 #include "components/sync_driver/sync_driver_features.h" |
15 #include "components/sync_driver/sync_driver_switches.h" | 16 #include "components/sync_driver/sync_driver_switches.h" |
16 #include "components/sync_driver/sync_prefs.h" | 17 #include "components/sync_driver/sync_prefs.h" |
17 | 18 |
18 namespace sync_driver { | 19 namespace sync_driver { |
19 | 20 |
20 #if defined(ENABLE_PRE_SYNC_BACKUP) | 21 #if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) |
21 // Number of rollback attempts to try before giving up. | 22 // Number of rollback attempts to try before giving up. |
22 static const int kRollbackLimits = 3; | 23 static const int kRollbackLimits = 3; |
23 | 24 |
24 // Finch experiment name and group. | 25 // Finch experiment name and group. |
25 static char kSyncBackupFinchName[] = "SyncBackup"; | 26 static char kSyncBackupFinchName[] = "SyncBackup"; |
26 static char kSyncBackupFinchDisabled[] = "disabled"; | 27 static char kSyncBackupFinchDisabled[] = "disabled"; |
27 #endif | 28 #endif |
28 | 29 |
29 BackupRollbackController::BackupRollbackController( | 30 BackupRollbackController::BackupRollbackController( |
30 sync_driver::SyncPrefs* sync_prefs, | 31 sync_driver::SyncPrefs* sync_prefs, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 int rollback_tries = sync_prefs_->GetRemainingRollbackTries(); | 65 int rollback_tries = sync_prefs_->GetRemainingRollbackTries(); |
65 if (rollback_tries <= 0) | 66 if (rollback_tries <= 0) |
66 return false; // No pending rollback. | 67 return false; // No pending rollback. |
67 | 68 |
68 sync_prefs_->SetRemainingRollbackTries(rollback_tries - 1); | 69 sync_prefs_->SetRemainingRollbackTries(rollback_tries - 1); |
69 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, start_rollback_); | 70 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, start_rollback_); |
70 return true; | 71 return true; |
71 } | 72 } |
72 | 73 |
73 void BackupRollbackController::OnRollbackReceived() { | 74 void BackupRollbackController::OnRollbackReceived() { |
74 #if defined(ENABLE_PRE_SYNC_BACKUP) | 75 #if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) |
75 sync_prefs_->SetRemainingRollbackTries(kRollbackLimits); | 76 sync_prefs_->SetRemainingRollbackTries(kRollbackLimits); |
76 #endif | 77 #endif |
77 } | 78 } |
78 | 79 |
79 void BackupRollbackController::OnRollbackDone() { | 80 void BackupRollbackController::OnRollbackDone() { |
80 #if defined(ENABLE_PRE_SYNC_BACKUP) | 81 #if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) |
81 sync_prefs_->SetRemainingRollbackTries(0); | 82 sync_prefs_->SetRemainingRollbackTries(0); |
82 #endif | 83 #endif |
83 } | 84 } |
84 | 85 |
85 // static | 86 // static |
86 bool BackupRollbackController::IsBackupEnabled() { | 87 bool BackupRollbackController::IsBackupEnabled() { |
87 #if defined(ENABLE_PRE_SYNC_BACKUP) | 88 #if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) |
88 const std::string group_name = | 89 const std::string group_name = |
89 base::FieldTrialList::FindFullName(kSyncBackupFinchName); | 90 base::FieldTrialList::FindFullName(kSyncBackupFinchName); |
90 | 91 |
91 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 92 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
92 switches::kSyncDisableBackup) || | 93 switches::kSyncDisableBackup) || |
93 group_name == kSyncBackupFinchDisabled) { | 94 group_name == kSyncBackupFinchDisabled) { |
94 return false; | 95 return false; |
95 } | 96 } |
96 return true; | 97 return true; |
97 #else | 98 #else |
98 return false; | 99 return false; |
99 #endif | 100 #endif |
100 } | 101 } |
101 | 102 |
102 } // namespace sync_driver | 103 } // namespace sync_driver |
OLD | NEW |