Commit 8f33bb97 authored by tzik@chromium.org's avatar tzik@chromium.org

Wire-up DeleteFileSystem to DRT

DeleteFileSystem will be used in Inspector to allow web developers to clear their filesystem.
And DRT support of DeleteFileSystem will help unittest of Inspector.

BUG=139366


Review URL: https://chromiumcodereview.appspot.com/10824305

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151836 0039d316-1c4b-4281-b951-d872f2087c98
parent 0de630cb
......@@ -804,6 +804,13 @@ void OpenFileSystem(WebFrame* frame, WebFileSystem::Type type,
fileSystem->OpenFileSystem(frame, type, size, create, callbacks);
}
void DeleteFileSystem(WebFrame* frame, WebFileSystem::Type type,
WebFileSystemCallbacks* callbacks) {
SimpleFileSystem* fileSystem = static_cast<SimpleFileSystem*>(
test_environment->webkit_platform_support()->fileSystem());
fileSystem->DeleteFileSystem(frame, type, callbacks);
}
WebKit::WebString RegisterIsolatedFileSystem(
const WebKit::WebVector<WebKit::WebString>& filenames) {
fileapi::IsolatedContext::FileInfoSet files;
......
......@@ -233,8 +233,14 @@ WebKit::WebThemeEngine* GetThemeEngine();
WebKit::WebURL GetDevToolsPathAsURL();
// - FileSystem
void OpenFileSystem(WebKit::WebFrame* frame, WebKit::WebFileSystem::Type type,
long long size, bool create, WebKit::WebFileSystemCallbacks* callbacks);
void OpenFileSystem(WebKit::WebFrame* frame,
WebKit::WebFileSystem::Type type,
long long size,
bool create,
WebKit::WebFileSystemCallbacks* callbacks);
void DeleteFileSystem(WebKit::WebFrame* frame,
WebKit::WebFileSystem::Type type,
WebKit::WebFileSystemCallbacks* callbacks);
// Returns a filesystem ID for the newly created isolated filesystem.
WebKit::WebString RegisterIsolatedFileSystem(
......
......@@ -91,7 +91,7 @@ SimpleFileSystem::~SimpleFileSystem() {
}
void SimpleFileSystem::OpenFileSystem(
WebFrame* frame, WebFileSystem::Type web_filesystem_type,
WebFrame* frame, WebFileSystem::Type type,
long long, bool create,
WebFileSystemCallbacks* callbacks) {
if (!frame || !file_system_context_.get()) {
......@@ -100,22 +100,24 @@ void SimpleFileSystem::OpenFileSystem(
return;
}
fileapi::FileSystemType type;
if (web_filesystem_type == WebFileSystem::TypeTemporary)
type = fileapi::kFileSystemTypeTemporary;
else if (web_filesystem_type == WebFileSystem::TypePersistent)
type = fileapi::kFileSystemTypePersistent;
else if (web_filesystem_type == WebFileSystem::TypeExternal)
type = fileapi::kFileSystemTypeExternal;
else {
// Unknown type filesystem is requested.
GURL origin_url(frame->document().securityOrigin().toString());
file_system_context_->OpenFileSystem(
origin_url, static_cast<fileapi::FileSystemType>(type), create,
OpenFileSystemHandler(callbacks));
}
void SimpleFileSystem::DeleteFileSystem(
WebFrame* frame, WebFileSystem::Type type,
WebFileSystemCallbacks* callbacks) {
if (!frame || !file_system_context_.get()) {
callbacks->didFail(WebKit::WebFileErrorSecurity);
return;
}
GURL origin_url(frame->document().securityOrigin().toString());
file_system_context_->OpenFileSystem(
origin_url, type, create, OpenFileSystemHandler(callbacks));
file_system_context_->DeleteFileSystem(
origin_url, static_cast<fileapi::FileSystemType>(type),
DeleteFileSystemHandler(callbacks));
}
void SimpleFileSystem::move(
......@@ -296,6 +298,12 @@ SimpleFileSystem::OpenFileSystemHandler(WebFileSystemCallbacks* callbacks) {
AsWeakPtr(), base::Unretained(callbacks));
}
FileSystemContext::DeleteFileSystemCallback
SimpleFileSystem::DeleteFileSystemHandler(WebFileSystemCallbacks* callbacks) {
return base::Bind(&SimpleFileSystem::DidDeleteFileSystem,
AsWeakPtr(), callbacks);
}
FileSystemOperationInterface::SnapshotFileCallback
SimpleFileSystem::SnapshotFileHandler(const GURL& blob_url,
WebFileSystemCallbacks* callbacks) {
......@@ -364,6 +372,15 @@ void SimpleFileSystem::DidOpenFileSystem(
}
}
void SimpleFileSystem::DidDeleteFileSystem(
WebFileSystemCallbacks* callbacks,
base::PlatformFileError result) {
if (result == base::PLATFORM_FILE_OK)
callbacks->didSucceed();
else
callbacks->didFail(fileapi::PlatformFileErrorToWebFileError(result));
}
void SimpleFileSystem::DidCreateSnapshotFile(
const GURL& blob_url,
WebFileSystemCallbacks* callbacks,
......
......@@ -42,6 +42,9 @@ class SimpleFileSystem
long long size,
bool create,
WebKit::WebFileSystemCallbacks* callbacks);
void DeleteFileSystem(WebKit::WebFrame* frame,
WebKit::WebFileSystem::Type type,
WebKit::WebFileSystemCallbacks* callbacks);
fileapi::FileSystemContext* file_system_context() {
return file_system_context_.get();
......@@ -115,6 +118,8 @@ class SimpleFileSystem
ReadDirectoryHandler(WebKit::WebFileSystemCallbacks* callbacks);
fileapi::FileSystemContext::OpenFileSystemCallback OpenFileSystemHandler(
WebKit::WebFileSystemCallbacks* callbacks);
fileapi::FileSystemContext::DeleteFileSystemCallback DeleteFileSystemHandler(
WebKit::WebFileSystemCallbacks* callbacks);
fileapi::FileSystemOperationInterface::SnapshotFileCallback
SnapshotFileHandler(const GURL& blob_url,
WebKit::WebFileSystemCallbacks* callbacks);
......@@ -132,6 +137,8 @@ class SimpleFileSystem
void DidOpenFileSystem(WebKit::WebFileSystemCallbacks* callbacks,
base::PlatformFileError result,
const std::string& name, const GURL& root);
void DidDeleteFileSystem(WebKit::WebFileSystemCallbacks* callbacks,
base::PlatformFileError result);
void DidCreateSnapshotFile(
const GURL& blob_url,
WebKit::WebFileSystemCallbacks* callbacks,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment