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

Unified Diff: third_party/WebKit/Source/core/fileapi/FileReader.cpp

Issue 2491363003: Make FileReader.abort() (synchronously) follow the spec. (Closed)
Patch Set: Created 4 years, 1 month 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 | « third_party/WebKit/Source/core/fileapi/FileReader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/fileapi/FileReader.cpp
diff --git a/third_party/WebKit/Source/core/fileapi/FileReader.cpp b/third_party/WebKit/Source/core/fileapi/FileReader.cpp
index 036e3606fe2fce495f2937c28e2133521bf91c55..1ec15f70a957deb7afe7e1f0b7e75de4cfcd30b1 100644
--- a/third_party/WebKit/Source/core/fileapi/FileReader.cpp
+++ b/third_party/WebKit/Source/core/fileapi/FileReader.cpp
@@ -322,10 +322,6 @@ void FileReader::executePendingRead() {
m_blobDataHandle = nullptr;
}
-static void delayedAbort(FileReader* reader) {
- reader->doAbort();
-}
-
void FileReader::abort() {
DVLOG(1) << "aborting";
@@ -335,20 +331,12 @@ void FileReader::abort() {
}
m_loadingState = LoadingStateAborted;
- // Schedule to have the abort done later since abort() might be called from
- // the event handler and we do not want the resource loading code to be in the
- // stack.
- getExecutionContext()->postTask(
- BLINK_FROM_HERE,
- createSameThreadTask(&delayedAbort, wrapPersistent(this)));
-}
-
-void FileReader::doAbort() {
DCHECK_NE(kDone, m_state);
- AutoReset<bool> firingEvents(&m_stillFiringEvents, true);
+ m_state = kDone;
- terminate();
+ AutoReset<bool> firingEvents(&m_stillFiringEvents, true);
+ // Setting error implicitly makes |result| return null.
m_error = FileError::createDOMException(FileError::kAbortErr);
// Unregister the reader.
@@ -361,10 +349,18 @@ void FileReader::doAbort() {
// All possible events have fired and we're done, no more pending activity.
ThrottlingController::finishReader(getExecutionContext(), this, finalStep);
+
+ // ..but perform the loader cancellation asynchronously as abort() could be
+ // called from the event handler and we do not want the resource loading code
+ // to be on the stack when doing so. The persistent reference keeps the
+ // reader alive until the task has completed.
+ getExecutionContext()->postTask(
+ BLINK_FROM_HERE,
+ createSameThreadTask(&FileReader::terminate, wrapPersistent(this)));
}
void FileReader::result(StringOrArrayBuffer& resultAttribute) const {
- if (!m_loader || m_error)
+ if (m_error || !m_loader)
return;
if (m_readType == FileReaderLoader::ReadAsArrayBuffer)
@@ -445,8 +441,7 @@ void FileReader::didFail(FileError::ErrorCode errorCode) {
DCHECK_NE(kDone, m_state);
m_state = kDone;
- m_error = FileError::createDOMException(
- static_cast<FileError::ErrorCode>(errorCode));
+ m_error = FileError::createDOMException(errorCode);
// Unregister the reader.
ThrottlingController::FinishReaderType finalStep =
« no previous file with comments | « third_party/WebKit/Source/core/fileapi/FileReader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698