summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/fileapi')
-rw-r--r--webkit/fileapi/file_system_operation_unittest.cc28
-rw-r--r--webkit/fileapi/file_system_path_manager.cc18
-rw-r--r--webkit/fileapi/file_system_path_manager.h2
-rw-r--r--webkit/fileapi/file_system_path_manager_unittest.cc4
4 files changed, 48 insertions, 4 deletions
diff --git a/webkit/fileapi/file_system_operation_unittest.cc b/webkit/fileapi/file_system_operation_unittest.cc
index 370d95c..e5c25ad 100644
--- a/webkit/fileapi/file_system_operation_unittest.cc
+++ b/webkit/fileapi/file_system_operation_unittest.cc
@@ -463,6 +463,34 @@ TEST_F(FileSystemOperationTest, TestCreateFileFailure) {
EXPECT_EQ(request_id_, mock_dispatcher_->request_id());
}
+TEST_F(FileSystemOperationTest, TestCreateVeryLongName) {
+ ScopedTempDir dir;
+ ASSERT_TRUE(dir.CreateUniqueTempDir());
+
+#if defined(OS_WIN)
+ FilePath dir_path(FILE_PATH_LITERAL("\\\\?\\") + dir.path().value());
+#else
+ FilePath dir_path = dir.path();
+#endif
+
+ // TODO(kkanetkar): Once each platform's limitations have been enforced
+ // consider that in this test. Currently this test is for
+ // windows primarily.
+ FilePath dir1 = dir_path.AppendASCII(
+ "012345678901234567890123456789012345678901234567890123456789"
+ "012345678901234567890123456789012345678901234567890123456789"
+ "0123456789012345678901234567890123456789");
+ FilePath file = dir1.AppendASCII(
+ "012345678901234567890123456789012345678901234567890123456789"
+ "012345678901234567890123456789012345678901234567890123456789"
+ "0123456789012345678901234567890123456789");
+ operation()->CreateDirectory(dir1, false, true);
+ MessageLoop::current()->RunAllPending();
+ operation()->CreateFile(file, true);
+ MessageLoop::current()->RunAllPending();
+ EXPECT_TRUE(file_util::PathExists(file));
+}
+
TEST_F(FileSystemOperationTest, TestCreateFileSuccessFileExists) {
// Already existing file and exclusive false.
ScopedTempDir dir;
diff --git a/webkit/fileapi/file_system_path_manager.cc b/webkit/fileapi/file_system_path_manager.cc
index 2bd1f9e..50f22f9 100644
--- a/webkit/fileapi/file_system_path_manager.cc
+++ b/webkit/fileapi/file_system_path_manager.cc
@@ -124,6 +124,7 @@ class FileSystemPathManager::GetFileSystemRootPathTask
DispatchCallbackOnCallerThread(FilePath());
return;
}
+
DispatchCallbackOnCallerThread(root);
}
@@ -170,13 +171,25 @@ class FileSystemPathManager::GetFileSystemRootPathTask
scoped_ptr<FileSystemPathManager::GetRootPathCallback> callback_;
};
+FilePath FileSystemPathManager::GetFileSystemCommonRootDirectory(
+ const FilePath& root_path) {
+#if defined(OS_WIN)
+ // To specify an extended-length path, "\\?\" prefix is used. Else path names
+ // are limited to 260 characters.
+ FilePath::StringType extended_length_str(L"\\\\?\\");
+ extended_length_str.append(root_path.value());
+ return FilePath(extended_length_str).Append(kFileSystemDirectory);
+#endif
+ return root_path.Append(kFileSystemDirectory);
+}
+
FileSystemPathManager::FileSystemPathManager(
scoped_refptr<base::MessageLoopProxy> file_message_loop,
const FilePath& profile_path,
bool is_incognito,
bool allow_file_access_from_files)
: file_message_loop_(file_message_loop),
- base_path_(profile_path.Append(kFileSystemDirectory)),
+ base_path_(GetFileSystemCommonRootDirectory(profile_path)),
is_incognito_(is_incognito),
allow_file_access_from_files_(allow_file_access_from_files) {
}
@@ -215,7 +228,8 @@ void FileSystemPathManager::GetFileSystemRootPath(
DCHECK(!type_string.empty());
FilePath origin_base_path = base_path_.AppendASCII(storage_identifier)
- .AppendASCII(type_string);
+ .AppendASCII(type_string);
+
std::string name = storage_identifier + ":" + type_string;
scoped_refptr<GetFileSystemRootPathTask> task(
diff --git a/webkit/fileapi/file_system_path_manager.h b/webkit/fileapi/file_system_path_manager.h
index 12104ef..41ffd4d 100644
--- a/webkit/fileapi/file_system_path_manager.h
+++ b/webkit/fileapi/file_system_path_manager.h
@@ -28,6 +28,8 @@ class FileSystemPathManager {
bool allow_file_access_from_files);
~FileSystemPathManager();
+ static FilePath GetFileSystemCommonRootDirectory(const FilePath& root_path);
+
// Callback for GetFileSystemRootPath.
// If the request is accepted and the root filesystem for the origin exists
// the callback is called with success=true and valid root_path and name.
diff --git a/webkit/fileapi/file_system_path_manager_unittest.cc b/webkit/fileapi/file_system_path_manager_unittest.cc
index 7fa3672..4e18cd9 100644
--- a/webkit/fileapi/file_system_path_manager_unittest.cc
+++ b/webkit/fileapi/file_system_path_manager_unittest.cc
@@ -210,8 +210,8 @@ class FileSystemPathManagerTest : public testing::Test {
FilePath data_path() { return data_dir_->path(); }
FilePath file_system_path() {
- return data_dir_->path().Append(
- FileSystemPathManager::kFileSystemDirectory);
+ return FileSystemPathManager::GetFileSystemCommonRootDirectory(
+ data_dir_->path());
}
private: