OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 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 syntax = "proto2"; |
| 8 |
| 9 option java_api_version = 1; |
| 10 option cc_api_version = 1; |
| 11 option py_api_version = 1; |
| 12 option java_java5_enums = false; |
| 13 |
| 14 package sync_pb; |
| 15 |
| 16 // Used to store and send extended attributes, which are arbitrary |
| 17 // key value pairs. |
| 18 message ExtendedAttributes { |
| 19 repeated group ExtendedAttribute = 1 { |
| 20 required string key = 2; |
| 21 required bytes value = 3; |
| 22 } |
| 23 } |
| 24 |
| 25 // Used for inspecting how long we spent performing operations in different |
| 26 // backends. All times must be in millis. |
| 27 message ProfilingData { |
| 28 optional int64 meta_data_write_time = 1; |
| 29 optional int64 file_data_write_time = 2; |
| 30 optional int64 user_lookup_time = 3; |
| 31 optional int64 meta_data_read_time = 4; |
| 32 optional int64 file_data_read_time = 5; |
| 33 optional int64 total_request_time = 6; |
| 34 } |
| 35 |
| 36 message SyncEntity { |
| 37 // This item's identifier. In a commit of a new item, this will be a |
| 38 // client-generated ID. If the commit succeeds, the server will generate |
| 39 // a globally unique ID and return it to the committing client in the |
| 40 // CommitResponse.EntryResponse. In the context of a GetUpdatesResponse, |
| 41 // |id_string| is always the server generated ID. The original |
| 42 // client-generated ID is preserved in the |originator_client_id| field. |
| 43 // Present in both GetUpdatesResponse and CommitMessage. |
| 44 optional string id_string = 1; |
| 45 |
| 46 // An id referencing this item's parent in the hierarchy. In a |
| 47 // CommitMessage, it is accepted for this to be a client-generated temporary |
| 48 // ID if there was a new created item with that ID appearing earlier |
| 49 // in the message. In all other situations, it is a server ID. |
| 50 // Present in both GetUpdatesResponse and CommitMessage. |
| 51 optional string parent_id_string = 2; |
| 52 |
| 53 // old_parent_id is only set in commits and indicates the old server |
| 54 // parent(s) to remove. When omitted, the old parent is the same as |
| 55 // the new. |
| 56 // Present only in CommitMessage. |
| 57 optional string old_parent_id = 3; |
| 58 |
| 59 // The version of this item -- a monotonically increasing value that is |
| 60 // maintained by for each item. If zero in a CommitMessage, the server |
| 61 // will interpret this entity as a newly-created item and generate a |
| 62 // new server ID and an initial version number. If nonzero in a |
| 63 // CommitMessage, this item is treated as an update to an existing item, and |
| 64 // the server will use |id_string| to locate the item. Then, if the item's |
| 65 // current version on the server does not match |version|, the commit will |
| 66 // fail for that item. The server will not update it, and will return |
| 67 // a result code of CONFLICT. In a GetUpdatesResponse, |version| is |
| 68 // always positive and indentifies the revision of the item data being sent |
| 69 // to the client. |
| 70 // Present in both GetUpdatesResponse and CommitMessage. |
| 71 required int64 version = 4; |
| 72 |
| 73 // Last modification time (in java time milliseconds) |
| 74 // Present in both GetUpdatesResponse and CommitMessage. |
| 75 optional int64 mtime = 5; |
| 76 |
| 77 // Creation time. |
| 78 // Present in both GetUpdatesResponse and CommitMessage. |
| 79 optional int64 ctime = 6; |
| 80 |
| 81 // A unique-in-the parent name for this item. |
| 82 // Present in both GetUpdatesResponse and CommitMessage. |
| 83 required string name = 7; |
| 84 |
| 85 // non_unique_name holds the base name stored serverside, which is different |
| 86 // from |name| when |name| has been suffixed in a way to make it unique |
| 87 // among its siblings. In a GetUpdatesResponse, |non_unique_name| will |
| 88 // be supplied in addition to |name|, and the client may choose which |
| 89 // field to use depending on its needs. In a CommitMessage, |
| 90 // |non_unique_name| takes precedence over the |name| value if both are |
| 91 // supplied. |
| 92 // Present in both GetUpdatesResponse and CommitMessage. |
| 93 optional string non_unique_name = 8; |
| 94 |
| 95 // A value from a monotonically increasing sequence that indicates when |
| 96 // this item was last updated on the server. This is now equivalent |
| 97 // to version. This is now deprecated in favor of version. |
| 98 // Present only in GetUpdatesResponse. |
| 99 optional int64 sync_timestamp = 9; |
| 100 |
| 101 // If present, singleton_tag identifies this item as being a uniquely |
| 102 // instanced item. The server ensures that there is never more |
| 103 // than one entity in a user's store with the same singleton_tag value. |
| 104 // This value is used to identify and find e.g. the "Google Chrome" settings |
| 105 // folder without relying on it existing at a particular path, or having |
| 106 // a particular name, in the data store. |
| 107 // Present only in GetUpdatesResponse. |
| 108 optional string singleton_tag = 10; |
| 109 |
| 110 // If this group is present, it implies that this SyncEntity corresponds to |
| 111 // a bookmark or a bookmark folder. |
| 112 // |
| 113 // TODO(idana): for now, we put the bookmarks related information explicitly |
| 114 // in the protocol definition. When we start syncing more data types, it is |
| 115 // probably going to be better if we represent the different types as |
| 116 // extended attributes. |
| 117 optional group BookmarkData = 11 { |
| 118 // We use a required field to differentiate between a bookmark and a |
| 119 // bookmark folder. |
| 120 // Present in both GetUpdatesMessage and CommitMessage. |
| 121 required bool bookmark_folder = 12; |
| 122 |
| 123 // For bookmark objects, contains the bookmark's URL. |
| 124 // Present in both GetUpdatesResponse and CommitMessage. |
| 125 optional string bookmark_url = 13; |
| 126 |
| 127 // For bookmark objects, contains the bookmark's favicon. The favicon is |
| 128 // represented as a 16X16 PNG image. |
| 129 // Present in both GetUpdatesResponse and CommitMessage. |
| 130 optional bytes bookmark_favicon = 14; |
| 131 } |
| 132 |
| 133 // Supplies a numeric position for this item, relative to other items with |
| 134 // the same parent. This value is only meaningful in server-to-client |
| 135 // contexts; to specify a position in a client-to-server commit context, |
| 136 // use |insert_after_item_id|. |
| 137 // Present only in GetUpdatesResponse. |
| 138 optional int64 position_in_parent = 15; |
| 139 |
| 140 // Contains the ID of the element (under the same parent) after which this |
| 141 // element resides. An empty string indicates that the element is the first |
| 142 // element in the parent. This value is used during commits to specify |
| 143 // a relative position for a position change. In the context of |
| 144 // a GetUpdatesMessage, |position_in_parent| is used instead to |
| 145 // communicate position. |
| 146 // Present only in CommitMessage. |
| 147 optional string insert_after_item_id = 16; |
| 148 |
| 149 // Arbitrary key/value pairs associated with this item. |
| 150 // Present in both GetUpdatesResponse and CommitMessage. |
| 151 optional ExtendedAttributes extended_attributes = 17; |
| 152 |
| 153 // If true, indicates that this item has been (or should be) deleted. |
| 154 // Present in both GetUpdatesResponse and CommitMessage. |
| 155 optional bool deleted = 18 [default = false]; |
| 156 |
| 157 // A GUID that identifies the the sync client who initially committed |
| 158 // this entity. This value corresponds to |cache_guid| in CommitMessage. |
| 159 // This field, along with |originator_client_item_id|, can be used to |
| 160 // reunite the original with its official committed version in the case |
| 161 // where a client does not receive or process the commit response for |
| 162 // some reason. |
| 163 // Present only in GetUpdatesResponse. |
| 164 optional string originator_cache_guid = 19; |
| 165 |
| 166 // The local item id of this entry from the client that initially |
| 167 // committed this entity. Typically a negative integer. |
| 168 // Present only in GetUpdatesResponse. |
| 169 optional string originator_client_item_id = 20; |
| 170 }; |
| 171 |
| 172 message CommitMessage { |
| 173 repeated SyncEntity entries = 1; |
| 174 |
| 175 // A GUID that identifies the committing sync client. This value will be |
| 176 // returned as originator_cache_guid for any new items. |
| 177 optional string cache_guid = 2; |
| 178 }; |
| 179 |
| 180 message GetUpdatesCallerInfo { |
| 181 enum GET_UPDATES_SOURCE { |
| 182 UNKNOWN = 0; // The source was not set by the caller. |
| 183 FIRST_UPDATE = 1; // First update from an instance of Chrome. |
| 184 LOCAL = 2; // The source of the update was a local change. |
| 185 NOTIFICATION = 3; // The source of the update was a p2p notification. |
| 186 PERIODIC = 4; // The source of the update was periodic polling. |
| 187 SYNC_CYCLE_CONTINUATION = 5; // The source of the update was a |
| 188 } // continuation of a previous update. |
| 189 |
| 190 required GET_UPDATES_SOURCE source = 1; |
| 191 |
| 192 // True only if notifications were enabled for this GetUpdateMessage. |
| 193 optional bool notifications_enabled = 2; |
| 194 }; |
| 195 |
| 196 message GetUpdatesMessage { |
| 197 required int64 from_timestamp = 1; |
| 198 |
| 199 // Indicates the reason for the GetUpdatesMessage. |
| 200 optional GetUpdatesCallerInfo caller_info = 2; |
| 201 }; |
| 202 |
| 203 message AuthenticateMessage { |
| 204 required string auth_token = 1; |
| 205 }; |
| 206 |
| 207 message ClientToServerMessage { |
| 208 required string share = 1; |
| 209 optional int32 protocol_version = 2 [default = 20]; |
| 210 enum CONTENTS { |
| 211 COMMIT = 1; |
| 212 GET_UPDATES = 2; |
| 213 AUTHENTICATE = 3; |
| 214 } |
| 215 |
| 216 required CONTENTS message_contents = 3; |
| 217 optional CommitMessage commit = 4; |
| 218 optional GetUpdatesMessage get_updates = 5; |
| 219 optional AuthenticateMessage authenticate = 6; |
| 220 |
| 221 optional string store_birthday = 7; // Opaque store ID; if it changes, duck! |
| 222 // The client sets this if it detects a sync issue. The server will tell it |
| 223 // if it should perform a refresh. |
| 224 optional bool sync_problem_detected = 8 [default = false]; |
| 225 }; |
| 226 |
| 227 message CommitResponse { |
| 228 enum RESPONSE_TYPE { |
| 229 SUCCESS = 1; |
| 230 CONFLICT = 2; // You're out of date; update and check your data |
| 231 // TODO(ncarter): What's the difference between RETRY and TRANSIENT_ERROR? |
| 232 RETRY = 3; // Someone has a conflicting, non-expired session open |
| 233 INVALID_MESSAGE = 4; // What the client sent was invalid, and trying again |
| 234 // won't help. |
| 235 OVER_QUOTA = 5; // This operation would put you, or you are, over quota |
| 236 TRANSIENT_ERROR = 6; // Something went wrong; try again in a bit |
| 237 } |
| 238 repeated group EntryResponse = 1 { |
| 239 required RESPONSE_TYPE response_type = 2; |
| 240 |
| 241 // Sync servers may also return a new ID for an existing item, indicating |
| 242 // a new entry's been created to hold the data the client's sending up. |
| 243 optional string id_string = 3; |
| 244 |
| 245 // should be filled if our parent was assigned a new ID. |
| 246 optional string parent_id_string = 4; |
| 247 |
| 248 // This value is the same as the position_in_parent value returned within |
| 249 // the SyncEntity message in GetUpdatesResponse. It is returned if the |
| 250 // item was assigned a new position. |
| 251 optional int64 position_in_parent = 5; |
| 252 |
| 253 // The item's current version. |
| 254 optional int64 version = 6; |
| 255 |
| 256 // Allows the server to move-aside an entry as it's being committed. |
| 257 // This name is the same as the name field returned within the SyncEntity |
| 258 // message in GetUpdatesResponse. |
| 259 optional string name = 7; |
| 260 |
| 261 // This name is the same as the non_unique_name field returned within the |
| 262 // SyncEntity message in GetUpdatesResponse. |
| 263 optional string non_unique_name = 8; |
| 264 |
| 265 optional string error_message = 9; |
| 266 |
| 267 } |
| 268 }; |
| 269 |
| 270 message GetUpdatesResponse { |
| 271 repeated SyncEntity entries = 1; |
| 272 // If there are more changes on the server that weren't processed during this |
| 273 // GetUpdates request, the client should send another GetUpdates request and |
| 274 // use new_timestamp as the from_timestamp value within GetUpdatesMessage. |
| 275 optional int64 new_timestamp = 2; |
| 276 // The newest timestamp in the share. Used to give UI feedback on progress. |
| 277 optional int64 newest_timestamp = 3; |
| 278 }; |
| 279 |
| 280 // A user-identifying struct. For a given Google account the email and display |
| 281 // name can change, but obfuscated_id should be constant. |
| 282 // The obfuscated id is optional because at least one planned use of the proto |
| 283 // (sharing) does not require it. |
| 284 message UserIdentification { |
| 285 required string email = 1; // the user's full primary email address. |
| 286 optional string display_name = 2; // the user's display name. |
| 287 optional string obfuscated_id = 3; // an obfuscated, opaque user id. |
| 288 }; |
| 289 |
| 290 message AuthenticateResponse { |
| 291 // Optional only for backward compatibility. |
| 292 optional UserIdentification user = 1; |
| 293 }; |
| 294 |
| 295 message ThrottleParameters { |
| 296 // Deprecated. Remove this from the server side. |
| 297 required int32 min_measure_payload_size = 1; |
| 298 required double target_utilization = 2; |
| 299 required double measure_interval_max = 3; |
| 300 required double measure_interval_min = 4; |
| 301 required double observation_window = 5; |
| 302 }; |
| 303 |
| 304 // A command from the server instructing the client to update settings or |
| 305 // perform some operation. |
| 306 message ClientCommand { |
| 307 // Time to wait before sending any requests to the server. |
| 308 optional int32 set_sync_poll_interval = 1; // in seconds |
| 309 optional int32 set_sync_long_poll_interval = 2; // in seconds |
| 310 |
| 311 optional int32 max_commit_batch_size = 3; |
| 312 }; |
| 313 |
| 314 message ClientToServerResponse { |
| 315 optional CommitResponse commit = 1; |
| 316 optional GetUpdatesResponse get_updates = 2; |
| 317 optional AuthenticateResponse authenticate = 3; |
| 318 |
| 319 enum ERROR_TYPE { |
| 320 SUCCESS = 0; |
| 321 ACCESS_DENIED = 1; // Returned when the user doesn't have access to |
| 322 // store (instead of HTTP 401). |
| 323 NOT_MY_BIRTHDAY = 2; // Returned when the server and client disagree on |
| 324 // the store birthday. |
| 325 THROTTLED = 3; // Returned when the store has exceeded the allowed |
| 326 // bandwidth utilization. |
| 327 AUTH_EXPIRED = 4; // Auth token or cookie has expired. |
| 328 USER_NOT_ACTIVATED = 5; // User doesn't have the Chrome bit set on that |
| 329 // Google Account. |
| 330 AUTH_INVALID = 6; // Auth token or cookie is otherwise invalid. |
| 331 } |
| 332 optional ERROR_TYPE error_code = 4 [default = SUCCESS]; |
| 333 optional string error_message = 5; |
| 334 |
| 335 // Opaque store ID; if it changes, the contents of the client's cache |
| 336 // is meaningless to this server. This happens most typically when |
| 337 // you switch from one storage backend instance (say, a test instance) |
| 338 // to another (say, the official instance). |
| 339 optional string store_birthday = 6; |
| 340 |
| 341 optional ClientCommand client_command = 7; |
| 342 optional ProfilingData profiling_data = 8; |
| 343 }; |
| 344 |
OLD | NEW |