Home | History | Annotate | Download | only in drive
      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 
      8 syntax = "proto2";
      9 
     10 option optimize_for = LITE_RUNTIME;
     11 
     12 package drive;
     13 
     14 // Represents base::PlatformFileInfo.
     15 message PlatformFileInfoProto {
     16   optional int64 size = 1;
     17   optional bool is_directory = 2;
     18   optional bool is_symbolic_link = 3;
     19   optional int64 last_modified = 4;
     20   optional int64 last_accessed = 5;
     21   optional int64 creation_time = 6;
     22 }
     23 
     24 // File specific info, which is a part of ResourceEntry.
     25 message FileSpecificInfo {
     26   // This URL points to a thumbnail image. The thumbnail URL is not permanent
     27   // as it's not protected by authentication. See crbug.com/127697 for how
     28   // stale thumbnail URLs are handled.
     29   optional string thumbnail_url = 1;
     30 
     31   // This URL is used for opening hosted documents with Google Drive's web
     32   // interface.
     33   optional string alternate_url = 2;
     34 
     35   // Content mime type like "text/plain".
     36   optional string content_mime_type = 3;
     37 
     38   // The MD5 of contents of a regular file. Hosted files don't have MD5.
     39   optional string md5 = 4;
     40 
     41   // File extension, including the dot, used for hosted documents
     42   // (ex. ".gsheet" for hosted spreadsheets).
     43   optional string document_extension = 5;
     44 
     45   // True if the file is a hosted document (i.e. document hosted on
     46   // drive.google.com such as documents, spreadsheets, and presentations).
     47   optional bool is_hosted_document = 6;
     48 
     49   // The argument with ID 7 had been used, but got deleted. Next ID to use: 8.
     50 }
     51 
     52 // Directory specific info, which is a part of ResourceEntry.
     53 message DirectorySpecificInfo {
     54   // The changestamp of this directory. This value can be larger than the
     55   // changestamp of ResourceMetadata, if this directory was
     56   // "fast-fetched". See crbug.com/178348 for details about the "fast-fetch"
     57   // feature.
     58   optional int64 changestamp = 1;
     59 }
     60 
     61 // Represents metadata of a resource (file or directory) on Drive.
     62 message ResourceEntry {
     63   optional PlatformFileInfoProto file_info = 1;
     64   // Base name of the entry. The base name is used for file paths. Usually
     65   // identical to |title|, but some extra number is inserted if multiple
     66   // entries with the same title exist in the same directory, to ensure that
     67   // file paths are unique. For instance, if two files titled "foo.jpg" exist
     68   // in the same directory, which is allowed on drive.google.com, one of them
     69   // will have a base name of "foo (2).jpg".
     70   optional string base_name = 2;
     71 
     72   // Title of the entry. See the comment at |base_name|.
     73   optional string title = 3;
     74 
     75   // Resource ID of the entry. Guaranteed to be unique.
     76   optional string resource_id = 4;
     77 
     78   // Resource ID of the parent entry. Every entry is guaranteed to have the
     79   // single parent resource ID in ResourceMetadata. This requirement is
     80   // needed to represent contents in Drive as a file system tree, and
     81   // achieved as follows:
     82   //
     83   // 1) Entries without parents are allowed on drive.google.com. These
     84   // entries are collected to "drive/other", and have the resource ID of
     85   // "drive/other" as the parent resource ID.
     86   //
     87   // 2) Entries with multiple parents are allowed on drive.google.com. For
     88   // these entries, the first parent resource ID is chosen.
     89   optional string parent_resource_id = 7;
     90 
     91   // This field is used for processing the change list from the
     92   // server. Deleted entries won't be stored in ResourceMetadata.
     93   optional bool deleted = 11;
     94 
     95   // True if the entry is labeled with "shared-with-me".
     96   optional bool shared_with_me = 14;
     97 
     98   // File specific information, such as MD5.
     99   optional FileSpecificInfo file_specific_info = 9;
    100 
    101   // Directory specific information, such as changestamp.
    102   optional DirectorySpecificInfo directory_specific_info = 13;
    103 }
    104 
    105 // Container for the header part of ResourceMetadata.
    106 message ResourceMetadataHeader {
    107   // Monotonically increasing version number, which is changed when
    108   // incompatible change is made to the DB format. kDBVersion in
    109   // drive_resource_metadata_storage.h defines the current version.
    110   optional int32 version = 1;
    111   optional int64 largest_changestamp = 2;
    112 }
    113 
    114 // Message to store information of an existing cache file.
    115 message FileCacheEntry {
    116   // MD5 of the cache file. "local" if the file is locally modified.
    117   optional string md5 = 1;
    118 
    119   // True if the file is present locally.
    120   optional bool is_present = 2;
    121 
    122   // True if the file is pinned (i.e. available offline).
    123   optional bool is_pinned = 3;
    124 
    125   // True if the file is dirty (i.e. modified locally).
    126   optional bool is_dirty = 4;
    127 
    128   // TODO(hashimoto): Remove this block after DB merge. crbug.com/234487
    129   // True if the file is in the persistent directory.
    130   // optional bool is_persistent = 6;
    131 
    132   // When adding a new state, be sure to update TestFileCacheState and test
    133   // functions defined in drive_test_util.cc.
    134 }
    135