Chromium Code Reviews| Index: third_party/WebKit/Source/modules/filesystem/DOMFileSystem.cpp |
| diff --git a/third_party/WebKit/Source/modules/filesystem/DOMFileSystem.cpp b/third_party/WebKit/Source/modules/filesystem/DOMFileSystem.cpp |
| index 619f3c801317714b8dd2909811cfdfc35c28e272..2874834b230303bdbe95793e9382ac271d86f197 100644 |
| --- a/third_party/WebKit/Source/modules/filesystem/DOMFileSystem.cpp |
| +++ b/third_party/WebKit/Source/modules/filesystem/DOMFileSystem.cpp |
| @@ -31,6 +31,7 @@ |
| #include "modules/filesystem/DOMFileSystem.h" |
| #include "core/fileapi/BlobCallback.h" |
| +#include "core/inspector/InspectorInstrumentation.h" |
| #include "modules/filesystem/DOMFilePath.h" |
| #include "modules/filesystem/DirectoryEntry.h" |
| #include "modules/filesystem/FileEntry.h" |
| @@ -40,6 +41,7 @@ |
| #include "modules/filesystem/FileWriterCallback.h" |
| #include "modules/filesystem/MetadataCallback.h" |
| #include "platform/FileMetadata.h" |
| +#include "platform/WebTaskRunner.h" |
| #include "platform/weborigin/SecurityOrigin.h" |
| #include "public/platform/Platform.h" |
| #include "public/platform/WebFileSystem.h" |
| @@ -51,6 +53,18 @@ |
| namespace blink { |
| +namespace { |
| + |
| +void runCallback(ExecutionContext* executionContext, |
| + std::unique_ptr<WTF::Closure> task) { |
| + DCHECK(executionContext->isContextThread()); |
| + InspectorInstrumentation::AsyncTask asyncTask(executionContext, task.get(), |
| + true /* isInstrumented */); |
| + (*task)(); |
| +} |
| + |
| +} // namespace |
| + |
| // static |
| DOMFileSystem* DOMFileSystem::create(ExecutionContext* context, |
| const String& name, |
| @@ -122,10 +136,10 @@ void DOMFileSystem::reportError(ErrorCallbackBase* errorCallback, |
| void DOMFileSystem::reportError(ExecutionContext* executionContext, |
| ErrorCallbackBase* errorCallback, |
| FileError::ErrorCode fileError) { |
| - if (errorCallback) |
| - scheduleCallback( |
| - executionContext, |
| - createSameThreadTask(&ErrorCallbackBase::invoke, |
| + if (!errorCallback) |
| + return; |
| + scheduleCallback(executionContext, |
| + WTF::bind(&ErrorCallbackBase::invoke, |
| wrapPersistent(errorCallback), fileError)); |
| } |
| @@ -189,6 +203,17 @@ void DOMFileSystem::createFile(const FileEntry* fileEntry, |
| successCallback, errorCallback, m_context)); |
| } |
| +void DOMFileSystem::scheduleCallback(ExecutionContext* executionContext, |
| + std::unique_ptr<WTF::Closure> task) { |
| + DCHECK(executionContext->isContextThread()); |
| + InspectorInstrumentation::asyncTaskScheduled( |
| + executionContext, taskNameForInstrumentation(), task.get()); |
| + TaskRunnerHelper::get(TaskType::FileReading, executionContext) |
| + ->postTask(BLINK_FROM_HERE, |
| + WTF::bind(&runCallback, wrapPersistent(executionContext), |
|
tzik
2017/01/19 04:16:09
Can we use wrapWeakPersistent and check its value
nhiroki
2017/01/19 04:33:40
Done.
|
| + WTF::passed(std::move(task)))); |
| +} |
| + |
| DEFINE_TRACE(DOMFileSystem) { |
| DOMFileSystemBase::trace(visitor); |
| ContextLifecycleObserver::trace(visitor); |