diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-08 08:28:42 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-08 08:28:42 +0000 |
commit | 04c899fc2000109f747573413ab5174b6d38830e (patch) | |
tree | 63b3ec7a67d95dd830f320c1f913cf4683159c14 /webkit/fileapi | |
parent | cefe7529d1f24e7316c4b5a929bb3cbefffe1c02 (diff) | |
download | chromium_src-04c899fc2000109f747573413ab5174b6d38830e.zip chromium_src-04c899fc2000109f747573413ab5174b6d38830e.tar.gz chromium_src-04c899fc2000109f747573413ab5174b6d38830e.tar.bz2 |
Always populate FileSystemURL::virtual_path and deprecate WithPath() method
Since we no longer have is_craced flag it's hard to tell if
the given FileSystemURL has proper virtual_path or not.
(It's possible to have empty virtual_path even for the filesystems
that must have virtual_path, and it's hard to distinguish the case.)
I want to always populate the field for any filesystem types
and also want to deprecate WithPath() method as it's not very
consistent with other FileSystemURL construction methods.
BUG=174576
TEST=existing
Review URL: https://chromiumcodereview.appspot.com/12221042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181460 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi')
-rw-r--r-- | webkit/fileapi/cross_operation_delegate.cc | 10 | ||||
-rw-r--r-- | webkit/fileapi/file_system_context_unittest.cc | 20 | ||||
-rw-r--r-- | webkit/fileapi/file_system_url.cc | 12 | ||||
-rw-r--r-- | webkit/fileapi/file_system_url.h | 30 | ||||
-rw-r--r-- | webkit/fileapi/local_file_system_cross_operation_unittest.cc | 12 | ||||
-rw-r--r-- | webkit/fileapi/obfuscated_file_util_unittest.cc | 108 | ||||
-rw-r--r-- | webkit/fileapi/recursive_operation_delegate.cc | 10 | ||||
-rw-r--r-- | webkit/fileapi/recursive_operation_delegate.h | 1 |
8 files changed, 126 insertions, 77 deletions
diff --git a/webkit/fileapi/cross_operation_delegate.cc b/webkit/fileapi/cross_operation_delegate.cc index 47a405f..08e7865 100644 --- a/webkit/fileapi/cross_operation_delegate.cc +++ b/webkit/fileapi/cross_operation_delegate.cc @@ -222,9 +222,13 @@ FileSystemURL CrossOperationDelegate::CreateDestURL( DCHECK_EQ(src_root_.type(), src_url.type()); DCHECK_EQ(src_root_.origin(), src_url.origin()); - base::FilePath path = dest_root_.path(); - src_root_.path().AppendRelativePath(src_url.path(), &path); - return dest_root_.WithPath(path); + base::FilePath relative = dest_root_.virtual_path(); + src_root_.virtual_path().AppendRelativePath(src_url.virtual_path(), + &relative); + return file_system_context()->CreateCrackedFileSystemURL( + dest_root_.origin(), + dest_root_.mount_type(), + relative); } LocalFileSystemOperation* CrossOperationDelegate::NewDestOperation( diff --git a/webkit/fileapi/file_system_context_unittest.cc b/webkit/fileapi/file_system_context_unittest.cc index 7e82118..b72929c 100644 --- a/webkit/fileapi/file_system_context_unittest.cc +++ b/webkit/fileapi/file_system_context_unittest.cc @@ -226,7 +226,6 @@ TEST_F(FileSystemContextTest, CrackFileSystemURL) { FileSystemType expect_mount_type; FileSystemType expect_type; const base::FilePath::CharType* expect_path; - bool expect_virtual_path_empty; std::string expect_filesystem_id; }; @@ -235,41 +234,40 @@ TEST_F(FileSystemContextTest, CrackFileSystemURL) { { "pers_mount", "persistent", true /* is_valid */, kFileSystemTypePersistent, kFileSystemTypePersistent, - FPL("pers_mount/root/file"), true /* virtual path empty */, + FPL("pers_mount/root/file"), std::string() /* filesystem id */ }, { "temp_mount", "temporary", true /* is_valid */, kFileSystemTypeTemporary, kFileSystemTypeTemporary, - FPL("temp_mount/root/file"), true /* virtual path empty */, + FPL("temp_mount/root/file"), std::string() /* filesystem id */ }, // Should be cracked by isolated mount points: { kIsolatedFileSystemID, "isolated", true /* is_valid */, kFileSystemTypeIsolated, kFileSystemTypeNativeLocal, - DRIVE FPL("/test/isolated/root/file"), false /* virtual path empty */, + DRIVE FPL("/test/isolated/root/file"), kIsolatedFileSystemID }, // Should be cracked by system mount points: { "system", "external", true /* is_valid */, kFileSystemTypeExternal, kFileSystemTypeDrive, - DRIVE FPL("/test/sys/root/file"), false /* virtual path empty */, + DRIVE FPL("/test/sys/root/file"), "system" }, { kIsolatedFileSystemID, "external", true /* is_valid */, kFileSystemTypeExternal, kFileSystemTypeRestrictedNativeLocal, DRIVE FPL("/test/system/isolated/root/file"), - false /* virtual path empty */, kIsolatedFileSystemID }, // Should be cracked by FileSystemContext's ExternalMountPoints. { "ext", "external", true /* is_valid */, kFileSystemTypeExternal, kFileSystemTypeNativeLocal, - DRIVE FPL("/test/local/ext/root/file"), false /* virtual path empty */, + DRIVE FPL("/test/local/ext/root/file"), "ext" }, // Test for invalid filesystem url (made invalid by adding invalid @@ -277,14 +275,14 @@ TEST_F(FileSystemContextTest, CrackFileSystemURL) { { "sytem", "external", false /* is_valid */, // The rest of values will be ignored. - kFileSystemTypeUnknown, kFileSystemTypeUnknown, FPL(""), true, + kFileSystemTypeUnknown, kFileSystemTypeUnknown, FPL(""), std::string() }, // Test for URL with non-existing filesystem id. { "invalid", "external", false /* is_valid */, // The rest of values will be ignored. - kFileSystemTypeUnknown, kFileSystemTypeUnknown, FPL(""), true, + kFileSystemTypeUnknown, kFileSystemTypeUnknown, FPL(""), std::string() }, }; @@ -310,8 +308,7 @@ TEST_F(FileSystemContextTest, CrackFileSystemURL) { kTestCases[i].expect_mount_type, kTestCases[i].expect_type, base::FilePath(kTestCases[i].expect_path).NormalizePathSeparators(), - kTestCases[i].expect_virtual_path_empty ? - base::FilePath() : virtual_path.NormalizePathSeparators(), + virtual_path.NormalizePathSeparators(), kTestCases[i].expect_filesystem_id); } @@ -326,4 +323,3 @@ TEST_F(FileSystemContextTest, CrackFileSystemURL) { } // namespace } // namespace fileapi - diff --git a/webkit/fileapi/file_system_url.cc b/webkit/fileapi/file_system_url.cc index 5f38e53..e77cb1a 100644 --- a/webkit/fileapi/file_system_url.cc +++ b/webkit/fileapi/file_system_url.cc @@ -100,6 +100,7 @@ FileSystemURL::FileSystemURL(const GURL& url) : type_(kFileSystemTypeUnknown), mount_type_(kFileSystemTypeUnknown) { is_valid_ = ParseFileSystemURL(url, &origin_, &type_, &path_); + virtual_path_ = path_; mount_type_ = type_; } @@ -110,22 +111,23 @@ FileSystemURL::FileSystemURL(const GURL& origin, origin_(origin), type_(type), mount_type_(type), - path_(path.NormalizePathSeparators()) { + path_(path.NormalizePathSeparators()), + virtual_path_(path.NormalizePathSeparators()) { } FileSystemURL::FileSystemURL(const GURL& origin, - FileSystemType original_type, - const base::FilePath& original_path, + FileSystemType mount_type, + const base::FilePath& virtual_path, const std::string& filesystem_id, FileSystemType cracked_type, const base::FilePath& cracked_path) : is_valid_(true), origin_(origin), type_(cracked_type), - mount_type_(original_type), + mount_type_(mount_type), path_(cracked_path.NormalizePathSeparators()), filesystem_id_(filesystem_id), - virtual_path_(original_path.NormalizePathSeparators()) { + virtual_path_(virtual_path.NormalizePathSeparators()) { } FileSystemURL::~FileSystemURL() {} diff --git a/webkit/fileapi/file_system_url.h b/webkit/fileapi/file_system_url.h index 99b187b..f4eacd0 100644 --- a/webkit/fileapi/file_system_url.h +++ b/webkit/fileapi/file_system_url.h @@ -23,8 +23,10 @@ namespace fileapi { // // Example: For a URL 'filesystem:http://foo.com/temporary/foo/bar': // origin() returns 'http://foo.com', -// type() and mount_type() return kFileSystemTypeTemporary, +// type() returns kFileSystemTypeTemporary, // path() returns 'foo/bar', +// virtual_path() returns the same value as path() +// mount_type() returns the same value as type() // // All other accessors return empty or invalid value. // @@ -49,12 +51,16 @@ namespace fileapi { // origin() returns 'http://bar.com', // type() returns the kFileSystemTypeFoo, // path() returns '/media/removable/foo/bar', -// -// Additionally, following accessors would return valid values: -// filesystem_id() returns 'mount_name', and // virtual_path() returns 'mount_name/foo/bar', // mount_type() returns kFileSystemTypeExternal. // +// Note that in either case virtual_path() always returns the path part after +// 'type' part in the original URL, and mount_type() always returns the 'type' +// part in the original URL. +// +// Additionally, following accessors would return valid values: +// filesystem_id() returns 'mount_name'. +// // It is imposible to directly create a valid FileSystemURL instance (except by // using CreatedForTest methods, which should not be used in production code). // To get a valid FileSystemURL, one of the following methods can be used: @@ -76,8 +82,8 @@ class WEBKIT_STORAGE_EXPORT FileSystemURL { // Should be used only in tests. static FileSystemURL CreateForTest(const GURL& url); static FileSystemURL CreateForTest(const GURL& origin, - FileSystemType type, - const base::FilePath& path); + FileSystemType mount_type, + const base::FilePath& virtual_path); // Returns true if this instance represents a valid FileSystem URL. bool is_valid() const { return is_valid_; } @@ -105,13 +111,15 @@ class WEBKIT_STORAGE_EXPORT FileSystemURL { std::string DebugString() const; - // Returns a new FileSystemURL with the given path. + // DEPRECATED: Returns a new FileSystemURL with the given path. // This creates a new FileSystemURL, copies all fields of this instance // to that one, resets the path_ to the given |path| and resets the // virtual_path to *empty*. // Note that the resulting FileSystemURL loses original URL information // if it was a cracked filesystem; i.e. virtual_path and mount_type will // be set to empty values. + // + // TODO(kinuko): deprecate this. http://crbug.com/174576 FileSystemURL WithPath(const base::FilePath& path) const; // Returns true if this URL is a strict parent of the |child|. @@ -130,12 +138,12 @@ class WEBKIT_STORAGE_EXPORT FileSystemURL { explicit FileSystemURL(const GURL& filesystem_url); FileSystemURL(const GURL& origin, - FileSystemType type, - const base::FilePath& internal_path); + FileSystemType mount_type, + const base::FilePath& virtual_path); // Creates a cracked FileSystemURL. FileSystemURL(const GURL& origin, - FileSystemType original_type, - const base::FilePath& original_path, + FileSystemType mount_type, + const base::FilePath& virtual_path, const std::string& filesystem_id, FileSystemType cracked_type, const base::FilePath& cracked_path); diff --git a/webkit/fileapi/local_file_system_cross_operation_unittest.cc b/webkit/fileapi/local_file_system_cross_operation_unittest.cc index ad1d748..9a6da2d 100644 --- a/webkit/fileapi/local_file_system_cross_operation_unittest.cc +++ b/webkit/fileapi/local_file_system_cross_operation_unittest.cc @@ -194,7 +194,10 @@ class CrossOperationTestHelper { base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED; for (size_t i = 0; i < test_case_size; ++i) { const test::TestCaseRecord& test_case = test_cases[i]; - FileSystemURL url = root.WithPath(root.path().Append(test_case.path)); + FileSystemURL url = file_system_context_->CreateCrackedFileSystemURL( + root.origin(), + root.mount_type(), + root.virtual_path().Append(test_case.path)); if (test_case.is_directory) result = CreateDirectory(url); else @@ -223,9 +226,12 @@ class CrossOperationTestHelper { directories.pop(); ASSERT_EQ(base::PLATFORM_FILE_OK, ReadDirectory(dir, &entries)); for (size_t i = 0; i < entries.size(); ++i) { - FileSystemURL url = dir.WithPath(dir.path().Append(entries[i].name)); + FileSystemURL url = file_system_context_->CreateCrackedFileSystemURL( + dir.origin(), + dir.mount_type(), + dir.virtual_path().Append(entries[i].name)); FilePath relative; - root.path().AppendRelativePath(url.path(), &relative); + root.virtual_path().AppendRelativePath(url.virtual_path(), &relative); relative = relative.NormalizePathSeparators(); ASSERT_TRUE(ContainsKey(test_case_map, relative)); if (entries[i].is_directory) { diff --git a/webkit/fileapi/obfuscated_file_util_unittest.cc b/webkit/fileapi/obfuscated_file_util_unittest.cc index ef0f2bc..40cee9c 100644 --- a/webkit/fileapi/obfuscated_file_util_unittest.cc +++ b/webkit/fileapi/obfuscated_file_util_unittest.cc @@ -89,6 +89,25 @@ const OriginEnumerationTestRecord kOriginEnumerationTestRecords[] = { {"http://example.com:8000", false, true}, }; +FileSystemURL FileSystemURLAppend( + const FileSystemURL& url, const FilePath::StringType& child) { + return FileSystemURL::CreateForTest( + url.origin(), url.mount_type(), url.virtual_path().Append(child)); +} + +FileSystemURL FileSystemURLAppendUTF8( + const FileSystemURL& url, const std::string& child) { + return FileSystemURL::CreateForTest( + url.origin(), + url.mount_type(), + url.virtual_path().Append(FilePath::FromUTF8Unsafe(child))); +} + +FileSystemURL FileSystemURLDirName(const FileSystemURL& url) { + return FileSystemURL::CreateForTest( + url.origin(), url.mount_type(), url.virtual_path().DirName()); +} + } // namespace (anonymous) // TODO(ericu): The vast majority of this and the other FSFU subclass tests @@ -335,14 +354,14 @@ class ObfuscatedFileUtilTest : public testing::Test { context.reset(NewContext(NULL)); ASSERT_EQ(base::PLATFORM_FILE_OK, ofu()->EnsureFileExists( - context.get(), root_url.WithPath(root_url.path().Append(*iter)), + context.get(), FileSystemURLAppend(root_url, *iter), &created)); ASSERT_FALSE(created); } for (iter = directories.begin(); iter != directories.end(); ++iter) { context.reset(NewContext(NULL)); EXPECT_TRUE(DirectoryExists( - root_url.WithPath(root_url.path().Append(*iter)))); + FileSystemURLAppend(root_url, *iter))); } } @@ -415,7 +434,7 @@ class ObfuscatedFileUtilTest : public testing::Test { ASSERT_EQ(base::PLATFORM_FILE_OK, ofu()->EnsureFileExists( context.get(), - root_url.WithPath(root_url.path().Append(*iter)), + FileSystemURLAppend(root_url, *iter), &created)); ASSERT_TRUE(created); } @@ -425,7 +444,8 @@ class ObfuscatedFileUtilTest : public testing::Test { context.reset(NewContext(NULL)); EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory( - context.get(), root_url.WithPath(root_url.path().Append(*iter)), + context.get(), + FileSystemURLAppend(root_url, *iter), exclusive, recursive)); } ValidateTestDirectory(root_url, *files, *directories); @@ -584,15 +604,15 @@ class ObfuscatedFileUtilTest : public testing::Test { bool copy, bool overwrite) { scoped_ptr<FileSystemOperationContext> context; - const FileSystemURL src_dir_url(base_dir.WithPath( - base_dir.path().AppendASCII("foo_dir"))); - const FileSystemURL dest_dir_url(base_dir.WithPath( - base_dir.path().AppendASCII("bar_dir"))); + const FileSystemURL src_dir_url( + FileSystemURLAppendUTF8(base_dir, "foo_dir")); + const FileSystemURL dest_dir_url( + FileSystemURLAppendUTF8(base_dir, "bar_dir")); - const FileSystemURL src_file_url(src_dir_url.WithPath( - src_dir_url.path().AppendASCII("hoge"))); - const FileSystemURL dest_file_url(dest_dir_url.WithPath( - dest_dir_url.path().AppendASCII("fuga"))); + const FileSystemURL src_file_url( + FileSystemURLAppendUTF8(src_dir_url, "hoge")); + const FileSystemURL dest_file_url( + FileSystemURLAppendUTF8(dest_dir_url, "fuga")); context.reset(NewContext(NULL)); EXPECT_EQ(base::PLATFORM_FILE_OK, @@ -714,7 +734,7 @@ TEST_F(ObfuscatedFileUtilTest, TestCreateAndDeleteFile) { bool recursive = true; FileSystemURL directory_url = CreateURLFromUTF8( "series/of/directories"); - url = directory_url.WithPath(directory_url.path().AppendASCII("file name")); + url = FileSystemURLAppendUTF8(directory_url, "file name"); EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory( context.get(), directory_url, exclusive, recursive)); // The oepration created 3 directories recursively. @@ -895,7 +915,7 @@ TEST_F(ObfuscatedFileUtilTest, TestEnsureFileExists) { bool recursive = true; EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory( context.get(), - url.WithPath(url.path().DirName()), + FileSystemURLDirName(url), exclusive, recursive)); // 2 directories: path/ and path/to. EXPECT_EQ(2, change_observer()->get_and_reset_create_directory_count()); @@ -940,17 +960,17 @@ TEST_F(ObfuscatedFileUtilTest, TestDirectoryOps) { context.reset(NewContext(NULL)); EXPECT_FALSE(ofu()->IsDirectoryEmpty(context.get(), root)); - EXPECT_TRUE(DirectoryExists(url.WithPath(url.path().DirName()))); + EXPECT_TRUE(DirectoryExists(FileSystemURLDirName(url))); context.reset(NewContext(NULL)); EXPECT_FALSE(ofu()->IsDirectoryEmpty(context.get(), - url.WithPath(url.path().DirName()))); + FileSystemURLDirName(url))); // Can't remove a non-empty directory. context.reset(NewContext(NULL)); EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_EMPTY, ofu()->DeleteDirectory(context.get(), - url.WithPath(url.path().DirName()))); + FileSystemURLDirName(url))); EXPECT_TRUE(change_observer()->HasNoChange()); base::PlatformFileInfo file_info; @@ -1141,8 +1161,9 @@ TEST_F(ObfuscatedFileUtilTest, TestPathQuotas) { std::vector<base::FilePath::StringType> components; url.path().GetComponents(&components); path_cost = 0; - for (std::vector<base::FilePath::StringType>::iterator iter = components.begin(); - iter != components.end(); ++iter) { + typedef std::vector<base::FilePath::StringType>::iterator iterator; + for (iterator iter = components.begin(); + iter != components.end(); ++iter) { path_cost += ObfuscatedFileUtil::ComputeFilePathCost( base::FilePath(*iter)); } @@ -1175,7 +1196,7 @@ TEST_F(ObfuscatedFileUtilTest, TestCopyOrMoveFileNotFound) { context.reset(NewContext(NULL)); ASSERT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory( context.get(), - source_url.WithPath(source_url.path().DirName()), + FileSystemURLDirName(source_url), exclusive, recursive)); EXPECT_EQ(2, change_observer()->get_and_reset_create_directory_count()); is_copy_not_move = false; @@ -1216,12 +1237,12 @@ TEST_F(ObfuscatedFileUtilTest, TestCopyOrMoveFileSuccess) { context.reset(NewContext(NULL)); ASSERT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory( context.get(), - source_url.WithPath(source_url.path().DirName()), + FileSystemURLDirName(source_url), exclusive, recursive)); context.reset(NewContext(NULL)); ASSERT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory( context.get(), - dest_url.WithPath(dest_url.path().DirName()), + FileSystemURLDirName(dest_url), exclusive, recursive)); bool created = false; @@ -1350,8 +1371,8 @@ TEST_F(ObfuscatedFileUtilTest, TestMovePathQuotasWithoutRename) { ASSERT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory( context.get(), dir_url, exclusive, recursive)); - FileSystemURL dest_url = dir_url.WithPath( - dir_url.path().Append(src_url.path())); + FileSystemURL dest_url = FileSystemURLAppend( + dir_url, src_url.path().value()); bool is_copy = false; int64 allowed_bytes_growth = -1000; // Over quota, this should still work. @@ -1666,8 +1687,8 @@ TEST_F(ObfuscatedFileUtilTest, TestDirectoryTimestampForCreation) { ofu()->CreateDirectory(context.get(), dir_url, false, false)); // EnsureFileExists, create case. - FileSystemURL url(dir_url.WithPath( - dir_url.path().AppendASCII("EnsureFileExists_file"))); + FileSystemURL url(FileSystemURLAppendUTF8( + dir_url, "EnsureFileExists_file")); bool created = false; ClearTimestamp(dir_url); context.reset(NewContext(NULL)); @@ -1686,7 +1707,7 @@ TEST_F(ObfuscatedFileUtilTest, TestDirectoryTimestampForCreation) { EXPECT_EQ(base::Time(), GetModifiedTime(dir_url)); // fail case. - url = dir_url.WithPath(dir_url.path().AppendASCII("EnsureFileExists_dir")); + url = FileSystemURLAppendUTF8(dir_url, "EnsureFileExists_dir"); context.reset(NewContext(NULL)); EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory(context.get(), url, false, false)); @@ -1698,7 +1719,7 @@ TEST_F(ObfuscatedFileUtilTest, TestDirectoryTimestampForCreation) { EXPECT_EQ(base::Time(), GetModifiedTime(dir_url)); // CreateOrOpen, create case. - url = dir_url.WithPath(dir_url.path().AppendASCII("CreateOrOpen_file")); + url = FileSystemURLAppendUTF8(dir_url, "CreateOrOpen_file"); base::PlatformFile file_handle = base::kInvalidPlatformFileValue; created = false; ClearTimestamp(dir_url); @@ -1742,8 +1763,8 @@ TEST_F(ObfuscatedFileUtilTest, TestDirectoryTimestampForCreation) { // CreateDirectory, create case. // Creating CreateDirectory_dir and CreateDirectory_dir/subdir. - url = dir_url.WithPath(dir_url.path().AppendASCII("CreateDirectory_dir")); - FileSystemURL subdir_url(url.WithPath(url.path().AppendASCII("subdir"))); + url = FileSystemURLAppendUTF8(dir_url, "CreateDirectory_dir"); + FileSystemURL subdir_url(FileSystemURLAppendUTF8(url, "subdir")); ClearTimestamp(dir_url); context.reset(NewContext(NULL)); EXPECT_EQ(base::PLATFORM_FILE_OK, @@ -1753,7 +1774,7 @@ TEST_F(ObfuscatedFileUtilTest, TestDirectoryTimestampForCreation) { // create subdir case. // Creating CreateDirectory_dir/subdir2. - subdir_url = url.WithPath(url.path().AppendASCII("subdir2")); + subdir_url = FileSystemURLAppendUTF8(url, "subdir2"); ClearTimestamp(dir_url); ClearTimestamp(url); context.reset(NewContext(NULL)); @@ -1764,7 +1785,7 @@ TEST_F(ObfuscatedFileUtilTest, TestDirectoryTimestampForCreation) { EXPECT_NE(base::Time(), GetModifiedTime(url)); // fail case. - url = dir_url.WithPath(dir_url.path().AppendASCII("CreateDirectory_dir")); + url = FileSystemURLAppendUTF8(dir_url, "CreateDirectory_dir"); ClearTimestamp(dir_url); context.reset(NewContext(NULL)); EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, @@ -1773,9 +1794,9 @@ TEST_F(ObfuscatedFileUtilTest, TestDirectoryTimestampForCreation) { EXPECT_EQ(base::Time(), GetModifiedTime(dir_url)); // CopyInForeignFile, create case. - url = dir_url.WithPath(dir_url.path().AppendASCII("CopyInForeignFile_file")); - FileSystemURL src_path = dir_url.WithPath( - dir_url.path().AppendASCII("CopyInForeignFile_src_file")); + url = FileSystemURLAppendUTF8(dir_url, "CopyInForeignFile_file"); + FileSystemURL src_path = FileSystemURLAppendUTF8( + dir_url, "CopyInForeignFile_src_file"); context.reset(NewContext(NULL)); EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->EnsureFileExists(context.get(), src_path, &created)); @@ -1803,8 +1824,8 @@ TEST_F(ObfuscatedFileUtilTest, TestDirectoryTimestampForDeletion) { ofu()->CreateDirectory(context.get(), dir_url, false, false)); // DeleteFile, delete case. - FileSystemURL url = dir_url.WithPath( - dir_url.path().AppendASCII("DeleteFile_file")); + FileSystemURL url = FileSystemURLAppendUTF8( + dir_url, "DeleteFile_file"); bool created = false; context.reset(NewContext(NULL)); EXPECT_EQ(base::PLATFORM_FILE_OK, @@ -1825,8 +1846,8 @@ TEST_F(ObfuscatedFileUtilTest, TestDirectoryTimestampForDeletion) { EXPECT_EQ(base::Time(), GetModifiedTime(dir_url)); // DeleteDirectory, fail case. - url = dir_url.WithPath(dir_url.path().AppendASCII("DeleteDirectory_dir")); - FileSystemURL file_path(url.WithPath(url.path().AppendASCII("pakeratta"))); + url = FileSystemURLAppendUTF8(dir_url, "DeleteDirectory_dir"); + FileSystemURL file_path(FileSystemURLAppendUTF8(url, "pakeratta")); context.reset(NewContext(NULL)); EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory(context.get(), url, true, true)); @@ -1866,8 +1887,8 @@ TEST_F(ObfuscatedFileUtilTest, TestDirectoryTimestampForCopyAndMove) { TEST_F(ObfuscatedFileUtilTest, TestFileEnumeratorTimestamp) { FileSystemURL dir = CreateURLFromUTF8("foo"); - FileSystemURL url1 = dir.WithPath(dir.path().AppendASCII("bar")); - FileSystemURL url2 = dir.WithPath(dir.path().AppendASCII("baz")); + FileSystemURL url1 = FileSystemURLAppendUTF8(dir, "bar"); + FileSystemURL url2 = FileSystemURLAppendUTF8(dir, "baz"); scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); EXPECT_EQ(base::PLATFORM_FILE_OK, @@ -1907,7 +1928,10 @@ TEST_F(ObfuscatedFileUtilTest, TestFileEnumeratorTimestamp) { base::FilePath file_path; EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->GetFileInfo(context.get(), - dir.WithPath(file_path_each), + FileSystemURL::CreateForTest( + dir.origin(), + dir.mount_type(), + file_path_each), &file_info, &file_path)); EXPECT_EQ(file_info.is_directory, file_enum->IsDirectory()); EXPECT_EQ(file_info.last_modified, file_enum->LastModifiedTime()); diff --git a/webkit/fileapi/recursive_operation_delegate.cc b/webkit/fileapi/recursive_operation_delegate.cc index 4efdefc..733bc7c 100644 --- a/webkit/fileapi/recursive_operation_delegate.cc +++ b/webkit/fileapi/recursive_operation_delegate.cc @@ -59,6 +59,11 @@ FileSystemContext* RecursiveOperationDelegate::file_system_context() { return original_operation_->file_system_context(); } +const FileSystemContext* RecursiveOperationDelegate::file_system_context() + const { + return original_operation_->file_system_context(); +} + void RecursiveOperationDelegate::ProcessNextDirectory() { DCHECK(pending_files_.empty()); if (inflight_operations_ > 0) @@ -138,7 +143,10 @@ void RecursiveOperationDelegate::DidReadDirectory( return; } for (size_t i = 0; i < entries.size(); i++) { - FileSystemURL url = parent.WithPath(parent.path().Append(entries[i].name)); + FileSystemURL url = file_system_context()->CreateCrackedFileSystemURL( + parent.origin(), + parent.mount_type(), + parent.virtual_path().Append(entries[i].name)); if (entries[i].is_directory) pending_directories_.push(url); else diff --git a/webkit/fileapi/recursive_operation_delegate.h b/webkit/fileapi/recursive_operation_delegate.h index 8b0626f..8c2a36f 100644 --- a/webkit/fileapi/recursive_operation_delegate.h +++ b/webkit/fileapi/recursive_operation_delegate.h @@ -72,6 +72,7 @@ class RecursiveOperationDelegate base::PlatformFileError* error); FileSystemContext* file_system_context(); + const FileSystemContext* file_system_context() const; private: void ProcessNextDirectory(); |