summaryrefslogtreecommitdiffstats
path: root/chromium/base/files
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2023-09-05 12:37:36 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2023-10-17 13:53:46 +0000
commit5a424f4a7b188b75da63eb697f63558af0b17f6f (patch)
tree54c427fcbc567dac8181ab5fd22d20e72cc51609 /chromium/base/files
parentacbcf08a6dffdfe90a6eaf661fcd6923f0de2447 (diff)
BASELINE: Update Chromium to 116.0.5845.183
Change-Id: Iaaf57e02c218c93993a5044c659b63674e2c8a12 Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/512320 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/base/files')
-rw-r--r--chromium/base/files/file.h7
-rw-r--r--chromium/base/files/file_enumerator.h8
-rw-r--r--chromium/base/files/file_error_or_unittest.cc13
-rw-r--r--chromium/base/files/file_path.cc6
-rw-r--r--chromium/base/files/file_path_watcher_unittest.cc6
-rw-r--r--chromium/base/files/file_util.h2
-rw-r--r--chromium/base/files/file_util_android.cc2
-rw-r--r--chromium/base/files/file_util_mac.mm8
-rw-r--r--chromium/base/files/file_util_unittest.cc6
-rw-r--r--chromium/base/files/file_util_win.cc5
-rw-r--r--chromium/base/files/file_win.cc2
-rw-r--r--chromium/base/files/important_file_writer.cc3
-rw-r--r--chromium/base/files/os_validation_win_unittest.cc2
13 files changed, 45 insertions, 25 deletions
diff --git a/chromium/base/files/file.h b/chromium/base/files/file.h
index 35abbc2e4cb..1e0b440c920 100644
--- a/chromium/base/files/file.h
+++ b/chromium/base/files/file.h
@@ -34,6 +34,9 @@ using stat_wrapper_t = struct stat;
// obvious non-modifying way are marked as const. Any method that forward calls
// to the OS is not considered const, even if there is no apparent change to
// member variables.
+//
+// On POSIX, if the given file is a symbolic link, most of the methods apply to
+// the file that the symbolic link resolves to.
class BASE_EXPORT File {
public:
// FLAG_(OPEN|CREATE).* are mutually exclusive. You should specify exactly one
@@ -369,9 +372,11 @@ class BASE_EXPORT File {
static std::string ErrorToString(Error error);
#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
- // Wrapper for stat() or stat64().
+ // Wrapper for stat().
static int Stat(const char* path, stat_wrapper_t* sb);
+ // Wrapper for fstat().
static int Fstat(int fd, stat_wrapper_t* sb);
+ // Wrapper for lstat().
static int Lstat(const char* path, stat_wrapper_t* sb);
#endif
diff --git a/chromium/base/files/file_enumerator.h b/chromium/base/files/file_enumerator.h
index cbcfcafbaf9..0e40bdd440e 100644
--- a/chromium/base/files/file_enumerator.h
+++ b/chromium/base/files/file_enumerator.h
@@ -139,6 +139,14 @@ class BASE_EXPORT FileEnumerator {
// since the underlying code uses OS-specific matching routines. In general,
// Windows matching is less featureful than others, so test there first.
// If unspecified, this will match all files.
+ //
+ // |folder_search_policy| optionally specifies a search behavior. Refer to
+ // |FolderSearchPolicy| for a list of folder search policies and the meaning
+ // of them. If |recursive| is false, this parameter has no effect.
+ //
+ // |error_policy| optionally specifies the behavior when an error occurs.
+ // Refer to |ErrorPolicy| for a list of error policies and the meaning of
+ // them.
FileEnumerator(const FilePath& root_path, bool recursive, int file_type);
FileEnumerator(const FilePath& root_path,
bool recursive,
diff --git a/chromium/base/files/file_error_or_unittest.cc b/chromium/base/files/file_error_or_unittest.cc
index 6945710f830..0a6e5c242d5 100644
--- a/chromium/base/files/file_error_or_unittest.cc
+++ b/chromium/base/files/file_error_or_unittest.cc
@@ -11,23 +11,22 @@ namespace base {
namespace {
TEST(FileErrorOrDeathTest, Error) {
- FileErrorOr<int> error;
- error = unexpected(File::Error::FILE_ERROR_FAILED);
- EXPECT_FALSE(error.has_value());
+ FileErrorOr<int> error = unexpected(File::Error::FILE_ERROR_FAILED);
+ ASSERT_FALSE(error.has_value());
EXPECT_EQ(error.error(), File::Error::FILE_ERROR_FAILED);
EXPECT_DEATH_IF_SUPPORTED(error.value(), "");
}
TEST(FileErrorOrDeathTest, Value) {
- FileErrorOr<int> value(42);
- EXPECT_TRUE(value.has_value());
+ FileErrorOr<int> value = 42;
+ ASSERT_TRUE(value.has_value());
EXPECT_EQ(value.value(), 42);
EXPECT_DEATH_IF_SUPPORTED(value.error(), "");
}
TEST(FileErrorOrDeathTest, ConstValue) {
- const FileErrorOr<int> const_value(1234);
- EXPECT_TRUE(const_value.has_value());
+ const FileErrorOr<int> const_value = 1234;
+ ASSERT_TRUE(const_value.has_value());
EXPECT_EQ(const_value.value(), 1234);
EXPECT_DEATH_IF_SUPPORTED(const_value.error(), "");
}
diff --git a/chromium/base/files/file_path.cc b/chromium/base/files/file_path.cc
index 59bbc6e15da..71ca2666bb9 100644
--- a/chromium/base/files/file_path.cc
+++ b/chromium/base/files/file_path.cc
@@ -461,7 +461,7 @@ FilePath FilePath::AddExtension(StringPieceType extension) const {
*(str.end() - 1) != kExtensionSeparator) {
str.append(1, kExtensionSeparator);
}
- str.append(extension.data(), extension.size());
+ str.append(extension);
return FilePath(str);
}
@@ -487,7 +487,7 @@ FilePath FilePath::ReplaceExtension(StringPieceType extension) const {
StringType str = no_ext.value();
if (extension[0] != kExtensionSeparator)
str.append(1, kExtensionSeparator);
- str.append(extension.data(), extension.size());
+ str.append(extension);
return FilePath(str);
}
@@ -553,7 +553,7 @@ FilePath FilePath::Append(StringPieceType component) const {
}
}
- new_path.path_.append(appended.data(), appended.size());
+ new_path.path_.append(appended);
return new_path;
}
diff --git a/chromium/base/files/file_path_watcher_unittest.cc b/chromium/base/files/file_path_watcher_unittest.cc
index 113f94f5489..8d2d231c528 100644
--- a/chromium/base/files/file_path_watcher_unittest.cc
+++ b/chromium/base/files/file_path_watcher_unittest.cc
@@ -55,6 +55,12 @@ namespace {
class TestDelegate;
+#if BUILDFLAG(IS_FUCHSIA)
+// FilePatchWatcherImpl is not implemented (see crbug.com/851641).
+// Disable all tests.
+#define FilePathWatcherTest DISABLED_FilePathWatcherTest
+#endif
+
// Aggregates notifications from the test delegates and breaks the run loop
// the test thread is waiting on once they all came in.
class NotificationCollector
diff --git a/chromium/base/files/file_util.h b/chromium/base/files/file_util.h
index 0b0c7df1517..0a9a27717e7 100644
--- a/chromium/base/files/file_util.h
+++ b/chromium/base/files/file_util.h
@@ -494,7 +494,7 @@ BASE_EXPORT bool CreateWinHardLink(const FilePath& to_file,
// This function will return if the given file is a symlink or not.
BASE_EXPORT bool IsLink(const FilePath& file_path);
-// Returns information about the given file path.
+// Returns information about the given file path. Also see |File::GetInfo|.
BASE_EXPORT bool GetFileInfo(const FilePath& file_path, File::Info* info);
// Sets the time of the last access and the time of the last modification.
diff --git a/chromium/base/files/file_util_android.cc b/chromium/base/files/file_util_android.cc
index 1f921f55195..fa09a5782eb 100644
--- a/chromium/base/files/file_util_android.cc
+++ b/chromium/base/files/file_util_android.cc
@@ -6,7 +6,7 @@
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
-#include "base/base_jni_headers/FileUtils_jni.h"
+#include "base/base_jni/FileUtils_jni.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
diff --git a/chromium/base/files/file_util_mac.mm b/chromium/base/files/file_util_mac.mm
index b7859735725..4d5d51b9425 100644
--- a/chromium/base/files/file_util_mac.mm
+++ b/chromium/base/files/file_util_mac.mm
@@ -15,14 +15,18 @@
#include "base/strings/string_util.h"
#include "base/threading/scoped_blocking_call.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
namespace base {
bool CopyFile(const FilePath& from_path, const FilePath& to_path) {
ScopedBlockingCall scoped_blocking_call(FROM_HERE, BlockingType::MAY_BLOCK);
if (from_path.ReferencesParent() || to_path.ReferencesParent())
return false;
- return (copyfile(from_path.value().c_str(),
- to_path.value().c_str(), NULL, COPYFILE_DATA) == 0);
+ return (copyfile(from_path.value().c_str(), to_path.value().c_str(),
+ /*state=*/nullptr, COPYFILE_DATA) == 0);
}
bool GetTempDir(base::FilePath* path) {
diff --git a/chromium/base/files/file_util_unittest.cc b/chromium/base/files/file_util_unittest.cc
index 42dd27e90ce..c59c226c992 100644
--- a/chromium/base/files/file_util_unittest.cc
+++ b/chromium/base/files/file_util_unittest.cc
@@ -28,7 +28,6 @@
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
-#include "base/guid.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/rand_util.h"
@@ -45,6 +44,7 @@
#include "base/threading/platform_thread.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
+#include "base/uuid.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h"
@@ -659,7 +659,7 @@ TEST_F(FileUtilTest, DevicePathToDriveLetter) {
// Get a drive letter.
std::wstring real_drive_letter = AsWString(
ToUpperASCII(AsStringPiece16(temp_dir_.GetPath().value().substr(0, 2))));
- if (!isalpha(real_drive_letter[0]) || ':' != real_drive_letter[1]) {
+ if (!IsAsciiAlpha(real_drive_letter[0]) || ':' != real_drive_letter[1]) {
LOG(ERROR) << "Can't get a drive letter to test with.";
return;
}
@@ -4585,7 +4585,7 @@ TEST(FileUtilMultiThreadedTest, MultiThreadedTempFiles) {
ScopedFILE output_file(CreateAndOpenTemporaryStream(&output_filename));
EXPECT_TRUE(output_file);
- const std::string content = GenerateGUID();
+ const std::string content = Uuid::GenerateRandomV4().AsLowercaseString();
#if BUILDFLAG(IS_WIN)
HANDLE handle =
reinterpret_cast<HANDLE>(_get_osfhandle(_fileno(output_file.get())));
diff --git a/chromium/base/files/file_util_win.cc b/chromium/base/files/file_util_win.cc
index ba5b58dd015..d7b5fb20aeb 100644
--- a/chromium/base/files/file_util_win.cc
+++ b/chromium/base/files/file_util_win.cc
@@ -31,7 +31,6 @@
#include "base/files/memory_mapped_file.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
-#include "base/guid.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
@@ -50,6 +49,7 @@
#include "base/threading/scoped_blocking_call.h"
#include "base/threading/scoped_thread_priority.h"
#include "base/time/time.h"
+#include "base/uuid.h"
#include "base/win/scoped_handle.h"
#include "base/win/security_util.h"
#include "base/win/sid.h"
@@ -617,7 +617,8 @@ File CreateAndOpenTemporaryFileInDir(const FilePath& dir, FilePath* temp_file) {
// Although it is nearly impossible to get a duplicate name with GUID, we
// still use a loop here in case it happens.
for (int i = 0; i < 100; ++i) {
- temp_name = dir.Append(FormatTemporaryFileName(UTF8ToWide(GenerateGUID())));
+ temp_name = dir.Append(FormatTemporaryFileName(
+ UTF8ToWide(Uuid::GenerateRandomV4().AsLowercaseString())));
file.Initialize(temp_name, kFlags);
if (file.IsValid())
break;
diff --git a/chromium/base/files/file_win.cc b/chromium/base/files/file_win.cc
index a7187780d36..71c4a2566a5 100644
--- a/chromium/base/files/file_win.cc
+++ b/chromium/base/files/file_win.cc
@@ -359,8 +359,6 @@ File::Error File::OSErrorToFileError(DWORD last_error) {
case ERROR_DISK_CORRUPT: // The disk structure is corrupted and unreadable.
return FILE_ERROR_IO;
default:
- UmaHistogramSparse("PlatformFile.UnknownErrors.Windows",
- static_cast<int>(last_error));
// This function should only be called for errors.
DCHECK_NE(static_cast<DWORD>(ERROR_SUCCESS), last_error);
return FILE_ERROR_FAILED;
diff --git a/chromium/base/files/important_file_writer.cc b/chromium/base/files/important_file_writer.cc
index ef7da13e330..81021e5290b 100644
--- a/chromium/base/files/important_file_writer.cc
+++ b/chromium/base/files/important_file_writer.cc
@@ -58,8 +58,7 @@ void UmaHistogramTimesWithSuffix(const char* histogram_name,
std::string histogram_full_name(histogram_name);
if (!histogram_suffix.empty()) {
histogram_full_name.append(".");
- histogram_full_name.append(histogram_suffix.data(),
- histogram_suffix.length());
+ histogram_full_name.append(histogram_suffix);
}
UmaHistogramTimes(histogram_full_name, sample);
}
diff --git a/chromium/base/files/os_validation_win_unittest.cc b/chromium/base/files/os_validation_win_unittest.cc
index a380ee37599..96ce377bcdb 100644
--- a/chromium/base/files/os_validation_win_unittest.cc
+++ b/chromium/base/files/os_validation_win_unittest.cc
@@ -225,7 +225,7 @@ class OpenFileTest : public OsValidationTest,
if (bitfield & bit_name.bit) {
if (!result->empty())
result->append(" | ");
- result->append(bit_name.name.data(), bit_name.name.size());
+ result->append(bit_name.name);
bitfield &= ~bit_name.bit;
}
++bits_begin;