Commit 7f6604cb authored by Eric Roman's avatar Eric Roman Committed by Commit Bot

Account for byte range restriction in URLLoaderCompletionStatus sizes for file://.

Bug: 759230
Change-Id: Ic94211a04bc97afd01097b099a42ad7d365f09cc
Reviewed-on: https://chromium-review.googlesource.com/c/1244297Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Eric Roman <eroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596021}
parent 4cf2f73e
...@@ -560,8 +560,6 @@ class FileURLLoader : public network::mojom::URLLoader { ...@@ -560,8 +560,6 @@ class FileURLLoader : public network::mojom::URLLoader {
size_t first_byte_to_send = 0; size_t first_byte_to_send = 0;
size_t total_bytes_to_send = static_cast<size_t>(info.size); 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()) { if (byte_range.IsValid()) {
first_byte_to_send = first_byte_to_send =
static_cast<size_t>(byte_range.first_byte_position()); static_cast<size_t>(byte_range.first_byte_position());
...@@ -570,6 +568,8 @@ class FileURLLoader : public network::mojom::URLLoader { ...@@ -570,6 +568,8 @@ class FileURLLoader : public network::mojom::URLLoader {
first_byte_to_send + 1; first_byte_to_send + 1;
} }
total_bytes_written_ = static_cast<size_t>(total_bytes_to_send);
head.content_length = base::saturated_cast<int64_t>(total_bytes_to_send); head.content_length = base::saturated_cast<int64_t>(total_bytes_to_send);
if (first_byte_to_send < initial_read_size) { if (first_byte_to_send < initial_read_size) {
...@@ -677,7 +677,9 @@ class FileURLLoader : public network::mojom::URLLoader { ...@@ -677,7 +677,9 @@ class FileURLLoader : public network::mojom::URLLoader {
network::mojom::URLLoaderClientPtr client_; network::mojom::URLLoaderClientPtr client_;
std::unique_ptr<RedirectData> redirect_data_; std::unique_ptr<RedirectData> redirect_data_;
// In case of successful loads, this holds the total of bytes written. // In case of successful loads, this holds the total number of bytes written
// to the response (this may be smaller than the total size of the file when
// a byte range was requested).
// It is used to set some of the URLLoaderCompletionStatus data passed back // It is used to set some of the URLLoaderCompletionStatus data passed back
// to the URLLoaderClients (eg SimpleURLLoader). // to the URLLoaderClients (eg SimpleURLLoader).
size_t total_bytes_written_ = 0; size_t total_bytes_written_ = 0;
......
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