summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorvabr <vabr@chromium.org>2015-12-01 01:47:44 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-01 09:48:51 +0000
commit4bcbb121d634b0d087af5e35dcefface2b33aec2 (patch)
tree737ad3d5a9e84b3db760c52db1cfb03bc11d762c /components
parent3c201fa28b53246177fed8d6b9454da4b0625df2 (diff)
downloadchromium_src-4bcbb121d634b0d087af5e35dcefface2b33aec2.zip
chromium_src-4bcbb121d634b0d087af5e35dcefface2b33aec2.tar.gz
chromium_src-4bcbb121d634b0d087af5e35dcefface2b33aec2.tar.bz2
Reland of Convert enable_pre_sync_backup flag to new flags system. (patchset #1 id:1 of https://codereview.chromium.org/1490713002/ )
Reason for revert: Speculative revert did not help. Relanding. Original issue's description: > Revert of Convert enable_pre_sync_backup flag to new flags system. (patchset #2 id:20001 of https://codereview.chromium.org/1487873003/ ) > > Reason for revert: > Speculative revert, CrOS compile broken, more info on the bug. > BUG=563927 > > Original issue's description: > > 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. > > > > Reland of http://crrev.com/1478623004#ps60001 > > TBR=zea@chromium.org > > > > Committed: https://crrev.com/db7f9756dc6e236589b90c76d6fa0f1244601e78 > > Cr-Commit-Position: refs/heads/master@{#362365} > > TBR=zea@chromium.org,brettw@chromium.org > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > > Committed: https://crrev.com/3c201fa28b53246177fed8d6b9454da4b0625df2 > Cr-Commit-Position: refs/heads/master@{#362368} TBR=zea@chromium.org,brettw@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=563927 Review URL: https://codereview.chromium.org/1490723002 Cr-Commit-Position: refs/heads/master@{#362369}
Diffstat (limited to 'components')
-rw-r--r--components/browser_sync.gypi1
-rw-r--r--components/browser_sync/browser/profile_sync_service.cc5
-rw-r--r--components/components_tests.gyp1
-rw-r--r--components/sync_driver.gypi21
-rw-r--r--components/sync_driver/BUILD.gn13
-rw-r--r--components/sync_driver/backup_rollback_controller.cc9
-rw-r--r--components/sync_driver/backup_rollback_controller_unittest.cc3
7 files changed, 46 insertions, 7 deletions
diff --git a/components/browser_sync.gypi b/components/browser_sync.gypi
index 03393c7..6abdffd 100644
--- a/components/browser_sync.gypi
+++ b/components/browser_sync.gypi
@@ -30,6 +30,7 @@
'syncable_prefs',
'sync_bookmarks',
'sync_driver',
+ 'sync_driver_features',
'sync_sessions',
'variations',
'version_info',
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/components_tests.gyp b/components/components_tests.gyp
index 2a08ccee..bf7b8d9 100644
--- a/components/components_tests.gyp
+++ b/components/components_tests.gyp
@@ -1050,6 +1050,7 @@
'components.gyp:ssl_errors',
'components.gyp:suggestions',
'components.gyp:sync_bookmarks',
+ 'components.gyp:sync_driver_features',
'components.gyp:sync_driver_test_support',
'components.gyp:sync_sessions',
'components.gyp:sync_sessions_test_support',
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: