ModelType cleaned out upstream

This type, header, and derived types are now gone, with the new
`DataType` being used. This change corrects variable naming, header
inclusions, etc.

Chromium change:
https://chromium.googlesource.com/chromium/src/+/41d2a6c29f4b0a3ed5321841ddf8b3d715f02d58

commit 41d2a6c29f4b0a3ed5321841ddf8b3d715f02d58
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Wed Aug 7 11:47:19 2024 +0000

    [sync] Migrate remaining components/sync from ModelType to DataType

    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. This patch
    tackles occurrences under components/sync and some dependencies.

    Most of the changes were auto-generated via commands below, which also
    required manually excluding some undesired changes:
    git grep -l model_type -- components/sync | \
      grep -v model_type\\.h | grep -v data_type\\.h | \
      grep -v BUILD.gn | \
      xargs sed -i 's/model_type/data_type/g'
    git grep -l ModelType -- components/sync | \
      grep -v model_type\\.h | grep -v data_type\\.h | \
      xargs sed -i -E 's/([^.]|^)ModelType/\1DataType/g'
    git grep -l UserSelectableTypeToAllModelTypes | \
      xargs sed -i '/UserSelectableTypeToAllModelTypes/UserSelectableTypeToAllDataTypes
    /g'
    git diff --name-only HEAD | \
      xargs sed -i "s/DataTypeEntityChange/ModelTypeEntityChange/g"
    git diff --name-only HEAD | \
      xargs sed -i "s/InvalidationPerDataType/InvalidationPerModelType/g"
    git diff --name-only HEAD | \
      xargs sed -i "s/Model type/Data type/g"
    git diff --name-only HEAD | \
      xargs sed -i "s/model type/data type/g"
    git cl format

    NO_IFTTT=Matches enums.xml without additional changes

    Change-Id: I1edd7f45f6ff22e0dfd2a959431d38ca4593e7d4
    Bug: 356649891

https://chromium.googlesource.com/chromium/src/+/1cce04152760c71cde8c8fe90bbb1241128a7b13

commit 1cce04152760c71cde8c8fe90bbb1241128a7b13
Author: Mikel Astiz <mastiz@chromium.org>
Date:   Wed Aug 7 17:10:53 2024 +0000

    [sync] Clean up leftovers after ModelType rename to DataType

    A recent patch series renamed syncer::ModelType to syncer::DataType,
    with a temporary alias being introduced for a gradual migration. Now
    that all references have been migrated to the new name, the temporary
    alias can be removed from code.

    The patch also includes some minor leftover renames.

    Change-Id: Ibed5292fd96fdcbe9592b4bd268faa428da50627
    Bug: 356649891
This commit is contained in:
Claudio DeSouza
2024-09-10 14:42:37 -04:00
committed by mkarolin
parent c143316435
commit 6c4933e918
13 changed files with 29 additions and 30 deletions
@@ -9,13 +9,13 @@ namespace syncer {
namespace {
void SimulatePollFailedRegularTransientError(ModelTypeSet requested_types,
void SimulatePollFailedRegularTransientError(DataTypeSet requested_types,
SyncCycle* cycle) {
cycle->mutable_status_controller()->set_last_download_updates_result(
SyncerError::ProtocolError(TRANSIENT_ERROR));
}
void SimulatePollFailedNigoryNotReady(ModelTypeSet requested_types,
void SimulatePollFailedNigoryNotReady(DataTypeSet requested_types,
SyncCycle* cycle) {
cycle->mutable_status_controller()->set_last_download_updates_result(
SyncerError::ProtocolError(TRANSIENT_ERROR));
@@ -46,10 +46,10 @@ const int kFailedAttemtpsToAckDeviceDelete = 5;
std::unique_ptr<BraveDeviceInfo> BraveSpecificsToModel(
const DeviceInfoSpecifics& specifics) {
ModelTypeSet data_types;
DataTypeSet data_types;
for (const int field_number :
specifics.invalidation_fields().interested_data_type_ids()) {
ModelType data_type = GetModelTypeFromSpecificsFieldNumber(field_number);
DataType data_type = GetDataTypeFromSpecificsFieldNumber(field_number);
if (!IsRealDataType(data_type)) {
DLOG(WARNING) << "Unknown field number " << field_number;
continue;
@@ -7,7 +7,7 @@
#define BRAVE_COMPONENTS_HISTORY_CORE_BROWSER_SYNC_BRAVE_HISTORY_DATA_TYPE_CONTROLLER_H_
#include "components/history/core/browser/sync/history_data_type_controller.h"
#include "components/sync/base/model_type.h"
#include "components/sync/base/data_type.h"
class PrefService;
@@ -34,7 +34,7 @@ base::TimeDelta kMinimalTimeBetweenResetMarker = base::Minutes(30);
} // namespace
BraveDataTypeWorker::BraveDataTypeWorker(
ModelType type,
DataType type,
const sync_pb::DataTypeState& initial_state,
Cryptographer* cryptographer,
bool encryption_enabled,
@@ -110,7 +110,7 @@ bool BraveDataTypeWorker::IsResetProgressMarkerRequired(
}
void BraveDataTypeWorker::ResetProgressMarker() {
VLOG(1) << "Reset progress marker for type " << ModelTypeToDebugString(type_);
VLOG(1) << "Reset progress marker for type " << DataTypeToDebugString(type_);
// Normal reset of progress marker due to 7th failure
// P3A sample is 0
base::UmaHistogramExactLinear("Brave.Sync.ProgressTokenEverReset", 0, 1);
@@ -8,7 +8,7 @@
#include "base/feature_list.h"
#include "base/gtest_prod_util.h"
#include "components/sync/base/model_type.h"
#include "components/sync/base/data_type.h"
#include "components/sync/base/passphrase_enums.h"
#include "components/sync/engine/commit_and_get_updates_types.h"
#include "components/sync/engine/data_type_worker.h"
@@ -32,7 +32,7 @@ FORWARD_DECLARE_TEST(BraveDataTypeWorkerTest,
class BraveDataTypeWorker : public DataTypeWorker {
public:
BraveDataTypeWorker(ModelType type,
BraveDataTypeWorker(DataType type,
const sync_pb::DataTypeState& initial_state,
Cryptographer* cryptographer,
bool encryption_enabled,
@@ -29,27 +29,27 @@ namespace syncer {
class BraveDataTypeWorkerTest : public ::testing::Test {
protected:
explicit BraveDataTypeWorkerTest(ModelType model_type = PREFERENCES)
: model_type_(model_type) {}
explicit BraveDataTypeWorkerTest(DataType data_type = PREFERENCES)
: data_type_(data_type) {}
~BraveDataTypeWorkerTest() override = default;
void NormalInitialize() {
DataTypeState initial_state;
initial_state.mutable_progress_marker()->set_data_type_id(
GetSpecificsFieldNumberFromModelType(model_type_));
GetSpecificsFieldNumberFromDataType(data_type_));
initial_state.mutable_progress_marker()->set_token(
"some_saved_progress_token");
initial_state.set_initial_sync_state(
sync_pb::DataTypeState_InitialSyncState_INITIAL_SYNC_DONE);
InitializeWithState(model_type_, initial_state);
InitializeWithState(data_type_, initial_state);
nudge_handler()->ClearCounters();
}
void InitializeWithState(const ModelType type, const DataTypeState& state) {
void InitializeWithState(const DataType type, const DataTypeState& state) {
DCHECK(!worker());
auto processor = std::make_unique<MockDataTypeProcessor>();
@@ -82,7 +82,7 @@ class BraveDataTypeWorkerTest : public ::testing::Test {
private:
base::test::SingleThreadTaskEnvironment task_environment;
const ModelType model_type_;
const DataType data_type_;
FakeCryptographer cryptographer_;
CancelationSignal cancelation_signal_;
std::unique_ptr<BraveDataTypeWorker> worker_;
@@ -22,7 +22,7 @@ BraveSyncManagerImpl::~BraveSyncManagerImpl() = default;
void BraveSyncManagerImpl::StartSyncingNormally(base::Time last_poll_time) {
SyncManagerImpl::StartSyncingNormally(last_poll_time);
// Remove this hack when we have FCM invalidation integrated.
RefreshTypes(ModelTypeSet::All());
RefreshTypes(DataTypeSet::All());
}
void BraveSyncManagerImpl::PermanentlyDeleteAccount(
@@ -364,12 +364,12 @@ void BraveSyncServiceImpl::UpdateP3AObjectsNumber() {
for (UserSelectableType user_selected_type :
GetUserSettings()->GetSelectedTypes()) {
ModelType model_type =
UserSelectableTypeToCanonicalModelType(user_selected_type);
DataType data_type =
UserSelectableTypeToCanonicalDataType(user_selected_type);
auto dtc_it = data_type_manager_->GetControllerMap().find(model_type);
auto dtc_it = data_type_manager_->GetControllerMap().find(data_type);
CHECK(dtc_it != data_type_manager_->GetControllerMap().end())
<< "Missing controller for type " << ModelTypeToDebugString(model_type);
<< "Missing controller for type " << DataTypeToDebugString(data_type);
DataTypeController* controller = dtc_it->second.get();
controller->GetTypeEntitiesCount(
@@ -104,9 +104,9 @@ class BraveSyncServiceImplTest : public testing::Test {
~BraveSyncServiceImplTest() override { sync_service_impl_->Shutdown(); }
void CreateSyncService(
ModelTypeSet registered_types = ModelTypeSet({BOOKMARKS})) {
DataTypeSet registered_types = DataTypeSet({BOOKMARKS})) {
DataTypeController::TypeVector controllers;
for (ModelType type : registered_types) {
for (DataType type : registered_types) {
controllers.push_back(std::make_unique<FakeDataTypeController>(type));
}
@@ -589,7 +589,7 @@ TEST_F(BraveSyncServiceImplTest, OnlyBookmarksAfterSetup) {
TEST_F(BraveSyncServiceImplTest, P3aForHistoryThroughDelegate) {
OSCryptMocker::SetUp();
CreateSyncService(ModelTypeSet({BOOKMARKS, HISTORY}));
CreateSyncService(DataTypeSet({BOOKMARKS, HISTORY}));
EXPECT_FALSE(engine());
brave_sync_service_impl()->SetSyncCode(kValidSyncCode);
task_environment_.RunUntilIdle();
@@ -30,7 +30,7 @@ BraveDeviceInfo::BraveDeviceInfo(
const std::optional<DeviceInfo::SharingInfo>& sharing_info,
const std::optional<PhoneAsASecurityKeyInfo>& paask_info,
const std::string& fcm_registration_token,
const ModelTypeSet& interested_data_types,
const DataTypeSet& interested_data_types,
std::optional<base::Time> floating_workspace_last_signin_timestamp,
bool is_self_delete_supported)
: DeviceInfo(guid,
@@ -40,7 +40,7 @@ class BraveDeviceInfo : public DeviceInfo {
const std::optional<DeviceInfo::SharingInfo>& sharing_info,
const std::optional<PhoneAsASecurityKeyInfo>& paask_info,
const std::string& fcm_registration_token,
const ModelTypeSet& interested_data_types,
const DataTypeSet& interested_data_types,
std::optional<base::Time> floating_workspace_last_signin_timestamp,
bool is_self_delete_supported);
BraveDeviceInfo(const BraveDeviceInfo&) = delete;
+1 -1
View File
@@ -20,7 +20,7 @@
#include "components/browser_sync/browser_sync_switches.h"
#include "components/component_updater/component_updater_switches.h"
#include "components/sync/base/command_line_switches.h"
#include "components/sync/base/model_type.h"
#include "components/sync/base/data_type.h"
#include "components/variations/variations_switches.h"
#include "ios/chrome/browser/flags/chrome_switches.h"
@@ -7,7 +7,7 @@
#include <unordered_map>
#include "components/sync/base/model_type.h"
#include "components/sync/base/data_type.h"
#include "components/sync/base/user_selectable_type.h"
#include "components/sync/service/sync_service.h"
#include "components/sync/service/sync_user_settings.h"
@@ -88,12 +88,11 @@ BraveSyncUserSelectableTypes options_from_user_types(
- (BraveSyncUserSelectableTypes)activeSelectableTypes {
DCHECK_CURRENTLY_ON(web::WebThread::UI);
syncer::ModelTypeSet active_types = sync_service_->GetActiveDataTypes();
syncer::DataTypeSet active_types = sync_service_->GetActiveDataTypes();
syncer::UserSelectableTypeSet user_types;
for (syncer::UserSelectableType type : syncer::UserSelectableTypeSet::All()) {
if (active_types.Has(
syncer::UserSelectableTypeToCanonicalModelType(type))) {
if (active_types.Has(syncer::UserSelectableTypeToCanonicalDataType(type))) {
user_types.Put(type);
}
}