Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(814)

Unified Diff: webkit/browser/fileapi/file_system_context.cc

Issue 23856002: SyncFS: Support resolveLocalFileSystemURL on SyncFileSystem (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/browser/fileapi/file_system_context.h ('k') | webkit/common/fileapi/file_system_info.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/browser/fileapi/file_system_context.cc
diff --git a/webkit/browser/fileapi/file_system_context.cc b/webkit/browser/fileapi/file_system_context.cc
index 26a48d49a3ca7451d89969acb833c1c05dfb7f78..0888661c3cc062d414f5426deb9197f3e2383ade 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
« no previous file with comments | « webkit/browser/fileapi/file_system_context.h ('k') | webkit/common/fileapi/file_system_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698