Skip to content

Commit

Permalink
Componentize chrome/browser/sync/backup_rollback_controller
Browse files Browse the repository at this point in the history
. Moved backup_rollback_controller.[cc/h] and its unittest to components/sync_driver
. Added backup_rollback_controller_unittest into .gn build.
. Formatted backup_rollback_controller files using cl format.
. Added backup_rollback_controller* under sync_driver namespace.

BUG=511242

Review URL: https://codereview.chromium.org/1354883003

Cr-Commit-Position: refs/heads/master@{#349906}
  • Loading branch information
abhishek.a21 authored and Commit bot committed Sep 21, 2015
1 parent 4fc4051 commit 4316e6a
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 29 deletions.
6 changes: 3 additions & 3 deletions chrome/browser/sync/profile_sync_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ ProfileSyncService::ProfileSyncService(
base::Bind(&ProfileSyncService::StartUpSlowBackendComponents,
startup_controller_weak_factory_.GetWeakPtr(),
SYNC)));
backup_rollback_controller_.reset(new browser_sync::BackupRollbackController(
backup_rollback_controller_.reset(new sync_driver::BackupRollbackController(
&sync_prefs_,
signin_.get(),
base::Bind(&ProfileSyncService::StartUpSlowBackendComponents,
Expand Down Expand Up @@ -361,7 +361,7 @@ void ProfileSyncService::Initialize() {
#endif

bool running_rollback = false;
if (browser_sync::BackupRollbackController::IsBackupEnabled()) {
if (sync_driver::BackupRollbackController::IsBackupEnabled()) {
// Backup is needed if user's not signed in or signed in but previous
// backup didn't finish, i.e. backend didn't switch from backup to sync.
need_backup_ = !IsSignedIn() || sync_prefs_.GetFirstSyncTime().is_null();
Expand Down Expand Up @@ -2242,7 +2242,7 @@ void ProfileSyncService::GoogleSignedOut(const std::string& account_id,
sync_disabled_by_admin_ = false;
RequestStop(CLEAR_DATA);

if (browser_sync::BackupRollbackController::IsBackupEnabled()) {
if (sync_driver::BackupRollbackController::IsBackupEnabled()) {
need_backup_ = true;
backup_finished_ = false;
}
Expand Down
5 changes: 2 additions & 3 deletions chrome/browser/sync/profile_sync_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "chrome/browser/browsing_data/browsing_data_remover.h"
#include "chrome/browser/sync/backup_rollback_controller.h"
#include "chrome/browser/sync/glue/sync_backend_host.h"
#include "chrome/browser/sync/sessions/sessions_sync_manager.h"
#include "chrome/browser/sync/startup_controller.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/signin/core/browser/signin_manager_base.h"
#include "components/sync_driver/backup_rollback_controller.h"
#include "components/sync_driver/data_type_controller.h"
#include "components/sync_driver/data_type_manager.h"
#include "components/sync_driver/data_type_manager_observer.h"
Expand Down Expand Up @@ -937,8 +937,7 @@ class ProfileSyncService : public sync_driver::SyncService,

scoped_ptr<browser_sync::StartupController> startup_controller_;

scoped_ptr<browser_sync::BackupRollbackController>
backup_rollback_controller_;
scoped_ptr<sync_driver::BackupRollbackController> backup_rollback_controller_;

// Mode of current backend.
BackendMode backend_mode_;
Expand Down
2 changes: 0 additions & 2 deletions chrome/chrome_browser.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -2841,8 +2841,6 @@
'browser/supervised_user/supervised_user_theme.h',
],
'chrome_browser_sync_sources': [
'browser/sync/backup_rollback_controller.cc',
'browser/sync/backup_rollback_controller.h',
'browser/sync/chrome_sync_client.cc',
'browser/sync/chrome_sync_client.h',
'browser/sync/glue/autofill_data_type_controller.cc',
Expand Down
1 change: 0 additions & 1 deletion chrome/chrome_tests_unit.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@
'browser/sync/abstract_profile_sync_service_test.cc',
'browser/sync/abstract_profile_sync_service_test.h',
'browser/sync/backend_migrator_unittest.cc',
'browser/sync/backup_rollback_controller_unittest.cc',
'browser/sync/glue/autofill_data_type_controller_unittest.cc',
'browser/sync/glue/bookmark_data_type_controller_unittest.cc',
'browser/sync/glue/browser_thread_model_worker_unittest.cc',
Expand Down
1 change: 1 addition & 0 deletions components/components_tests.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@
],
'sync_driver_unittest_sources': [
'sync_driver/about_sync_util_unittest.cc',
'sync_driver/backup_rollback_controller_unittest.cc',
'sync_driver/data_type_manager_impl_unittest.cc',
'sync_driver/device_info_data_type_controller_unittest.cc',
'sync_driver/device_info_sync_service_unittest.cc',
Expand Down
2 changes: 2 additions & 0 deletions components/sync_driver.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
'sync_driver/backend_data_type_configurer.h',
'sync_driver/backend_migrator.cc',
'sync_driver/backend_migrator.h',
'sync_driver/backup_rollback_controller.cc',
'sync_driver/backup_rollback_controller.h',
'sync_driver/change_processor.cc',
'sync_driver/change_processor.h',
'sync_driver/data_type_controller.cc',
Expand Down
3 changes: 3 additions & 0 deletions components/sync_driver/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ source_set("sync_driver") {
"backend_data_type_configurer.h",
"backend_migrator.cc",
"backend_migrator.h",
"backup_rollback_controller.cc",
"backup_rollback_controller.h",
"change_processor.cc",
"change_processor.h",
"data_type_controller.cc",
Expand Down Expand Up @@ -193,6 +195,7 @@ source_set("unit_tests") {
testonly = true
sources = [
"about_sync_util_unittest.cc",
"backup_rollback_controller_unittest.cc",
"data_type_manager_impl_unittest.cc",
"device_info_data_type_controller_unittest.cc",
"device_info_sync_service_unittest.cc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@
// 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 "components/sync_driver/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 {
namespace sync_driver {

#if defined(ENABLE_PRE_SYNC_BACKUP)
// Number of rollback attempts to try before giving up.
Expand All @@ -33,11 +32,9 @@ BackupRollbackController::BackupRollbackController(
: sync_prefs_(sync_prefs),
signin_(signin),
start_backup_(start_backup),
start_rollback_(start_rollback) {
}
start_rollback_(start_rollback) {}

BackupRollbackController::~BackupRollbackController() {
}
BackupRollbackController::~BackupRollbackController() {}

bool BackupRollbackController::StartBackup() {
if (!IsBackupEnabled())
Expand All @@ -64,7 +61,7 @@ bool BackupRollbackController::StartRollback() {

int rollback_tries = sync_prefs_->GetRemainingRollbackTries();
if (rollback_tries <= 0)
return false; // No pending rollback.
return false; // No pending rollback.

sync_prefs_->SetRemainingRollbackTries(rollback_tries - 1);
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, start_rollback_);
Expand Down Expand Up @@ -100,4 +97,4 @@ bool BackupRollbackController::IsBackupEnabled() {
#endif
}

} // namespace browser_sync
} // namespace sync_driver
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_SYNC_BACKUP_ROLLBACK_CONTROLLER_H_
#define CHROME_BROWSER_SYNC_BACKUP_ROLLBACK_CONTROLLER_H_
#ifndef COMPONENTS_SYNC_DRIVER_BACKUP_ROLLBACK_CONTROLLER_H_
#define COMPONENTS_SYNC_DRIVER_BACKUP_ROLLBACK_CONTROLLER_H_

#include "base/callback.h"
#include "base/memory/weak_ptr.h"

class SigninManagerWrapper;

namespace sync_driver {
class SyncPrefs;
}

namespace browser_sync {
class SyncPrefs;

// BackupRollbackController takes two closures for starting backup/rollback
// process. It calls the closures according to user's signin status or
Expand Down Expand Up @@ -58,6 +56,6 @@ class BackupRollbackController {
DISALLOW_COPY_AND_ASSIGN(BackupRollbackController);
};

} // namespace browser_sync
} // namespace sync_driver

#endif // CHROME_BROWSER_SYNC_BACKUP_ROLLBACK_CONTROLLER_H_
#endif // COMPONENTS_SYNC_DRIVER_BACKUP_ROLLBACK_CONTROLLER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// 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 "components/sync_driver/backup_rollback_controller.h"

#include "base/command_line.h"
#include "base/location.h"
Expand Down Expand Up @@ -59,7 +59,7 @@ class BackupRollbackControllerTest : public testing::Test {
EXPECT_CALL(signin_wrapper_, GetEffectiveUsername())
.WillRepeatedly(Return(""));

controller_.reset(new browser_sync::BackupRollbackController(
controller_.reset(new sync_driver::BackupRollbackController(
&fake_prefs_, &signin_wrapper_,
base::Bind(&BackupRollbackControllerTest::ControllerCallback,
base::Unretained(this), true),
Expand All @@ -75,7 +75,7 @@ class BackupRollbackControllerTest : public testing::Test {

MockSigninManagerWrapper signin_wrapper_;
FakeSyncPrefs fake_prefs_;
scoped_ptr<browser_sync::BackupRollbackController> controller_;
scoped_ptr<sync_driver::BackupRollbackController> controller_;
bool backup_started_;
bool rollback_started_;
base::MessageLoop loop_;
Expand Down Expand Up @@ -143,4 +143,3 @@ TEST_F(BackupRollbackControllerTest, NoRollbackIfDisabled) {
#endif

} // anonymous namespace

0 comments on commit 4316e6a

Please sign in to comment.