Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: chrome/browser/sync/backup_rollback_controller.cc

Issue 1143343005: chrome/browser: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/sync/backup_rollback_controller.h" 5 #include "chrome/browser/sync/backup_rollback_controller.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/location.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/single_thread_task_runner.h"
11 #include "base/thread_task_runner_handle.h"
10 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" 12 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h"
11 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
12 #include "components/sync_driver/sync_prefs.h" 14 #include "components/sync_driver/sync_prefs.h"
13 15
14 namespace browser_sync { 16 namespace browser_sync {
15 17
16 #if defined(ENABLE_PRE_SYNC_BACKUP) 18 #if defined(ENABLE_PRE_SYNC_BACKUP)
17 // Number of rollback attempts to try before giving up. 19 // Number of rollback attempts to try before giving up.
18 static const int kRollbackLimits = 3; 20 static const int kRollbackLimits = 3;
19 21
(...skipping 16 matching lines...) Expand all
36 BackupRollbackController::~BackupRollbackController() { 38 BackupRollbackController::~BackupRollbackController() {
37 } 39 }
38 40
39 bool BackupRollbackController::StartBackup() { 41 bool BackupRollbackController::StartBackup() {
40 if (!IsBackupEnabled()) 42 if (!IsBackupEnabled())
41 return false; 43 return false;
42 44
43 // Disable rollback to previous backup DB because it will be overwritten by 45 // Disable rollback to previous backup DB because it will be overwritten by
44 // new backup. 46 // new backup.
45 sync_prefs_->SetRemainingRollbackTries(0); 47 sync_prefs_->SetRemainingRollbackTries(0);
46 base::MessageLoop::current()->PostTask(FROM_HERE, start_backup_); 48 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, start_backup_);
47 return true; 49 return true;
48 } 50 }
49 51
50 bool BackupRollbackController::StartRollback() { 52 bool BackupRollbackController::StartRollback() {
51 if (!IsBackupEnabled()) 53 if (!IsBackupEnabled())
52 return false; 54 return false;
53 55
54 // Don't roll back if disabled or user is signed in. 56 // Don't roll back if disabled or user is signed in.
55 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 57 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
56 switches::kSyncDisableRollback) || 58 switches::kSyncDisableRollback) ||
57 !signin_->GetEffectiveUsername().empty()) { 59 !signin_->GetEffectiveUsername().empty()) {
58 sync_prefs_->SetRemainingRollbackTries(0); 60 sync_prefs_->SetRemainingRollbackTries(0);
59 return false; 61 return false;
60 } 62 }
61 63
62 int rollback_tries = sync_prefs_->GetRemainingRollbackTries(); 64 int rollback_tries = sync_prefs_->GetRemainingRollbackTries();
63 if (rollback_tries <= 0) 65 if (rollback_tries <= 0)
64 return false; // No pending rollback. 66 return false; // No pending rollback.
65 67
66 sync_prefs_->SetRemainingRollbackTries(rollback_tries - 1); 68 sync_prefs_->SetRemainingRollbackTries(rollback_tries - 1);
67 base::MessageLoop::current()->PostTask(FROM_HERE, start_rollback_); 69 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, start_rollback_);
68 return true; 70 return true;
69 } 71 }
70 72
71 void BackupRollbackController::OnRollbackReceived() { 73 void BackupRollbackController::OnRollbackReceived() {
72 #if defined(ENABLE_PRE_SYNC_BACKUP) 74 #if defined(ENABLE_PRE_SYNC_BACKUP)
73 sync_prefs_->SetRemainingRollbackTries(kRollbackLimits); 75 sync_prefs_->SetRemainingRollbackTries(kRollbackLimits);
74 #endif 76 #endif
75 } 77 }
76 78
77 void BackupRollbackController::OnRollbackDone() { 79 void BackupRollbackController::OnRollbackDone() {
(...skipping 13 matching lines...) Expand all
91 group_name == kSyncBackupFinchDisabled) { 93 group_name == kSyncBackupFinchDisabled) {
92 return false; 94 return false;
93 } 95 }
94 return true; 96 return true;
95 #else 97 #else
96 return false; 98 return false;
97 #endif 99 #endif
98 } 100 }
99 101
100 } // namespace browser_sync 102 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/backend_migrator.cc ('k') | chrome/browser/sync/backup_rollback_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698