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