summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-22 05:03:05 +0000
committerkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-22 05:03:05 +0000
commit1d31b8366140cc83e94c77f496ff0f94e57dec70 (patch)
tree807b3f7cf44246db8fa4c39a003c160af9ab6b8f /webkit
parenta17e0cd18c9b1c70c8970767809ea8205b904da6 (diff)
downloadchromium_src-1d31b8366140cc83e94c77f496ff0f94e57dec70.zip
chromium_src-1d31b8366140cc83e94c77f496ff0f94e57dec70.tar.gz
chromium_src-1d31b8366140cc83e94c77f496ff0f94e57dec70.tar.bz2
Remove thread restriction of fileapi::FileSystemContext::ResolveURL.
BUG=363962 Review URL: https://codereview.chromium.org/242443004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@265179 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/browser/fileapi/file_system_context.cc43
-rw-r--r--webkit/browser/fileapi/file_system_context.h16
2 files changed, 48 insertions, 11 deletions
diff --git a/webkit/browser/fileapi/file_system_context.cc b/webkit/browser/fileapi/file_system_context.cc
index f6e7df3..847a68b 100644
--- a/webkit/browser/fileapi/file_system_context.cc
+++ b/webkit/browser/fileapi/file_system_context.cc
@@ -51,10 +51,29 @@ void DidGetMetadataForResolveURL(
base::File::Error error,
const base::File::Info& file_info) {
if (error != base::File::FILE_OK) {
- callback.Run(error, FileSystemInfo(), base::FilePath(), false);
+ if (error == base::File::FILE_ERROR_NOT_FOUND) {
+ callback.Run(base::File::FILE_OK, info, path,
+ FileSystemContext::RESOLVED_ENTRY_NOT_FOUND);
+ } else {
+ callback.Run(error, FileSystemInfo(), base::FilePath(),
+ FileSystemContext::RESOLVED_ENTRY_NOT_FOUND);
+ }
return;
}
- callback.Run(error, info, path, file_info.is_directory);
+ callback.Run(error, info, path, file_info.is_directory ?
+ FileSystemContext::RESOLVED_ENTRY_DIRECTORY :
+ FileSystemContext::RESOLVED_ENTRY_FILE);
+}
+
+void RelayResolveURLCallback(
+ scoped_refptr<base::MessageLoopProxy> message_loop,
+ const FileSystemContext::ResolveURLCallback& callback,
+ base::File::Error result,
+ const FileSystemInfo& info,
+ const base::FilePath& file_path,
+ FileSystemContext::ResolvedEntryType type) {
+ message_loop->PostTask(
+ FROM_HERE, base::Bind(callback, result, info, file_path, type));
}
} // namespace
@@ -322,15 +341,24 @@ void FileSystemContext::OpenFileSystem(
void FileSystemContext::ResolveURL(
const FileSystemURL& url,
const ResolveURLCallback& callback) {
- // TODO(nhiroki, kinuko): Remove this thread restriction, so it can be called
- // on either UI or IO thread.
- DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
DCHECK(!callback.is_null());
+ // If not on IO thread, forward before passing the task to the backend.
+ if (!io_task_runner_->RunsTasksOnCurrentThread()) {
+ ResolveURLCallback relay_callback =
+ base::Bind(&RelayResolveURLCallback,
+ base::MessageLoopProxy::current(), callback);
+ io_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&FileSystemContext::ResolveURL, this, url, relay_callback));
+ return;
+ }
+
FileSystemBackend* backend = GetFileSystemBackend(url.type());
if (!backend) {
callback.Run(base::File::FILE_ERROR_SECURITY,
- FileSystemInfo(), base::FilePath(), false);
+ FileSystemInfo(), base::FilePath(),
+ FileSystemContext::RESOLVED_ENTRY_NOT_FOUND);
return;
}
@@ -560,7 +588,8 @@ void FileSystemContext::DidOpenFileSystemForResolveURL(
DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
if (error != base::File::FILE_OK) {
- callback.Run(error, FileSystemInfo(), base::FilePath(), false);
+ callback.Run(error, FileSystemInfo(), base::FilePath(),
+ FileSystemContext::RESOLVED_ENTRY_NOT_FOUND);
return;
}
diff --git a/webkit/browser/fileapi/file_system_context.h b/webkit/browser/fileapi/file_system_context.h
index ba91af7..6e53981 100644
--- a/webkit/browser/fileapi/file_system_context.h
+++ b/webkit/browser/fileapi/file_system_context.h
@@ -188,10 +188,15 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext
OpenFileSystemCallback;
// Used for ResolveURL.
+ enum ResolvedEntryType {
+ RESOLVED_ENTRY_FILE,
+ RESOLVED_ENTRY_DIRECTORY,
+ RESOLVED_ENTRY_NOT_FOUND,
+ };
typedef base::Callback<void(base::File::Error result,
const FileSystemInfo& info,
const base::FilePath& file_path,
- bool is_directory)> ResolveURLCallback;
+ ResolvedEntryType type)> ResolveURLCallback;
// Used for DeleteFileSystem and OpenPluginPrivateFileSystem.
typedef base::Callback<void(base::File::Error result)> StatusCallback;
@@ -207,9 +212,12 @@ 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.
+ // Opens the filesystem for the given |url| as read-only, if the filesystem
+ // backend referred by the URL allows opening by resolveURL. Otherwise it
+ // fails with FILE_ERROR_SECURITY. The entry pointed by the URL can be
+ // absent; in that case RESOLVED_ENTRY_NOT_FOUND type is returned to the
+ // callback for indicating the absence. Can be called from any thread with
+ // a message loop. |callback| is invoked on the caller thread.
void ResolveURL(
const FileSystemURL& url,
const ResolveURLCallback& callback);