chore: bump chromium to 32e0bab929213da1019992bf31d29 (master) (#19488)

This commit is contained in:
Electron Bot 2019-08-02 16:56:46 -07:00 committed by Jeremy Apthorp
parent d0800aa200
commit e959137a4b
112 changed files with 524 additions and 5639 deletions

View file

@ -27,6 +27,23 @@ namespace asar {
namespace {
net::Error ConvertMojoResultToNetError(MojoResult result) {
switch (result) {
case MOJO_RESULT_OK:
return net::OK;
case MOJO_RESULT_NOT_FOUND:
return net::ERR_FILE_NOT_FOUND;
case MOJO_RESULT_PERMISSION_DENIED:
return net::ERR_ACCESS_DENIED;
case MOJO_RESULT_RESOURCE_EXHAUSTED:
return net::ERR_INSUFFICIENT_RESOURCES;
case MOJO_RESULT_ABORTED:
return net::ERR_ABORTED;
default:
return net::ERR_FAILED;
}
}
constexpr size_t kDefaultFileUrlPipeSize = 65536;
// Because this makes things simpler.
@ -55,7 +72,6 @@ class AsarURLLoader : public network::mojom::URLLoader {
void FollowRedirect(const std::vector<std::string>& removed_headers,
const net::HttpRequestHeaders& modified_headers,
const base::Optional<GURL>& new_url) override {}
void ProceedWithResponse() override {}
void SetPriority(net::RequestPriority priority,
int32_t intra_priority_value) override {}
void PauseReadingBodyFromNet() override {}
@ -121,24 +137,17 @@ class AsarURLLoader : public network::mojom::URLLoader {
// requests at the same time.
base::File file(info.unpacked ? real_path : archive->path(),
base::File::FLAG_OPEN | base::File::FLAG_READ);
// Move cursor to sub-file.
file.Seek(base::File::FROM_BEGIN, info.offset);
auto file_data_source =
std::make_unique<mojo::FileDataSource>(std::move(file));
mojo::DataPipeProducer::DataSource* data_source = file_data_source.get();
// File reading logics are copied from FileURLLoader.
if (!file.IsValid()) {
OnClientComplete(net::FileErrorToNetError(file.error_details()));
std::vector<char> initial_read_buffer(net::kMaxBytesToSniff);
auto read_result =
data_source->Read(info.offset, base::span<char>(initial_read_buffer));
if (read_result.result != MOJO_RESULT_OK) {
OnClientComplete(ConvertMojoResultToNetError(read_result.result));
return;
}
char initial_read_buffer[net::kMaxBytesToSniff];
int initial_read_result =
file.ReadAtCurrentPos(initial_read_buffer, net::kMaxBytesToSniff);
if (initial_read_result < 0) {
base::File::Error read_error = base::File::GetLastFileError();
DCHECK_NE(base::File::FILE_OK, read_error);
OnClientComplete(net::FileErrorToNetError(read_error));
return;
}
size_t initial_read_size = static_cast<size_t>(initial_read_result);
std::string range_header;
net::HttpByteRange byte_range;
@ -162,27 +171,25 @@ class AsarURLLoader : public network::mojom::URLLoader {
}
}
size_t first_byte_to_send = 0;
size_t total_bytes_to_send = static_cast<size_t>(info.size);
uint64_t first_byte_to_send = 0;
uint64_t total_bytes_to_send = info.size;
if (byte_range.IsValid()) {
first_byte_to_send =
static_cast<size_t>(byte_range.first_byte_position());
first_byte_to_send = byte_range.first_byte_position();
total_bytes_to_send =
static_cast<size_t>(byte_range.last_byte_position()) -
first_byte_to_send + 1;
byte_range.last_byte_position() - first_byte_to_send + 1;
}
total_bytes_written_ = static_cast<size_t>(total_bytes_to_send);
total_bytes_written_ = 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 < read_result.bytes_read) {
// Write any data we read for MIME sniffing, constraining by range where
// applicable. This will always fit in the pipe (see assertion near
// |kDefaultFileUrlPipeSize| definition).
uint32_t write_size = std::min(
static_cast<uint32_t>(initial_read_size - first_byte_to_send),
static_cast<uint32_t>(read_result.bytes_read - first_byte_to_send),
static_cast<uint32_t>(total_bytes_to_send));
const uint32_t expected_write_size = write_size;
MojoResult result = pipe.producer_handle->WriteData(
@ -194,14 +201,14 @@ class AsarURLLoader : public network::mojom::URLLoader {
}
// Discount the bytes we just sent from the total range.
first_byte_to_send = initial_read_size;
first_byte_to_send = read_result.bytes_read;
total_bytes_to_send -= write_size;
}
if (!net::GetMimeTypeFromFile(path, &head.mime_type)) {
std::string new_type;
net::SniffMimeType(initial_read_buffer, initial_read_result, request.url,
head.mime_type,
net::SniffMimeType(initial_read_buffer.data(), read_result.bytes_read,
request.url, head.mime_type,
net::ForceSniffFileUrlsForHtml::kDisabled, &new_type);
head.mime_type.assign(new_type);
head.did_mime_sniff = true;
@ -225,14 +232,14 @@ class AsarURLLoader : public network::mojom::URLLoader {
// (i.e., no range request) this Seek is effectively a no-op.
//
// Note that in Electron we also need to add file offset.
file.Seek(base::File::FROM_BEGIN,
static_cast<int64_t>(first_byte_to_send) + info.offset);
file_data_source->SetRange(
first_byte_to_send + info.offset,
first_byte_to_send + info.offset + total_bytes_to_send);
data_producer_ = std::make_unique<mojo::DataPipeProducer>(
std::move(pipe.producer_handle));
data_producer_->Write(
std::make_unique<mojo::FileDataSource>(std::move(file),
total_bytes_to_send),
std::move(file_data_source),
base::BindOnce(&AsarURLLoader::OnFileWritten, base::Unretained(this)));
}