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

Unified Diff: Source/core/fileapi/File.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/File.h ('k') | Source/core/fileapi/FileReader.h » ('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 de776d5acfee62729976119c903e6f667c9a3112..74da421d0a2d19f2296219718b0cfa9b05e7fa9f 100644
--- a/Source/core/fileapi/File.cpp
+++ b/Source/core/fileapi/File.cpp
@@ -162,7 +162,7 @@ double File::lastModifiedDate() const
return m_snapshotModificationTime * msPerSecond;
time_t modificationTime;
- if (getFileModificationTime(m_path, modificationTime) && isValidFileTime(modificationTime))
+ if (hasBackingFile() && getFileModificationTime(m_path, modificationTime) && isValidFileTime(modificationTime))
return modificationTime * msPerSecond;
return currentTime() * msPerSecond;
@@ -176,7 +176,7 @@ unsigned long long File::size() const
// FIXME: JavaScript cannot represent sizes as large as unsigned long long, we need to
// come up with an exception to throw if file size is not representable.
long long size;
- if (!getFileSize(m_path, size))
+ if (!hasBackingFile() || !getFileSize(m_path, size))
return 0;
return static_cast<unsigned long long>(size);
}
@@ -215,7 +215,7 @@ void File::captureSnapshot(long long& snapshotSize, double& snapshotModification
// Obtains a snapshot of the file by capturing its current size and modification time. This is used when we slice a file for the first time.
// If we fail to retrieve the size or modification time, probably due to that the file has been deleted, 0 size is returned.
FileMetadata metadata;
- if (!getFileMetadata(m_path, metadata)) {
+ if (!hasBackingFile() || !getFileMetadata(m_path, metadata)) {
snapshotSize = 0;
snapshotModificationTime = invalidFileTime();
return;
@@ -225,6 +225,21 @@ void File::captureSnapshot(long long& snapshotSize, double& snapshotModification
snapshotModificationTime = metadata.modificationTime;
}
+void File::close(ExecutionContext* executionContext)
+{
+ 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);
+ }
+}
+
void File::appendTo(BlobData& blobData) const
{
if (!m_hasBackingFile) {
« no previous file with comments | « Source/core/fileapi/File.h ('k') | Source/core/fileapi/FileReader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698