chore: bump chromium to 32e0bab929213da1019992bf31d29 (master) (#19488)
This commit is contained in:
parent
d0800aa200
commit
e959137a4b
112 changed files with 524 additions and 5639 deletions
|
@ -1,34 +0,0 @@
|
|||
// Copyright (c) 2014 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/net/asar/asar_protocol_handler.h"
|
||||
|
||||
#include "base/task_runner.h"
|
||||
#include "net/base/filename_util.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "shell/browser/net/asar/url_request_asar_job.h"
|
||||
|
||||
namespace asar {
|
||||
|
||||
AsarProtocolHandler::AsarProtocolHandler(
|
||||
const scoped_refptr<base::TaskRunner>& file_task_runner)
|
||||
: file_task_runner_(file_task_runner) {}
|
||||
|
||||
AsarProtocolHandler::~AsarProtocolHandler() {}
|
||||
|
||||
net::URLRequestJob* AsarProtocolHandler::MaybeCreateJob(
|
||||
net::URLRequest* request,
|
||||
net::NetworkDelegate* network_delegate) const {
|
||||
base::FilePath full_path;
|
||||
net::FileURLToFilePath(request->url(), &full_path);
|
||||
auto* job = new URLRequestAsarJob(request, network_delegate);
|
||||
job->Initialize(file_task_runner_, full_path);
|
||||
return job;
|
||||
}
|
||||
|
||||
bool AsarProtocolHandler::IsSafeRedirectTarget(const GURL& location) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace asar
|
|
@ -1,37 +0,0 @@
|
|||
// Copyright (c) 2014 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_BROWSER_NET_ASAR_ASAR_PROTOCOL_HANDLER_H_
|
||||
#define SHELL_BROWSER_NET_ASAR_ASAR_PROTOCOL_HANDLER_H_
|
||||
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "net/url_request/url_request_job_factory.h"
|
||||
|
||||
namespace base {
|
||||
class TaskRunner;
|
||||
}
|
||||
|
||||
namespace asar {
|
||||
|
||||
class AsarProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler {
|
||||
public:
|
||||
explicit AsarProtocolHandler(
|
||||
const scoped_refptr<base::TaskRunner>& file_task_runner);
|
||||
~AsarProtocolHandler() override;
|
||||
|
||||
// net::URLRequestJobFactory::ProtocolHandler:
|
||||
net::URLRequestJob* MaybeCreateJob(
|
||||
net::URLRequest* request,
|
||||
net::NetworkDelegate* network_delegate) const override;
|
||||
bool IsSafeRedirectTarget(const GURL& location) const override;
|
||||
|
||||
private:
|
||||
const scoped_refptr<base::TaskRunner> file_task_runner_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AsarProtocolHandler);
|
||||
};
|
||||
|
||||
} // namespace asar
|
||||
|
||||
#endif // SHELL_BROWSER_NET_ASAR_ASAR_PROTOCOL_HANDLER_H_
|
|
@ -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)));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue