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_GDATA_GDATA_UTIL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UTIL_H_ |
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UTIL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 // Grants read-only file access permissions to the process whose id is |pid| | 56 // Grants read-only file access permissions to the process whose id is |pid| |
57 // with ChildProcessSecurityPolicy for all possible cache paths that may be | 57 // with ChildProcessSecurityPolicy for all possible cache paths that may be |
58 // given to the specified file. | 58 // given to the specified file. |
59 void SetPermissionsForGDataCacheFiles(Profile* profile, | 59 void SetPermissionsForGDataCacheFiles(Profile* profile, |
60 int pid, | 60 int pid, |
61 const FilePath& path); | 61 const FilePath& path); |
62 | 62 |
63 // Returns true if gdata is currently active with the specified profile. | 63 // Returns true if gdata is currently active with the specified profile. |
64 bool IsGDataAvailable(Profile* profile); | 64 bool IsGDataAvailable(Profile* profile); |
| 65 |
| 66 // Escapes a file name in GData cache. |
| 67 // Replaces percent ('%'), period ('.') and slash ('/') with %XX (hex) |
| 68 std::string EscapeCacheFileName(const std::string& filename); |
| 69 |
| 70 // Unescapes a file path in GData cache. |
| 71 // This is the inverse of EscapeCacheFileName. |
| 72 std::string UnescapeCacheFileName(const std::string& filename); |
| 73 |
| 74 // Extracts resource_id, md5, and extra_extension from cache path. |
| 75 // Case 1: Pinned and outgoing symlinks only have resource_id. |
| 76 // Example: path="/user/GCache/v1/pinned/pdf:a1b2" => |
| 77 // resource_id="pdf:a1b2", md5="", extra_extension=""; |
| 78 // Case 2: Normal files have both resource_id and md5. |
| 79 // Example: path="/user/GCache/v1/tmp/pdf:a1b2.01234567" => |
| 80 // resource_id="pdf:a1b2", md5="01234567", extra_extension=""; |
| 81 // Case 3: Mounted files have all three parts. |
| 82 // Example: path="/user/GCache/v1/persistent/pdf:a1b2.01234567.mounted" => |
| 83 // resource_id="pdf:a1b2", md5="01234567", extra_extension="mounted". |
| 84 void ParseCacheFilePath(const FilePath& path, |
| 85 std::string* resource_id, |
| 86 std::string* md5, |
| 87 std::string* extra_extension); |
65 } // namespace util | 88 } // namespace util |
66 } // namespace gdata | 89 } // namespace gdata |
67 | 90 |
68 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UTIL_H_ | 91 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UTIL_H_ |
OLD | NEW |