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

Unified Diff: storage/browser/blob/blob_reader.cc

Issue 1846363002: [BlobAsync] Adding better error reporting and some new tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed switch statement Created 4 years, 9 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: storage/browser/blob/blob_reader.cc
diff --git a/storage/browser/blob/blob_reader.cc b/storage/browser/blob/blob_reader.cc
index 0ac6622b958da020bcf3ec8dc1ddf3cd7f259909..2a07a83960c6dc1679ed679d850fc9f78b7e45d4 100644
--- a/storage/browser/blob/blob_reader.cc
+++ b/storage/browser/blob/blob_reader.cc
@@ -37,6 +37,24 @@ bool IsFileType(DataElement::Type type) {
return false;
}
}
+
+int TransformBlobErrorToNetError(IPCBlobCreationCancelCode reason) {
+ switch (reason) {
+ case IPCBlobCreationCancelCode::UNKNOWN:
+ return net::ERR_FAILED;
+ case IPCBlobCreationCancelCode::OUT_OF_MEMORY:
+ return net::ERR_OUT_OF_MEMORY;
+ case IPCBlobCreationCancelCode::FILE_WRITE_FAILED:
+ return net::ERR_FILE_NO_SPACE;
+ case IPCBlobCreationCancelCode::SOURCE_DIED_IN_TRANSIT:
+ return net::ERR_UNEXPECTED;
+ case IPCBlobCreationCancelCode::BLOB_DEREFERENCED_WHILE_BUILDING:
+ return net::ERR_UNEXPECTED;
+ case IPCBlobCreationCancelCode::REFERENCED_BLOB_BROKEN:
+ return net::ERR_INVALID_HANDLE;
+ }
+ NOTREACHED();
+}
} // namespace
BlobReader::FileStreamReaderProvider::~FileStreamReaderProvider() {}
@@ -183,9 +201,10 @@ BlobReader::Status BlobReader::ReportError(int net_error) {
}
void BlobReader::AsyncCalculateSize(const net::CompletionCallback& done,
- bool async_succeeded) {
+ bool async_succeeded,
+ IPCBlobCreationCancelCode reason) {
if (!async_succeeded) {
- InvalidateCallbacksAndDone(net::ERR_FAILED, done);
+ InvalidateCallbacksAndDone(TransformBlobErrorToNetError(reason), done);
return;
}
DCHECK(!blob_handle_->IsBroken()) << "Callback should have returned false.";

Powered by Google App Engine
This is Rietveld 408576698