diff options
author | brettw <brettw@chromium.org> | 2015-11-30 16:10:29 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-01 00:11:13 +0000 |
commit | bc4bccdacc16ccdf314870049033e03c463e478e (patch) | |
tree | dcdd7277df3242c97dd22d01bbbadbe107519fbf /components | |
parent | b50f00c17dac2371146653d82acef7338f386d8c (diff) | |
download | chromium_src-bc4bccdacc16ccdf314870049033e03c463e478e.zip chromium_src-bc4bccdacc16ccdf314870049033e03c463e478e.tar.gz chromium_src-bc4bccdacc16ccdf314870049033e03c463e478e.tar.bz2 |
Convert enable_pre_sync_backup flag to new flags system.
This flag's usage is very isolated so is a good candidate for the new system. There is now a generated header for the #define rather than a global define.
Review URL: https://codereview.chromium.org/1478623004
Cr-Commit-Position: refs/heads/master@{#362284}
Diffstat (limited to 'components')
-rw-r--r-- | components/browser_sync/browser/profile_sync_service.cc | 5 | ||||
-rw-r--r-- | components/sync_driver.gypi | 21 | ||||
-rw-r--r-- | components/sync_driver/BUILD.gn | 13 | ||||
-rw-r--r-- | components/sync_driver/backup_rollback_controller.cc | 9 | ||||
-rw-r--r-- | components/sync_driver/backup_rollback_controller_unittest.cc | 3 |
5 files changed, 44 insertions, 7 deletions
diff --git a/components/browser_sync/browser/profile_sync_service.cc b/components/browser_sync/browser/profile_sync_service.cc index 4ace523..04cb904 100644 --- a/components/browser_sync/browser/profile_sync_service.cc +++ b/components/browser_sync/browser/profile_sync_service.cc @@ -49,6 +49,7 @@ #include "components/sync_driver/signin_manager_wrapper.h" #include "components/sync_driver/sync_api_component_factory.h" #include "components/sync_driver/sync_client.h" +#include "components/sync_driver/sync_driver_features.h" #include "components/sync_driver/sync_driver_switches.h" #include "components/sync_driver/sync_error_controller.h" #include "components/sync_driver/sync_stopped_reporter.h" @@ -338,7 +339,7 @@ void ProfileSyncService::Initialize() { need_backup_ = false; } -#if defined(ENABLE_PRE_SYNC_BACKUP) +#if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) if (!running_rollback && !IsSignedIn()) { CleanUpBackup(); } @@ -2566,7 +2567,7 @@ void ProfileSyncService::ClearBrowsingDataSinceFirstSync() { void ProfileSyncService::CheckSyncBackupIfNeeded() { DCHECK_EQ(backend_mode_, SYNC); -#if defined(ENABLE_PRE_SYNC_BACKUP) +#if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) const base::Time last_synced_time = sync_prefs_.GetLastSyncedTime(); // Check backup once a day. if (!last_backup_time_ && diff --git a/components/sync_driver.gypi b/components/sync_driver.gypi index 7bda955..fa4aeb3 100644 --- a/components/sync_driver.gypi +++ b/components/sync_driver.gypi @@ -18,6 +18,7 @@ 'invalidation_public', 'os_crypt', 'signin_core_browser', + 'sync_driver_features', 'version_info', ], 'include_dirs': [ @@ -152,6 +153,26 @@ ], }, { + # GN version: //components/sync_driver:features + 'target_name': 'sync_driver_features', + 'includes': [ '../build/buildflag_header.gypi' ], + 'variables': { + 'buildflag_header_path': 'components/sync_driver/sync_driver_features.h', + 'variables': { + 'conditions': [ + ['OS=="win" or OS=="mac" or (OS=="linux" and chromeos==0)', { + 'enable_pre_sync_backup%': 1, + }, { + 'enable_pre_sync_backup%': 0, + }], + ], + }, + 'buildflag_flags': [ + "ENABLE_PRE_SYNC_BACKUP=<(enable_pre_sync_backup)", + ], + }, + }, + { 'target_name': 'sync_driver_test_support', 'type': 'static_library', 'dependencies': [ diff --git a/components/sync_driver/BUILD.gn b/components/sync_driver/BUILD.gn index ffe41b8..38b89a8 100644 --- a/components/sync_driver/BUILD.gn +++ b/components/sync_driver/BUILD.gn @@ -2,6 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/buildflag_header.gni") import("//build/config/features.gni") source_set("sync_driver") { @@ -120,6 +121,9 @@ source_set("sync_driver") { "user_selectable_sync_type.h", ] + public_deps = [ + ":features", + ] deps = [ "//base", "//base:prefs", @@ -250,3 +254,12 @@ source_set("unit_tests") { ] } } + +buildflag_header("features") { + header = "sync_driver_features.h" + + # Whether to back up data before sync. + enable_pre_sync_backup = is_win || is_mac || (is_linux && !is_chromeos) + + flags = [ "ENABLE_PRE_SYNC_BACKUP=$enable_pre_sync_backup" ] +} diff --git a/components/sync_driver/backup_rollback_controller.cc b/components/sync_driver/backup_rollback_controller.cc index b33bd60..3629973 100644 --- a/components/sync_driver/backup_rollback_controller.cc +++ b/components/sync_driver/backup_rollback_controller.cc @@ -12,12 +12,13 @@ #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" #include "components/sync_driver/signin_manager_wrapper.h" +#include "components/sync_driver/sync_driver_features.h" #include "components/sync_driver/sync_driver_switches.h" #include "components/sync_driver/sync_prefs.h" namespace sync_driver { -#if defined(ENABLE_PRE_SYNC_BACKUP) +#if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) // Number of rollback attempts to try before giving up. static const int kRollbackLimits = 3; @@ -71,20 +72,20 @@ bool BackupRollbackController::StartRollback() { } void BackupRollbackController::OnRollbackReceived() { -#if defined(ENABLE_PRE_SYNC_BACKUP) +#if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) sync_prefs_->SetRemainingRollbackTries(kRollbackLimits); #endif } void BackupRollbackController::OnRollbackDone() { -#if defined(ENABLE_PRE_SYNC_BACKUP) +#if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) sync_prefs_->SetRemainingRollbackTries(0); #endif } // static bool BackupRollbackController::IsBackupEnabled() { -#if defined(ENABLE_PRE_SYNC_BACKUP) +#if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) const std::string group_name = base::FieldTrialList::FindFullName(kSyncBackupFinchName); diff --git a/components/sync_driver/backup_rollback_controller_unittest.cc b/components/sync_driver/backup_rollback_controller_unittest.cc index 9b94f21..7d5f9b6 100644 --- a/components/sync_driver/backup_rollback_controller_unittest.cc +++ b/components/sync_driver/backup_rollback_controller_unittest.cc @@ -12,6 +12,7 @@ #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "components/sync_driver/signin_manager_wrapper.h" +#include "components/sync_driver/sync_driver_features.h" #include "components/sync_driver/sync_driver_switches.h" #include "components/sync_driver/sync_prefs.h" #include "testing/gmock/include/gmock/gmock.h" @@ -21,7 +22,7 @@ using ::testing::Return; namespace { -#if defined(ENABLE_PRE_SYNC_BACKUP) +#if BUILDFLAG(ENABLE_PRE_SYNC_BACKUP) class MockSigninManagerWrapper : public SigninManagerWrapper { public: |