Commit d1319ede authored by Rushan Suleymanov's avatar Rushan Suleymanov Committed by Commit Bot

[Sync] Add feature flag to disable cache guid mismatch logic.

This patch introduces the flag which may be used to disable the logic in
Nigori which removes metadata on cache guid mismatch.

When the flag is disabled, the cache guid from model_type_state will
never be changed.

Bug: 1063021
Change-Id: If46232655e1903a3458a7880cb2d713be7395d14
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2127206Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Commit-Queue: Rushan Suleymanov <rushans@google.com>
Cr-Commit-Position: refs/heads/master@{#754525}
parent 7bcbf8b1
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
namespace switches { namespace switches {
const base::Feature kSyncNigoriRemoveMetadataOnCacheGuidMismatch{
"SyncNigoriRemoveMetadataOnCacheGuidMismatch",
base::FEATURE_ENABLED_BY_DEFAULT};
// Force disables scrypt key derivation for custom passphrase. If this feature // Force disables scrypt key derivation for custom passphrase. If this feature
// is enabled, scrypt will be considered as an unsupported method, and Chrome // is enabled, scrypt will be considered as an unsupported method, and Chrome
// will not be able to access data encrypted using scrypt-derived keys (valid // will not be able to access data encrypted using scrypt-derived keys (valid
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
namespace switches { namespace switches {
extern const base::Feature kSyncNigoriRemoveMetadataOnCacheGuidMismatch;
extern const base::Feature kSyncForceDisableScryptForCustomPassphrase; extern const base::Feature kSyncForceDisableScryptForCustomPassphrase;
extern const base::Feature kSyncE2ELatencyMeasurement; extern const base::Feature kSyncE2ELatencyMeasurement;
extern const base::Feature kSyncCustomSharingMessageNudgeDelay; extern const base::Feature kSyncCustomSharingMessageNudgeDelay;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/sequenced_task_runner_handle.h"
#include "components/sync/base/client_tag_hash.h" #include "components/sync/base/client_tag_hash.h"
#include "components/sync/base/data_type_histogram.h" #include "components/sync/base/data_type_histogram.h"
#include "components/sync/base/sync_base_switches.h"
#include "components/sync/base/time.h" #include "components/sync/base/time.h"
#include "components/sync/engine/commit_queue.h" #include "components/sync/engine/commit_queue.h"
#include "components/sync/engine_impl/conflict_resolver.h" #include "components/sync/engine_impl/conflict_resolver.h"
...@@ -417,13 +418,24 @@ void NigoriModelTypeProcessor::ConnectIfReady() { ...@@ -417,13 +418,24 @@ void NigoriModelTypeProcessor::ConnectIfReady() {
return; return;
} }
if (model_type_state_.initial_sync_done() && if (base::FeatureList::IsEnabled(
model_type_state_.cache_guid() != activation_request_.cache_guid) { switches::kSyncNigoriRemoveMetadataOnCacheGuidMismatch)) {
ClearMetadataAndReset(); if (model_type_state_.initial_sync_done() &&
DCHECK(model_ready_to_sync_); model_type_state_.cache_guid() != activation_request_.cache_guid) {
} ClearMetadataAndReset();
DCHECK(model_ready_to_sync_);
}
model_type_state_.set_cache_guid(activation_request_.cache_guid); model_type_state_.set_cache_guid(activation_request_.cache_guid);
} else {
// Legacy logic.
if (!model_type_state_.has_cache_guid()) {
model_type_state_.set_cache_guid(activation_request_.cache_guid);
} else if (model_type_state_.cache_guid() !=
activation_request_.cache_guid) {
// Not implemented in legacy codepath.
}
}
// Cache GUID verification earlier above guarantees the user is the same. // Cache GUID verification earlier above guarantees the user is the same.
model_type_state_.set_authenticated_account_id( model_type_state_.set_authenticated_account_id(
......
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/test/mock_callback.h" #include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "components/sync/base/client_tag_hash.h" #include "components/sync/base/client_tag_hash.h"
#include "components/sync/base/sync_base_switches.h"
#include "components/sync/base/time.h" #include "components/sync/base/time.h"
#include "components/sync/engine/commit_queue.h" #include "components/sync/engine/commit_queue.h"
#include "components/sync/nigori/nigori_sync_bridge.h" #include "components/sync/nigori/nigori_sync_bridge.h"
...@@ -546,6 +548,32 @@ TEST_F(NigoriModelTypeProcessorTest, ShouldResetDataOnCacheGuidMismatch) { ...@@ -546,6 +548,32 @@ TEST_F(NigoriModelTypeProcessorTest, ShouldResetDataOnCacheGuidMismatch) {
std::move(updates)); std::move(updates));
} }
TEST_F(NigoriModelTypeProcessorTest,
ShouldNotResetDataOnCacheGuidMismatchWhenDisabled) {
base::test::ScopedFeatureList features;
features.InitAndDisableFeature(
switches::kSyncNigoriRemoveMetadataOnCacheGuidMismatch);
SimulateModelReadyToSync(/*initial_sync_done=*/true);
ASSERT_TRUE(ProcessorHasEntity());
syncer::DataTypeActivationRequest request;
request.error_handler = base::DoNothing();
const char kOtherCacheGuid[] = "OtherCacheGuid";
request.cache_guid = kOtherCacheGuid;
ASSERT_NE(processor()->GetMetadata().model_type_state.cache_guid(),
kOtherCacheGuid);
ASSERT_TRUE(processor()->IsTrackingMetadata());
EXPECT_CALL(*mock_nigori_sync_bridge(), ApplyDisableSyncChanges()).Times(0);
processor()->OnSyncStarting(request, base::DoNothing());
EXPECT_TRUE(processor()->IsTrackingMetadata());
EXPECT_EQ(processor()->GetModelTypeStateForTest().cache_guid(), kCacheGuid);
EXPECT_TRUE(ProcessorHasEntity());
}
TEST_F(NigoriModelTypeProcessorTest, ShouldDisconnectWhenMergeSyncDataFails) { TEST_F(NigoriModelTypeProcessorTest, ShouldDisconnectWhenMergeSyncDataFails) {
SimulateModelReadyToSync(/*initial_sync_done=*/false); SimulateModelReadyToSync(/*initial_sync_done=*/false);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment