| name | sync-new-data-type |
| description | Adds scaffolding for a new Sync data type in Chromium across protocol buffers, DataType definitions, feature flags, controller builders, unit tests, and metrics. |
Add New Sync Data Type
This skill provides step-by-step guidance for adding the initial scaffold (CL
#1) for a new Sync data type in Chromium.
Overview
Introducing a new Sync data type involves wiring up protocol buffers, enum
definitions, type info tables, feature flags, controller builders,
unit/integration tests, and histogram metrics.
This skill automates creating the scaffold CL by dynamically inspecting the
codebase for current static_assert counters and enum values.
Inputs Required
Before starting, obtain the following inputs from the user:
- Data Type Name (
<DATA_TYPE> in UPPER_SNAKE_CASE): e.g., FOO_BAR,
PASSKEY_METADATA
- Bug Number (
<BUG_NUMBER>): e.g., 123456789
Derived Casing Conventions
From <DATA_TYPE> (e.g., FOO_BAR), compute the following variations:
UPPER_SNAKE_CASE: <DATA_TYPE> (e.g., FOO_BAR)
lower_snake_case: <lower_snake_case> (e.g., foo_bar)
CamelCase / PascalCase: <CamelCase> (e.g., FooBar)
Title Case: <Title Case> (e.g., Foo Bar)
Instructions
Inspect the existing codebase dynamically to discover current static_assert
counters and enum values, then make all necessary scaffold changes across the
following files:
1. Protocol Buffers & Build Rules
-
components/sync/protocol/<lower_snake_case>_specifics.proto (Create New
File): Create this file with standard Chromium boilerplate:
// Copyright 2026 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// If you change or add any fields in this file, update proto_visitors.h and
// potentially proto_enum_conversions.{h, cc}.
syntax = "proto2";
option java_multiple_files = true;
option java_package = "org.chromium.components.sync.protocol";
option optimize_for = LITE_RUNTIME;
package sync_pb;
// FIXME (in this CL): document.
message <CamelCase>Specifics {
// TODO(crbug.com/<BUG_NUMBER>): In CL #2, add fields that you wish to sync, then
// update proto_visitors.h and potentially proto_enum_conversions.*.
}
-
components/sync/protocol/entity_specifics.proto:
-
components/sync/protocol/protocol_sources.gni:
- Add
"<lower_snake_case>_specifics.proto", in alphabetical order to
sync_protocol_sources.
-
components/sync/protocol/proto_visitors.h:
- Add
#include "components/sync/protocol/<lower_snake_case>_specifics.pb.h"
in alphabetical order to the list of includes at the top.
2. Core DataType & Feature Declarations
-
components/sync/base/data_type.h:
- In
enum DataType:
- Add
// FIXME (in this CL): document. and <DATA_TYPE>, right before
LAST_USER_DATA_TYPE.
- Update
LAST_USER_DATA_TYPE = <DATA_TYPE>,.
- In
enum class DataTypeForHistograms:
- Inspect the current maximum integer value
M assigned to the last entry
before kMaxValue.
- Add
k<CamelCase> = <M + 1>, and update kMaxValue = k<CamelCase>,.
-
components/sync/base/data_type.cc:
- In
kDataTypeInfoTable: Add the new entry struct:
{
.type = <DATA_TYPE>,
.specifics_field_number =
sync_pb::EntitySpecifics::k<CamelCase>FieldNumber,
.debug_string = "<Title Case>",
.histogram_suffix = "<DATA_TYPE>",
.stable_lowercase_string = "<lower_snake_case>",
.encryption_policy =
EncryptionPolicy::kEncryptedIfCustomPassphraseSet,
.priority = DataTypePriority::kRegular,
.communication_direction = CommunicationDirection::kRegularTwoWay,
.apply_updates_batch_policy = ApplyUpdatesBatchPolicy::kStandard,
.unsynced_data_check_on_signout_policy =
UnsyncedDataCheckOnSignoutPolicy::kNone,
.cross_user_sharing_policy = CrossUserSharingPolicy::kNone,
.local_sync_support_policy = LocalSyncSupportPolicy::kUnsupported,
},
- Increment
static_assert(GetNumDataTypes() == N, ...) from N to N + 1.
- In
AddDefaultFieldValue(): Add
case <DATA_TYPE>: specifics->mutable_<lower_snake_case>(); break;.
- In
DataTypeHistogramValue(): Add
.
3. Controller Builder & Settings
-
components/browser_sync/common_controller_builder.h &
components/browser_sync/common_controller_builder.cc:
- In
common_controller_builder.h: Declare
std::unique_ptr<syncer::DataTypeController> Create<CamelCase>DataTypeController();.
- In
common_controller_builder.cc:
- In
Build():
if (!disabled_types.Has(syncer::<DATA_TYPE>)) {
add_controller(Create<CamelCase>DataTypeController());
}
- Add implementation:
std::unique_ptr<syncer::DataTypeController>
CommonControllerBuilder::Create<CamelCase>DataTypeController() {
if (!base::FeatureList::IsEnabled(syncer::kSync<CamelCase>)) {
return nullptr;
}
;
}
4. Tests & Metrics
-
chrome/browser/sync/sync_service_factory_unittest.cc:
-
ios/chrome/browser/sync/model/sync_service_factory_unittest.mm:
-
chrome/browser/sync/test/integration/sync_test.cc:
- In
AllowedTypesInStandaloneTransportMode():
-
tools/metrics/histograms/metadata/sync/enums.xml:
- In
<enum name="SyncDataTypes">:
- Add
<int value="<M + 1>" label="<Title Case>"/> matching the histogram
enum integer added in data_type.h.
-
tools/metrics/histograms/metadata/sync/histograms.xml:
- In
<variants name="SyncDataType"> (or DataType suffix variants):
5. Verification & Commit Message
- Verify that all updated
static_assert statements match
syncer::GetNumDataTypes().
- Format git commit message as:
[Sync] Add scaffold for DataType::<DATA_TYPE>
Adds the new DataType enum value and an empty specifics proto for
DataType::<DATA_TYPE>.
Follow-up CL roadmap:
- CL #2: Add fields to <lower_snake_case>_specifics.proto and proto_visitors.h.
- CL #3: Map <DATA_TYPE> to a UserSelectableType in user_selectable_type.cc.
- CL #4: Register DataTypeController in CommonControllerBuilder.
- CL #5+: Implement DataTypeSyncBridge and integration tests.
Bug: <BUG_NUMBER>
- Post-generation Review: Prompt the user to review the generated code and
address all
FIXME (in this CL) markers:
- Field number in
components/sync/protocol/entity_specifics.proto.
- DataType policies (
encryption_policy, communication_direction, etc.) in
components/sync/base/data_type.cc.
- Feature flag declaration in
components/sync/base/features.h.
- Controller builder registration in
components/browser_sync/common_controller_builder.cc.