Commit 86d0536a authored by Robbie McElrath's avatar Robbie McElrath Committed by Commit Bot

Fix ExternalFileURLLoader error handling

When ExternalFileURLLoader gets an error when reading data from disk,
it handles the error, and then tries to continue copying data. This
makes it stop when it encounters an error.

Bug: 925565
Change-Id: I61938040c485ecd7e607363366433532281547e0
Reviewed-on: https://chromium-review.googlesource.com/c/1437706Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarNaoki Fukino <fukino@chromium.org>
Commit-Queue: Robbie McElrath <rmcelrath@chromium.org>
Cr-Commit-Position: refs/heads/master@{#626492}
parent d2e7ed1f
......@@ -112,7 +112,11 @@ class FileSystemReaderDataPipeProducer {
// be called when the read is complete.
if (read_size == net::ERR_IO_PENDING)
return;
OnWroteData(read_size);
net::Error write_error = FinishWrite(read_size);
if (write_error != net::OK) {
CompleteWithResult(write_error);
return;
}
}
CompleteWithResult(net::OK);
}
......@@ -120,23 +124,24 @@ class FileSystemReaderDataPipeProducer {
int64_t total_bytes_written() { return total_bytes_written_; }
private:
void OnWroteData(int read_size) {
net::Error FinishWrite(int read_size) {
MojoResult result =
producer_handle_->EndWriteData(std::max<int>(0, read_size));
if (read_size <= 0) {
CompleteWithResult(static_cast<net::Error>(read_size));
return;
}
if (result != MOJO_RESULT_OK) {
CompleteWithResult(MojoResultToErrorCode(result));
return;
}
if (read_size <= 0)
return static_cast<net::Error>(read_size);
if (result != MOJO_RESULT_OK)
return MojoResultToErrorCode(result);
remaining_bytes_ -= read_size;
total_bytes_written_ += read_size;
return net::OK;
}
void OnPendingReadComplete(int read_result) {
OnWroteData(read_result);
net::Error result = FinishWrite(read_result);
if (result != net::OK) {
CompleteWithResult(result);
return;
}
Write();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment