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

Unified Diff: Source/modules/filesystem/LocalFileSystem.cpp

Issue 277353002: Use asynchronized api for file system request. [blink] (3/4) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update CL according to changes in CL 289793002. Created 6 years, 7 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
Index: Source/modules/filesystem/LocalFileSystem.cpp
diff --git a/Source/modules/filesystem/LocalFileSystem.cpp b/Source/modules/filesystem/LocalFileSystem.cpp
index 98d046d5beecfa556938bcf35821c9b5f255a86a..6a2a3b4fb9f533487302fbae251e7c545952fcc0 100644
--- a/Source/modules/filesystem/LocalFileSystem.cpp
+++ b/Source/modules/filesystem/LocalFileSystem.cpp
@@ -41,8 +41,10 @@
#include "modules/filesystem/FileSystemClient.h"
#include "modules/filesystem/InspectorFileSystemAgent.h"
#include "platform/AsyncFileSystemCallbacks.h"
+#include "platform/PermissionCallbacks.h"
#include "public/platform/Platform.h"
#include "public/platform/WebFileSystem.h"
+#include "wtf/Functional.h"
namespace WebCore {
@@ -66,16 +68,16 @@ LocalFileSystem::~LocalFileSystem()
void LocalFileSystem::resolveURL(ExecutionContext* context, const KURL& fileSystemURL, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
{
- if (!client() || !client()->allowFileSystem(context)) {
+ if (!client() || !client()->requestFileSystemAccessSync(context)) {
kinuko 2014/05/16 10:47:05 Why we call Sync one here? resolveURL could be ca
Xi Han 2014/05/16 19:48:44 Great catch! The deleteFileSystem is the same case
context->postTask(createCallbackTask(&fileSystemNotAllowed, callbacks));
return;
}
blink::Platform::current()->fileSystem()->resolveURL(fileSystemURL, callbacks);
}
-void LocalFileSystem::requestFileSystem(ExecutionContext* context, FileSystemType type, long long size, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void LocalFileSystem::requestFileSystemSync(ExecutionContext* context, FileSystemType type, long long size, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
{
- if (!client() || !client()->allowFileSystem(context)) {
+ if (!client() || !client()->requestFileSystemAccessSync(context)) {
context->postTask(createCallbackTask(&fileSystemNotAllowed, callbacks));
return;
}
@@ -83,12 +85,38 @@ void LocalFileSystem::requestFileSystem(ExecutionContext* context, FileSystemTyp
blink::Platform::current()->fileSystem()->openFileSystem(storagePartition, static_cast<blink::WebFileSystemType>(type), callbacks);
}
+void LocalFileSystem::requestFileSystemAsync(ExecutionContext* context, FileSystemType type, long long size, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+{
+ if (!client()) {
+ context->postTask(createCallbackTask(&fileSystemNotAllowed, callbacks));
+ return;
+ }
+ client()->requestFileSystemAccessAsync(context, PermissionCallbacks::create(
+ bind(&LocalFileSystem::fileSystemAllowedCallbacks, this, context, type, callbacks),
kinuko 2014/05/16 10:47:05 I haven't looked deeper into the bind implementati
Xi Han 2014/05/16 19:48:44 Done.
+ bind(&LocalFileSystem::fileSystemNotAllowedCallbacks, this, context, callbacks)));
+}
+
+void LocalFileSystem::fileSystemNotAllowedCallbacks(
+ ExecutionContext* context,
+ PassOwnPtr<AsyncFileSystemCallbacks> callbacks) {
+ context->postTask(createCallbackTask(&fileSystemNotAllowed, callbacks));
+}
+
+void LocalFileSystem::fileSystemAllowedCallbacks(
+ ExecutionContext* context,
+ FileSystemType type,
+ PassOwnPtr<AsyncFileSystemCallbacks> callbacks) {
+ KURL storagePartition = KURL(KURL(), context->securityOrigin()->toString());
+ blink::Platform::current()->fileSystem()->openFileSystem(storagePartition, static_cast<blink::WebFileSystemType>(type), callbacks);
+}
+
void LocalFileSystem::deleteFileSystem(ExecutionContext* context, FileSystemType type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
{
ASSERT(context);
ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument());
- if (!client() || !client()->allowFileSystem(context)) {
+
+ if (!client() || !client()->requestFileSystemAccessSync(context)) {
context->postTask(createCallbackTask(&fileSystemNotAllowed, callbacks));
return;
}

Powered by Google App Engine
This is Rietveld 408576698