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

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

Issue 157363003: Implement Blob.close(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 6 years, 10 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
« no previous file with comments | « Source/core/fileapi/FileReader.h ('k') | Source/core/html/PublicURLManager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fileapi/FileReader.cpp
diff --git a/Source/core/fileapi/FileReader.cpp b/Source/core/fileapi/FileReader.cpp
index 012d118b6a57988c1a56fbdc0da7cbf0870b2c48..362e398e2e08496ef2e3b0ef932d89ea70870fb5 100644
--- a/Source/core/fileapi/FileReader.cpp
+++ b/Source/core/fileapi/FileReader.cpp
@@ -220,7 +220,16 @@ void FileReader::readInternal(Blob* blob, FileReaderLoader::ReadType type, Excep
return;
}
- m_blob = blob;
+ if (blob->hasBeenClosed()) {
+ exceptionState.throwDOMException(InvalidStateError, String(blob->isFile() ? "File" : "Blob") + " has been closed.");
+ return;
+ }
+
+ // "Snapshot" the Blob data rather than the Blob itself as ongoing
+ // read operations should not be affected if close() is called on
+ // the Blob being read.
+ m_blobDataHandle = blob->blobDataHandle();
+ m_blobType = blob->type();
m_readType = type;
m_state = LOADING;
m_loadingState = LoadingStatePending;
@@ -235,8 +244,9 @@ void FileReader::executePendingRead()
m_loader = adoptPtr(new FileReaderLoader(m_readType, this));
m_loader->setEncoding(m_encoding);
- m_loader->setDataType(m_blob->type());
- m_loader->start(executionContext(), m_blob->blobDataHandle());
+ m_loader->setDataType(m_blobType);
+ m_loader->start(executionContext(), m_blobDataHandle);
+ m_blobDataHandle = nullptr;
}
static void delayedAbort(ExecutionContext*, FileReader* reader)
« no previous file with comments | « Source/core/fileapi/FileReader.h ('k') | Source/core/html/PublicURLManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698