Chromium Code Reviews| Index: chrome/browser/chromeos/gdata/gdata_util.cc |
| diff --git a/chrome/browser/chromeos/gdata/gdata_util.cc b/chrome/browser/chromeos/gdata/gdata_util.cc |
| index 21b2129545f7d2c4d4b46cc9158281245b47ca04..5c22ad3cb11dd284343c05fad19be4f760749010 100644 |
| --- a/chrome/browser/chromeos/gdata/gdata_util.cc |
| +++ b/chrome/browser/chromeos/gdata/gdata_util.cc |
| @@ -221,6 +221,11 @@ void InsertGDataCachePathsPermissions( |
| kReadOnlyFilePermissions)); |
| cache_paths->push_back(std::make_pair( |
| file_system->GetCacheFilePath(resource_id, file_md5, |
| + GDataRootDirectory::CACHE_TYPE_PERSISTENT, |
| + GDataFileSystem::CACHED_FILE_MOUNTED), |
| + kReadOnlyFilePermissions)); |
| + cache_paths->push_back(std::make_pair( |
| + file_system->GetCacheFilePath(resource_id, file_md5, |
| GDataRootDirectory::CACHE_TYPE_TMP, |
| GDataFileSystem::CACHED_FILE_FROM_SERVER), |
| kReadOnlyFilePermissions)); |
| @@ -259,5 +264,46 @@ bool IsGDataAvailable(Profile* profile) { |
| return true; |
| } |
| +// Extracts resource_id, md5, and extra_suffix from cache path. |
| +// Pinned and outgoing symlinks have no md5 extension. |
| +// The extra_suffix is only non-empty for mounted archives. |
|
satorux1
2012/04/20 21:46:10
We usually don't have a function comment in .cc fi
|
| +void ParseCacheFilePath(const FilePath& path, |
| + std::string* resource_id, |
| + std::string* md5, |
| + std::string* extra_suffix) |
| +{ |
|
satorux1
2012/04/20 21:46:10
move { to the previous line.
|
| + DCHECK(resource_id); |
| + DCHECK(md5); |
| + DCHECK(extra_suffix); |
| + |
| + // Extract up to two extensions from the right. |
| + FilePath base_name = path.BaseName(); |
| + int num_extensions; |
|
satorux1
2012/04/20 21:46:10
please initialize this with 0, to be extra defensi
|
| + FilePath::StringType extension[2]; |
|
satorux1
2012/04/20 21:46:10
extension -> extensions
|
| + for (num_extensions = 0; num_extensions < 2; ++num_extensions) { |
|
satorux1
2012/04/20 21:46:10
rather than 2, please do arraysize(extensions)
|
| + extension[num_extensions] = base_name.Extension(); |
| + if (!extension[num_extensions].empty()) { |
| + // FilePath::Extension returns ".", so strip it. |
| + extension[num_extensions] = |
|
satorux1
2012/04/20 21:46:10
instead of using a fixed array, using vector<> and
|
| + GDataEntry::UnescapeUtf8FileName(extension[num_extensions].substr(1)); |
| + base_name = base_name.RemoveExtension(); |
| + } else { |
| + break; |
| + } |
| + } |
| + |
| + *resource_id = GDataEntry::UnescapeUtf8FileName( |
| + base_name.RemoveExtension().value()); |
| + if (num_extensions == 2) { |
| + // The extra_suffix is non-empty: "<resource_id>.<md5>.<extra_suffix>". |
| + *extra_suffix = extension[0]; |
| + *md5 = extension[1]; |
| + } else { |
| + // The extra_suffix is not present: "<resource_id>.<md5>". |
| + *extra_suffix = std::string(); |
| + *md5 = extension[0]; |
| + } |
| +} |
| + |
| } // namespace util |
| } // namespace gdata |