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.
5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_RESOURCE_ENTRY_CONVERSION_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_RESOURCE_ENTRY_CONVERSION_H_
11 struct PlatformFileInfo;
14 namespace google_apis {
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.
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:
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.
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);
40 // Converts the resource entry to the platform file info.
41 void ConvertResourceEntryToPlatformFileInfo(const ResourceEntry& entry,
42 base::PlatformFileInfo* file_info);
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);
51 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_RESOURCE_ENTRY_CONVERSION_H_