summaryrefslogtreecommitdiffstats
path: root/content/child
diff options
context:
space:
mode:
Diffstat (limited to 'content/child')
-rw-r--r--content/child/fileapi/file_system_dispatcher.cc38
-rw-r--r--content/child/fileapi/file_system_dispatcher.h12
-rw-r--r--content/child/fileapi/webfilesystem_impl.cc36
-rw-r--r--content/child/fileapi/webfilesystem_impl.h3
4 files changed, 88 insertions, 1 deletions
diff --git a/content/child/fileapi/file_system_dispatcher.cc b/content/child/fileapi/file_system_dispatcher.cc
index c564f8d..fa73ad1 100644
--- a/content/child/fileapi/file_system_dispatcher.cc
+++ b/content/child/fileapi/file_system_dispatcher.cc
@@ -10,6 +10,7 @@
#include "base/process/process.h"
#include "content/child/child_thread.h"
#include "content/common/fileapi/file_system_messages.h"
+#include "webkit/common/fileapi/file_system_info.h"
namespace content {
@@ -20,6 +21,7 @@ class FileSystemDispatcher::CallbackDispatcher {
typedef FileSystemDispatcher::MetadataCallback MetadataCallback;
typedef FileSystemDispatcher::ReadDirectoryCallback ReadDirectoryCallback;
typedef FileSystemDispatcher::OpenFileSystemCallback OpenFileSystemCallback;
+ typedef FileSystemDispatcher::ResolveURLCallback ResolveURLCallback;
typedef FileSystemDispatcher::WriteCallback WriteCallback;
typedef FileSystemDispatcher::OpenFileCallback OpenFileCallback;
@@ -57,6 +59,13 @@ class FileSystemDispatcher::CallbackDispatcher {
dispatcher->error_callback_ = error_callback;
return dispatcher;
}
+ static CallbackDispatcher* Create(const ResolveURLCallback& callback,
+ const StatusCallback& error_callback) {
+ CallbackDispatcher* dispatcher = new CallbackDispatcher;
+ dispatcher->resolve_callback_ = callback;
+ dispatcher->error_callback_ = error_callback;
+ return dispatcher;
+ }
static CallbackDispatcher* Create(const WriteCallback& callback,
const StatusCallback& error_callback) {
CallbackDispatcher* dispatcher = new CallbackDispatcher;
@@ -105,6 +114,12 @@ class FileSystemDispatcher::CallbackDispatcher {
filesystem_callback_.Run(name, root);
}
+ void DidResolveURL(const fileapi::FileSystemInfo& info,
+ const base::FilePath& file_path,
+ bool is_directory) {
+ resolve_callback_.Run(info, file_path, is_directory);
+ }
+
void DidWrite(int64 bytes, bool complete) {
write_callback_.Run(bytes, complete);
}
@@ -123,6 +138,7 @@ class FileSystemDispatcher::CallbackDispatcher {
CreateSnapshotFileCallback snapshot_callback_;
ReadDirectoryCallback directory_callback_;
OpenFileSystemCallback filesystem_callback_;
+ ResolveURLCallback resolve_callback_;
WriteCallback write_callback_;
OpenFileCallback open_callback_;
@@ -150,6 +166,7 @@ bool FileSystemDispatcher::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(FileSystemDispatcher, msg)
IPC_MESSAGE_HANDLER(FileSystemMsg_DidOpenFileSystem, OnDidOpenFileSystem)
+ IPC_MESSAGE_HANDLER(FileSystemMsg_DidResolveURL, OnDidResolveURL)
IPC_MESSAGE_HANDLER(FileSystemMsg_DidSucceed, OnDidSucceed)
IPC_MESSAGE_HANDLER(FileSystemMsg_DidReadDirectory, OnDidReadDirectory)
IPC_MESSAGE_HANDLER(FileSystemMsg_DidReadMetadata, OnDidReadMetadata)
@@ -174,6 +191,16 @@ void FileSystemDispatcher::OpenFileSystem(
request_id, origin_url, type, size, create));
}
+void FileSystemDispatcher::ResolveURL(
+ const GURL& filesystem_url,
+ const ResolveURLCallback& success_callback,
+ const StatusCallback& error_callback) {
+ int request_id = dispatchers_.Add(
+ CallbackDispatcher::Create(success_callback, error_callback));
+ ChildThread::current()->Send(new FileSystemHostMsg_ResolveURL(
+ request_id, filesystem_url));
+}
+
void FileSystemDispatcher::DeleteFileSystem(
const GURL& origin_url,
fileapi::FileSystemType type,
@@ -362,6 +389,17 @@ void FileSystemDispatcher::OnDidOpenFileSystem(int request_id,
dispatchers_.Remove(request_id);
}
+void FileSystemDispatcher::OnDidResolveURL(int request_id,
+ const fileapi::FileSystemInfo& info,
+ const base::FilePath& file_path,
+ bool is_directory) {
+ DCHECK(info.root_url.is_valid());
+ CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id);
+ DCHECK(dispatcher);
+ dispatcher->DidResolveURL(info, file_path, is_directory);
+ dispatchers_.Remove(request_id);
+}
+
void FileSystemDispatcher::OnDidSucceed(int request_id) {
CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id);
DCHECK(dispatcher);
diff --git a/content/child/fileapi/file_system_dispatcher.h b/content/child/fileapi/file_system_dispatcher.h
index f3957c3..72ecee6 100644
--- a/content/child/fileapi/file_system_dispatcher.h
+++ b/content/child/fileapi/file_system_dispatcher.h
@@ -24,6 +24,7 @@ struct PlatformFileInfo;
namespace fileapi {
struct DirectoryEntry;
+struct FileSystemInfo;
}
class GURL;
@@ -49,6 +50,10 @@ class FileSystemDispatcher : public IPC::Listener {
const std::string& name,
const GURL& root)> OpenFileSystemCallback;
typedef base::Callback<void(
+ const fileapi::FileSystemInfo& info,
+ const base::FilePath& file_path,
+ bool is_directory)> ResolveURLCallback;
+ typedef base::Callback<void(
int64 bytes,
bool complete)> WriteCallback;
typedef base::Callback<void(
@@ -68,6 +73,9 @@ class FileSystemDispatcher : public IPC::Listener {
bool create,
const OpenFileSystemCallback& success_callback,
const StatusCallback& error_callback);
+ void ResolveURL(const GURL& filesystem_url,
+ const ResolveURLCallback& success_callback,
+ const StatusCallback& error_callback);
void DeleteFileSystem(const GURL& origin_url,
fileapi::FileSystemType type,
const StatusCallback& callback);
@@ -144,6 +152,10 @@ class FileSystemDispatcher : public IPC::Listener {
void OnDidOpenFileSystem(int request_id,
const std::string& name,
const GURL& root);
+ void OnDidResolveURL(int request_id,
+ const fileapi::FileSystemInfo& info,
+ const base::FilePath& file_path,
+ bool is_directory);
void OnDidSucceed(int request_id);
void OnDidReadMetadata(int request_id,
const base::PlatformFileInfo& file_info);
diff --git a/content/child/fileapi/webfilesystem_impl.cc b/content/child/fileapi/webfilesystem_impl.cc
index ac91214..ae3be406 100644
--- a/content/child/fileapi/webfilesystem_impl.cc
+++ b/content/child/fileapi/webfilesystem_impl.cc
@@ -154,6 +154,21 @@ void OpenFileSystemCallbackAdapter(
MakeTuple(UTF8ToUTF16(name), root));
}
+void ResolveURLCallbackAdapter(
+ int thread_id, int callbacks_id,
+ WaitableCallbackResults* waitable_results,
+ const fileapi::FileSystemInfo& info,
+ const base::FilePath& file_path, bool is_directory) {
+ base::FilePath normalized_path(
+ fileapi::VirtualPath::GetNormalizedFilePath(file_path));
+ CallbackFileSystemCallbacks(
+ thread_id, callbacks_id, waitable_results,
+ &WebFileSystemCallbacks::didResolveURL,
+ MakeTuple(UTF8ToUTF16(info.name), info.root_url,
+ static_cast<WebKit::WebFileSystemType>(info.mount_type),
+ normalized_path.AsUTF16Unsafe(), is_directory));
+}
+
void StatusCallbackAdapter(int thread_id, int callbacks_id,
WaitableCallbackResults* waitable_results,
base::PlatformFileError error) {
@@ -332,6 +347,25 @@ void WebFileSystemImpl::openFileSystem(
make_scoped_ptr(waitable_results));
}
+void WebFileSystemImpl::resolveURL(
+ const WebKit::WebURL& filesystem_url,
+ WebFileSystemCallbacks callbacks) {
+ int callbacks_id = RegisterCallbacks(callbacks);
+ WaitableCallbackResults* waitable_results =
+ WaitableCallbackResults::MaybeCreate(callbacks);
+ CallDispatcherOnMainThread(
+ main_thread_loop_.get(),
+ &FileSystemDispatcher::ResolveURL,
+ MakeTuple(GURL(filesystem_url),
+ base::Bind(&ResolveURLCallbackAdapter,
+ CurrentWorkerId(), callbacks_id,
+ base::Unretained(waitable_results)),
+ base::Bind(&StatusCallbackAdapter,
+ CurrentWorkerId(), callbacks_id,
+ base::Unretained(waitable_results))),
+ make_scoped_ptr(waitable_results));
+}
+
void WebFileSystemImpl::deleteFileSystem(
const WebKit::WebURL& storage_partition,
WebKit::WebFileSystemType type,
@@ -481,7 +515,7 @@ void WebFileSystemImpl::fileExists(
MakeTuple(GURL(path), false /* directory */,
base::Bind(&StatusCallbackAdapter,
CurrentWorkerId(), callbacks_id,
-base::Unretained(waitable_results))),
+ base::Unretained(waitable_results))),
make_scoped_ptr(waitable_results));
}
diff --git a/content/child/fileapi/webfilesystem_impl.h b/content/child/fileapi/webfilesystem_impl.h
index 7550545..8f390ff 100644
--- a/content/child/fileapi/webfilesystem_impl.h
+++ b/content/child/fileapi/webfilesystem_impl.h
@@ -54,6 +54,9 @@ class WebFileSystemImpl
const WebKit::WebFileSystemType type,
bool create,
WebKit::WebFileSystemCallbacks);
+ virtual void resolveURL(
+ const WebKit::WebURL& filesystem_url,
+ WebKit::WebFileSystemCallbacks) OVERRIDE;
virtual void deleteFileSystem(
const WebKit::WebURL& storage_partition,
const WebKit::WebFileSystemType type,