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

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

Issue 184473002: Sync Blob.close() behavior wrt updated spec. (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/File.h ('k') | Source/modules/filesystem/InspectorFileSystemAgent.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fileapi/File.cpp
diff --git a/Source/core/fileapi/File.cpp b/Source/core/fileapi/File.cpp
index d05e36087bb81e70f744645ea5e127852bbcf207..127eaca08570e883380f1ebac60a3d9f3473aacf 100644
--- a/Source/core/fileapi/File.cpp
+++ b/Source/core/fileapi/File.cpp
@@ -26,6 +26,8 @@
#include "config.h"
#include "core/fileapi/File.h"
+#include "bindings/v8/ExceptionState.h"
+#include "core/dom/ExceptionCode.h"
#include "platform/FileMetadata.h"
#include "platform/MIMETypeRegistry.h"
#include "public/platform/Platform.h"
@@ -181,10 +183,15 @@ unsigned long long File::size() const
return static_cast<unsigned long long>(size);
}
-PassRefPtrWillBeRawPtr<Blob> File::slice(long long start, long long end, const String& contentType) const
+PassRefPtrWillBeRawPtr<Blob> File::slice(long long start, long long end, const String& contentType, ExceptionState& exceptionState) const
{
+ if (hasBeenClosed()) {
+ exceptionState.throwDOMException(InvalidStateError, "File has been closed.");
+ return nullptr;
+ }
+
if (!m_hasBackingFile)
- return Blob::slice(start, end, contentType);
+ return Blob::slice(start, end, contentType, exceptionState);
// FIXME: This involves synchronous file operation. We need to figure out how to make it asynchronous.
long long size;
@@ -225,19 +232,22 @@ void File::captureSnapshot(long long& snapshotSize, double& snapshotModification
snapshotModificationTime = metadata.modificationTime;
}
-void File::close(ExecutionContext* executionContext)
+void File::close(ExecutionContext* executionContext, ExceptionState& exceptionState)
{
- if (!hasBeenClosed()) {
- // Reset the File to its closed representation, an empty
- // Blob. The name isn't cleared, as it should still be
- // available.
- m_hasBackingFile = false;
- m_path = String();
- m_fileSystemURL = KURL();
- invalidateSnapshotMetadata();
- m_relativePath = String();
- Blob::close(executionContext);
+ if (hasBeenClosed()) {
+ exceptionState.throwDOMException(InvalidStateError, "Blob has been closed.");
+ return;
}
+
+ // Reset the File to its closed representation, an empty
+ // Blob. The name isn't cleared, as it should still be
+ // available.
+ m_hasBackingFile = false;
+ m_path = String();
+ m_fileSystemURL = KURL();
+ invalidateSnapshotMetadata();
+ m_relativePath = String();
+ Blob::close(executionContext, exceptionState);
}
void File::appendTo(BlobData& blobData) const
« no previous file with comments | « Source/core/fileapi/File.h ('k') | Source/modules/filesystem/InspectorFileSystemAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698