diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-29 10:46:47 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-11-02 12:02:10 +0000 |
commit | 99677208ff3b216fdfec551fbe548da5520cd6fb (patch) | |
tree | 476a4865c10320249360e859d8fdd3e01833b03a /chromium/base/files/file_util.h | |
parent | c30a6232df03e1efbd9f3b226777b07e087a1122 (diff) |
BASELINE: Update Chromium to 86.0.4240.124
Change-Id: Ide0ff151e94cd665ae6521a446995d34a9d1d644
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/base/files/file_util.h')
-rw-r--r-- | chromium/base/files/file_util.h | 65 |
1 files changed, 36 insertions, 29 deletions
diff --git a/chromium/base/files/file_util.h b/chromium/base/files/file_util.h index c9c2470942f..6b8623c71a4 100644 --- a/chromium/base/files/file_util.h +++ b/chromium/base/files/file_util.h @@ -79,32 +79,14 @@ BASE_EXPORT bool DeleteFile(const FilePath& path); // the symlink. (even if the symlink points to a non-existent file) // // WARNING: USING THIS EQUIVALENT TO "rm -rf", SO USE WITH CAUTION. -// TODO(thestig): Rename to DeletePathRecursively(). -BASE_EXPORT bool DeleteFileRecursively(const FilePath& path); - -// DEPRECATED. Please use the functions immediately above. -// https://crbug.com/1009837 -// -// Deletes the given path, whether it's a file or a directory. -// If it's a directory, it's perfectly happy to delete all of the -// directory's contents. Passing true to recursively delete -// subdirectories and their contents as well. -// Returns true if successful, false otherwise. It is considered successful -// to attempt to delete a file that does not exist. -// -// In POSIX environment and if |path| is a symbolic link, this deletes only -// the symlink. (even if the symlink points to a non-existent file) -// -// WARNING: USING THIS WITH recursive==true IS EQUIVALENT -// TO "rm -rf", SO USE WITH CAUTION. -BASE_EXPORT bool DeleteFile(const FilePath& path, bool recursive); +BASE_EXPORT bool DeletePathRecursively(const FilePath& path); // Simplified way to get a callback to do DeleteFile(path) and ignore the // DeleteFile() result. BASE_EXPORT OnceCallback<void(const FilePath&)> GetDeleteFileCallback(); -// Simplified way to get a callback to do DeleteFileRecursively(path) and ignore -// the DeleteFileRecursively() result. +// Simplified way to get a callback to do DeletePathRecursively(path) and ignore +// the DeletePathRecursively() result. BASE_EXPORT OnceCallback<void(const FilePath&)> GetDeletePathRecursivelyCallback(); @@ -503,6 +485,30 @@ BASE_EXPORT FilePath GetUniquePath(const FilePath& path); // false. BASE_EXPORT bool SetNonBlocking(int fd); +// Possible results of PreReadFile(). +// These values are persisted to logs. Entries should not be renumbered and +// numeric values should never be reused. +enum class PrefetchResultCode { + kSuccess = 0, + kInvalidFile = 1, + kSlowSuccess = 2, + kSlowFailed = 3, + kMemoryMapFailedSlowUsed = 4, + kMemoryMapFailedSlowFailed = 5, + kFastFailed = 6, + kFastFailedSlowUsed = 7, + kFastFailedSlowFailed = 8, + kMaxValue = kFastFailedSlowFailed +}; + +struct PrefetchResult { + bool succeeded() const { + return code_ == PrefetchResultCode::kSuccess || + code_ == PrefetchResultCode::kSlowSuccess; + } + const PrefetchResultCode code_; +}; + // Hints the OS to prefetch the first |max_bytes| of |file_path| into its cache. // // If called at the appropriate time, this can reduce the latency incurred by @@ -516,17 +522,18 @@ BASE_EXPORT bool SetNonBlocking(int fd); // executable code or as data. Windows treats the file backed pages in RAM // differently, and specifying the wrong value results in two copies in RAM. // -// Returns false if prefetching definitely failed. A return value of true does -// not guarantee that the entire desired range was prefetched. +// Returns a PrefetchResult indicating whether prefetch succeeded, and the type +// of failure if it did not. A return value of kSuccess does not guarantee that +// the entire desired range was prefetched. // // Calling this before using ::LoadLibrary() on Windows is more efficient memory // wise, but we must be sure no other threads try to LoadLibrary() the file // while we are doing the mapping and prefetching, or the process will get a // private copy of the DLL via COW. -BASE_EXPORT bool PreReadFile( - const FilePath& file_path, - bool is_executable, - int64_t max_bytes = std::numeric_limits<int64_t>::max()); +BASE_EXPORT PrefetchResult +PreReadFile(const FilePath& file_path, + bool is_executable, + int64_t max_bytes = std::numeric_limits<int64_t>::max()); #if defined(OS_POSIX) || defined(OS_FUCHSIA) @@ -567,7 +574,7 @@ BASE_EXPORT bool VerifyPathControlledByUser(const base::FilePath& base, const std::set<gid_t>& group_gids); #endif // defined(OS_POSIX) || defined(OS_FUCHSIA) -#if defined(OS_MACOSX) && !defined(OS_IOS) +#if defined(OS_MAC) // Is |path| writable only by a user with administrator privileges? // This function uses Mac OS conventions. The super user is assumed to have // uid 0, and the administrator group is assumed to be named "admin". @@ -576,7 +583,7 @@ BASE_EXPORT bool VerifyPathControlledByUser(const base::FilePath& base, // "admin", are not writable by all users, and contain no symbolic links. // Will return false if |path| does not exist. BASE_EXPORT bool VerifyPathControlledByAdmin(const base::FilePath& path); -#endif // defined(OS_MACOSX) && !defined(OS_IOS) +#endif // defined(OS_MAC) // Returns the maximum length of path component on the volume containing // the directory |path|, in the number of FilePath::CharType, or -1 on failure. |