Commit a9ee4a68 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Switch to 1-parameter version of base::DeleteFile() in chrome/chrome_cleaner/.

The 1-parameter version is simpler, and the 2-parameter version is
deprecated.

Bug: 1009837
Change-Id: Iee024c6196b4f32fcbb82fbba568977931792660
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2284358Reviewed-by: default avatarJoe Mason <joenotcharles@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#785997}
parent c241eac7
...@@ -90,7 +90,7 @@ class ScopedChildProcessWithTempDir { ...@@ -90,7 +90,7 @@ class ScopedChildProcessWithTempDir {
void DeleteSampleDll(const base::string16& sample_dll, void DeleteSampleDll(const base::string16& sample_dll,
const base::FilePath& directory) { const base::FilePath& directory) {
CHECK(base::DeleteFile(directory.Append(sample_dll), /*recursive=*/false)); CHECK(base::DeleteFile(directory.Append(sample_dll)));
} }
void ReplaceSampleDll(const base::string16& sample_dll, void ReplaceSampleDll(const base::string16& sample_dll,
......
...@@ -93,7 +93,7 @@ class SandboxTest : public base::MultiProcessTest { ...@@ -93,7 +93,7 @@ class SandboxTest : public base::MultiProcessTest {
// exist. // exist.
sandbox_process_log_file_path_ = sandbox_process_log_file_path_ =
ScopedLogging::GetLogFilePath(kSandboxLogFileSuffix); ScopedLogging::GetLogFilePath(kSandboxLogFileSuffix);
EXPECT_TRUE(base::DeleteFile(sandbox_process_log_file_path_, false)); EXPECT_TRUE(base::DeleteFile(sandbox_process_log_file_path_));
} }
void TearDown() override { void TearDown() override {
...@@ -148,7 +148,7 @@ MULTIPROCESS_TEST_MAIN(MockSandboxProcessMain) { ...@@ -148,7 +148,7 @@ MULTIPROCESS_TEST_MAIN(MockSandboxProcessMain) {
base::FilePath temp_file; base::FilePath temp_file;
if (base::CreateTemporaryFileInDir(product_path, &temp_file)) { if (base::CreateTemporaryFileInDir(product_path, &temp_file)) {
have_write_access = true; have_write_access = true;
base::DeleteFile(temp_file, /*recursive=*/false); base::DeleteFile(temp_file);
} }
#if BUILDFLAG(IS_OFFICIAL_CHROME_CLEANER_BUILD) #if BUILDFLAG(IS_OFFICIAL_CHROME_CLEANER_BUILD)
......
...@@ -667,7 +667,7 @@ TEST_P(CleanerLoggingServiceTest, CompleteFailure) { ...@@ -667,7 +667,7 @@ TEST_P(CleanerLoggingServiceTest, CompleteFailure) {
// Now forget about the scheduled logs upload retry. // Now forget about the scheduled logs upload retry.
registry_logger_->GetNextLogFilePath(&log_file); registry_logger_->GetNextLogFilePath(&log_file);
ASSERT_FALSE(log_file.empty()); ASSERT_FALSE(log_file.empty());
bool success = base::DeleteFile(log_file, false); bool success = base::DeleteFile(log_file);
EXPECT_TRUE(success) << "Failed to delete " << log_file.value(); EXPECT_TRUE(success) << "Failed to delete " << log_file.value();
bool more_log_files = registry_logger_->RemoveLogFilePath(log_file); bool more_log_files = registry_logger_->RemoveLogFilePath(log_file);
EXPECT_FALSE(more_log_files); EXPECT_FALSE(more_log_files);
......
...@@ -119,7 +119,7 @@ void PendingLogsService::ClearPendingLogFile( ...@@ -119,7 +119,7 @@ void PendingLogsService::ClearPendingLogFile(
LOG(ERROR) << "Failed to delete logs upload retry task."; LOG(ERROR) << "Failed to delete logs upload retry task.";
} }
if (!base::DeleteFile(log_file, false)) if (!base::DeleteFile(log_file))
LOG(ERROR) << "Failed to delete '" << SanitizePath(log_file) << "'."; LOG(ERROR) << "Failed to delete '" << SanitizePath(log_file) << "'.";
} }
......
...@@ -172,7 +172,7 @@ TEST_F(PendingLogsServiceTest, SuccessfulRegistration) { ...@@ -172,7 +172,7 @@ TEST_F(PendingLogsServiceTest, SuccessfulRegistration) {
// Cleanup. // Cleanup.
EXPECT_FALSE(registry_logger_->RemoveLogFilePath(log_file)); EXPECT_FALSE(registry_logger_->RemoveLogFilePath(log_file));
EXPECT_TRUE(base::DeleteFile(log_file, false)); EXPECT_TRUE(base::DeleteFile(log_file));
} }
TEST_F(PendingLogsServiceTest, FailToRegisterScheduledTask) { TEST_F(PendingLogsServiceTest, FailToRegisterScheduledTask) {
......
...@@ -937,7 +937,7 @@ void TruncateLogFileToTail(const base::FilePath& path, ...@@ -937,7 +937,7 @@ void TruncateLogFileToTail(const base::FilePath& path,
if (bytes_read != tail_size_bytes) { if (bytes_read != tail_size_bytes) {
// Something went wrong, clean the file. // Something went wrong, clean the file.
base::DeleteFile(path, /*recursive=*/false); base::DeleteFile(path);
return; return;
} }
......
...@@ -49,7 +49,7 @@ void DeleteEmptyDirectories(base::FilePath directory) { ...@@ -49,7 +49,7 @@ void DeleteEmptyDirectories(base::FilePath directory) {
// folders list for the corresponding UwS, because they are not necessarily // folders list for the corresponding UwS, because they are not necessarily
// matched by any rule by the scanner. // matched by any rule by the scanner.
LOG(INFO) << "Deleting empty directory " << SanitizePath(directory); LOG(INFO) << "Deleting empty directory " << SanitizePath(directory);
if (!base::DeleteFile(directory, /*recursive=*/false)) if (!base::DeleteFile(directory))
break; break;
directory = directory.DirName(); directory = directory.DirName();
} }
...@@ -194,7 +194,7 @@ void FileRemover::RemoveFile(const base::FilePath& path, ...@@ -194,7 +194,7 @@ void FileRemover::RemoveFile(const base::FilePath& path,
return; return;
} }
if (!base::DeleteFile(path, /*recursive=*/false)) { if (!base::DeleteFile(path)) {
// If the attempt to delete the file fails, propagate the failure as // If the attempt to delete the file fails, propagate the failure as
// normal so that the engine knows about it and can try a backup action, // normal so that the engine knows about it and can try a backup action,
// but also register the file for post-reboot removal in case the engine // but also register the file for post-reboot removal in case the engine
......
...@@ -282,8 +282,8 @@ class CleanerTest ...@@ -282,8 +282,8 @@ class CleanerTest
if (locked_file_.IsValid()) if (locked_file_.IsValid())
locked_file_.Close(); locked_file_.Close();
// Remove any leftover UwS. // Remove any leftover UwS.
base::DeleteFile(scan_only_test_uws_, /*recursive=*/false); base::DeleteFile(scan_only_test_uws_);
base::DeleteFile(removable_test_uws_, /*recursive=*/false); base::DeleteFile(removable_test_uws_);
} }
void InitializeRemovableUwSArchivePath() { void InitializeRemovableUwSArchivePath() {
...@@ -486,7 +486,7 @@ TEST_P(CleanerTest, NoPotentialFalsePositivesOnCleanMachine) { ...@@ -486,7 +486,7 @@ TEST_P(CleanerTest, NoPotentialFalsePositivesOnCleanMachine) {
chrome_cleaner::ExecutionMode::kCleanup))); chrome_cleaner::ExecutionMode::kCleanup)));
// Delete the scan only uws to make the machine clean. // Delete the scan only uws to make the machine clean.
base::DeleteFile(scan_only_test_uws_, /*recursive=*/false); base::DeleteFile(scan_only_test_uws_);
ExpectExitCode(command_line, chrome_cleaner::RESULT_CODE_NO_PUPS_FOUND); ExpectExitCode(command_line, chrome_cleaner::RESULT_CODE_NO_PUPS_FOUND);
} }
......
...@@ -26,11 +26,11 @@ TEST(GenerateTestUwsTest, WriteTestUwS) { ...@@ -26,11 +26,11 @@ TEST(GenerateTestUwsTest, WriteTestUwS) {
base::FilePath uws_file_a = base::FilePath uws_file_a =
startup_dir.Append(chrome_cleaner::kTestUwsAFilename); startup_dir.Append(chrome_cleaner::kTestUwsAFilename);
ASSERT_TRUE(base::DeleteFile(uws_file_a, /*recursive=*/false)); ASSERT_TRUE(base::DeleteFile(uws_file_a));
base::FilePath uws_file_b = base::FilePath uws_file_b =
startup_dir.Append(chrome_cleaner::kTestUwsBFilename); startup_dir.Append(chrome_cleaner::kTestUwsBFilename);
ASSERT_TRUE(base::DeleteFile(uws_file_b, /*recursive=*/false)); ASSERT_TRUE(base::DeleteFile(uws_file_b));
// Delete the output files on exit, including on early exit. // Delete the output files on exit, including on early exit.
base::ScopedClosureRunner delete_uws_file_a( base::ScopedClosureRunner delete_uws_file_a(
......
...@@ -27,7 +27,7 @@ ScopedFile::ScopedFile(const base::FilePath& file_path) ...@@ -27,7 +27,7 @@ ScopedFile::ScopedFile(const base::FilePath& file_path)
ScopedFile::~ScopedFile() { ScopedFile::~ScopedFile() {
if (base::PathExists(file_path_)) if (base::PathExists(file_path_))
PCHECK(base::DeleteFile(file_path_, false /*recursive*/)); PCHECK(base::DeleteFile(file_path_));
} }
const base::FilePath& ScopedFile::file_path() { const base::FilePath& ScopedFile::file_path() {
......
...@@ -80,7 +80,7 @@ void OnArchiveDone(const base::FilePath& zip_file_path, ...@@ -80,7 +80,7 @@ void OnArchiveDone(const base::FilePath& zip_file_path,
if (result_code != ZipArchiverResultCode::kSuccess) { if (result_code != ZipArchiverResultCode::kSuccess) {
// The zip file handle has been closed by mojo. Delete the incomplete zip // The zip file handle has been closed by mojo. Delete the incomplete zip
// file directly. // file directly.
if (!base::DeleteFile(zip_file_path, /*recursive=*/false)) if (!base::DeleteFile(zip_file_path))
LOG(ERROR) << "Failed to delete the incomplete zip file."; LOG(ERROR) << "Failed to delete the incomplete zip file.";
} }
// Call |result_callback| for SandboxedZipArchiver::Archive. // Call |result_callback| for SandboxedZipArchiver::Archive.
......
...@@ -202,7 +202,7 @@ TEST_F(ZipArchiverSandboxedArchiverTest, Archive) { ...@@ -202,7 +202,7 @@ TEST_F(ZipArchiverSandboxedArchiverTest, Archive) {
} }
TEST_F(ZipArchiverSandboxedArchiverTest, SourceFileNotFound) { TEST_F(ZipArchiverSandboxedArchiverTest, SourceFileNotFound) {
ASSERT_TRUE(base::DeleteFile(test_file_.GetSourceFilePath(), false)); ASSERT_TRUE(base::DeleteFile(test_file_.GetSourceFilePath()));
EXPECT_EQ(ZipArchiverResultCode::kErrorCannotOpenSourceFile, EXPECT_EQ(ZipArchiverResultCode::kErrorCannotOpenSourceFile,
Archive(test_file_.GetSourceFilePath())); Archive(test_file_.GetSourceFilePath()));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment