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 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_RESOURCE_ENTRY_CONVERSION_H_
      6 #define CHROME_BROWSER_CHROMEOS_DRIVE_RESOURCE_ENTRY_CONVERSION_H_
      7 
      8 #include <string>
      9 
     10 namespace base {
     11 struct PlatformFileInfo;
     12 }
     13 
     14 namespace google_apis {
     15 class ResourceEntry;
     16 }
     17 
     18 namespace drive {
     19 
     20 class ResourceEntry;
     21 
     22 // Converts a google_apis::ResourceEntry into a drive::ResourceEntry.
     23 // If the conversion succeeded, return true and sets the result to |out_entry|.
     24 // |out_parent_resource_id| will be set to the resource ID of the parent entry.
     25 // If failed, it returns false and keeps output arguments untouched.
     26 //
     27 // Every entry is guaranteed to have one parent resource ID in ResourceMetadata.
     28 // This requirement is needed to represent contents in Drive as a file system
     29 // tree, and achieved as follows:
     30 //
     31 // 1) Entries without parents are allowed on drive.google.com. These entries are
     32 // collected to "drive/other", and have "drive/other" as the parent.
     33 //
     34 // 2) Entries with multiple parents are allowed on drive.google.com. For these
     35 // entries, the first parent is chosen.
     36 bool ConvertToResourceEntry(const google_apis::ResourceEntry& input,
     37                             ResourceEntry* out_entry,
     38                             std::string* out_parent_resource_id);
     39 
     40 // Converts the resource entry to the platform file info.
     41 void ConvertResourceEntryToPlatformFileInfo(const ResourceEntry& entry,
     42                                             base::PlatformFileInfo* file_info);
     43 
     44 // Converts the platform file info and sets it to the .file_info field of
     45 // the resource entry.
     46 void SetPlatformFileInfoToResourceEntry(const base::PlatformFileInfo& file_info,
     47                                         ResourceEntry* entry);
     48 
     49 }  // namespace drive
     50 
     51 #endif  // CHROME_BROWSER_CHROMEOS_DRIVE_RESOURCE_ENTRY_CONVERSION_H_
     52