ModelType enum and ModelTypeState renamed
This is in line with previous changes, where the prefix `Model` is being replaced with `Data`. This change corrects the name of types, variables, inclusion paths, and also renames shadow files. Chromium changes: https://chromium.googlesource.com/chromium/src/+/1f5656458d6879d589bc1568ee1dab13050d0fc5 commit 1f5656458d6879d589bc1568ee1dab13050d0fc5 Author: Mikel Astiz <mastiz@chromium.org> Date: Tue Aug 6 16:15:30 2024 +0000 [sync] Rename ModelTypeState to DataTypeState See linked bug for rationale. The proto is renamed without behavioral changes using the commands below. Note that some occurrences need to be excluded because they are database column names that would require a migration, which also means the patch needs careful review. git grep -l ModelTypeState | \ xargs rename 's/model_type_state/data_type_state/' git mv components/sync/protocol/model_type_state_helper_unittest.cc \ components/sync/protocol/data_type_state_helper_unittest.cc git add . tools/git/mass-rename.py git grep -l ModelTypeState | \ xargs sed -i 's/ModelTypeState/DataTypeState/g' git grep -l model_type_state | \ xargs sed -i 's/model_type_state/data_type_state/g' git grep -l _data_type_state | \ xargs sed -i -E 's/(autofill|history|plus_address_sync|typed_url)_data_type_state/\1_model_type_state/g' git cl format Some forward declaration orderings and includes were fixed manually. Change-Id: I97a371fee5c7688a5090cf034a0418b989f29862 Bug: 356649891 https://chromium.googlesource.com/chromium/src/+/209e0271904abe753d64602d165b791005a98905 commit 209e0271904abe753d64602d165b791005a98905 Author: Mikel Astiz <mastiz@chromium.org> Date: Tue Aug 6 09:13:48 2024 +0000 [sync] Rename enum ModelType to DataType (with temporary alias) Pure refactoring without behavioral changes. All occurrences of syncer::ModelType are about to be replaced with syncer::DataType, following the rationale in the linked bug. As a first step, the enum and some of the functions that come together with it are forked, in order to allow a gradual migration. The renames in Java code are bundled into this first patch as they aren't that many and they are harder to split. Change-Id: Ibeeabd0355ee2c86bdfd99b7002c95bc6a1f3ccf Bug: 356649891
This commit is contained in:
+4
-5
@@ -1,17 +1,16 @@
|
||||
/* Copyright (c) 2020 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#define EncryptableUserTypes EncryptableUserTypes_ChromiumImpl
|
||||
#include "src/components/sync/base/model_type.cc"
|
||||
#include "src/components/sync/base/data_type.cc"
|
||||
#undef EncryptableUserTypes
|
||||
|
||||
|
||||
namespace syncer {
|
||||
|
||||
ModelTypeSet EncryptableUserTypes() {
|
||||
ModelTypeSet encryptable_user_types = EncryptableUserTypes_ChromiumImpl();
|
||||
DataTypeSet EncryptableUserTypes() {
|
||||
DataTypeSet encryptable_user_types = EncryptableUserTypes_ChromiumImpl();
|
||||
// Brave sync has encryption setup ready when sync chain created
|
||||
encryptable_user_types.Put(DEVICE_INFO);
|
||||
encryptable_user_types.Put(HISTORY);
|
||||
+5
-5
@@ -3,18 +3,18 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_BASE_MODEL_TYPE_H_
|
||||
#define BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_BASE_MODEL_TYPE_H_
|
||||
#ifndef BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_BASE_DATA_TYPE_H_
|
||||
#define BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_BASE_DATA_TYPE_H_
|
||||
|
||||
#define LowPriorityUserTypes LowPriorityUserTypes_ChromiumImpl
|
||||
|
||||
#include "src/components/sync/base/model_type.h" // IWYU pragma: export
|
||||
#include "src/components/sync/base/data_type.h" // IWYU pragma: export
|
||||
|
||||
#undef LowPriorityUserTypes
|
||||
|
||||
namespace syncer {
|
||||
|
||||
constexpr ModelTypeSet LowPriorityUserTypes() {
|
||||
constexpr DataTypeSet LowPriorityUserTypes() {
|
||||
auto low_priority_user_types = LowPriorityUserTypes_ChromiumImpl();
|
||||
// Directives must be synced after history entities. If
|
||||
// history delete directives are processed before retrieving history upon
|
||||
@@ -29,4 +29,4 @@ constexpr ModelTypeSet LowPriorityUserTypes() {
|
||||
|
||||
} // namespace syncer
|
||||
|
||||
#endif // BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_BASE_MODEL_TYPE_H_
|
||||
#endif // BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_BASE_DATA_TYPE_H_
|
||||
+6
-6
@@ -1,27 +1,27 @@
|
||||
/* Copyright (c) 2020 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "src/components/sync/base/model_type_unittest.cc"
|
||||
#include "src/components/sync/base/data_type_unittest.cc"
|
||||
|
||||
namespace syncer {
|
||||
namespace {
|
||||
|
||||
TEST(ModelTypeTest, EncryptableUserTypes) {
|
||||
TEST(DataTypeTest, EncryptableUserTypes) {
|
||||
EXPECT_TRUE(EncryptableUserTypes().Has(DEVICE_INFO));
|
||||
EXPECT_TRUE(EncryptableUserTypes().Has(HISTORY));
|
||||
}
|
||||
|
||||
TEST(ModelTypeTest, LowPriorityUserTypes) {
|
||||
TEST(DataTypeTest, LowPriorityUserTypes) {
|
||||
EXPECT_TRUE(LowPriorityUserTypes().Has(HISTORY_DELETE_DIRECTIVES));
|
||||
EXPECT_FALSE(LowPriorityUserTypes().Has(HISTORY));
|
||||
EXPECT_TRUE(LowPriorityUserTypes().Has(USER_EVENTS));
|
||||
}
|
||||
|
||||
// This test is supposed to fail when sync types are increased/decreased
|
||||
TEST(ModelTypeTest, ModelTypeCounts) {
|
||||
EXPECT_EQ(static_cast<int>(ModelTypeForHistograms::kMaxValue), 68);
|
||||
TEST(DataTypeTest, DataTypeCounts) {
|
||||
EXPECT_EQ(static_cast<int>(DataTypeForHistograms::kMaxValue), 68);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "brave/components/sync/engine/brave_data_type_worker.h"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_ENGINE_DATA_TYPE_WORKER_H_
|
||||
#define BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_ENGINE_DATA_TYPE_WORKER_H_
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
#ifndef BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_MODEL_METADATA_BATCH_H_
|
||||
#define BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_MODEL_METADATA_BATCH_H_
|
||||
|
||||
#define SetModelTypeState \
|
||||
ClearProgressToken(); \
|
||||
void SetModelTypeState
|
||||
#define SetDataTypeState \
|
||||
ClearProgressToken(); \
|
||||
void SetDataTypeState
|
||||
|
||||
#include "src/components/sync/model/metadata_batch.h" // IWYU pragma: export
|
||||
|
||||
#undef SetModelTypeState
|
||||
#undef SetDataTypeState
|
||||
|
||||
#endif // BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_MODEL_METADATA_BATCH_H_
|
||||
|
||||
@@ -224,9 +224,9 @@ TEST_F(DeviceInfoSyncBridgeTest, BraveExpireOldEntriesUponStartup) {
|
||||
|
||||
TEST_F(DeviceInfoSyncBridgeTest, BraveResetsProgressMarkerOnce) {
|
||||
const DeviceInfoSpecifics specifics = CreateLocalDeviceSpecifics();
|
||||
ModelTypeState model_type_state = StateWithEncryption("ekn");
|
||||
model_type_state.mutable_progress_marker()->set_token("ABC");
|
||||
WriteToStoreWithMetadata({specifics}, model_type_state);
|
||||
DataTypeState data_type_state = StateWithEncryption("ekn");
|
||||
data_type_state.mutable_progress_marker()->set_token("ABC");
|
||||
WriteToStoreWithMetadata({specifics}, data_type_state);
|
||||
|
||||
{
|
||||
base::RunLoop run_loop;
|
||||
@@ -238,9 +238,8 @@ TEST_F(DeviceInfoSyncBridgeTest, BraveResetsProgressMarkerOnce) {
|
||||
.WillOnce([&run_loop](std::unique_ptr<MetadataBatch> batch) {
|
||||
// When model is loaded for the first time and the progress token
|
||||
// was set then the token should be reset
|
||||
EXPECT_TRUE(batch->GetModelTypeState().has_progress_marker());
|
||||
EXPECT_FALSE(
|
||||
batch->GetModelTypeState().progress_marker().has_token());
|
||||
EXPECT_TRUE(batch->GetDataTypeState().has_progress_marker());
|
||||
EXPECT_FALSE(batch->GetDataTypeState().progress_marker().has_token());
|
||||
run_loop.Quit();
|
||||
});
|
||||
|
||||
@@ -256,8 +255,8 @@ TEST_F(DeviceInfoSyncBridgeTest, BraveResetsProgressMarkerOnce) {
|
||||
.WillOnce([&run_loop](std::unique_ptr<MetadataBatch> batch) {
|
||||
// When the progress token already was reset, then do not reset it
|
||||
// again
|
||||
EXPECT_TRUE(batch->GetModelTypeState().has_progress_marker());
|
||||
EXPECT_TRUE(batch->GetModelTypeState().progress_marker().has_token());
|
||||
EXPECT_TRUE(batch->GetDataTypeState().has_progress_marker());
|
||||
EXPECT_TRUE(batch->GetDataTypeState().progress_marker().has_token());
|
||||
run_loop.Quit();
|
||||
});
|
||||
run_loop.Run();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <utility>
|
||||
|
||||
@@ -35,7 +35,7 @@ base::TimeDelta kMinimalTimeBetweenResetMarker = base::Minutes(30);
|
||||
|
||||
BraveDataTypeWorker::BraveDataTypeWorker(
|
||||
ModelType type,
|
||||
const sync_pb::ModelTypeState& initial_state,
|
||||
const sync_pb::DataTypeState& initial_state,
|
||||
Cryptographer* cryptographer,
|
||||
bool encryption_enabled,
|
||||
PassphraseType passphrase_type,
|
||||
@@ -115,7 +115,7 @@ void BraveDataTypeWorker::ResetProgressMarker() {
|
||||
// P3A sample is 0
|
||||
base::UmaHistogramExactLinear("Brave.Sync.ProgressTokenEverReset", 0, 1);
|
||||
last_reset_marker_time_ = base::Time::Now();
|
||||
model_type_state_.mutable_progress_marker()->clear_token();
|
||||
data_type_state_.mutable_progress_marker()->clear_token();
|
||||
}
|
||||
|
||||
} // namespace syncer
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BRAVE_COMPONENTS_SYNC_ENGINE_BRAVE_DATA_TYPE_WORKER_H_
|
||||
#define BRAVE_COMPONENTS_SYNC_ENGINE_BRAVE_DATA_TYPE_WORKER_H_
|
||||
@@ -33,7 +33,7 @@ FORWARD_DECLARE_TEST(BraveDataTypeWorkerTest,
|
||||
class BraveDataTypeWorker : public DataTypeWorker {
|
||||
public:
|
||||
BraveDataTypeWorker(ModelType type,
|
||||
const sync_pb::ModelTypeState& initial_state,
|
||||
const sync_pb::DataTypeState& initial_state,
|
||||
Cryptographer* cryptographer,
|
||||
bool encryption_enabled,
|
||||
PassphraseType passphrase_type,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
* You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <utility>
|
||||
|
||||
@@ -23,7 +23,7 @@ using base::subtle::TimeNowIgnoringOverride;
|
||||
using sync_pb::CommitResponse_ResponseType;
|
||||
using sync_pb::CommitResponse_ResponseType_CONFLICT;
|
||||
using sync_pb::CommitResponse_ResponseType_TRANSIENT_ERROR;
|
||||
using sync_pb::ModelTypeState;
|
||||
using sync_pb::DataTypeState;
|
||||
|
||||
namespace syncer {
|
||||
|
||||
@@ -35,21 +35,21 @@ class BraveDataTypeWorkerTest : public ::testing::Test {
|
||||
~BraveDataTypeWorkerTest() override = default;
|
||||
|
||||
void NormalInitialize() {
|
||||
ModelTypeState initial_state;
|
||||
DataTypeState initial_state;
|
||||
initial_state.mutable_progress_marker()->set_data_type_id(
|
||||
GetSpecificsFieldNumberFromModelType(model_type_));
|
||||
initial_state.mutable_progress_marker()->set_token(
|
||||
"some_saved_progress_token");
|
||||
|
||||
initial_state.set_initial_sync_state(
|
||||
sync_pb::ModelTypeState_InitialSyncState_INITIAL_SYNC_DONE);
|
||||
sync_pb::DataTypeState_InitialSyncState_INITIAL_SYNC_DONE);
|
||||
|
||||
InitializeWithState(model_type_, initial_state);
|
||||
|
||||
nudge_handler()->ClearCounters();
|
||||
}
|
||||
|
||||
void InitializeWithState(const ModelType type, const ModelTypeState& state) {
|
||||
void InitializeWithState(const ModelType type, const DataTypeState& state) {
|
||||
DCHECK(!worker());
|
||||
|
||||
auto processor = std::make_unique<MockDataTypeProcessor>();
|
||||
@@ -73,11 +73,11 @@ class BraveDataTypeWorkerTest : public ::testing::Test {
|
||||
MockNudgeHandler* nudge_handler() { return &mock_nudge_handler_; }
|
||||
|
||||
bool IsProgressMarkerEmpty() {
|
||||
return worker()->model_type_state_.progress_marker().token().empty();
|
||||
return worker()->data_type_state_.progress_marker().token().empty();
|
||||
}
|
||||
|
||||
void FillProgressMarker() {
|
||||
worker()->model_type_state_.mutable_progress_marker()->set_token("TOKEN1");
|
||||
worker()->data_type_state_.mutable_progress_marker()->set_token("TOKEN1");
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ test("brave_unit_tests") {
|
||||
"//chrome/browser/signin/test_signin_client_builder.h",
|
||||
"//components/domain_reliability/test_util.cc",
|
||||
"//components/domain_reliability/test_util.h",
|
||||
"//components/sync/base/model_type_unittest.cc",
|
||||
"//components/sync/base/data_type_unittest.cc",
|
||||
"//components/sync/engine/sync_scheduler_impl_unittest.cc",
|
||||
"//components/sync/service/sync_auth_manager_unittest.cc",
|
||||
"//components/sync_device_info/device_info_sync_bridge_unittest.cc",
|
||||
|
||||
Reference in New Issue
Block a user