summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authornhiroki@chromium.org <nhiroki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-17 17:51:51 +0000
committernhiroki@chromium.org <nhiroki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-17 17:51:51 +0000
commitf84ae11a4f08c60692c5688458185f117d33779d (patch)
tree52ab76732e457021908857ab4f378be4d3d70028 /webkit
parent4c6fec6b90c4225b16dec499281ae570be2435ef (diff)
downloadchromium_src-f84ae11a4f08c60692c5688458185f117d33779d.zip
chromium_src-f84ae11a4f08c60692c5688458185f117d33779d.tar.gz
chromium_src-f84ae11a4f08c60692c5688458185f117d33779d.tar.bz2
SyncFS: Support resolveLocalFileSystemURL on SyncFileSystem
window.resolveLocalFileSystemURL is originally defined only for FileSystem API, but it'd be nice if it works on SyncFileSystem in a similar way. For that this change adds new IPC messages and interfaces. Blink side change depends on this: https://codereview.chromium.org/23537011/ BUG=177137 TEST=manual (Get FileSystemURL for a file on SyncFS, and then resolve it) TEST=unit_tests TEST=run_webkit_tests.sh http/tests/inspector/filesystem/\* TEST=run_webkit_tests.sh http/tests/inspector/filesystem/\* Review URL: https://chromiumcodereview.appspot.com/23856002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223635 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/browser/fileapi/file_system_context.cc68
-rw-r--r--webkit/browser/fileapi/file_system_context.h25
-rw-r--r--webkit/common/fileapi/file_system_info.cc24
-rw-r--r--webkit/common/fileapi/file_system_info.h31
-rw-r--r--webkit/common/fileapi/file_system_util.cc2
-rw-r--r--webkit/storage_common.gyp2
6 files changed, 148 insertions, 4 deletions
diff --git a/webkit/browser/fileapi/file_system_context.cc b/webkit/browser/fileapi/file_system_context.cc
index 26a48d4..0888661 100644
--- a/webkit/browser/fileapi/file_system_context.cc
+++ b/webkit/browser/fileapi/file_system_context.cc
@@ -27,6 +27,7 @@
#include "webkit/browser/fileapi/test_file_system_backend.h"
#include "webkit/browser/quota/quota_manager.h"
#include "webkit/browser/quota/special_storage_policy.h"
+#include "webkit/common/fileapi/file_system_info.h"
#include "webkit/common/fileapi/file_system_util.h"
using quota::QuotaClient;
@@ -49,6 +50,19 @@ void DidOpenFileSystem(
callback.Run(error, filesystem_name, filesystem_root);
}
+void DidGetMetadataForResolveURL(
+ const base::FilePath& path,
+ const FileSystemContext::ResolveURLCallback& callback,
+ const FileSystemInfo& info,
+ base::PlatformFileError error,
+ const base::PlatformFileInfo& file_info) {
+ if (error != base::PLATFORM_FILE_OK) {
+ callback.Run(error, FileSystemInfo(), base::FilePath(), false);
+ return;
+ }
+ callback.Run(error, info, path, file_info.is_directory);
+}
+
} // namespace
// static
@@ -275,6 +289,26 @@ void FileSystemContext::OpenFileSystem(
base::Bind(&DidOpenFileSystem, callback));
}
+void FileSystemContext::ResolveURL(
+ const FileSystemURL& url,
+ const ResolveURLCallback& callback) {
+ DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
+ DCHECK(!callback.is_null());
+
+ FileSystemBackend* backend = GetFileSystemBackend(url.type());
+ if (!backend) {
+ callback.Run(base::PLATFORM_FILE_ERROR_SECURITY,
+ FileSystemInfo(), base::FilePath(), false);
+ return;
+ }
+
+ backend->OpenFileSystem(
+ url.origin(), url.type(),
+ OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT,
+ base::Bind(&FileSystemContext::DidOpenFileSystemForResolveURL,
+ this, url, callback));
+}
+
void FileSystemContext::DeleteFileSystem(
const GURL& origin_url,
FileSystemType type,
@@ -424,8 +458,7 @@ FileSystemURL FileSystemContext::CrackFileSystemURL(
return current;
}
-void FileSystemContext::RegisterBackend(
- FileSystemBackend* backend) {
+void FileSystemContext::RegisterBackend(FileSystemBackend* backend) {
const FileSystemType mount_types[] = {
kFileSystemTypeTemporary,
kFileSystemTypePersistent,
@@ -452,4 +485,35 @@ void FileSystemContext::RegisterBackend(
}
}
+void FileSystemContext::DidOpenFileSystemForResolveURL(
+ const FileSystemURL& url,
+ const FileSystemContext::ResolveURLCallback& callback,
+ const GURL& filesystem_root,
+ const std::string& filesystem_name,
+ base::PlatformFileError error) {
+ DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
+
+ if (error != base::PLATFORM_FILE_OK) {
+ callback.Run(error, FileSystemInfo(), base::FilePath(), false);
+ return;
+ }
+
+ fileapi::FileSystemInfo info(
+ filesystem_name, filesystem_root, url.mount_type());
+
+ // Extract the virtual path not containing a filesystem type part from |url|.
+ base::FilePath parent =
+ base::FilePath::FromUTF8Unsafe(filesystem_root.path());
+ base::FilePath child = base::FilePath::FromUTF8Unsafe(url.ToGURL().path());
+ base::FilePath path;
+
+ if (parent != child) {
+ bool result = parent.AppendRelativePath(child, &path);
+ DCHECK(result);
+ }
+
+ operation_runner()->GetMetadata(
+ url, base::Bind(&DidGetMetadataForResolveURL, path, callback, info));
+}
+
} // namespace fileapi
diff --git a/webkit/browser/fileapi/file_system_context.h b/webkit/browser/fileapi/file_system_context.h
index 9762b68..21a31b8 100644
--- a/webkit/browser/fileapi/file_system_context.h
+++ b/webkit/browser/fileapi/file_system_context.h
@@ -49,8 +49,8 @@ class CopyOrMoveFileValidatorFactory;
class ExternalFileSystemBackend;
class ExternalMountPoints;
class FileStreamWriter;
-class FileSystemFileUtil;
class FileSystemBackend;
+class FileSystemFileUtil;
class FileSystemOperation;
class FileSystemOperationRunner;
class FileSystemOptions;
@@ -61,6 +61,7 @@ class MountPoints;
class SandboxFileSystemBackend;
struct DefaultContextDeleter;
+struct FileSystemInfo;
// This class keeps and provides a file system context for FileSystem API.
// An instance of this class is created and owned by profile.
@@ -154,6 +155,12 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext
const std::string& name,
const GURL& root)> OpenFileSystemCallback;
+ // Used for ResolveURL.
+ typedef base::Callback<void(base::PlatformFileError result,
+ const FileSystemInfo& info,
+ const base::FilePath& file_path,
+ bool is_directory)> ResolveURLCallback;
+
// Used for DeleteFileSystem.
typedef base::Callback<void(base::PlatformFileError result)>
DeleteFileSystemCallback;
@@ -169,8 +176,15 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext
OpenFileSystemMode mode,
const OpenFileSystemCallback& callback);
+ // Opens the filesystem for the given |url| as read-only, and then checks the
+ // existence of the file entry referred by the URL. This should be called on
+ // the IO thread.
+ void ResolveURL(
+ const FileSystemURL& url,
+ const ResolveURLCallback& callback);
+
// Deletes the filesystem for the given |origin_url| and |type|. This should
- // be called on the IO Thread.
+ // be called on the IO thread.
void DeleteFileSystem(
const GURL& origin_url,
FileSystemType type,
@@ -274,6 +288,13 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext
// the constructor.
void RegisterBackend(FileSystemBackend* backend);
+ void DidOpenFileSystemForResolveURL(
+ const FileSystemURL& url,
+ const ResolveURLCallback& callback,
+ const GURL& filesystem_root,
+ const std::string& filesystem_name,
+ base::PlatformFileError error);
+
// Returns a FileSystemBackend, used only by test code.
SandboxFileSystemBackend* sandbox_backend() const {
return sandbox_backend_.get();
diff --git a/webkit/common/fileapi/file_system_info.cc b/webkit/common/fileapi/file_system_info.cc
new file mode 100644
index 0000000..269c021
--- /dev/null
+++ b/webkit/common/fileapi/file_system_info.cc
@@ -0,0 +1,24 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/common/fileapi/file_system_info.h"
+
+namespace fileapi {
+
+FileSystemInfo::FileSystemInfo()
+ : mount_type(fileapi::kFileSystemTypeTemporary) {
+}
+
+FileSystemInfo::FileSystemInfo(const std::string& name,
+ const GURL& root_url,
+ fileapi::FileSystemType mount_type)
+ : name(name),
+ root_url(root_url),
+ mount_type(mount_type) {
+}
+
+FileSystemInfo::~FileSystemInfo() {
+}
+
+} // namespace fileapi
diff --git a/webkit/common/fileapi/file_system_info.h b/webkit/common/fileapi/file_system_info.h
new file mode 100644
index 0000000..b71739a
--- /dev/null
+++ b/webkit/common/fileapi/file_system_info.h
@@ -0,0 +1,31 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_INFO_H_
+#define WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_INFO_H_
+
+#include "url/gurl.h"
+#include "webkit/common/fileapi/file_system_types.h"
+#include "webkit/common/webkit_storage_common_export.h"
+
+namespace fileapi {
+
+// This struct is used to send the necessary information for Blink to create a
+// DOMFileSystem. Since Blink side only uses mount_type (rather than
+// detailed/cracked filesystem type) this only contains mount_type but not type.
+struct WEBKIT_STORAGE_COMMON_EXPORT FileSystemInfo {
+ FileSystemInfo();
+ FileSystemInfo(const std::string& filesystem_name,
+ const GURL& root_url,
+ fileapi::FileSystemType mount_type);
+ ~FileSystemInfo();
+
+ std::string name;
+ GURL root_url;
+ fileapi::FileSystemType mount_type;
+};
+
+} // namespace fileapi
+
+#endif // WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_INFO_H_
diff --git a/webkit/common/fileapi/file_system_util.cc b/webkit/common/fileapi/file_system_util.cc
index bc9aba7..6229bc2 100644
--- a/webkit/common/fileapi/file_system_util.cc
+++ b/webkit/common/fileapi/file_system_util.cc
@@ -296,6 +296,8 @@ WebKit::WebFileError PlatformFileErrorToWebFileError(
return WebKit::WebFileErrorSecurity;
case base::PLATFORM_FILE_ERROR_NO_SPACE:
return WebKit::WebFileErrorQuotaExceeded;
+ case base::PLATFORM_FILE_ERROR_INVALID_URL:
+ return WebKit::WebFileErrorEncoding;
default:
return WebKit::WebFileErrorInvalidModification;
}
diff --git a/webkit/storage_common.gyp b/webkit/storage_common.gyp
index 01e8f23..a77d4c5 100644
--- a/webkit/storage_common.gyp
+++ b/webkit/storage_common.gyp
@@ -32,6 +32,8 @@
'common/database/database_identifier.cc',
'common/fileapi/directory_entry.cc',
'common/fileapi/directory_entry.h',
+ 'common/fileapi/file_system_info.cc',
+ 'common/fileapi/file_system_info.h',
'common/fileapi/file_system_types.h',
'common/fileapi/file_system_util.cc',
'common/fileapi/file_system_util.h',