1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4//
5// Sync protocol for communication between sync client and server.
6
7// If you change or add any fields in this file, update proto_visitors.h and
8// potentially proto_enum_conversions.{h, cc}. If you add new Specifics proto,
9// also update proto_value_conversions.{h, cc}.
10
11syntax = "proto2";
12
13option java_multiple_files = true;
14option java_package = "org.chromium.components.sync.protocol";
15
16option optimize_for = LITE_RUNTIME;
17
18package sync_pb;
19
20import "components/sync/protocol/app_list_specifics.proto";
21import "components/sync/protocol/app_notification_specifics.proto";
22import "components/sync/protocol/app_setting_specifics.proto";
23import "components/sync/protocol/app_specifics.proto";
24import "components/sync/protocol/arc_package_specifics.proto";
25import "components/sync/protocol/autofill_specifics.proto";
26import "components/sync/protocol/autofill_offer_specifics.proto";
27import "components/sync/protocol/bookmark_specifics.proto";
28import "components/sync/protocol/client_commands.proto";
29import "components/sync/protocol/client_debug_info.proto";
30import "components/sync/protocol/device_info_specifics.proto";
31import "components/sync/protocol/dictionary_specifics.proto";
32import "components/sync/protocol/encryption.proto";
33import "components/sync/protocol/experiments_specifics.proto";
34import "components/sync/protocol/extension_setting_specifics.proto";
35import "components/sync/protocol/extension_specifics.proto";
36import "components/sync/protocol/favicon_image_specifics.proto";
37import "components/sync/protocol/favicon_tracking_specifics.proto";
38import "components/sync/protocol/get_updates_caller_info.proto";
39import "components/sync/protocol/history_delete_directive_specifics.proto";
40import "components/sync/protocol/managed_user_setting_specifics.proto";
41import "components/sync/protocol/managed_user_shared_setting_specifics.proto";
42import "components/sync/protocol/managed_user_specifics.proto";
43import "components/sync/protocol/managed_user_whitelist_specifics.proto";
44import "components/sync/protocol/nigori_specifics.proto";
45import "components/sync/protocol/os_preference_specifics.proto";
46import "components/sync/protocol/os_priority_preference_specifics.proto";
47import "components/sync/protocol/password_specifics.proto";
48import "components/sync/protocol/preference_specifics.proto";
49import "components/sync/protocol/printer_specifics.proto";
50import "components/sync/protocol/priority_preference_specifics.proto";
51import "components/sync/protocol/reading_list_specifics.proto";
52import "components/sync/protocol/search_engine_specifics.proto";
53import "components/sync/protocol/security_event_specifics.proto";
54import "components/sync/protocol/send_tab_to_self_specifics.proto";
55import "components/sync/protocol/session_specifics.proto";
56import "components/sync/protocol/sharing_message_specifics.proto";
57import "components/sync/protocol/sync_enums.proto";
58import "components/sync/protocol/synced_notification_app_info_specifics.proto";
59import "components/sync/protocol/synced_notification_specifics.proto";
60import "components/sync/protocol/theme_specifics.proto";
61import "components/sync/protocol/typed_url_specifics.proto";
62import "components/sync/protocol/unique_position.proto";
63import "components/sync/protocol/user_consent_specifics.proto";
64import "components/sync/protocol/user_event_specifics.proto";
65import "components/sync/protocol/web_app_specifics.proto";
66import "components/sync/protocol/wifi_configuration_specifics.proto";
67
68// Used for inspecting how long we spent performing operations in different
69// backends. All times must be in millis.
70message ProfilingData {
71  optional int64 meta_data_write_time = 1;
72  optional int64 file_data_write_time = 2;
73  optional int64 user_lookup_time = 3;
74  optional int64 meta_data_read_time = 4;
75  optional int64 file_data_read_time = 5;
76  optional int64 total_request_time = 6;
77}
78
79message EntitySpecifics {
80  // If a datatype is encrypted, this field will contain the encrypted
81  // original EntitySpecifics. The extension for the datatype will continue
82  // to exist, but contain only the default values.
83  // Note that currently passwords employ their own legacy encryption scheme and
84  // do not use this field.
85  optional EncryptedData encrypted = 1;
86
87  // To add new datatype-specific fields to the protocol, extend
88  // EntitySpecifics.  First, pick a non-colliding tag number by
89  // picking a Cr-Commit-Position of one of your past commits
90  // to src.chromium.org.  Then, in a different protocol buffer
91  // definition, define your message type, and add an optional field
92  // to the list below using the unique tag value you selected.
93  //
94  //  optional MyDatatypeSpecifics my_datatype = 32222;
95  //
96  // where:
97  //   - 32222 is the non-colliding tag number you picked earlier.
98  //   - MyDatatypeSpecifics is the type (probably a message type defined
99  //     in your new .proto file) that you want to associate with each
100  //     object of the new datatype.
101  //   - my_datatype is the field identifier you'll use to access the
102  //     datatype specifics from the code.
103  //
104  // Server implementations are obligated to preserve the contents of
105  // EntitySpecifics when it contains unrecognized fields.  In this
106  // way, it is possible to add new datatype fields without having
107  // to update the server.
108  //
109  // Note: The tag selection process is based on legacy versions of the
110  // protocol which used protobuf extensions. We have kept the process
111  // consistent as the old values cannot change.  The 5+ digit nature of the
112  // tags also makes them recognizable (individually and collectively) from
113  // noise in logs and debugging contexts, and creating a divergent subset of
114  // tags would only make things a bit more confusing.
115
116  oneof specifics_variant {
117    AutofillSpecifics autofill = 31729;
118    BookmarkSpecifics bookmark = 32904;
119    PreferenceSpecifics preference = 37702;
120    TypedUrlSpecifics typed_url = 40781;
121    ThemeSpecifics theme = 41210;
122    // TODO(crbug.com/1012648): |app_notification| isn't used by the client
123    // anymore, but the server still needs it for now.
124    AppNotification app_notification = 45184 [deprecated = true];
125    PasswordSpecifics password = 45873;
126    NigoriSpecifics nigori = 47745;
127    ExtensionSpecifics extension = 48119;
128    AppSpecifics app = 48364;
129    SessionSpecifics session = 50119;
130    AutofillProfileSpecifics autofill_profile = 63951;
131    SearchEngineSpecifics search_engine = 88610;
132    ExtensionSettingSpecifics extension_setting = 96159;
133    AppSettingSpecifics app_setting = 103656;
134    HistoryDeleteDirectiveSpecifics history_delete_directive = 150251;
135    // TODO(crbug.com/1012648): |synced_notification| and
136    // |synced_notification_app_info| aren't used by the client anymore, but the
137    // server still needs them for now.
138    SyncedNotificationSpecifics synced_notification = 153108
139        [deprecated = true];
140    SyncedNotificationAppInfoSpecifics synced_notification_app_info = 235816
141        [deprecated = true];
142    DeviceInfoSpecifics device_info = 154522;
143    // TODO(crbug.com/1009361): |experiments| isn't used by the client anymore,
144    // but the server still needs it for now.
145    ExperimentsSpecifics experiments = 161496 [deprecated = true];
146    PriorityPreferenceSpecifics priority_preference = 163425;
147    DictionarySpecifics dictionary = 170540;
148    FaviconTrackingSpecifics favicon_tracking = 181534;
149    FaviconImageSpecifics favicon_image = 182019;
150    ManagedUserSettingSpecifics managed_user_setting = 186662;
151    // TODO(tschumann): Remove once server-side dependencies are resolved.
152    ManagedUserSpecifics managed_user = 194582 [deprecated = true];
153    // TODO(tschumann): Remove once server-side dependencies are resolved.
154    ManagedUserSharedSettingSpecifics managed_user_shared_setting = 202026
155        [deprecated = true];
156    ManagedUserWhitelistSpecifics managed_user_whitelist = 306060;
157    AppListSpecifics app_list = 229170;
158    AutofillWalletSpecifics autofill_wallet = 306270;
159    WalletMetadataSpecifics wallet_metadata = 330441;
160    ArcPackageSpecifics arc_package = 340906;
161    PrinterSpecifics printer = 410745;
162    ReadingListSpecifics reading_list = 411028;
163    UserEventSpecifics user_event = 455206;
164    UserConsentSpecifics user_consent = 556014;
165    SendTabToSelfSpecifics send_tab_to_self = 601980;
166    SecurityEventSpecifics security_event = 600372;
167    WebAppSpecifics web_app = 673225;
168    WifiConfigurationSpecifics wifi_configuration = 662827;
169    OsPreferenceSpecifics os_preference = 702141;
170    OsPriorityPreferenceSpecifics os_priority_preference = 703915;
171    SharingMessageSpecifics sharing_message = 728866;
172    AutofillOfferSpecifics autofill_offer = 774329;
173  }
174  reserved 218175;
175  reserved "wifi_credential";
176  reserved 223759;
177  reserved "article";
178  reserved 545005;
179  reserved "mountain_share";
180}
181
182message SyncEntity {
183  // This item's identifier.  In a commit of a new item, this will be a
184  // client-generated ID.  If the commit succeeds, the server will generate
185  // a globally unique ID and return it to the committing client in the
186  // CommitResponse.EntryResponse.  In the context of a GetUpdatesResponse,
187  // |id_string| is always the server generated ID.  The original
188  // client-generated ID is preserved in the |originator_client_id| field.
189  // Present in both GetUpdatesResponse and CommitMessage.
190  optional string id_string = 1;
191
192  // An id referencing this item's parent in the hierarchy.  In a
193  // CommitMessage, it is accepted for this to be a client-generated temporary
194  // ID if there was a new created item with that ID appearing earlier
195  // in the message.  In all other situations, it is a server ID.
196  // Present in both GetUpdatesResponse and CommitMessage.
197  optional string parent_id_string = 2;
198
199  reserved 3;
200  reserved "old_parent_id";
201
202  // The version of this item -- a monotonically increasing value that is
203  // maintained by for each item.  If zero in a CommitMessage, the server
204  // will interpret this entity as a newly-created item and generate a
205  // new server ID and an initial version number.  If nonzero in a
206  // CommitMessage, this item is treated as an update to an existing item, and
207  // the server will use |id_string| to locate the item.  Then, if the item's
208  // current version on the server does not match |version|, the commit will
209  // fail for that item.  The server will not update it, and will return
210  // a result code of CONFLICT.  In a GetUpdatesResponse, |version| is
211  // always positive and indentifies the revision of the item data being sent
212  // to the client.
213  // Present in both GetUpdatesResponse and CommitMessage.
214  // WARNING: This field used to be required before M60. Any client before this
215  // will fail to deserialize if this field is missing.
216  optional int64 version = 4;
217
218  // Last modification time (in java time milliseconds)
219  // Present in both GetUpdatesResponse and CommitMessage.
220  optional int64 mtime = 5;
221
222  // Creation time.
223  // Present in both GetUpdatesResponse and CommitMessage.
224  optional int64 ctime = 6;
225
226  // The name of this item.
227  // Historical note:
228  //   Since November 2010, this value is no different from non_unique_name.
229  //   Before then, server implementations would maintain a unique-within-parent
230  //   value separate from its base, "non-unique" value.  Clients had not
231  //   depended on the uniqueness of the property since November 2009; it was
232  //   removed from Chromium by http://codereview.chromium.org/371029 .
233  // Present in both GetUpdatesResponse and CommitMessage.
234  // WARNING: This field used to be required before M60. Any client before this
235  // will fail to deserialize if this field is missing.
236  optional string name = 7;
237
238  // The name of this item.  Same as |name|.
239  // |non_unique_name| should take precedence over the |name| value if both
240  // are supplied.  For efficiency, clients and servers should avoid setting
241  // this redundant value.
242  // Present in both GetUpdatesResponse and CommitMessage.
243  optional string non_unique_name = 8;
244
245  reserved 9;
246  reserved "sync_timestamp";
247
248  // If present, this tag identifies this item as being a uniquely
249  // instanced item.  The server ensures that there is never more
250  // than one entity in a user's store with the same tag value.
251  // This value is used to identify and find e.g. the "Google Chrome" settings
252  // folder without relying on it existing at a particular path, or having
253  // a particular name, in the data store.
254  //
255  // This variant of the tag is created by the server, so clients can't create
256  // an item with a tag using this field.
257  //
258  // Use client_defined_unique_tag if you want to create one from the client.
259  //
260  // An item can't have both a client_defined_unique_tag and
261  // a server_defined_unique_tag.
262  //
263  // Present only in GetUpdatesResponse.
264  optional string server_defined_unique_tag = 10;
265
266  reserved 11;
267  reserved "BookmarkData";
268  reserved 12;
269  reserved "bookmark_folder";
270  reserved 13;
271  reserved "bookmark_url";
272  reserved 14;
273  reserved "bookmark_favicon";
274
275  // Supplies a numeric position for this item, relative to other items with the
276  // same parent.  Deprecated in M26, though clients are still required to set
277  // it.
278  //
279  // Present in both GetUpdatesResponse and CommitMessage.
280  //
281  // At one point this was used as an alternative / supplement to
282  // the deprecated |insert_after_item_id|, but now it, too, has been
283  // deprecated.
284  //
285  // In order to maintain compatibility with older clients, newer clients should
286  // still set this field.  Its value should be based on the first 8 bytes of
287  // this item's |unique_position|.
288  //
289  // Nerwer clients must also support the receipt of items that contain
290  // |position_in_parent| but no |unique_position|.  They should locally convert
291  // the given int64 position to a UniquePosition.
292  //
293  // The conversion from int64 to UniquePosition is as follows:
294  // The int64 value will have its sign bit flipped then placed in big endian
295  // order as the first 8 bytes of the UniquePosition.  The subsequent bytes of
296  // the UniquePosition will consist of the item's unique suffix.
297  //
298  // Conversion from UniquePosition to int64 reverses this process: the first 8
299  // bytes of the position are to be interpreted as a big endian int64 value
300  // with its sign bit flipped.
301  optional int64 position_in_parent = 15 [deprecated = true];
302
303  // Contains the ID of the element (under the same parent) after which this
304  // element resides. An empty string indicates that the element is the first
305  // element in the parent.  This value is used during commits to specify
306  // a relative position for a position change.  In the context of
307  // a GetUpdatesMessage, |position_in_parent| is used instead to
308  // communicate position.
309  //
310  // Present only in CommitMessage.
311  //
312  // This is deprecated.  Clients are allowed to omit this as long as they
313  // include |position_in_parent| instead.
314  optional string insert_after_item_id = 16 [deprecated = true];
315
316  reserved 17;
317  reserved "extended_attributes";
318
319  // If true, indicates that this item has been (or should be) deleted.
320  // Present in both GetUpdatesResponse and CommitMessage.
321  optional bool deleted = 18 [default = false];
322
323  // A GUID that identifies the the sync client who initially committed
324  // this entity.  This value corresponds to |cache_guid| in CommitMessage.
325  // This field, along with |originator_client_item_id|, can be used to
326  // reunite the original with its official committed version in the case
327  // where a client does not receive or process the commit response for
328  // some reason.
329  //
330  // Present only in GetUpdatesResponse.
331  //
332  // This field is also used in determining the unique identifier used in
333  // bookmarks' unique_position field.
334  optional string originator_cache_guid = 19;
335
336  // Item ID as generated by the client that initially created this entity. Used
337  // exclusively for bookmarks (other datatypes use client_defined_unique_tag).
338  // There are three generation of bookmarks that have populated this field
339  // differently, depending on which version of the browser created the
340  // bookmark:
341  // 1. For bookmarks created before M44 (2015), the field got populated with an
342  //    ID that is locally unique, but not globally unique (usually a negative
343  //    number).
344  // 2. For bookmarks created between M45 and M51, both inclusive, the field got
345  //    populated with a globally unique GUID in uppercase form.
346  // 3. For bookmarks created with M52 or above, the field gets populated with
347  //    a globally unique GUID in lowercase form.
348  //
349  // Present only in GetUpdatesResponse.
350  optional string originator_client_item_id = 20;
351
352  // Extensible container for datatype-specific data.
353  // This became available in version 23 of the protocol.
354  optional EntitySpecifics specifics = 21;
355
356  // Indicate whether this is a folder or not. Available in version 23+.
357  optional bool folder = 22 [default = false];
358
359  // A client defined unique hash for this entity.
360  // Similar to server_defined_unique_tag.
361  //
362  // When initially committing an entity, a client can request that the entity
363  // is unique per that account. To do so, the client should specify a
364  // client_defined_unique_tag. At most one entity per tag value may exist.
365  // per account. The server will enforce uniqueness on this tag
366  // and fail attempts to create duplicates of this tag.
367  // Will be returned in any updates for this entity.
368  //
369  // The difference between server_defined_unique_tag and
370  // client_defined_unique_tag is the creator of the entity. Server defined
371  // tags are entities created by the server at account creation,
372  // while client defined tags are entities created by the client at any time.
373  //
374  // During GetUpdates, a sync entity update will come back with ONE of:
375  // a) Originator and cache id - If client committed the item as non "unique"
376  // b) Server tag - If server committed the item as unique
377  // c) Client tag - If client committed the item as unique
378  //
379  // May be present in CommitMessages for the initial creation of an entity.
380  // If present in Commit updates for the entity, it will be ignored.
381  //
382  // Available in version 24+.
383  //
384  // May be returned in GetUpdatesMessage and sent up in CommitMessage.
385  //
386  optional string client_defined_unique_tag = 23;
387
388  // This positioning system had a relatively short life.  It was made obsolete
389  // by |unique_position| before either the client or server made much of an
390  // attempt to support it.  In fact, no client ever read or set this field.
391  //
392  // Deprecated in M26.
393  optional bytes ordinal_in_parent = 24 [deprecated = true];
394
395  // This is the fourth attempt at positioning.
396  //
397  // This field is present in both GetUpdatesResponse and CommitMessage, if the
398  // item's type requires it and the client that wrote the item supports it (M26
399  // or higher).  Clients must also be prepared to handle updates from clients
400  // that do not set this field.
401  //
402  // This field will not be set for items whose type ignores positioning.
403  // Clients should not attempt to read this field on the receipt of an item of
404  // a type that ignores positioning.
405  //
406  // Refer to its definition in unique_position.proto for more information about
407  // its internal representation.
408  optional UniquePosition unique_position = 25;
409
410  // This used to be a list of sync attachment IDs, but it was never launched
411  // and the code has been removed as of M66.
412  reserved 26;
413  reserved "attachment_id";
414}
415
416// This message contains diagnostic information used to correlate
417// commit-related traffic with extensions-related mutations to the
418// data models in chromium.  It plays no functional role in
419// processing this CommitMessage.
420message ChromiumExtensionsActivity {
421  // The human-readable ID identifying the extension responsible
422  // for the traffic reported in this ChromiumExtensionsActivity.
423  optional string extension_id = 1;
424
425  // How many times the extension successfully invoked a write
426  // operation through the bookmarks API since the last CommitMessage.
427  optional uint32 bookmark_writes_since_last_commit = 2;
428}
429
430// Client specific configuration information.
431message ClientConfigParams {
432  // The set of data types this client has enabled. Note that this does not
433  // include proxy types, as they do not have protocol field numbers and are
434  // placeholder types that implicitly enable protocol types.
435  repeated int32 enabled_type_ids = 1;
436
437  // Whether the PROXY_TABS proxy datatype is enabled on this client.
438  optional bool tabs_datatype_enabled = 2;
439
440  // Whether the account(s) present in the content area's cookie jar match the
441  // chrome account. If multiple accounts are present in the cookie jar, a
442  // mismatch implies all of them are different from the chrome account.
443  optional bool cookie_jar_mismatch = 3;
444
445  // Indicates that the client is not aware of any other active clients for the
446  // user. This flag shows that it is not necessary to send invalidations for
447  // the committed data. The client is considered active if it's DeviceInfo has
448  // updated recent enough.
449  optional bool single_client = 4;
450}
451
452message CommitMessage {
453  repeated SyncEntity entries = 1;
454
455  // A GUID that identifies the committing sync client.  This value will be
456  // returned as originator_cache_guid for any new items.
457  optional string cache_guid = 2;
458
459  repeated ChromiumExtensionsActivity extensions_activity = 3;
460
461  // The configuration of this client at commit time. Used by the server to
462  // make commit-time decisions about how to process datatypes that might
463  // involve server-side interaction, and e.g require explicit user intent for
464  // syncing a particular data type regardless of whether a commit for that
465  // datatype is currently being sent up.
466  optional ClientConfigParams config_params = 4;
467
468  // Set of optional per-client datatype contexts.
469  repeated DataTypeContext client_contexts = 5;
470
471  // This field need to be 256 bytes if set. This attempts to mitigate CRIME
472  // attacks when sync communicate from client to server with compression. So if
473  // compression is used, this need to set a 256 random ASCII bytes. If no
474  // compression, this field should not be set. The server can ignore the
475  // padding.
476  optional string padding = 6;
477}
478
479// This message communicates additional per-type information related to
480// requests with origin GU_TRIGGER.  This message is not relevant when any
481// other origin value is used.
482// Introduced in M29.
483message GetUpdateTriggers {
484  // An opaque-to-the-client string of bytes, received through a notification,
485  // that the server may interpret as a hint about the location of the latest
486  // version of the data for this type.
487  //
488  // Note that this will eventually replace the 'optional' field of the same
489  // name defined in the progress marker, but the client and server should
490  // support both until it's safe to deprecate the old one.
491  //
492  // This field was introduced in M29.
493  repeated string notification_hint = 1;
494
495  // This flag is set if the client was forced to drop hints because the number
496  // of queued hints exceeded its limit.  The oldest hints will be discarded
497  // first.  Introduced in M29.
498  optional bool client_dropped_hints = 2;
499
500  // This flag is set when the client suspects that its list of invalidation
501  // hints may be incomplete.  This may be the case if:
502  // - The client is syncing for the first time.
503  // - The client has just restarted and it was unable to keep track of
504  //   invalidations that were received prior to the restart.
505  // - The client's connection to the invalidation server is currently or
506  //   was recently broken.
507  //
508  // It's difficult to provide more details here.  This is implemented by
509  // setting the flag to false whenever anything that might adversely affect
510  // notifications happens (eg. a crash, restart on a platform that doesn't
511  // support invalidation ack-tracking, transient invalidation error) and is
512  // unset only after we've experienced one successful sync cycle while
513  // notifications were enabled.
514  //
515  // This flag was introduced in M29.
516  optional bool invalidations_out_of_sync = 3;
517
518  // This counts the number of times the syncer has been asked to commit
519  // changes for this type since the last successful sync cycle.  The number of
520  // nudges may not be related to the actual number of items modified.  It
521  // often correlates with the number of user actions, but that's not always
522  // the case.
523  // Introduced in M29.
524  optional int64 local_modification_nudges = 4;
525
526  // This counts the number of times the syncer has been explicitly asked to
527  // fetch updates for this type since the last successful sync cycle.  These
528  // explicit refresh requests should be relatively rare on most platforms, and
529  // associated with user actions.  For example, at the time of this writing
530  // the most common (only?) source of refresh requests is when a user opens
531  // the new tab page on a platform that does not support sessions
532  // invalidations.
533  // Introduced in M29.
534  optional int64 datatype_refresh_nudges = 5;
535
536  // This flag is set if the invalidation server reports that it may have
537  // dropped some invalidations at some point.  Introduced in M33.
538  optional bool server_dropped_hints = 6;
539
540  // This flag is set if this GetUpdate request is due at least in part due
541  // to the fact that this type has not finished initial sync yet, and the
542  // client would like to initialize itself with the server data.
543  //
544  // Only some types support performing an initial sync as part of a normal
545  // GetUpdate request.  Many types must be in configure mode when fetching
546  // initial sync data.
547  //
548  // Introduced in M38.
549  optional bool initial_sync_in_progress = 7;
550
551  // This flag is set if this GetUpdate request is due to client receiving
552  // conflict response from server, so client needs to sync and then resolve
553  // conflict locally, and then commit again.
554  //
555  // Introduced in M42.
556  optional bool sync_for_resolve_conflict_in_progress = 8;
557}
558
559message GarbageCollectionDirective {
560  enum Type {
561    UNKNOWN = 0;
562    VERSION_WATERMARK = 1;
563    AGE_WATERMARK = 2;
564    DEPRECATED_MAX_ITEM_COUNT = 3 [deprecated = true];
565  }
566
567  optional Type type = 1 [default = UNKNOWN];
568
569  // This field specifies the watermark for the versions which should get
570  // garbage collected.  The client should purge all sync entities when
571  // receiving any value of this.  This is a change from previous behavior,
572  // where the client would only be required to purge items older than the
573  // specified watermark.
574  // TODO(crbug.com/877951): Rename this to make clear that whenever it's set,
575  // the client will delete ALL data, regardless of its value.
576  optional int64 version_watermark = 2;
577
578  // This field specifies the watermark in terms of age in days.  The client
579  // should purge all sync entities which are older than this specific value
580  // based on last modified time.
581  optional int32 age_watermark_in_days = 3;
582
583  reserved 4;
584  reserved "max_number_of_items";
585}
586
587message DataTypeProgressMarker {
588  // An integer identifying the data type whose progress is tracked by this
589  // marker.  The legitimate values of this field correspond to the protobuf
590  // field numbers of all EntitySpecifics fields supported by the server.
591  // These values are externally declared in per-datatype .proto files.
592  optional int32 data_type_id = 1;
593
594  // An opaque-to-the-client sequence of bytes that the server may interpret
595  // as an indicator of the client's knowledge state.  If this is empty or
596  // omitted by the client, it indicates that the client is initiating a
597  // a first-time sync of this datatype.  Otherwise, clients must supply a
598  // value previously returned by the server in an earlier GetUpdatesResponse.
599  // These values are not comparable or generable on the client.
600  //
601  // The opaque semantics of this field are to afford server implementations
602  // some flexibility in implementing progress tracking.  For instance,
603  // a server implementation built on top of a distributed storage service --
604  // or multiple heterogenous such services -- might need to supply a vector
605  // of totally ordered monotonic update timestamps, rather than a single
606  // monotonically increasing value.  Other optimizations may also be
607  // possible if the server is allowed to embed arbitrary information in
608  // the progress token.
609  //
610  // Server implementations should keep the size of these tokens relatively
611  // small, on the order of tens of bytes, and they should remain small
612  // regardless of the number of items synchronized.  (A possible bad server
613  // implementation would be for progress_token to contain a list of all the
614  // items ever sent to the client.  Servers shouldn't do this.)
615  optional bytes token = 2;
616
617  // Clients that previously downloaded updates synced using the timestamp based
618  // progress tracking mechanism, but which wish to switch over to the opaque
619  // token mechanism can set this field in a GetUpdatesMessage.  The server
620  // will perform a get updates operation as normal from the indicated
621  // timestamp, and return only an opaque progress token.
622  optional int64 timestamp_token_for_migration = 3 [deprecated = true];
623
624  // An opaque-to-the-client string of bytes, received through a notification,
625  // that the server may interpret as a hint about the location of the latest
626  // version of the data for this type.
627  //
628  // Deprecated in M29.  We should use the repeated field version in the
629  // PerClientTypeState instead.
630  optional string notification_hint = 4 [deprecated = true];
631
632  // This field will be included only in GetUpdates with origin GU_TRIGGER.
633  optional GetUpdateTriggers get_update_triggers = 5;
634
635  // The garbage collection directive for this data type.  The client should
636  // purge items locally based on this directive.  Since this directive is
637  // designed to be sent from server only, the client should persist it locally
638  // as needed and avoid sending it to the server.
639  optional GarbageCollectionDirective gc_directive = 6;
640}
641
642message GetUpdatesMessage {
643  reserved 1;
644  reserved "from_timestamp";
645
646  // Indicates the reason for the GetUpdatesMessage.
647  // This was *mostly* deprecated in M29.  GetUpdatesOrigin is the new way to
648  // encode the reason for the GetUpdates request, but some parts of the server
649  // still rely on this field.  It also still contains the
650  // "notifications_enabled" flag which needs to be moved elsewhere before this
651  // can be fully removed. See https://crbug.com/510165.
652  optional GetUpdatesCallerInfo caller_info = 2;
653
654  // Indicates whether related folders should be fetched.
655  optional bool fetch_folders = 3 [default = true];
656
657  // Client-requested limit on the maximum number of updates to return at once.
658  // The server may opt to return fewer updates than this amount, but it should
659  // not return more.
660  optional int32 batch_size = 5;
661
662  // Per-datatype progress marker.  If present, the server will ignore
663  // the values of requested_types and from_timestamp, using this instead.
664  //
665  // With the exception of certain configuration or initial sync requests, the
666  // client should include one instance of this field for each enabled data
667  // type.
668  repeated DataTypeProgressMarker from_progress_marker = 6;
669
670  // Indicates whether the response should be sent in chunks.  This may be
671  // needed for devices with limited memory resources.  If true, the response
672  // will include one or more ClientToServerResponses, with the frist one
673  // containing GetUpdatesMetadataResponse, and the remaining ones, if any,
674  // containing GetUpdatesStreamingResponse.  These ClientToServerResponses are
675  // delimited by a length prefix, which is encoded as a varint.
676  optional bool streaming = 7 [default = false];
677
678  // Whether the client needs the server to provide an encryption key for this
679  // account.
680  // Note: this should typically only be set on the first GetUpdates a client
681  // requests. Clients are expected to persist the encryption key from then on.
682  // The allowed frequency for requesting encryption keys is much lower than
683  // other datatypes, so repeated usage will likely result in throttling.
684  optional bool need_encryption_key = 8 [default = false];
685
686  // Whether to create the mobile bookmarks folder if it's not
687  // already created.  Set to true by all modern clients.
688  optional bool create_mobile_bookmarks_folder = 1000
689      [default = false, deprecated = true];
690
691  // This value is an updated version of the GetUpdatesCallerInfo's
692  // GetUpdatesSource.  It describes the reason for the GetUpdate request.
693  // Introduced in M29.
694  optional SyncEnums.GetUpdatesOrigin get_updates_origin = 9;
695
696  // Whether this GU also serves as a retry GU. Any GU that happens after
697  // retry timer timeout is a retry GU effectively.
698  optional bool is_retry = 10 [default = false];
699
700  // Set of optional per-client datatype contexts.
701  repeated DataTypeContext client_contexts = 11;
702
703  reserved 4;
704  reserved "requested_types";
705}
706
707// Message from a client asking the server to clear its data.
708message ClearServerDataMessage {
709  // No arguments needed as the store birthday and user identifier are part of
710  // an enclosing message.
711}
712
713// Response to a ClearServerData request.
714message ClearServerDataResponse {
715  // No result fields necessary. Success/failure is indicated in
716  // ClientToServerResponse.
717}
718
719// The client must preserve, store, and resend the chip bag with
720// every request.  The server depends on the chip bag in order
721// to precisely choreograph a client-server state machines.
722//
723// Because the client stores and sends this data on every request,
724// the contents of the chip bag should be kept relatively small.
725//
726// If the server does not return a chip bag, the client must assume
727// that there has been no change to the chip bag.  The client must
728// resend the bag of chips it had prior on the next request.
729//
730// The client must make the chip bag durable if and only if it
731// processes the response from the server.
732message ChipBag {
733  // Server chips are deliberately oqaque, allowing the server
734  // to encapsulate its state machine logic.
735  optional bytes server_chips = 1;
736}
737
738// Information about the syncer's state.
739message ClientStatus {
740  // Flag to indicate if the client has detected hierarchy conflcits.  The flag
741  // is left unset if update application has not been attempted yet.
742  //
743  // The server should attempt to resolve any hierarchy conflicts when this flag
744  // is set.  The client may not assume that any particular action will be
745  // taken.  There is no guarantee the problem will be addressed in a reasonable
746  // amount of time.
747  optional bool hierarchy_conflict_detected = 1;
748
749  // Whether the client has full sync (or, sync the feature) enabled or not.
750  optional bool is_sync_feature_enabled = 2;
751}
752
753// A single datatype's sync context. Allows the datatype to pass along
754// datatype specific information with its own server backend.
755message DataTypeContext {
756  // The type this context is associated with.
757  optional int32 data_type_id = 1;
758  // The context for the datatype.
759  optional bytes context = 2;
760  // The version of the context.
761  optional int64 version = 3;
762}
763
764message ClientToServerMessage {
765  // |share| field is only used on the server for logging and can sometimes
766  // contain empty string. It is still useful for logging username when it can't
767  // be derived from access token in case of auth error.
768  required string share = 1;
769
770  optional int32 protocol_version = 2 [default = 52];
771  enum Contents {
772    COMMIT = 1;
773    GET_UPDATES = 2;
774    DEPRECATED_3 = 3;
775    DEPRECATED_4 = 4;
776    CLEAR_SERVER_DATA = 5;
777  }
778
779  // Each ClientToServerMessage contains one request defined by the
780  // message_contents. Each type has a corresponding message field that will be
781  // present iff the message is of that type. E.g. a commit message will have a
782  // message_contents of COMMIT and its commit field will be present.
783  required Contents message_contents = 3;
784  optional CommitMessage commit = 4;
785  optional GetUpdatesMessage get_updates = 5;
786  reserved 6;
787  reserved "authenticate";
788
789  reserved 9;
790
791  optional string store_birthday = 7;  // Opaque store ID; if it changes, duck!
792  // The client sets this if it detects a sync issue. The server will tell it
793  // if it should perform a refresh.
794  optional bool sync_problem_detected = 8 [default = false];
795
796  // Client side state information for debugging purpose.
797  // This is only sent on the first getupdates of every sync cycle,
798  // as an optimization to save bandwidth.
799  optional DebugInfo debug_info = 10;
800
801  // Per-client state for use by the server. Sent with every message sent to the
802  // server.
803  optional ChipBag bag_of_chips = 11;
804
805  // Google API key.
806  optional string api_key = 12;
807
808  // Client's self-reported state.
809  // The client should set this on every message sent to the server, though its
810  // member fields may often be unset.
811  optional ClientStatus client_status = 13;
812
813  // The ID that our invalidation client used to identify itself to the server.
814  // Sending the ID here allows the server to not send notifications of our own
815  // changes to our invalidator.
816  optional string invalidator_client_id = 14;
817
818  // Identifies this ClientToServerMessage as a clear server data request. This
819  // field is present when message_contents is CLEAR_SERVER_DATA.
820  optional ClearServerDataMessage clear_server_data = 15;
821}
822
823// This request allows the client to convert a specific crash identifier
824// into more general information (e.g. hash of the crashing call stack)
825// suitable for upload in an (authenticated) DebugInfo event.
826message GetCrashInfoRequest {
827  // Id of the uploaded crash.
828  optional string crash_id = 1;
829
830  // Time that the crash occurred.
831  optional int64 crash_time_millis = 2;
832}
833
834// Proto to be written in its entirety to the debug info log.
835message GetCrashInfoResponse {
836  // Hash of the crashing call stack.
837  optional string stack_id = 1;
838
839  // Time of the crash, potentially rounded to remove
840  // significant bits.
841  optional int64 crash_time_millis = 2;
842}
843
844message CommitResponse {
845  enum ResponseType {
846    SUCCESS = 1;
847    CONFLICT = 2;  // You're out of date; update and check your data
848    // TODO(ncarter): What's the difference between RETRY and TRANSIENT_ERROR?
849    RETRY = 3;            // Someone has a conflicting, non-expired session open
850    INVALID_MESSAGE = 4;  // What the client sent was invalid, and trying again
851                          // won't help.
852    OVER_QUOTA = 5;  // This operation would put you, or you are, over quota
853    TRANSIENT_ERROR = 6;  // Something went wrong; try again in a bit
854  }
855  repeated group EntryResponse = 1 {
856    required ResponseType response_type = 2;
857
858    // Sync servers may also return a new ID for an existing item, indicating
859    // a new entry's been created to hold the data the client's sending up.
860    optional string id_string = 3;
861
862    // should be filled if our parent was assigned a new ID.
863    optional string parent_id_string = 4;
864
865    reserved 5;
866    reserved "position_in_parent";
867
868    // The item's current version.
869    optional int64 version = 6;
870
871    // Allows the server to move-aside an entry as it's being committed.
872    // This name is the same as the name field returned within the SyncEntity
873    // message in GetUpdatesResponse.
874    optional string name = 7;
875
876    // This name is the same as the non_unique_name field returned within the
877    // SyncEntity message in GetUpdatesResponse.
878    optional string non_unique_name = 8;
879
880    optional string error_message = 9;
881
882    // Last modification time (in java time milliseconds).  Allows the server
883    // to override the client-supplied mtime during a commit operation.
884    optional int64 mtime = 10;
885
886    message DatatypeSpecificError {
887      oneof datatype_error {
888        SharingMessageCommitError sharing_message_error = 1;
889      }
890    }
891    // Datatype specific error (if any).
892    optional DatatypeSpecificError datatype_specific_error = 11;
893  }
894}
895
896message GetUpdatesResponse {
897  // New sync entries that the client should apply.
898  repeated SyncEntity entries = 1;
899
900  reserved 2;
901  reserved "new_timestamp";
902
903  reserved 3;
904  reserved "newest_timestamp";
905
906  // Approximate count of changes remaining - use this for UI feedback.
907  // If present and zero, this estimate is firm: the server has no changes
908  // after the current batch.
909  optional int64 changes_remaining = 4;
910
911  // Opaque, per-datatype timestamp-like tokens.  Clients should retain and
912  // persist the values returned in this field, and present them back to the
913  // server to indicate the starting point for future update requests.
914  //
915  // This will be sent only if the client provided |from_progress_marker|
916  // in the update request.
917  //
918  // The server may provide a new progress marker even if this is the end of
919  // the batch, or if there were no new updates on the server; and the client
920  // must save these.  If the server does not provide a |new_progress_marker|
921  // value for a particular datatype, when the request provided a
922  // |from_progress_marker| value for that datatype, the client should
923  // interpret this to mean "no change from the previous state" and retain its
924  // previous progress-marker value for that datatype.
925  //
926  // Progress markers in the context of a response will never have the
927  // |timestamp_token_for_migration| field set.
928  repeated DataTypeProgressMarker new_progress_marker = 5;
929
930  // The current encryption keys associated with this account. Will be set if
931  // the GetUpdatesMessage in the request had need_encryption_key == true or
932  // the server has updated the set of encryption keys (e.g. due to a key
933  // rotation).
934  repeated bytes encryption_keys = 6;
935
936  // Set of optional datatype contexts server mutations.
937  repeated DataTypeContext context_mutations = 7;
938}
939
940message ClientToServerResponse {
941  optional CommitResponse commit = 1;
942  optional GetUpdatesResponse get_updates = 2;
943  reserved 3;
944  reserved "authenticate";
945
946  // Up until protocol_version 24, the default was SUCCESS which made it
947  // impossible to add new enum values since older clients would parse any
948  // out-of-range value as SUCCESS. Starting with 25, unless explicitly set,
949  // the error_code will be UNKNOWN so that clients know when they're
950  // out-of-date. Note also that when using protocol_version < 25,
951  // TRANSIENT_ERROR is not supported. Instead, the server sends back a HTTP
952  // 400 error code. This is deprecated now.
953  optional SyncEnums.ErrorType error_code = 4 [default = UNKNOWN];
954  optional string error_message = 5;
955
956  // Opaque store ID; if it changes, the contents of the client's cache
957  // is meaningless to this server.  This happens most typically when
958  // you switch from one storage backend instance (say, a test instance)
959  // to another (say, the official instance).
960  optional string store_birthday = 6;
961
962  optional ClientCommand client_command = 7;
963  optional ProfilingData profiling_data = 8;
964  reserved 9;
965  reserved 10;
966  reserved "stream_metadata";
967  reserved 11;
968  reserved "stream_data";
969
970  // The data types whose storage has been migrated.  Present when the value of
971  // error_code is MIGRATION_DONE.
972  repeated int32 migrated_data_type_id = 12;
973
974  message Error {
975    optional SyncEnums.ErrorType error_type = 1 [default = UNKNOWN];
976    optional string error_description = 2;
977    reserved 3;
978    reserved "url";
979    optional SyncEnums.Action action = 4 [default = UNKNOWN_ACTION];
980
981    // Currently meaningful if |error_type| is throttled or partial_failure.
982    // In the throttled case, if this field is absent then the whole client
983    // (all datatypes) is throttled.
984    // In the partial_failure case, this field denotes partial failures. The
985    // client should retry those datatypes with exponential backoff.
986    repeated int32 error_data_type_ids = 5;
987  }
988  optional Error error = 13;
989
990  // The new per-client state for this client. If set, should be persisted and
991  // sent with any subsequent ClientToServerMessages.
992  optional ChipBag new_bag_of_chips = 14;
993
994  // Present if this ClientToServerResponse is in response to a ClearServerData
995  // request.
996  optional ClearServerDataResponse clear_server_data = 15;
997}
998
999// A message to notify the server of certain sync events. Idempotent. Send these
1000// to the /event endpoint.
1001message EventRequest {
1002  optional SyncDisabledEvent sync_disabled = 1;
1003}
1004
1005message EventResponse {}
1006
1007// A message indicating that the sync engine has been disabled on a client.
1008message SyncDisabledEvent {
1009  // The GUID that identifies the sync client.
1010  optional string cache_guid = 1;
1011
1012  // The store birthday that the client was using before disabling sync.
1013  optional string store_birthday = 2;
1014}
1015