Commit 4051ddff authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

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

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

Bug: 1009837
Change-Id: I74f7c0697d077d5cdea3501a86a558911762e3ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2284366Reviewed-by: default avatarKaran Bhatia <karandeepb@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786039}
parent 77c07452
......@@ -218,8 +218,8 @@ TEST_F(FileSequenceHelperTest, IndexedRulesetDeleted) {
// Now delete the first and third indexed rulesets. This would cause a
// re-index.
base::DeleteFile(test_cases[0].source.indexed_path(), false /* recursive */);
base::DeleteFile(test_cases[2].source.indexed_path(), false /* recursive */);
base::DeleteFile(test_cases[0].source.indexed_path());
base::DeleteFile(test_cases[2].source.indexed_path());
test_cases[0].expected_result.reindexing_successful = true;
test_cases[2].expected_result.reindexing_successful = true;
......@@ -276,10 +276,10 @@ TEST_F(FileSequenceHelperTest, JSONAndIndexedRulesetDeleted) {
TestLoadRulesets(test_cases);
base::DeleteFile(test_cases[0].source.json_path(), false /* recursive */);
base::DeleteFile(test_cases[1].source.json_path(), false /* recursive */);
base::DeleteFile(test_cases[0].source.indexed_path(), false /* recursive */);
base::DeleteFile(test_cases[1].source.indexed_path(), false /* recursive */);
base::DeleteFile(test_cases[0].source.json_path());
base::DeleteFile(test_cases[1].source.json_path());
base::DeleteFile(test_cases[0].source.indexed_path());
base::DeleteFile(test_cases[1].source.indexed_path());
// Reindexing will fail since the JSON ruleset is now deleted.
test_cases[0].expected_result.reindexing_successful = false;
......@@ -299,8 +299,8 @@ TEST_F(FileSequenceHelperTest, UpdateDynamicRules) {
// Simulate adding rules for the first time i.e. with no JSON and indexed
// ruleset files.
RulesetSource source = CreateTemporarySource();
base::DeleteFile(source.json_path(), false /* recursive */);
base::DeleteFile(source.indexed_path(), false /* recursive */);
base::DeleteFile(source.json_path());
base::DeleteFile(source.indexed_path());
// Test success.
std::vector<api::declarative_net_request::Rule> api_rules;
......
......@@ -51,8 +51,7 @@ std::unique_ptr<VerifiedContents> ReadVerifiedContents(
std::unique_ptr<VerifiedContents> verified_contents =
VerifiedContents::Create(key.verifier_key, verified_contents_path);
if (!verified_contents) {
if (delete_invalid_file &&
!base::DeleteFile(verified_contents_path, false)) {
if (delete_invalid_file && !base::DeleteFile(verified_contents_path)) {
LOG(WARNING) << "Failed to delete " << verified_contents_path.value();
}
return nullptr;
......
......@@ -156,7 +156,7 @@ class ContentVerifyJobUnittest : public ExtensionsTest {
observer.WaitForOnHashesReady();
run_content_read_step(verify_job.get(), &resource_contents);
break;
};
}
return observer.WaitForJobFinished();
}
......@@ -280,8 +280,7 @@ TEST_F(ContentVerifyJobUnittest, DeletedAndMissingFiles) {
{
// Once background.js is deleted, verification will result in HASH_MISMATCH.
// Delete the existent file first.
EXPECT_TRUE(
base::DeleteFile(unzipped_path.Append(existent_resource_path), false));
EXPECT_TRUE(base::DeleteFile(unzipped_path.Append(existent_resource_path)));
// Deleted file will serve empty contents.
std::string empty_contents;
......@@ -361,8 +360,7 @@ void WriteIncorrectComputedHashes(const base::FilePath& extension_path,
ASSERT_TRUE(
base::PathExists(file_util::GetComputedHashesPath(extension_path)));
base::DeleteFile(file_util::GetComputedHashesPath(extension_path),
false /* recursive */);
base::DeleteFile(file_util::GetComputedHashesPath(extension_path));
int block_size = extension_misc::kContentVerificationDefaultBlockSize;
ComputedHashes::Data incorrect_computed_hashes_data;
......@@ -386,8 +384,7 @@ void WriteEmptyComputedHashes(const base::FilePath& extension_path) {
ASSERT_TRUE(
base::PathExists(file_util::GetComputedHashesPath(extension_path)));
base::DeleteFile(file_util::GetComputedHashesPath(extension_path),
false /* recursive */);
base::DeleteFile(file_util::GetComputedHashesPath(extension_path));
ComputedHashes::Data incorrect_computed_hashes_data;
......@@ -418,7 +415,7 @@ TEST_F(ContentVerifyJobUnittest, DeletedResourceAndCorruptedComputedHashes) {
base::FilePath unzipped_path = temp_dir.GetPath();
WriteIncorrectComputedHashes(unzipped_path, resource_path);
EXPECT_TRUE(
base::DeleteFile(unzipped_path.Append(base::FilePath(kResource)), false));
base::DeleteFile(unzipped_path.Append(base::FilePath(kResource))));
content_verifier()->ClearCacheForTesting();
{
......@@ -451,7 +448,7 @@ TEST_F(ContentVerifyJobUnittest, DeletedResourceAndCleanedComputedHashes) {
base::FilePath unzipped_path = temp_dir.GetPath();
WriteEmptyComputedHashes(unzipped_path);
EXPECT_TRUE(
base::DeleteFile(unzipped_path.Append(base::FilePath(kResource)), false));
base::DeleteFile(unzipped_path.Append(base::FilePath(kResource))));
content_verifier()->ClearCacheForTesting();
{
......@@ -600,8 +597,7 @@ TEST_F(ContentVerifyJobWithoutSignedHashesUnittest, ComputedHashesLoad) {
{
// Case where computed_hashes.json doesn't exist.
base::DeleteFile(file_util::GetComputedHashesPath(unzipped_path),
false /* recursive */);
base::DeleteFile(file_util::GetComputedHashesPath(unzipped_path));
TestContentVerifySingleJobObserver observer(extension->id(), kResourcePath);
content_verifier()->ClearCacheForTesting();
......
......@@ -280,7 +280,7 @@ bool ExtensionCreator::Run(const base::FilePath& extension_dir,
result = true;
}
base::DeleteFile(zip_path, false);
base::DeleteFile(zip_path);
return result;
}
......
......@@ -34,7 +34,7 @@ std::tuple<std::vector<uint8_t>, bool, bool> ReadAndDeleteBinaryFile(
base::ReadFile(path, reinterpret_cast<char*>(contents.data()),
file_size) == file_size;
}
bool delete_success = base::DeleteFile(path, /*recursive=*/false);
bool delete_success = base::DeleteFile(path);
return std::make_tuple(std::move(contents), read_success, delete_success);
}
......
......@@ -22,7 +22,7 @@ std::tuple<std::string, bool, bool> ReadAndDeleteTextFile(
const base::FilePath& path) {
std::string contents;
bool read_success = base::ReadFileToString(path, &contents);
bool delete_success = base::DeleteFile(path, /*recursive=*/false);
bool delete_success = base::DeleteFile(path);
return std::make_tuple(contents, read_success, delete_success);
}
......
......@@ -76,7 +76,7 @@ bool VerifyJunctionFreeLocation(base::FilePath* temp_dir) {
// If you change the exit points of this function please make sure all
// exit points delete this temp file!
if (base::WriteFile(temp_file, ".", 1) != 1) {
base::DeleteFile(temp_file, false);
base::DeleteFile(temp_file);
return false;
}
......@@ -91,7 +91,7 @@ bool VerifyJunctionFreeLocation(base::FilePath* temp_dir) {
}
// Clean up the temp file.
base::DeleteFile(temp_file, false);
base::DeleteFile(temp_file);
return normalized;
}
......
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