drive.proto 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. // Protocol buffer definitions for representing Drive files and directories,
  6. // and serializing them for the resource metadata database.
  7. syntax = "proto2";
  8. option optimize_for = LITE_RUNTIME;
  9. package drive;
  10. // Represents base::PlatformFileInfo.
  11. message PlatformFileInfoProto {
  12. optional int64 size = 1;
  13. optional bool is_directory = 2;
  14. optional bool is_symbolic_link = 3;
  15. optional int64 last_modified = 4;
  16. optional int64 last_accessed = 5;
  17. optional int64 creation_time = 6;
  18. optional bool is_team_drive_root = 7;
  19. }
  20. // Represents a property for a file.
  21. message Property {
  22. optional string key = 1;
  23. optional string value = 2;
  24. // Visibility of the property. Either restricted to the same client, or
  25. // public.
  26. enum Visibility {
  27. PRIVATE = 0;
  28. PUBLIC = 1;
  29. }
  30. optional Visibility visibility = 3;
  31. }
  32. // Capabilities (current permissions) info for an entry.
  33. message CapabilitiesInfo {
  34. // Whether the current user can copy this file. For a Team Drive root, whether
  35. // the current user can copy files in this Team Drive.
  36. optional bool can_copy = 1;
  37. // Whether the current user can delete this file. For a Team Drive root,
  38. // whether the current user can delete the Team Drive.
  39. optional bool can_delete = 2;
  40. // Whether the current user can rename this file. For a Team Drive root,
  41. // whether the current user can rename the Team Drive.
  42. optional bool can_rename = 3;
  43. // Whether the current user can add children to this folder. For a Team Drive
  44. // root, whether the current user can add children to folders in this Team
  45. // Drive. This is always false when the item is not a folder or a Team Drive.
  46. optional bool can_add_children = 4;
  47. // Whether the current user can modify the sharing settings for this file. For
  48. // a Team Drive root, whether the current user can share files or folders in
  49. // this Team Drive.
  50. optional bool can_share = 5;
  51. }
  52. // File specific info, which is a part of ResourceEntry.
  53. message FileSpecificInfo {
  54. // The argument with ID 1 (thumbnail_url) had been used, but got deleted.
  55. // The argument with ID 2 (alternate_url) had been used, but got deleted.
  56. // Content mime type like "text/plain".
  57. optional string content_mime_type = 3;
  58. // The MD5 of contents of a regular file. Hosted files don't have MD5.
  59. optional string md5 = 4;
  60. // File extension, including the dot, used for hosted documents
  61. // (ex. ".gsheet" for hosted spreadsheets).
  62. optional string document_extension = 5;
  63. // True if the file is a hosted document (i.e. document hosted on
  64. // drive.google.com such as documents, spreadsheets, and presentations).
  65. optional bool is_hosted_document = 6;
  66. // The argument with ID 7 had been used, but got deleted.
  67. // Width of the media if the file is an image.
  68. optional int64 image_width = 8;
  69. // Height of the media if the file is an image.
  70. optional int64 image_height = 9;
  71. // Rotation of the image in clockwise degrees (if an image).
  72. optional int64 image_rotation = 10;
  73. // Cache related states.
  74. optional FileCacheEntry cache_state = 11;
  75. }
  76. // Represents metadata for a single team drive, store in the root entry.
  77. message TeamDriveRootSpecificInfo {
  78. // The individual start page token for this team drive.
  79. optional string start_page_token = 1;
  80. }
  81. // Directory specific info, which is a part of ResourceEntry.
  82. message DirectorySpecificInfo {
  83. // The changestamp of this directory. This value can be larger than the
  84. // changestamp of ResourceMetadata, if this directory was
  85. // "fast-fetched". See crbug.com/178348 for details about the "fast-fetch"
  86. // feature.
  87. // TODO(slangley): Remove changestamp once migration code can be removed.
  88. optional int64 changestamp = 1 [deprecated = true];
  89. // The start page token of this directory. This value may not match the
  90. // start_page_token of ResourceMetadata if the directory was "fast-fetched".
  91. optional string start_page_token = 2;
  92. // The last time we read this directory from the server when fast fetching.
  93. // This is used on initial load when we do not have the full list of files
  94. // fetched from the server to prevent repeated reading of the directory file
  95. // list.
  96. optional int64 last_read_time_ms = 3;
  97. }
  98. // Represents metadata of a resource (file or directory) on Drive.
  99. // Next Entry: 24
  100. message ResourceEntry {
  101. optional PlatformFileInfoProto file_info = 1;
  102. // Base name of the entry. The base name is used for file paths. Usually
  103. // identical to |title|, but some extra number is inserted if multiple
  104. // entries with the same title exist in the same directory, to ensure that
  105. // file paths are unique. For instance, if two files titled "foo.jpg" exist
  106. // in the same directory, which is allowed on drive.google.com, one of them
  107. // will have a base name of "foo (2).jpg".
  108. optional string base_name = 2;
  109. // Title of the entry. See the comment at |base_name|.
  110. optional string title = 3;
  111. // Resource ID of the entry. Guaranteed to be unique.
  112. optional string resource_id = 4;
  113. // Local ID of the entry.
  114. optional string local_id = 15;
  115. // Local ID of the parent entry.
  116. optional string parent_local_id = 7;
  117. // This field is used for processing the change list from the
  118. // server. Deleted entries won't be stored in ResourceMetadata.
  119. optional bool deleted = 11;
  120. // True if the entry is labeled "starred".
  121. optional bool starred = 20;
  122. // True if the entry is labeled with "shared-with-me", i.e., owned by someone
  123. // else initially and later shared to the current user.
  124. optional bool shared_with_me = 14;
  125. // True if the entry is labeled "shared". Either the entry itself or its
  126. // ancestor is shared (to the user from / by the user to) other accounts.
  127. optional bool shared = 17;
  128. // The capabilities (current permissions) for this file/folder/team drive.
  129. optional CapabilitiesInfo capabilities_info = 24;
  130. // File specific information, such as MD5.
  131. optional FileSpecificInfo file_specific_info = 9;
  132. // Directory specific information, such as changestamp.
  133. optional DirectorySpecificInfo directory_specific_info = 13;
  134. // Team Drive root specific information, if this entry is a team drive root.
  135. optional TeamDriveRootSpecificInfo team_drive_root_specific_info = 23;
  136. // Used to remember whether this entry is edited locally or not.
  137. enum EditState {
  138. CLEAN = 0; // No local edit.
  139. DIRTY = 1; // Edited locally.
  140. SYNCING = 2; // Local change is being synced to the server.
  141. }
  142. // Indicates whether this entry's metadata is edited locally or not.
  143. optional EditState metadata_edit_state = 16;
  144. // The time of the last modification. This is a timestamp used for conflict
  145. // resolution and can not be modified arbitrarily by users, in contrast to
  146. // PlatformFileInfoProto.last_modified and last_modified_by_me.
  147. optional int64 modification_date = 18;
  148. // List of new properties which are not synced yet via Drive API. Note, that
  149. // currently existing properties are never fetched via Drive API, as they are
  150. // never used. That would cause growing the proto size for no reason.
  151. repeated Property new_properties = 19;
  152. // The time of the last modification by the user. When the file is modified
  153. // by other users, this timestamp is not updated.
  154. // This timestamp is similar to last_modified in PlatformFileInfoProto rather
  155. // than modification_date; it will be set to the same value as last_modified
  156. // if the operation is done by the user. This field is here, not in
  157. // PlatformFileInfoProto, just because this field does not have a
  158. // corresponding field in base::File::Info.
  159. optional int64 last_modified_by_me = 21;
  160. // This URL is used for opening hosted documents with Google Drive's web
  161. // interface.
  162. optional string alternate_url = 22;
  163. }
  164. // Container for the header part of ResourceMetadata.
  165. message ResourceMetadataHeader {
  166. // Monotonically increasing version number, which is changed when
  167. // incompatible change is made to the DB format. kDBVersion in
  168. // resource_metadata_storage.h defines the current version.
  169. optional int32 version = 1;
  170. // TODO(slangley): Remove changestamp once migration code can be removed.
  171. optional int64 largest_changestamp = 2 [deprecated = true];
  172. // The argument with ID 3 (starred_property_initialized) had been used, but
  173. // got deleted.
  174. reserved 3;
  175. // The start_page_token for the users default corpus changelist.
  176. optional string start_page_token = 4;
  177. }
  178. // Message to store information of an existing cache file.
  179. message FileCacheEntry {
  180. // MD5 of the cache file.
  181. optional string md5 = 1;
  182. // True if the file is present locally.
  183. optional bool is_present = 2;
  184. // True if the file is pinned (i.e. available offline).
  185. optional bool is_pinned = 3;
  186. // True if the file is dirty (i.e. modified locally).
  187. optional bool is_dirty = 4;
  188. // When adding a new state, be sure to update TestFileCacheState and test
  189. // functions defined in test_util.cc.
  190. }