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

Unified Diff: WebCore/html/FileStream.cpp

Issue 1769002: BlobBuilder/FormData refactor attempt (Closed)
Patch Set: back to simple FormData Created 10 years, 7 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 | « WebCore/html/FileReader.cpp ('k') | WebCore/html/FormDataList.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: WebCore/html/FileStream.cpp
diff --git a/WebCore/html/FileStream.cpp b/WebCore/html/FileStream.cpp
index 9a06eed9fd66f8e37f37f9dd50435b56e9cc6141..f859b63a1c1b34c36e74c09124fa0913f6af6704 100644
--- a/WebCore/html/FileStream.cpp
+++ b/WebCore/html/FileStream.cpp
@@ -72,48 +72,53 @@ void FileStream::openForRead(Blob* blob)
if (isHandleValid(m_handle))
return;
+ // FIXME: Need to handle multiple items that may include non-file ones when BlobBuilder is introduced.
+ ASSERT(blob->items().size() >= 1);
+ const FileBlobItem* fileItem = blob->items().at(0)->toFileBlobItem();
+ if (!fileItem) {
+ ASSERT(false);
+ m_client->didFail(NOT_READABLE_ERR);
+ return;
+ }
+
// Check if the file exists by querying its modification time. We choose not to call fileExists() in order to save an
// extra file system call when the modification time is needed to check the validity of the sliced file blob.
// Per the spec, we need to return different error codes to differentiate between non-existent file and permission error.
// openFile() could not tell use the failure reason.
time_t currentModificationTime;
- if (!getFileModificationTime(blob->path(), currentModificationTime)) {
+ if (!getFileModificationTime(fileItem->path(), currentModificationTime)) {
m_client->didFail(NOT_FOUND_ERR);
return;
}
// Open the file blob.
- m_handle = openFile(blob->path(), OpenForRead);
+ m_handle = openFile(fileItem->path(), OpenForRead);
if (!isHandleValid(m_handle)) {
m_client->didFail(NOT_READABLE_ERR);
return;
}
#if ENABLE(BLOB_SLICE)
- // Check the modificationt time for the possible file change.
- if (blob->modificationTime() != Blob::doNotCheckFileChange && static_cast<time_t>(blob->modificationTime()) != currentModificationTime) {
- m_client->didFail(NOT_READABLE_ERR);
- return;
- }
-
- // Jump to the beginning position if the file has been sliced.
- if (blob->start() > 0) {
- if (!seekFile(m_handle, blob->start(), SeekFromBeginning)) {
+ const FileRangeBlobItem* fileRangeItem = fileItem->toFileRangeBlobItem();
+ if (fileRangeItem) {
+ // Check the modificationt time for the possible file change.
+ if (static_cast<time_t>(fileRangeItem->snapshotModificationTime()) != currentModificationTime) {
m_client->didFail(NOT_READABLE_ERR);
return;
}
+
+ // Jump to the beginning position if the file has been sliced.
+ if (fileRangeItem->start() > 0) {
+ if (seekFile(m_handle, fileRangeItem->start(), SeekFromBeginning) < 0) {
+ m_client->didFail(NOT_READABLE_ERR);
+ return;
+ }
+ }
}
#endif
// Get the size.
-#if ENABLE(BLOB_SLICE)
- m_totalBytesToRead = blob->length();
- if (m_totalBytesToRead == Blob::toEndOfFile)
- m_totalBytesToRead = blob->size() - blob->start();
-#else
m_totalBytesToRead = blob->size();
-#endif
-
m_client->didGetSize(m_totalBytesToRead);
}
« no previous file with comments | « WebCore/html/FileReader.cpp ('k') | WebCore/html/FormDataList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698