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

Unified Diff: chrome/browser/sync/backup_rollback_controller.cc

Issue 1354883003: Componentize chrome/browser/sync/backup_rollback_controller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/backup_rollback_controller.cc
diff --git a/chrome/browser/sync/backup_rollback_controller.cc b/chrome/browser/sync/backup_rollback_controller.cc
deleted file mode 100644
index a80d703da669e7f1be0ee237e25518e63e56f700..0000000000000000000000000000000000000000
--- a/chrome/browser/sync/backup_rollback_controller.cc
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/sync/backup_rollback_controller.h"
-
-#include "base/command_line.h"
-#include "base/location.h"
-#include "base/metrics/field_trial.h"
-#include "base/single_thread_task_runner.h"
-#include "base/thread_task_runner_handle.h"
-#include "chrome/common/chrome_switches.h"
-#include "components/sync_driver/signin_manager_wrapper.h"
-#include "components/sync_driver/sync_driver_switches.h"
-#include "components/sync_driver/sync_prefs.h"
-
-namespace browser_sync {
-
-#if defined(ENABLE_PRE_SYNC_BACKUP)
-// Number of rollback attempts to try before giving up.
-static const int kRollbackLimits = 3;
-
-// Finch experiment name and group.
-static char kSyncBackupFinchName[] = "SyncBackup";
-static char kSyncBackupFinchDisabled[] = "disabled";
-#endif
-
-BackupRollbackController::BackupRollbackController(
- sync_driver::SyncPrefs* sync_prefs,
- const SigninManagerWrapper* signin,
- base::Closure start_backup,
- base::Closure start_rollback)
- : sync_prefs_(sync_prefs),
- signin_(signin),
- start_backup_(start_backup),
- start_rollback_(start_rollback) {
-}
-
-BackupRollbackController::~BackupRollbackController() {
-}
-
-bool BackupRollbackController::StartBackup() {
- if (!IsBackupEnabled())
- return false;
-
- // Disable rollback to previous backup DB because it will be overwritten by
- // new backup.
- sync_prefs_->SetRemainingRollbackTries(0);
- base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, start_backup_);
- return true;
-}
-
-bool BackupRollbackController::StartRollback() {
- if (!IsBackupEnabled())
- return false;
-
- // Don't roll back if disabled or user is signed in.
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kSyncDisableRollback) ||
- !signin_->GetEffectiveUsername().empty()) {
- sync_prefs_->SetRemainingRollbackTries(0);
- return false;
- }
-
- int rollback_tries = sync_prefs_->GetRemainingRollbackTries();
- if (rollback_tries <= 0)
- return false; // No pending rollback.
-
- sync_prefs_->SetRemainingRollbackTries(rollback_tries - 1);
- base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, start_rollback_);
- return true;
-}
-
-void BackupRollbackController::OnRollbackReceived() {
-#if defined(ENABLE_PRE_SYNC_BACKUP)
- sync_prefs_->SetRemainingRollbackTries(kRollbackLimits);
-#endif
-}
-
-void BackupRollbackController::OnRollbackDone() {
-#if defined(ENABLE_PRE_SYNC_BACKUP)
- sync_prefs_->SetRemainingRollbackTries(0);
-#endif
-}
-
-// static
-bool BackupRollbackController::IsBackupEnabled() {
-#if defined(ENABLE_PRE_SYNC_BACKUP)
- const std::string group_name =
- base::FieldTrialList::FindFullName(kSyncBackupFinchName);
-
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kSyncDisableBackup) ||
- group_name == kSyncBackupFinchDisabled) {
- return false;
- }
- return true;
-#else
- return false;
-#endif
-}
-
-} // namespace browser_sync
« no previous file with comments | « chrome/browser/sync/backup_rollback_controller.h ('k') | chrome/browser/sync/backup_rollback_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698