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

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: Avoid warning from PHP's fread() on empty reads 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
Index: Source/core/fileapi/FileReader.cpp
diff --git a/Source/core/fileapi/FileReader.cpp b/Source/core/fileapi/FileReader.cpp
index c94eadb93f630995f4302f736f19d287a60275d6..fe615df78c88ac0529f28c1045fd3b60154eb27c 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()) {
michaeln 2014/02/12 20:33:04 The big question is where else do we have to make
sof 2014/02/12 22:28:26 Yes, that is a question still on the table. I don'
+ 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 = 0;
}
static void delayedAbort(ExecutionContext*, FileReader* reader)

Powered by Google App Engine
This is Rietveld 408576698