Commit 296934bc authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Switch to 1-parameter version of base::Delete() in c/b/chromeos.

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

Bug: 1009837
Change-Id: I133debebd80f65889f53d89a2d3c96beb1b3580b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2261695Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782752}
parent 6bd761cf
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
namespace arc { namespace arc {
void DeletePrintDocument(const base::FilePath& file_path) { void DeletePrintDocument(const base::FilePath& file_path) {
if (!base::DeleteFile(file_path, false)) if (!base::DeleteFile(file_path))
LOG(ERROR) << "Failed to delete print document."; LOG(ERROR) << "Failed to delete print document.";
} }
......
...@@ -44,7 +44,7 @@ void WriteFile(const base::FilePath& path, base::Optional<std::string> blob) { ...@@ -44,7 +44,7 @@ void WriteFile(const base::FilePath& path, base::Optional<std::string> blob) {
// Deletes file at |path|. Prints an error or failure. // Deletes file at |path|. Prints an error or failure.
void RemoveFile(const base::FilePath& path) { void RemoveFile(const base::FilePath& path) {
if (!base::DeleteFile(path, false /* recursive */)) if (!base::DeleteFile(path))
LOG(ERROR) << "Failed to delete file " << path.value(); LOG(ERROR) << "Failed to delete file " << path.value();
} }
......
...@@ -163,7 +163,7 @@ class CrostiniExportImportTest : public testing::Test { ...@@ -163,7 +163,7 @@ class CrostiniExportImportTest : public testing::Test {
// they can trigger and execute against a destroyed service. // they can trigger and execute against a destroyed service.
guest_os::GuestOsSharePath::GetForProfile(profile())->Shutdown(); guest_os::GuestOsSharePath::GetForProfile(profile())->Shutdown();
task_environment_.RunUntilIdle(); task_environment_.RunUntilIdle();
base::DeleteFile(tarball_, false); base::DeleteFile(tarball_);
test_helper_.reset(); test_helper_.reset();
profile_.reset(); profile_.reset();
} }
......
...@@ -196,7 +196,7 @@ bool InstallIconFromFileThread(const base::FilePath& icon_path, ...@@ -196,7 +196,7 @@ bool InstallIconFromFileThread(const base::FilePath& icon_path,
if (wrote != static_cast<int>(content_png.size())) { if (wrote != static_cast<int>(content_png.size())) {
VLOG(2) << "Failed to write Crostini icon file: " VLOG(2) << "Failed to write Crostini icon file: "
<< icon_path.MaybeAsASCII(); << icon_path.MaybeAsASCII();
if (!base::DeleteFile(icon_path, false)) { if (!base::DeleteFile(icon_path)) {
VLOG(2) << "Couldn't delete broken icon file" << icon_path.MaybeAsASCII(); VLOG(2) << "Couldn't delete broken icon file" << icon_path.MaybeAsASCII();
} }
return false; return false;
......
...@@ -907,7 +907,7 @@ TEST_F(GuestOsSharePathTest, UnshareOnDeleteMountExists) { ...@@ -907,7 +907,7 @@ TEST_F(GuestOsSharePathTest, UnshareOnDeleteMountExists) {
SetUpVolume(); SetUpVolume();
crostini::CrostiniManager::GetForProfile(profile())->AddRunningVmForTesting( crostini::CrostiniManager::GetForProfile(profile())->AddRunningVmForTesting(
crostini::kCrostiniDefaultVmName); crostini::kCrostiniDefaultVmName);
ASSERT_TRUE(base::DeleteFile(shared_path_, false)); ASSERT_TRUE(base::DeleteFile(shared_path_));
guest_os_share_path_->set_seneschal_callback_for_testing(base::BindRepeating( guest_os_share_path_->set_seneschal_callback_for_testing(base::BindRepeating(
&GuestOsSharePathTest::SeneschalUnsharePathCallback, &GuestOsSharePathTest::SeneschalUnsharePathCallback,
base::Unretained(this), "unshare-on-delete", shared_path_, Persist::NO, base::Unretained(this), "unshare-on-delete", shared_path_, Persist::NO,
......
...@@ -83,7 +83,7 @@ bool StartBackground(base::ProcessId pid, const base::FilePath& lacros_path) { ...@@ -83,7 +83,7 @@ bool StartBackground(base::ProcessId pid, const base::FilePath& lacros_path) {
// window, and we do not want to delete the existing log file. // window, and we do not want to delete the existing log file.
// TODO(erikchen): Currently, launching a second instance of chrome deletes // TODO(erikchen): Currently, launching a second instance of chrome deletes
// the existing log file, even though the new instance quickly exits. // the existing log file, even though the new instance quickly exits.
base::DeleteFile(LacrosLogPath(), /*recursive=*/false); base::DeleteFile(LacrosLogPath());
} }
return already_running; return already_running;
......
...@@ -167,7 +167,7 @@ void SessionFlagsManager::StoreStateToBackingFile() { ...@@ -167,7 +167,7 @@ void SessionFlagsManager::StoreStateToBackingFile() {
// If a user session is not active, clear the backing file so default flags // If a user session is not active, clear the backing file so default flags
// are used next time. // are used next time.
if (!session_active && !has_restart_job) { if (!session_active && !has_restart_job) {
base::DeleteFile(backing_file_, false /*recursive*/); base::DeleteFile(backing_file_);
return; return;
} }
......
...@@ -160,7 +160,7 @@ bool SaveAndDeleteImage(scoped_refptr<base::RefCountedBytes> image_bytes, ...@@ -160,7 +160,7 @@ bool SaveAndDeleteImage(scoped_refptr<base::RefCountedBytes> image_bytes,
return false; return false;
} }
if (!old_image_path.empty() && old_image_path != image_path) { if (!old_image_path.empty() && old_image_path != image_path) {
if (!base::DeleteFile(old_image_path, false /* recursive */)) { if (!base::DeleteFile(old_image_path)) {
LOG(ERROR) << "Failed to delete old image: " LOG(ERROR) << "Failed to delete old image: "
<< old_image_path.AsUTF8Unsafe(); << old_image_path.AsUTF8Unsafe();
return false; return false;
......
...@@ -292,7 +292,7 @@ class ArcAppInstallEventLogManagerTest : public testing::Test { ...@@ -292,7 +292,7 @@ class ArcAppInstallEventLogManagerTest : public testing::Test {
void VerifyAndDeleteLogFile() { void VerifyAndDeleteLogFile() {
VerifyLogFile(); VerifyLogFile();
base::DeleteFile(log_file_path_, false /* recursive */); base::DeleteFile(log_file_path_);
} }
TestLogTaskRunnerWrapper log_task_runner_wrapper_; TestLogTaskRunnerWrapper log_task_runner_wrapper_;
...@@ -342,7 +342,7 @@ TEST_F(ArcAppInstallEventLogManagerTest, CreateNonEmpty) { ...@@ -342,7 +342,7 @@ TEST_F(ArcAppInstallEventLogManagerTest, CreateNonEmpty) {
log.Store(); log.Store();
CreateManager(); CreateManager();
base::DeleteFile(log_file_path_, false /* recursive */); base::DeleteFile(log_file_path_);
FastForwardTo(kExpeditedUploadDelay - kOneMs); FastForwardTo(kExpeditedUploadDelay - kOneMs);
Mock::VerifyAndClearExpectations(&cloud_policy_client_); Mock::VerifyAndClearExpectations(&cloud_policy_client_);
......
...@@ -359,7 +359,7 @@ TEST_F(ArcAppInstallEventLogTest, AddStoreAndStore) { ...@@ -359,7 +359,7 @@ TEST_F(ArcAppInstallEventLogTest, AddStoreAndStore) {
log_->Store(); log_->Store();
EXPECT_TRUE(base::PathExists(file_name_)); EXPECT_TRUE(base::PathExists(file_name_));
EXPECT_TRUE(base::DeleteFile(file_name_, false /* recursive */)); EXPECT_TRUE(base::DeleteFile(file_name_));
log_->Store(); log_->Store();
EXPECT_FALSE(base::PathExists(file_name_)); EXPECT_FALSE(base::PathExists(file_name_));
...@@ -421,7 +421,7 @@ TEST_F(ArcAppInstallEventLogTest, StoreLoadAndStore) { ...@@ -421,7 +421,7 @@ TEST_F(ArcAppInstallEventLogTest, StoreLoadAndStore) {
VerifyTenLogEntriesEach(0 /* first_app_timestamp_offset */, VerifyTenLogEntriesEach(0 /* first_app_timestamp_offset */,
10 /* second_app_timestamp_offset*/); 10 /* second_app_timestamp_offset*/);
EXPECT_TRUE(base::DeleteFile(file_name_, false /* recursive */)); EXPECT_TRUE(base::DeleteFile(file_name_));
log.Store(); log.Store();
EXPECT_FALSE(base::PathExists(file_name_)); EXPECT_FALSE(base::PathExists(file_name_));
......
...@@ -391,7 +391,7 @@ TEST_F(ExtensionInstallEventLogTest, AddStoreAndStore) { ...@@ -391,7 +391,7 @@ TEST_F(ExtensionInstallEventLogTest, AddStoreAndStore) {
log_->Store(); log_->Store();
EXPECT_TRUE(base::PathExists(file_name_)); EXPECT_TRUE(base::PathExists(file_name_));
EXPECT_TRUE(base::DeleteFile(file_name_, false /* recursive */)); EXPECT_TRUE(base::DeleteFile(file_name_));
log_->Store(); log_->Store();
EXPECT_FALSE(base::PathExists(file_name_)); EXPECT_FALSE(base::PathExists(file_name_));
...@@ -453,7 +453,7 @@ TEST_F(ExtensionInstallEventLogTest, StoreLoadAndStore) { ...@@ -453,7 +453,7 @@ TEST_F(ExtensionInstallEventLogTest, StoreLoadAndStore) {
VerifyTenLogEntriesEach(0 /* first_extension_timestamp_offset */, VerifyTenLogEntriesEach(0 /* first_extension_timestamp_offset */,
10 /* second_extension_timestamp_offset*/); 10 /* second_extension_timestamp_offset*/);
EXPECT_TRUE(base::DeleteFile(file_name_, false /* recursive */)); EXPECT_TRUE(base::DeleteFile(file_name_));
log.Store(); log.Store();
EXPECT_FALSE(base::PathExists(file_name_)); EXPECT_FALSE(base::PathExists(file_name_));
......
...@@ -107,7 +107,7 @@ std::string ZipFiles( ...@@ -107,7 +107,7 @@ std::string ZipFiles(
PLOG(ERROR) << "Failed to read zipped system logs"; PLOG(ERROR) << "Failed to read zipped system logs";
return compressed_logs; return compressed_logs;
} }
base::DeleteFile(zip_file, false); base::DeleteFile(zip_file);
return compressed_logs; return compressed_logs;
} }
......
...@@ -255,7 +255,7 @@ class UserCloudPolicyStoreChromeOSTest : public testing::Test { ...@@ -255,7 +255,7 @@ class UserCloudPolicyStoreChromeOSTest : public testing::Test {
TEST_F(UserCloudPolicyStoreChromeOSTest, InitialStore) { TEST_F(UserCloudPolicyStoreChromeOSTest, InitialStore) {
// Start without any public key to trigger the initial key checks. // Start without any public key to trigger the initial key checks.
ASSERT_TRUE(base::DeleteFile(user_policy_key_file(), false)); ASSERT_TRUE(base::DeleteFile(user_policy_key_file()));
// Make the policy blob contain a new public key. // Make the policy blob contain a new public key.
policy_.SetDefaultNewSigningKey(); policy_.SetDefaultNewSigningKey();
...@@ -269,7 +269,7 @@ TEST_F(UserCloudPolicyStoreChromeOSTest, InitialStore) { ...@@ -269,7 +269,7 @@ TEST_F(UserCloudPolicyStoreChromeOSTest, InitialStore) {
TEST_F(UserCloudPolicyStoreChromeOSTest, InitialStoreValidationFail) { TEST_F(UserCloudPolicyStoreChromeOSTest, InitialStoreValidationFail) {
// Start without any public key to trigger the initial key checks. // Start without any public key to trigger the initial key checks.
ASSERT_TRUE(base::DeleteFile(user_policy_key_file(), false)); ASSERT_TRUE(base::DeleteFile(user_policy_key_file()));
// Make the policy blob contain a new public key. // Make the policy blob contain a new public key.
policy_.SetDefaultSigningKey(); policy_.SetDefaultSigningKey();
policy_.Build(); policy_.Build();
...@@ -285,7 +285,7 @@ TEST_F(UserCloudPolicyStoreChromeOSTest, InitialStoreValidationFail) { ...@@ -285,7 +285,7 @@ TEST_F(UserCloudPolicyStoreChromeOSTest, InitialStoreValidationFail) {
TEST_F(UserCloudPolicyStoreChromeOSTest, InitialStoreMissingSignatureFailure) { TEST_F(UserCloudPolicyStoreChromeOSTest, InitialStoreMissingSignatureFailure) {
// Start without any public key to trigger the initial key checks. // Start without any public key to trigger the initial key checks.
ASSERT_TRUE(base::DeleteFile(user_policy_key_file(), false)); ASSERT_TRUE(base::DeleteFile(user_policy_key_file()));
// Make the policy blob contain a new public key. // Make the policy blob contain a new public key.
policy_.SetDefaultSigningKey(); policy_.SetDefaultSigningKey();
policy_.Build(); policy_.Build();
...@@ -488,7 +488,7 @@ TEST_F(UserCloudPolicyStoreChromeOSTest, LoadValidationError) { ...@@ -488,7 +488,7 @@ TEST_F(UserCloudPolicyStoreChromeOSTest, LoadValidationError) {
TEST_F(UserCloudPolicyStoreChromeOSTest, LoadNoKey) { TEST_F(UserCloudPolicyStoreChromeOSTest, LoadNoKey) {
// The loaded policy can't be verified without the public key. // The loaded policy can't be verified without the public key.
ASSERT_TRUE(base::DeleteFile(user_policy_key_file(), false)); ASSERT_TRUE(base::DeleteFile(user_policy_key_file()));
ASSERT_NO_FATAL_FAILURE(PerformPolicyLoad(policy_.GetBlob())); ASSERT_NO_FATAL_FAILURE(PerformPolicyLoad(policy_.GetBlob()));
RunLoopAndExpectError(CloudPolicyStore::STATUS_VALIDATION_ERROR); RunLoopAndExpectError(CloudPolicyStore::STATUS_VALIDATION_ERROR);
VerifyStoreHasValidationError(); VerifyStoreHasValidationError();
...@@ -576,7 +576,7 @@ TEST_F(UserCloudPolicyStoreChromeOSTest, LoadImmediatelyNoUserPolicyKey) { ...@@ -576,7 +576,7 @@ TEST_F(UserCloudPolicyStoreChromeOSTest, LoadImmediatelyNoUserPolicyKey) {
session_manager_client_->set_user_policy(cryptohome_id_, policy_.GetBlob()); session_manager_client_->set_user_policy(cryptohome_id_, policy_.GetBlob());
// Ensure no policy data. // Ensure no policy data.
ASSERT_TRUE(base::DeleteFile(user_policy_key_file(), false)); ASSERT_TRUE(base::DeleteFile(user_policy_key_file()));
EXPECT_FALSE(store_->policy()); EXPECT_FALSE(store_->policy());
EXPECT_CALL(observer_, OnStoreError(store_.get())); EXPECT_CALL(observer_, OnStoreError(store_.get()));
......
...@@ -119,8 +119,8 @@ void OnCompressArchiveCompleted(const base::FilePath& tar_file_path, ...@@ -119,8 +119,8 @@ void OnCompressArchiveCompleted(const base::FilePath& tar_file_path,
LOG(ERROR) << "Failed compressing " << compressed_output_path.value(); LOG(ERROR) << "Failed compressing " << compressed_output_path.value();
content::GetUIThreadTaskRunner({})->PostTask( content::GetUIThreadTaskRunner({})->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), base::nullopt)); FROM_HERE, base::BindOnce(std::move(callback), base::nullopt));
base::DeleteFile(tar_file_path, false); base::DeleteFile(tar_file_path);
base::DeleteFile(compressed_output_path, false); base::DeleteFile(compressed_output_path);
return; return;
} }
...@@ -137,7 +137,7 @@ void CompressArchive(const base::FilePath& tar_file_path, ...@@ -137,7 +137,7 @@ void CompressArchive(const base::FilePath& tar_file_path,
LOG(ERROR) << "Failed adding user logs to " << tar_file_path.value(); LOG(ERROR) << "Failed adding user logs to " << tar_file_path.value();
content::GetUIThreadTaskRunner({})->PostTask( content::GetUIThreadTaskRunner({})->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), base::nullopt)); FROM_HERE, base::BindOnce(std::move(callback), base::nullopt));
base::DeleteFile(tar_file_path, false); base::DeleteFile(tar_file_path);
return; return;
} }
......
...@@ -52,7 +52,7 @@ const int kMaxDeviceTouchEventLogs = 7; ...@@ -52,7 +52,7 @@ const int kMaxDeviceTouchEventLogs = 7;
// Clean up intermediate log files dumped during feedback creation. // Clean up intermediate log files dumped during feedback creation.
void CleanupEventLog(const std::vector<base::FilePath>& log_paths) { void CleanupEventLog(const std::vector<base::FilePath>& log_paths) {
for (const base::FilePath& path : log_paths) for (const base::FilePath& path : log_paths)
base::DeleteFile(path, false); base::DeleteFile(path);
} }
// Check for all known log paths and find the ones whose filenames match a // Check for all known log paths and find the ones whose filenames match a
......
...@@ -84,7 +84,7 @@ class TPMFirmwareUpdateTest : public testing::Test { ...@@ -84,7 +84,7 @@ class TPMFirmwareUpdateTest : public testing::Test {
switch (availability) { switch (availability) {
case Availability::kPending: case Availability::kPending:
case Availability::kUnavailable: case Availability::kUnavailable:
base::DeleteFile(srk_vulnerable_roca_path, false); base::DeleteFile(srk_vulnerable_roca_path);
break; break;
case Availability::kAvailable: case Availability::kAvailable:
case Availability::kUnavailableROCAVulnerable: case Availability::kUnavailableROCAVulnerable:
...@@ -99,7 +99,7 @@ class TPMFirmwareUpdateTest : public testing::Test { ...@@ -99,7 +99,7 @@ class TPMFirmwareUpdateTest : public testing::Test {
&update_location_path)); &update_location_path));
switch (availability) { switch (availability) {
case Availability::kPending: case Availability::kPending:
base::DeleteFile(update_location_path, false); base::DeleteFile(update_location_path);
break; break;
case Availability::kUnavailable: case Availability::kUnavailable:
case Availability::kUnavailableROCAVulnerable: case Availability::kUnavailableROCAVulnerable:
......
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