diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/ui/base/resource/data_pack.cc | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/ui/base/resource/data_pack.cc')
-rw-r--r-- | chromium/ui/base/resource/data_pack.cc | 23 |
1 files changed, 20 insertions, 3 deletions
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 <utility> #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<base::MemoryMappedFile> mmap = std::make_unique<base::MemoryMappedFile>(); - 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())) { |