From c30a6232df03e1efbd9f3b226777b07e087a1122 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 12 Oct 2020 14:27:29 +0200 Subject: BASELINE: Update Chromium to 85.0.4183.140 Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen --- chromium/ui/base/resource/data_pack.cc | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'chromium/ui/base/resource/data_pack.cc') diff --git a/chromium/ui/base/resource/data_pack.cc b/chromium/ui/base/resource/data_pack.cc index 618204dfcda..09513e6aed2 100644 --- a/chromium/ui/base/resource/data_pack.cc +++ b/chromium/ui/base/resource/data_pack.cc @@ -10,6 +10,7 @@ #include #include "base/command_line.h" +#include "base/files/file.h" #include "base/files/file_util.h" #include "base/files/memory_mapped_file.h" #include "base/logging.h" @@ -41,8 +42,11 @@ static const size_t kHeaderLengthV5 = // We're crashing when trying to load a pak file on Windows. Add some error // codes for logging. // http://crbug.com/58056 +// These values are logged to UMA. Entries should not be renumbered and +// numeric values should never be reused. Keep in sync with "DataPackLoadErrors" +// in src/tools/metrics/histograms/enums.xml. enum LoadErrors { - INIT_FAILED = 1, + INIT_FAILED_OBSOLETE = 1, BAD_VERSION, INDEX_TRUNCATED, ENTRY_NOT_FOUND, @@ -50,6 +54,8 @@ enum LoadErrors { WRONG_ENCODING, INIT_FAILED_FROM_FILE, UNZIP_FAILED, + OPEN_FAILED, + MAP_FAILED, LOAD_ERRORS_COUNT, }; @@ -274,9 +280,20 @@ DataPack::~DataPack() { bool DataPack::LoadFromPath(const base::FilePath& path) { std::unique_ptr mmap = std::make_unique(); - if (!mmap->Initialize(path)) { + // Open the file for reading; allowing other consumers to also open it for + // reading and deleting. Do not allow others to write to it. + base::File data_file(path, base::File::FLAG_OPEN | base::File::FLAG_READ | + base::File::FLAG_EXCLUSIVE_WRITE | + base::File::FLAG_SHARE_DELETE); + if (!data_file.IsValid()) { + DLOG(ERROR) << "Failed to open datapack with base::File::Error " + << data_file.error_details(); + LogDataPackError(OPEN_FAILED); + return false; + } + if (!mmap->Initialize(std::move(data_file))) { DLOG(ERROR) << "Failed to mmap datapack"; - LogDataPackError(INIT_FAILED); + LogDataPackError(MAP_FAILED); return false; } if (MmapHasGzipHeader(mmap.get())) { -- cgit v1.2.1