Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / drive / resource_entry_conversion.h
blob2de228e7e08855f2bed4f9634dd83598518af29c
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 COMPONENTS_DRIVE_RESOURCE_ENTRY_CONVERSION_H_
6 #define COMPONENTS_DRIVE_RESOURCE_ENTRY_CONVERSION_H_
8 #include <string>
10 #include "base/files/file.h"
12 namespace google_apis {
13 class ChangeResource;
14 class FileResource;
17 namespace drive {
19 class ResourceEntry;
21 // Converts a google_apis::ChangeResource into a drive::ResourceEntry.
22 // If the conversion succeeded, return true and sets the result to |out_entry|.
23 // |out_parent_resource_id| will be set to the resource ID of the parent entry.
24 // If failed, it returns false and keeps output arguments untouched.
26 // Every entry is guaranteed to have one parent resource ID in ResourceMetadata.
27 // This requirement is needed to represent contents in Drive as a file system
28 // tree, and achieved as follows:
30 // 1) Entries without parents are allowed on drive.google.com. These entries are
31 // collected to "drive/other", and have "drive/other" as the parent.
33 // 2) Entries with multiple parents are allowed on drive.google.com. For these
34 // entries, the first parent is chosen.
35 bool ConvertChangeResourceToResourceEntry(
36 const google_apis::ChangeResource& input,
37 ResourceEntry* out_entry,
38 std::string* out_parent_resource_id);
40 // Converts a google_apis::FileResource into a drive::ResourceEntry.
41 // Also see the comment for ConvertChangeResourceToResourceEntry above.
42 bool ConvertFileResourceToResourceEntry(
43 const google_apis::FileResource& input,
44 ResourceEntry* out_entry,
45 std::string* out_parent_resource_id);
47 // Converts the resource entry to the platform file info.
48 void ConvertResourceEntryToFileInfo(const ResourceEntry& entry,
49 base::File::Info* file_info);
51 } // namespace drive
53 #endif // COMPONENTS_DRIVE_RESOURCE_ENTRY_CONVERSION_H_