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