tree: 1420e838a87eb9300e11649a8a1a61df15b013ff [path history] [tgz]
  1. app_list_specifics.proto
  2. app_setting_specifics.proto
  3. app_specifics.proto
  4. arc_package_specifics.proto
  5. autofill_offer_specifics.proto
  6. autofill_specifics.proto
  7. autofill_valuable_specifics.proto
  8. autofill_wallet_credential_specifics.proto
  9. autofill_wallet_usage_specifics.proto
  10. bookmark_model_metadata.proto
  11. bookmark_specifics.proto
  12. BUILD.gn
  13. client_commands.proto
  14. client_debug_info.proto
  15. collaboration_group_metadata.proto
  16. collaboration_group_specifics.proto
  17. collaboration_metadata.cc
  18. collaboration_metadata.h
  19. collaboration_metadata_unittest.cc
  20. contact_info_specifics.proto
  21. cookie_specifics.proto
  22. data_type_progress_marker.proto
  23. data_type_state.proto
  24. data_type_state_helper.cc
  25. data_type_state_helper.h
  26. data_type_store_schema_descriptor.proto
  27. deletion_origin.proto
  28. DEPS
  29. device_info_specifics.proto
  30. dictionary_specifics.proto
  31. encryption.proto
  32. entity_data.cc
  33. entity_data.h
  34. entity_data_unittest.cc
  35. entity_metadata.proto
  36. entity_specifics.proto
  37. extension_setting_specifics.proto
  38. extension_specifics.proto
  39. gaia_password_reuse.proto
  40. get_updates_caller_info.proto
  41. history_delete_directive_specifics.proto
  42. history_specifics.proto
  43. history_status.proto
  44. loopback_server.proto
  45. managed_user_setting_specifics.proto
  46. managed_user_shared_setting_specifics.proto
  47. nigori_local_data.proto
  48. nigori_specifics.proto
  49. note_entity.proto
  50. os_preference_specifics.proto
  51. os_priority_preference_specifics.proto
  52. password_sharing_invitation_specifics.proto
  53. password_sharing_recipients.proto
  54. password_specifics.proto
  55. persisted_entity_data.proto
  56. plus_address_setting_specifics.proto
  57. plus_address_specifics.proto
  58. power_bookmark_specifics.proto
  59. preference_specifics.proto
  60. printer_specifics.proto
  61. printers_authorization_server_specifics.proto
  62. priority_preference_specifics.proto
  63. product_comparison_specifics.proto
  64. proto_enum_conversions.cc
  65. proto_enum_conversions.h
  66. proto_enum_conversions_unittest.cc
  67. proto_memory_estimations.cc
  68. proto_memory_estimations.h
  69. proto_value_conversions.cc
  70. proto_value_conversions.h
  71. proto_value_conversions_unittest.cc
  72. proto_visitors.h
  73. protocol_sources.gni
  74. reading_list_specifics.proto
  75. README.md
  76. saved_tab_group_specifics.proto
  77. search_engine_specifics.proto
  78. security_event_specifics.proto
  79. send_tab_to_self_specifics.proto
  80. session_specifics.proto
  81. shared_tab_group_account_data_specifics.proto
  82. shared_tab_group_data_specifics.proto
  83. sharing_message_specifics.proto
  84. sync.proto
  85. sync_entity.proto
  86. sync_enums.proto
  87. sync_invalidations_payload.proto
  88. tab_group_attribution_metadata.proto
  89. test.proto
  90. theme_specifics.proto
  91. theme_specifics_ios.proto
  92. theme_types.proto
  93. typed_url_specifics.proto
  94. unencrypted_sharing_message.proto
  95. unique_position.proto
  96. user_consent_specifics.proto
  97. user_consent_types.proto
  98. user_event_specifics.proto
  99. web_apk_specifics.proto
  100. web_app_specifics.proto
  101. webauthn_credential_specifics.proto
  102. wifi_configuration_specifics.proto
  103. workspace_desk_specifics.proto
components/sync/protocol/README.md

Sync Protocol Style

General guidelines:

Some specific guidelines on top of the general ones above, or just things that often come up:

  • Avoid using “explicit version numbers” in your protobuf; instead, have your code test for the existence of a field to determine what to do. Protobufs were written precisely to avoid version-specific logic, and testing for fields is more robust.

  • Enum entries should be in ALL_CAPS (different from C++!), and for new code, the first entry should be a FOO_UNSPECIFIED = 0 one.

  • Timestamp fields must specify their epoch and unit in a suffix, in this format: _[unix|windows]_epoch_[seconds|millis|micros|nanos], e.g creation_time_unix_epoch_millis.

    • Many existing fields do not follow this format, and specify epoch/unit in a comment instead. Follow the format for all new fields, though!
  • Similarly, duration fields must specify their unit as _[minutes|seconds|millis|...].

  • Proto changes also require corresponding changes in proto_visitors.h and (where appropriate) in proto_enum_conversions.h/cc.

  • Backwards compatibility: In general, all changes must be fully backwards-compatible - consider that a single user might be running different versions of the browser simultaneously! Also note that Sync supports clients up to a few years old, so deprecating/removing an existing field is typically a multi-year process.

    • As one special case, renaming a field within a specifics message is generally safe (unless there are special server-side integrations that depend on the name). However, never rename fields anywhere outside of specifics.
    • Avoid repurposing existing fields. Instead, add a new field for the new data and deprecate the old field. Also consider adding code to migrate the old field to the new field.
  • Adding fields:

    • Any new fields in a proto are unrecognized by older clients. Thus, any such change faces an inherent risk of leading to data loss for a multi-client Sync user when an older client commits. It is recommended for the data type to follow Protection against data override by old Sync clients for forward-compatibility.
  • Deprecating fields:

    • If the field is still accessed: Mark it as [deprecated = true]. This is the common case, since the browser typically needs to continue supporting the old field for backwards compatibility reasons.
    • If the field is not accessed anymore (i.e. no non-ancient clients depend on the field being populated anymore, all migration code has been retired, etc): Remove the field, and add reserved entries for both its name and its tag number.
    • Note: If your data type is using the Protection against data override by old Sync clients, then even fields that aren't accessed anymore should not be removed from the proto definition, since they should still be treated as supported for the purpose of trimming. (Otherwise, the removed fields would forever be carried forward in the data.)
  • Deprecating enum values: This is particularly tricky, especially if the default value is not a FOO_UNSPECIFIED one (see above). A common pattern is prepending DEPRECATED_ to the entry name.

For reviewers:

  • Be extra careful with protocol changes, especially consider backward and forward compatibility.
  • In doubt, loop in a second reviewer from the Sync team.