Commit 402dbf5a authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Set more URLLoaderCompletionStatus data for successful FileURLLoaderFactory loads

This CL allows SimpleURLLoader's to successfully load file:// URLs, ie when
using FileURLLoaderFactory.

Prior to this CL, even on the file specified in the file:// URL is written
successfully, the URLLoaderCompletionStatus instance is passed to the
URLLoaderClient from FileURLLoader::OnFileWritten, had only with the
|error_code| set.

SimpleURLLoader checks other URLLoaderCompletionStatus class members,
(eg |decoded_body_length|) in order to consider the load actually successful.

BUG=773295,844928

Change-Id: I1040775fad2af7f0eb88f81e48bb355d48e5fc31
Reviewed-on: https://chromium-review.googlesource.com/1159042Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#580130}
parent 2f0bee38
......@@ -519,6 +519,9 @@ class FileURLLoader : public network::mojom::URLLoader {
size_t first_byte_to_send = 0;
size_t total_bytes_to_send = static_cast<size_t>(info.size);
total_bytes_written_ = static_cast<size_t>(info.size);
if (byte_range.IsValid()) {
first_byte_to_send =
static_cast<size_t>(byte_range.first_byte_position());
......@@ -607,10 +610,15 @@ class FileURLLoader : public network::mojom::URLLoader {
if (observer)
observer->OnDoneReading();
if (result == MOJO_RESULT_OK)
client_->OnComplete(network::URLLoaderCompletionStatus(net::OK));
else
if (result == MOJO_RESULT_OK) {
network::URLLoaderCompletionStatus status(net::OK);
status.encoded_data_length = total_bytes_written_;
status.encoded_body_length = total_bytes_written_;
status.decoded_body_length = total_bytes_written_;
client_->OnComplete(status);
} else {
client_->OnComplete(network::URLLoaderCompletionStatus(net::ERR_FAILED));
}
client_.reset();
MaybeDeleteSelf();
}
......@@ -619,6 +627,11 @@ class FileURLLoader : public network::mojom::URLLoader {
mojo::Binding<network::mojom::URLLoader> binding_;
network::mojom::URLLoaderClientPtr client_;
// In case of successful loads, this holds the total of bytes written.
// It is used to set some of the URLLoaderCompletionStatus data passed back
// to the URLLoaderClients (eg SimpleURLLoader).
size_t total_bytes_written_ = 0;
DISALLOW_COPY_AND_ASSIGN(FileURLLoader);
};
......
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