Chromium Code Reviews| Index: webkit/fileapi/file_system_url.cc |
| diff --git a/webkit/fileapi/file_system_url.cc b/webkit/fileapi/file_system_url.cc |
| index b69eda1d44f34eebd25e8038660f4edb1e952bab..93ee2ff3cdf8792e84394bdb762d6da521d12d9e 100644 |
| --- a/webkit/fileapi/file_system_url.cc |
| +++ b/webkit/fileapi/file_system_url.cc |
| @@ -42,6 +42,7 @@ bool CrackFileSystemURL( |
| { kFileSystemTypeExternal, kExternalDir }, |
| { kFileSystemTypeTest, kTestDir }, |
| }; |
| + |
| for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kValidTypes); ++i) { |
| if (StartsWithASCII(inner_path, kValidTypes[i].dir, true)) { |
| file_system_type = kValidTypes[i].type; |
| @@ -80,37 +81,86 @@ bool CrackFileSystemURL( |
| } // namespace |
| FileSystemURL::FileSystemURL() |
| - : type_(kFileSystemTypeUnknown), |
| - mount_type_(kFileSystemTypeUnknown), |
| - is_valid_(false) {} |
| + : is_valid_(false), |
| + is_cracked_(false), |
| + type_(kFileSystemTypeUnknown), |
| + mount_type_(kFileSystemTypeUnknown) { |
| +} |
| + |
| +// static |
| +FileSystemURL FileSystemURL::CreateForTest(const GURL& url) { |
| + return FileSystemURL(url); |
| +} |
| + |
| +FileSystemURL FileSystemURL::CreateForTest(const GURL& origin, |
| + FileSystemType type, |
| + const FilePath& path) { |
| + return FileSystemURL(origin, type, path); |
| +} |
| FileSystemURL::FileSystemURL(const GURL& url) |
| - : type_(kFileSystemTypeUnknown) { |
| - is_valid_ = CrackFileSystemURL(url, &origin_, &type_, &virtual_path_); |
| - MayCrackIsolatedPath(); |
| + : is_cracked_(false), |
| + type_(kFileSystemTypeUnknown), |
| + mount_type_(kFileSystemTypeUnknown) { |
| + is_valid_ = CrackFileSystemURL(url, &origin_, &type_, &path_); |
|
kinuko
2013/01/18 07:33:32
This overloaded verb 'crack' is now getting seriou
tbarzic
2013/01/18 21:33:15
Done.
|
| + mount_type_ = type_; |
| } |
| -FileSystemURL::FileSystemURL( |
| - const GURL& origin, |
| - FileSystemType type, |
| - const FilePath& path) |
| - : origin_(origin), |
| +FileSystemURL::FileSystemURL(const GURL& origin, |
| + FileSystemType type, |
| + const FilePath& path) |
| + : is_valid_(true), |
| + is_cracked_(false), |
| + origin_(origin), |
| type_(type), |
| - virtual_path_(path.NormalizePathSeparators()), |
| - is_valid_(true) { |
| - MayCrackIsolatedPath(); |
| + path_(path.NormalizePathSeparators()), |
| + mount_type_(type) { |
| +} |
| + |
| +FileSystemURL::FileSystemURL(const GURL& origin, |
| + FileSystemType original_type, |
| + const FilePath& original_path, |
| + const std::string& filesystem_id, |
| + FileSystemType cracked_type, |
| + const FilePath& cracked_path) |
| + : is_valid_(true), |
| + is_cracked_(true), |
| + origin_(origin), |
| + type_(cracked_type), |
| + path_(cracked_path.NormalizePathSeparators()), |
| + filesystem_id_(filesystem_id), |
| + mount_type_(original_type), |
| + virtual_path_(original_path) { |
| } |
| FileSystemURL::~FileSystemURL() {} |
| +// static |
| +FileSystemURL FileSystemURL::CreateForCrackedURL( |
| + const FileSystemURL& original, |
| + const std::string& filesystem_id, |
| + FileSystemType cracked_type, |
| + const FilePath& cracked_path) { |
| + if (!original.is_valid()) |
| + return FileSystemURL(); |
| + return FileSystemURL(original.origin(), |
| + original.type(), |
| + original.path(), |
| + filesystem_id, |
| + cracked_type, |
| + cracked_path); |
| +} |
| + |
| std::string FileSystemURL::DebugString() const { |
| if (!is_valid_) |
| return "invalid filesystem: URL"; |
| std::ostringstream ss; |
| ss << GetFileSystemRootURI(origin_, mount_type_); |
| - if (!virtual_path_.empty()) |
| + if (!is_cracked_ && !path_.empty()) |
| + ss << path_.value(); |
| + |
| + if (is_cracked_) { |
| ss << virtual_path_.value(); |
| - if (type_ != mount_type_ || path_ != virtual_path_) { |
| ss << " ("; |
| ss << GetFileSystemTypeString(type_) << "@" << filesystem_id_ << ":"; |
| ss << path_.value(); |
| @@ -153,19 +203,4 @@ bool FileSystemURL::Comparator::operator()(const FileSystemURL& lhs, |
| return lhs.path_ < rhs.path_; |
| } |
| -void FileSystemURL::MayCrackIsolatedPath() { |
| - path_ = virtual_path_; |
| - mount_type_ = type_; |
| - if (is_valid_ && IsolatedContext::IsIsolatedType(type_)) { |
| - // If the type is isolated, crack the path further to get the 'real' |
| - // filesystem type and path. |
| - is_valid_ = ExternalMountPoints::GetSystemInstance()->CrackVirtualPath( |
| - virtual_path_, &filesystem_id_, &type_, &path_); |
| - if (is_valid_) |
| - return; |
| - is_valid_ = IsolatedContext::GetInstance()->CrackVirtualPath( |
| - virtual_path_, &filesystem_id_, &type_, &path_); |
| - } |
| -} |
| - |
| } // namespace fileapi |