diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-01 19:41:02 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-01 19:41:02 +0000 |
commit | 918efbf64de58c82ffa3cd8799d9ad822811a37a (patch) | |
tree | 5ceffb5e1576177d75f1aa8546bcae074df63c1e | |
parent | e07f44f6b208541c9602bb9cc5f311612aaab64a (diff) | |
download | chromium_src-918efbf64de58c82ffa3cd8799d9ad822811a37a.zip chromium_src-918efbf64de58c82ffa3cd8799d9ad822811a37a.tar.gz chromium_src-918efbf64de58c82ffa3cd8799d9ad822811a37a.tar.bz2 |
Move file_util::Delete to the base namespace
BUG=
Review URL: https://codereview.chromium.org/16950028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209475 0039d316-1c4b-4281-b951-d872f2087c98
198 files changed, 779 insertions, 452 deletions
diff --git a/base/debug/trace_event_win_unittest.cc b/base/debug/trace_event_win_unittest.cc index 786b9d5..7d2a212 100644 --- a/base/debug/trace_event_win_unittest.cc +++ b/base/debug/trace_event_win_unittest.cc @@ -157,7 +157,7 @@ class TraceEventWinTest: public testing::Test { EXPECT_HRESULT_SUCCEEDED(controller_.Stop(&prop)); if (!log_file_.value().empty()) - file_util::Delete(log_file_, false); + base::Delete(log_file_, false); } void ExpectEvent(REFGUID guid, diff --git a/base/file_util.h b/base/file_util.h index 2bf46a9..0fa7017 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -57,10 +57,6 @@ BASE_EXPORT FilePath MakeAbsoluteFilePath(const FilePath& input); // particularly speedy in any platform. BASE_EXPORT int64 ComputeDirectorySize(const FilePath& root_path); -} // namespace base - -namespace file_util { - // 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 recursive deletes @@ -73,7 +69,13 @@ namespace file_util { // // WARNING: USING THIS WITH recursive==true IS EQUIVALENT // TO "rm -rf", SO USE WITH CAUTION. -BASE_EXPORT bool Delete(const base::FilePath& path, bool recursive); +BASE_EXPORT bool Delete(const FilePath& path, bool recursive); + +} // namespace base + +// ----------------------------------------------------------------------------- + +namespace file_util { #if defined(OS_WIN) // Schedules to delete the given path, whether it's a file or a directory, until diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index 77e080a..afb34b4 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -58,24 +58,8 @@ #include "base/chromeos/chromeos_version.h" #endif -using base::FileEnumerator; -using base::FilePath; -using base::MakeAbsoluteFilePath; - namespace base { -FilePath MakeAbsoluteFilePath(const FilePath& input) { - base::ThreadRestrictions::AssertIOAllowed(); - char full_path[PATH_MAX]; - if (realpath(input.value().c_str(), full_path) == NULL) - return FilePath(); - return FilePath(full_path); -} - -} // namespace base - -namespace file_util { - namespace { #if defined(OS_BSD) || defined(OS_MACOSX) @@ -152,16 +136,12 @@ bool VerifySpecificPathControlledByUser(const FilePath& path, } // namespace -static std::string TempFileName() { -#if defined(OS_MACOSX) - return base::StringPrintf(".%s.XXXXXX", base::mac::BaseBundleID()); -#endif - -#if defined(GOOGLE_CHROME_BUILD) - return std::string(".com.google.Chrome.XXXXXX"); -#else - return std::string(".org.chromium.Chromium.XXXXXX"); -#endif +FilePath MakeAbsoluteFilePath(const FilePath& input) { + ThreadRestrictions::AssertIOAllowed(); + char full_path[PATH_MAX]; + if (realpath(input.value().c_str(), full_path) == NULL) + return FilePath(); + return FilePath(full_path); } // TODO(erikkay): The Windows version of this accepts paths like "foo/bar/*" @@ -169,7 +149,7 @@ static std::string TempFileName() { // that functionality. If not, remove from file_util_win.cc, otherwise add it // here. bool Delete(const FilePath& path, bool recursive) { - base::ThreadRestrictions::AssertIOAllowed(); + ThreadRestrictions::AssertIOAllowed(); const char* path_str = path.value().c_str(); stat_wrapper_t file_info; int test = CallLstat(path_str, &file_info); @@ -205,6 +185,33 @@ bool Delete(const FilePath& path, bool recursive) { return success; } +} // namespace base + +// ----------------------------------------------------------------------------- + +namespace file_util { + +using base::stat_wrapper_t; +using base::CallStat; +using base::CallLstat; +using base::FileEnumerator; +using base::FilePath; +using base::MakeAbsoluteFilePath; +using base::RealPath; +using base::VerifySpecificPathControlledByUser; + +static std::string TempFileName() { +#if defined(OS_MACOSX) + return base::StringPrintf(".%s.XXXXXX", base::mac::BaseBundleID()); +#endif + +#if defined(GOOGLE_CHROME_BUILD) + return std::string(".com.google.Chrome.XXXXXX"); +#else + return std::string(".org.chromium.Chromium.XXXXXX"); +#endif +} + bool MoveUnsafe(const FilePath& from_path, const FilePath& to_path) { base::ThreadRestrictions::AssertIOAllowed(); // Windows compatibility: if to_path exists, from_path and to_path diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc index cbe8f26..7626957 100644 --- a/base/file_util_unittest.cc +++ b/base/file_util_unittest.cc @@ -738,9 +738,9 @@ TEST_F(FileUtilTest, DeleteNonExistent) { FilePath non_existent = temp_dir_.path().AppendASCII("bogus_file_dne.foobar"); ASSERT_FALSE(file_util::PathExists(non_existent)); - EXPECT_TRUE(file_util::Delete(non_existent, false)); + EXPECT_TRUE(base::Delete(non_existent, false)); ASSERT_FALSE(file_util::PathExists(non_existent)); - EXPECT_TRUE(file_util::Delete(non_existent, true)); + EXPECT_TRUE(base::Delete(non_existent, true)); ASSERT_FALSE(file_util::PathExists(non_existent)); } @@ -751,7 +751,7 @@ TEST_F(FileUtilTest, DeleteFile) { ASSERT_TRUE(file_util::PathExists(file_name)); // Make sure it's deleted - EXPECT_TRUE(file_util::Delete(file_name, false)); + EXPECT_TRUE(base::Delete(file_name, false)); EXPECT_FALSE(file_util::PathExists(file_name)); // Test recursive case, create a new file @@ -760,7 +760,7 @@ TEST_F(FileUtilTest, DeleteFile) { ASSERT_TRUE(file_util::PathExists(file_name)); // Make sure it's deleted - EXPECT_TRUE(file_util::Delete(file_name, true)); + EXPECT_TRUE(base::Delete(file_name, true)); EXPECT_FALSE(file_util::PathExists(file_name)); } @@ -777,7 +777,7 @@ TEST_F(FileUtilTest, DeleteSymlinkToExistentFile) { << "Failed to create symlink."; // Delete the symbolic link. - EXPECT_TRUE(file_util::Delete(file_link, false)); + EXPECT_TRUE(base::Delete(file_link, false)); // Make sure original file is not deleted. EXPECT_FALSE(file_util::PathExists(file_link)); @@ -799,7 +799,7 @@ TEST_F(FileUtilTest, DeleteSymlinkToNonExistentFile) { EXPECT_FALSE(file_util::PathExists(file_link)); // Delete the symbolic link. - EXPECT_TRUE(file_util::Delete(file_link, false)); + EXPECT_TRUE(base::Delete(file_link, false)); // Make sure the symbolic link is deleted. EXPECT_FALSE(file_util::IsLink(file_link)); @@ -843,7 +843,7 @@ TEST_F(FileUtilTest, ChangeFilePermissionsAndRead) { file_util::ReadFile(file_name, buffer, buffer_size)); // Delete the file. - EXPECT_TRUE(file_util::Delete(file_name, false)); + EXPECT_TRUE(base::Delete(file_name, false)); EXPECT_FALSE(file_util::PathExists(file_name)); delete[] buffer; @@ -888,7 +888,7 @@ TEST_F(FileUtilTest, ChangeFilePermissionsAndWrite) { EXPECT_TRUE(file_util::PathIsWritable(file_name)); // Delete the file. - EXPECT_TRUE(file_util::Delete(file_name, false)); + EXPECT_TRUE(base::Delete(file_name, false)); EXPECT_FALSE(file_util::PathExists(file_name)); } @@ -940,7 +940,7 @@ TEST_F(FileUtilTest, ChangeDirectoryPermissionsAndEnumerate) { EXPECT_EQ(c2.size(), 1); // Delete the file. - EXPECT_TRUE(file_util::Delete(subdir_path, true)); + EXPECT_TRUE(base::Delete(subdir_path, true)); EXPECT_FALSE(file_util::PathExists(subdir_path)); } @@ -965,12 +965,12 @@ TEST_F(FileUtilTest, DeleteWildCard) { directory_contents = directory_contents.Append(FPL("*")); // Delete non-recursively and check that only the file is deleted - EXPECT_TRUE(file_util::Delete(directory_contents, false)); + EXPECT_TRUE(base::Delete(directory_contents, false)); EXPECT_FALSE(file_util::PathExists(file_name)); EXPECT_TRUE(file_util::PathExists(subdir_path)); // Delete recursively and make sure all contents are deleted - EXPECT_TRUE(file_util::Delete(directory_contents, true)); + EXPECT_TRUE(base::Delete(directory_contents, true)); EXPECT_FALSE(file_util::PathExists(file_name)); EXPECT_FALSE(file_util::PathExists(subdir_path)); } @@ -988,11 +988,11 @@ TEST_F(FileUtilTest, DeleteNonExistantWildCard) { directory_contents = directory_contents.Append(FPL("*")); // Delete non-recursively and check nothing got deleted - EXPECT_TRUE(file_util::Delete(directory_contents, false)); + EXPECT_TRUE(base::Delete(directory_contents, false)); EXPECT_TRUE(file_util::PathExists(subdir_path)); // Delete recursively and check nothing got deleted - EXPECT_TRUE(file_util::Delete(directory_contents, true)); + EXPECT_TRUE(base::Delete(directory_contents, true)); EXPECT_TRUE(file_util::PathExists(subdir_path)); } #endif @@ -1017,11 +1017,11 @@ TEST_F(FileUtilTest, DeleteDirNonRecursive) { ASSERT_TRUE(file_util::PathExists(subdir_path2)); // Delete non-recursively and check that the empty dir got deleted - EXPECT_TRUE(file_util::Delete(subdir_path2, false)); + EXPECT_TRUE(base::Delete(subdir_path2, false)); EXPECT_FALSE(file_util::PathExists(subdir_path2)); // Delete non-recursively and check that nothing got deleted - EXPECT_FALSE(file_util::Delete(test_subdir, false)); + EXPECT_FALSE(base::Delete(test_subdir, false)); EXPECT_TRUE(file_util::PathExists(test_subdir)); EXPECT_TRUE(file_util::PathExists(file_name)); EXPECT_TRUE(file_util::PathExists(subdir_path1)); @@ -1047,11 +1047,11 @@ TEST_F(FileUtilTest, DeleteDirRecursive) { ASSERT_TRUE(file_util::PathExists(subdir_path2)); // Delete recursively and check that the empty dir got deleted - EXPECT_TRUE(file_util::Delete(subdir_path2, true)); + EXPECT_TRUE(base::Delete(subdir_path2, true)); EXPECT_FALSE(file_util::PathExists(subdir_path2)); // Delete recursively and check that everything got deleted - EXPECT_TRUE(file_util::Delete(test_subdir, true)); + EXPECT_TRUE(base::Delete(test_subdir, true)); EXPECT_FALSE(file_util::PathExists(file_name)); EXPECT_FALSE(file_util::PathExists(subdir_path1)); EXPECT_FALSE(file_util::PathExists(test_subdir)); @@ -1695,7 +1695,7 @@ TEST_F(FileUtilTest, CreateTemporaryFileTest) { for (int i = 0; i < 3; i++) EXPECT_FALSE(temp_files[i] == temp_files[(i+1)%3]); for (int i = 0; i < 3; i++) - EXPECT_TRUE(file_util::Delete(temp_files[i], false)); + EXPECT_TRUE(base::Delete(temp_files[i], false)); } TEST_F(FileUtilTest, CreateAndOpenTemporaryFileTest) { @@ -1718,7 +1718,7 @@ TEST_F(FileUtilTest, CreateAndOpenTemporaryFileTest) { // Close and delete. for (i = 0; i < 3; ++i) { EXPECT_TRUE(file_util::CloseFile(fps[i])); - EXPECT_TRUE(file_util::Delete(names[i], false)); + EXPECT_TRUE(base::Delete(names[i], false)); } } @@ -1727,7 +1727,7 @@ TEST_F(FileUtilTest, CreateNewTempDirectoryTest) { ASSERT_TRUE(file_util::CreateNewTempDirectory(FilePath::StringType(), &temp_dir)); EXPECT_TRUE(file_util::PathExists(temp_dir)); - EXPECT_TRUE(file_util::Delete(temp_dir, false)); + EXPECT_TRUE(base::Delete(temp_dir, false)); } TEST_F(FileUtilTest, CreateNewTemporaryDirInDirTest) { @@ -1738,7 +1738,7 @@ TEST_F(FileUtilTest, CreateNewTemporaryDirInDirTest) { &new_dir)); EXPECT_TRUE(file_util::PathExists(new_dir)); EXPECT_TRUE(temp_dir_.path().IsParent(new_dir)); - EXPECT_TRUE(file_util::Delete(new_dir, false)); + EXPECT_TRUE(base::Delete(new_dir, false)); } TEST_F(FileUtilTest, GetShmemTempDirTest) { @@ -1771,7 +1771,7 @@ TEST_F(FileUtilTest, CreateDirectoryTest) { EXPECT_TRUE(file_util::PathExists(test_path)); EXPECT_FALSE(file_util::CreateDirectory(test_path)); - EXPECT_TRUE(file_util::Delete(test_root, true)); + EXPECT_TRUE(base::Delete(test_root, true)); EXPECT_FALSE(file_util::PathExists(test_root)); EXPECT_FALSE(file_util::PathExists(test_path)); @@ -1817,9 +1817,9 @@ TEST_F(FileUtilTest, DetectDirectoryTest) { CreateTextFile(test_path, L"test file"); EXPECT_TRUE(file_util::PathExists(test_path)); EXPECT_FALSE(file_util::DirectoryExists(test_path)); - EXPECT_TRUE(file_util::Delete(test_path, false)); + EXPECT_TRUE(base::Delete(test_path, false)); - EXPECT_TRUE(file_util::Delete(test_root, true)); + EXPECT_TRUE(base::Delete(test_root, true)); } TEST_F(FileUtilTest, FileEnumeratorTest) { @@ -1937,13 +1937,13 @@ TEST_F(FileUtilTest, AppendToFile) { // Create a fresh, empty copy of this directory. if (file_util::PathExists(data_dir)) { - ASSERT_TRUE(file_util::Delete(data_dir, true)); + ASSERT_TRUE(base::Delete(data_dir, true)); } ASSERT_TRUE(file_util::CreateDirectory(data_dir)); // Create a fresh, empty copy of this directory. if (file_util::PathExists(data_dir)) { - ASSERT_TRUE(file_util::Delete(data_dir, true)); + ASSERT_TRUE(base::Delete(data_dir, true)); } ASSERT_TRUE(file_util::CreateDirectory(data_dir)); FilePath foobar(data_dir.Append(FILE_PATH_LITERAL("foobar.txt"))); @@ -1965,7 +1965,7 @@ TEST_F(FileUtilTest, TouchFile) { // Create a fresh, empty copy of this directory. if (file_util::PathExists(data_dir)) { - ASSERT_TRUE(file_util::Delete(data_dir, true)); + ASSERT_TRUE(base::Delete(data_dir, true)); } ASSERT_TRUE(file_util::CreateDirectory(data_dir)); diff --git a/base/file_util_win.cc b/base/file_util_win.cc index 39da988..44367a0 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -27,23 +27,8 @@ #include "base/win/scoped_handle.h" #include "base/win/windows_version.h" -using base::FilePath; -using base::g_bug108724_debug; - namespace base { -FilePath MakeAbsoluteFilePath(const FilePath& input) { - base::ThreadRestrictions::AssertIOAllowed(); - wchar_t file_path[MAX_PATH]; - if (!_wfullpath(file_path, input.value().c_str(), MAX_PATH)) - return FilePath(); - return FilePath(file_path); -} - -} // namespace base - -namespace file_util { - namespace { const DWORD kFileShareAll = @@ -51,8 +36,16 @@ const DWORD kFileShareAll = } // namespace +FilePath MakeAbsoluteFilePath(const FilePath& input) { + ThreadRestrictions::AssertIOAllowed(); + wchar_t file_path[MAX_PATH]; + if (!_wfullpath(file_path, input.value().c_str(), MAX_PATH)) + return FilePath(); + return FilePath(file_path); +} + bool Delete(const FilePath& path, bool recursive) { - base::ThreadRestrictions::AssertIOAllowed(); + ThreadRestrictions::AssertIOAllowed(); if (path.value().length() >= MAX_PATH) return false; @@ -60,8 +53,8 @@ bool Delete(const FilePath& path, bool recursive) { if (!recursive) { // If not recursing, then first check to see if |path| is a directory. // If it is, then remove it with RemoveDirectory. - base::PlatformFileInfo file_info; - if (GetFileInfo(path, &file_info) && file_info.is_directory) + PlatformFileInfo file_info; + if (file_util::GetFileInfo(path, &file_info) && file_info.is_directory) return RemoveDirectory(path.value().c_str()) != 0; // Otherwise, it's a file, wildcard or non-existant. Try DeleteFile first @@ -105,6 +98,13 @@ bool Delete(const FilePath& path, bool recursive) { return (err == 0 || err == ERROR_FILE_NOT_FOUND || err == 0x402); } +} // namespace base + +namespace file_util { + +using base::FilePath; +using base::kFileShareAll; + bool DeleteAfterReboot(const FilePath& path) { base::ThreadRestrictions::AssertIOAllowed(); diff --git a/base/files/file_path_watcher_browsertest.cc b/base/files/file_path_watcher_browsertest.cc index 7c37432..2a8b0cf 100644 --- a/base/files/file_path_watcher_browsertest.cc +++ b/base/files/file_path_watcher_browsertest.cc @@ -274,7 +274,7 @@ TEST_F(FilePathWatcherTest, DeletedFile) { ASSERT_TRUE(SetupWatch(test_file(), &watcher, delegate.get(), false)); // Now make sure we get notified if the file is deleted. - file_util::Delete(test_file(), false); + base::Delete(test_file(), false); ASSERT_TRUE(WaitForEvents()); DeleteDelegateOnFileThread(delegate.release()); } @@ -369,7 +369,7 @@ TEST_F(FilePathWatcherTest, NonExistentDirectory) { VLOG(1) << "Waiting for file change"; ASSERT_TRUE(WaitForEvents()); - ASSERT_TRUE(file_util::Delete(file, false)); + ASSERT_TRUE(base::Delete(file, false)); VLOG(1) << "Waiting for file deletion"; ASSERT_TRUE(WaitForEvents()); DeleteDelegateOnFileThread(delegate.release()); @@ -421,7 +421,7 @@ TEST_F(FilePathWatcherTest, DisappearingDirectory) { scoped_ptr<TestDelegate> delegate(new TestDelegate(collector())); ASSERT_TRUE(SetupWatch(file, &watcher, delegate.get(), false)); - ASSERT_TRUE(file_util::Delete(dir, true)); + ASSERT_TRUE(base::Delete(dir, true)); ASSERT_TRUE(WaitForEvents()); DeleteDelegateOnFileThread(delegate.release()); } @@ -433,7 +433,7 @@ TEST_F(FilePathWatcherTest, DeleteAndRecreate) { scoped_ptr<TestDelegate> delegate(new TestDelegate(collector())); ASSERT_TRUE(SetupWatch(test_file(), &watcher, delegate.get(), false)); - ASSERT_TRUE(file_util::Delete(test_file(), false)); + ASSERT_TRUE(base::Delete(test_file(), false)); VLOG(1) << "Waiting for file deletion"; ASSERT_TRUE(WaitForEvents()); @@ -466,7 +466,7 @@ TEST_F(FilePathWatcherTest, WatchDirectory) { ASSERT_TRUE(WaitForEvents()); #endif // !OS_MACOSX - ASSERT_TRUE(file_util::Delete(file1, false)); + ASSERT_TRUE(base::Delete(file1, false)); VLOG(1) << "Waiting for file1 deletion"; ASSERT_TRUE(WaitForEvents()); @@ -548,11 +548,11 @@ TEST_F(FilePathWatcherTest, RecursiveWatch) { ASSERT_TRUE(WaitForEvents()); // Delete "$dir/subdir/subdir_file1". - ASSERT_TRUE(file_util::Delete(subdir_file1, false)); + ASSERT_TRUE(base::Delete(subdir_file1, false)); ASSERT_TRUE(WaitForEvents()); // Delete "$dir/subdir/subdir_child_dir/child_dir_file1". - ASSERT_TRUE(file_util::Delete(child_dir_file1, false)); + ASSERT_TRUE(base::Delete(child_dir_file1, false)); ASSERT_TRUE(WaitForEvents()); DeleteDelegateOnFileThread(delegate.release()); } @@ -640,7 +640,7 @@ TEST_F(FilePathWatcherTest, DeleteLink) { ASSERT_TRUE(SetupWatch(test_link(), &watcher, delegate.get(), false)); // Now make sure we get notified if the link is deleted. - ASSERT_TRUE(file_util::Delete(test_link(), false)); + ASSERT_TRUE(base::Delete(test_link(), false)); ASSERT_TRUE(WaitForEvents()); DeleteDelegateOnFileThread(delegate.release()); } @@ -687,7 +687,7 @@ TEST_F(FilePathWatcherTest, DeleteTargetLinkedFile) { ASSERT_TRUE(SetupWatch(test_link(), &watcher, delegate.get(), false)); // Now make sure we get notified if the target file is deleted. - ASSERT_TRUE(file_util::Delete(test_file(), false)); + ASSERT_TRUE(base::Delete(test_file(), false)); ASSERT_TRUE(WaitForEvents()); DeleteDelegateOnFileThread(delegate.release()); } @@ -715,7 +715,7 @@ TEST_F(FilePathWatcherTest, LinkedDirectoryPart1) { VLOG(1) << "Waiting for file change"; ASSERT_TRUE(WaitForEvents()); - ASSERT_TRUE(file_util::Delete(file, false)); + ASSERT_TRUE(base::Delete(file, false)); VLOG(1) << "Waiting for file deletion"; ASSERT_TRUE(WaitForEvents()); DeleteDelegateOnFileThread(delegate.release()); @@ -745,7 +745,7 @@ TEST_F(FilePathWatcherTest, LinkedDirectoryPart2) { VLOG(1) << "Waiting for file change"; ASSERT_TRUE(WaitForEvents()); - ASSERT_TRUE(file_util::Delete(file, false)); + ASSERT_TRUE(base::Delete(file, false)); VLOG(1) << "Waiting for file deletion"; ASSERT_TRUE(WaitForEvents()); DeleteDelegateOnFileThread(delegate.release()); @@ -773,7 +773,7 @@ TEST_F(FilePathWatcherTest, LinkedDirectoryPart3) { VLOG(1) << "Waiting for file change"; ASSERT_TRUE(WaitForEvents()); - ASSERT_TRUE(file_util::Delete(file, false)); + ASSERT_TRUE(base::Delete(file, false)); VLOG(1) << "Waiting for file deletion"; ASSERT_TRUE(WaitForEvents()); DeleteDelegateOnFileThread(delegate.release()); diff --git a/base/files/file_util_proxy.cc b/base/files/file_util_proxy.cc index a1c568a..9f65da8e 100644 --- a/base/files/file_util_proxy.cc +++ b/base/files/file_util_proxy.cc @@ -213,7 +213,7 @@ PlatformFileError DeleteAdapter(const FilePath& file_path, bool recursive) { if (!file_util::PathExists(file_path)) { return PLATFORM_FILE_ERROR_NOT_FOUND; } - if (!file_util::Delete(file_path, recursive)) { + if (!base::Delete(file_path, recursive)) { if (!recursive && !file_util::IsDirectoryEmpty(file_path)) { return PLATFORM_FILE_ERROR_NOT_EMPTY; } diff --git a/base/files/file_util_proxy_unittest.cc b/base/files/file_util_proxy_unittest.cc index ef23fd8..a4ba571 100644 --- a/base/files/file_util_proxy_unittest.cc +++ b/base/files/file_util_proxy_unittest.cc @@ -219,7 +219,7 @@ TEST_F(FileUtilProxyTest, CreateTemporary) { EXPECT_EQ("test", data); // Make sure we can & do delete the created file to prevent leaks on the bots. - EXPECT_TRUE(file_util::Delete(path_, false)); + EXPECT_TRUE(base::Delete(path_, false)); } TEST_F(FileUtilProxyTest, GetFileInfo_File) { diff --git a/base/files/important_file_writer.cc b/base/files/important_file_writer.cc index ab62cc3..f10e7e6 100644 --- a/base/files/important_file_writer.cc +++ b/base/files/important_file_writer.cc @@ -73,20 +73,20 @@ bool ImportantFileWriter::WriteFileAtomically(const FilePath& path, if (!ClosePlatformFile(tmp_file)) { LogFailure(path, FAILED_CLOSING, "failed to close temporary file"); - file_util::Delete(tmp_file_path, false); + base::Delete(tmp_file_path, false); return false; } if (bytes_written < static_cast<int>(data.length())) { LogFailure(path, FAILED_WRITING, "error writing, bytes_written=" + IntToString(bytes_written)); - file_util::Delete(tmp_file_path, false); + base::Delete(tmp_file_path, false); return false; } if (!file_util::ReplaceFile(tmp_file_path, path)) { LogFailure(path, FAILED_RENAMING, "could not rename temporary file"); - file_util::Delete(tmp_file_path, false); + base::Delete(tmp_file_path, false); return false; } diff --git a/base/files/scoped_temp_dir.cc b/base/files/scoped_temp_dir.cc index 509f808..5666ce1 100644 --- a/base/files/scoped_temp_dir.cc +++ b/base/files/scoped_temp_dir.cc @@ -64,7 +64,7 @@ bool ScopedTempDir::Delete() { if (path_.empty()) return false; - bool ret = file_util::Delete(path_, true); + bool ret = base::Delete(path_, true); if (ret) { // We only clear the path if deleted the directory. path_.clear(); diff --git a/base/files/scoped_temp_dir_unittest.cc b/base/files/scoped_temp_dir_unittest.cc index 8497ac6..7acec84 100644 --- a/base/files/scoped_temp_dir_unittest.cc +++ b/base/files/scoped_temp_dir_unittest.cc @@ -77,7 +77,7 @@ TEST(ScopedTempDir, UniqueTempDirUnderPath) { EXPECT_TRUE(test_path.value().find(base_path.value()) != std::string::npos); } EXPECT_FALSE(file_util::DirectoryExists(test_path)); - file_util::Delete(base_path, true); + base::Delete(base_path, true); } TEST(ScopedTempDir, MultipleInvocations) { diff --git a/base/json/json_value_serializer_unittest.cc b/base/json/json_value_serializer_unittest.cc index b428e2a..78be11e 100644 --- a/base/json/json_value_serializer_unittest.cc +++ b/base/json/json_value_serializer_unittest.cc @@ -425,7 +425,7 @@ TEST_F(JSONFileValueSerializerTest, Roundtrip) { // Now compare file contents. EXPECT_TRUE(file_util::TextContentsEqual(original_file_path, written_file_path)); - EXPECT_TRUE(file_util::Delete(written_file_path, false)); + EXPECT_TRUE(base::Delete(written_file_path, false)); } TEST_F(JSONFileValueSerializerTest, RoundtripNested) { @@ -453,7 +453,7 @@ TEST_F(JSONFileValueSerializerTest, RoundtripNested) { // Now compare file contents. EXPECT_TRUE(file_util::TextContentsEqual(original_file_path, written_file_path)); - EXPECT_TRUE(file_util::Delete(written_file_path, false)); + EXPECT_TRUE(base::Delete(written_file_path, false)); } TEST_F(JSONFileValueSerializerTest, NoWhitespace) { diff --git a/base/memory/shared_memory_posix.cc b/base/memory/shared_memory_posix.cc index 66f5848..5d580d0 100644 --- a/base/memory/shared_memory_posix.cc +++ b/base/memory/shared_memory_posix.cc @@ -201,7 +201,7 @@ bool SharedMemory::Delete(const std::string& name) { return false; if (file_util::PathExists(path)) { - return file_util::Delete(path, false); + return base::Delete(path, false); } // Doesn't exist, so success. diff --git a/base/prefs/json_pref_store_unittest.cc b/base/prefs/json_pref_store_unittest.cc index 63b9e02..77f0c0d 100644 --- a/base/prefs/json_pref_store_unittest.cc +++ b/base/prefs/json_pref_store_unittest.cc @@ -148,7 +148,7 @@ void RunBasicJsonPrefStoreTest(JsonPrefStore* pref_store, pref_store->CommitPendingWrite(); RunLoop().RunUntilIdle(); EXPECT_TRUE(file_util::TextContentsEqual(golden_output_file, output_file)); - ASSERT_TRUE(file_util::Delete(output_file, false)); + ASSERT_TRUE(base::Delete(output_file, false)); } TEST_F(JsonPrefStoreTest, Basic) { diff --git a/base/test/test_file_util.h b/base/test/test_file_util.h index 418c480..cf20221 100644 --- a/base/test/test_file_util.h +++ b/base/test/test_file_util.h @@ -27,7 +27,7 @@ bool EvictFileFromSystemCacheWithRetry(const FilePath& file); // TODO(brettw) move all of this to the base namespace. namespace file_util { -// Wrapper over file_util::Delete. On Windows repeatedly invokes Delete in case +// Wrapper over base::Delete. On Windows repeatedly invokes Delete in case // of failure to workaround Windows file locking semantics. Returns true on // success. bool DieFileDie(const base::FilePath& file, bool recurse); diff --git a/base/test/test_file_util_posix.cc b/base/test/test_file_util_posix.cc index aa3e9a0..10701be 100644 --- a/base/test/test_file_util_posix.cc +++ b/base/test/test_file_util_posix.cc @@ -77,7 +77,7 @@ bool RestorePermissionInfo(const base::FilePath& path, bool DieFileDie(const base::FilePath& file, bool recurse) { // There is no need to workaround Windows problems on POSIX. // Just pass-through. - return file_util::Delete(file, recurse); + return base::Delete(file, recurse); } #if !defined(OS_LINUX) && !defined(OS_MACOSX) diff --git a/base/test/test_file_util_win.cc b/base/test/test_file_util_win.cc index 8e130d8..9e3697b 100644 --- a/base/test/test_file_util_win.cc +++ b/base/test/test_file_util_win.cc @@ -126,7 +126,7 @@ bool DieFileDie(const base::FilePath& file, bool recurse) { // into short chunks, so that if a try succeeds, we won't delay the test // for too long. for (int i = 0; i < kIterations; ++i) { - if (file_util::Delete(file, recurse)) + if (base::Delete(file, recurse)) return true; base::PlatformThread::Sleep(kTimeout); } diff --git a/base/win/event_trace_consumer_unittest.cc b/base/win/event_trace_consumer_unittest.cc index dbf6eed..b92bdc0 100644 --- a/base/win/event_trace_consumer_unittest.cc +++ b/base/win/event_trace_consumer_unittest.cc @@ -291,7 +291,7 @@ class EtwTraceConsumerDataTest: public EtwTraceConsumerBaseTest { } virtual void TearDown() { - EXPECT_TRUE(file_util::Delete(temp_file_, false)); + EXPECT_TRUE(base::Delete(temp_file_, false)); EtwTraceConsumerBaseTest::TearDown(); } @@ -335,7 +335,7 @@ class EtwTraceConsumerDataTest: public EtwTraceConsumerBaseTest { } HRESULT RoundTripEvent(PEVENT_TRACE_HEADER header, PEVENT_TRACE* trace) { - file_util::Delete(temp_file_, false); + base::Delete(temp_file_, false); HRESULT hr = LogEventToTempSession(header); if (SUCCEEDED(hr)) diff --git a/base/win/event_trace_controller_unittest.cc b/base/win/event_trace_controller_unittest.cc index 7b2e99e..4fe32c3 100644 --- a/base/win/event_trace_controller_unittest.cc +++ b/base/win/event_trace_controller_unittest.cc @@ -171,7 +171,7 @@ TEST_F(EtwTraceControllerTest, StartFileSession) { temp.value().c_str()); if (hr == E_ACCESSDENIED) { VLOG(1) << "You must be an administrator to run this test on Vista"; - file_util::Delete(temp, false); + base::Delete(temp, false); return; } @@ -181,7 +181,7 @@ TEST_F(EtwTraceControllerTest, StartFileSession) { EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); EXPECT_EQ(NULL, controller.session()); EXPECT_STREQ(L"", controller.session_name()); - file_util::Delete(temp, false); + base::Delete(temp, false); } TEST_F(EtwTraceControllerTest, EnableDisable) { diff --git a/chrome/browser/android/crash_dump_manager.cc b/chrome/browser/android/crash_dump_manager.cc index a7c2c19..eb41d2c 100644 --- a/chrome/browser/android/crash_dump_manager.cc +++ b/chrome/browser/android/crash_dump_manager.cc @@ -91,7 +91,7 @@ void CrashDumpManager::ProcessMinidump(const base::FilePath& minidump_path, if (file_size == 0) { // Empty minidump, this process did not crash. Just remove the file. - r = file_util::Delete(minidump_path, false); + r = base::Delete(minidump_path, false); DCHECK(r) << "Failed to delete temporary minidump file " << minidump_path.value(); return; @@ -115,7 +115,7 @@ void CrashDumpManager::ProcessMinidump(const base::FilePath& minidump_path, if (!r) { LOG(ERROR) << "Failed to move crash dump from " << minidump_path.value() << " to " << dest_path.value(); - file_util::Delete(minidump_path, false); + base::Delete(minidump_path, false); return; } LOG(INFO) << "Crash minidump successfully generated: " << diff --git a/chrome/browser/browser_shutdown.cc b/chrome/browser/browser_shutdown.cc index 925e33e..9cc661b 100644 --- a/chrome/browser/browser_shutdown.cc +++ b/chrome/browser/browser_shutdown.cc @@ -267,7 +267,7 @@ void ReadLastShutdownFile(ShutdownType type, int64 shutdown_ms = 0; if (file_util::ReadFileToString(shutdown_ms_file, &shutdown_ms_str)) base::StringToInt64(shutdown_ms_str, &shutdown_ms); - file_util::Delete(shutdown_ms_file, false); + base::Delete(shutdown_ms_file, false); if (type == NOT_VALID || shutdown_ms == 0 || num_procs == 0) return; diff --git a/chrome/browser/chrome_to_mobile_service.cc b/chrome/browser/chrome_to_mobile_service.cc index 7bd833f..eebde18 100644 --- a/chrome/browser/chrome_to_mobile_service.cc +++ b/chrome/browser/chrome_to_mobile_service.cc @@ -205,7 +205,7 @@ void ReadSnapshotFile(scoped_ptr<ChromeToMobileService::JobData> data, // Call this as a BlockingPoolSequencedTask [after posting SubmitSnapshotFile]. void DeleteSnapshotFile(const base::FilePath& snapshot) { DCHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - bool success = file_util::Delete(snapshot, false); + bool success = base::Delete(snapshot, false); DCHECK(success); } diff --git a/chrome/browser/chromeos/app_mode/kiosk_app_data.cc b/chrome/browser/chromeos/app_mode/kiosk_app_data.cc index 680ccc8..639d07f 100644 --- a/chrome/browser/chromeos/app_mode/kiosk_app_data.cc +++ b/chrome/browser/chromeos/app_mode/kiosk_app_data.cc @@ -277,7 +277,7 @@ void KioskAppData::ClearCache() { if (!icon_path_.empty()) { BrowserThread::PostBlockingPoolTask( FROM_HERE, - base::Bind(base::IgnoreResult(&file_util::Delete), icon_path_, false)); + base::Bind(base::IgnoreResult(&base::Delete), icon_path_, false)); } } diff --git a/chrome/browser/chromeos/contacts/contact_database.cc b/chrome/browser/chromeos/contacts/contact_database.cc index 8147297..cfff9b2 100644 --- a/chrome/browser/chromeos/contacts/contact_database.cc +++ b/chrome/browser/chromeos/contacts/contact_database.cc @@ -200,7 +200,7 @@ void ContactDatabase::InitFromTaskRunner(const base::FilePath& database_dir, // Delete the existing database and try again (just once, though). if (status.IsCorruption() && delete_and_retry_on_corruption) { LOG(WARNING) << "Deleting possibly-corrupt database"; - file_util::Delete(database_dir, true); + base::Delete(database_dir, true); delete_and_retry_on_corruption = false; histogram_result = HISTOGRAM_INIT_RESULT_DELETED_CORRUPTED; } else { diff --git a/chrome/browser/chromeos/drive/file_cache.cc b/chrome/browser/chromeos/drive/file_cache.cc index 78e765e..35a960b 100644 --- a/chrome/browser/chromeos/drive/file_cache.cc +++ b/chrome/browser/chromeos/drive/file_cache.cc @@ -123,7 +123,7 @@ void DeleteFilesSelectively(const base::FilePath& path_to_delete_pattern, if (!path_to_keep.empty() && current == path_to_keep) continue; - success = file_util::Delete(current, false); + success = base::Delete(current, false); if (!success) DVLOG(1) << "Error deleting " << current.value(); else @@ -310,7 +310,7 @@ bool FileCache::FreeDiskSpaceIfNeededFor(int64 num_bytes) { current = enumerator.Next()) { util::ParseCacheFilePath(current, &resource_id, &md5); if (!GetCacheEntry(resource_id, md5, &entry)) - file_util::Delete(current, false /* recursive */); + base::Delete(current, false /* recursive */); } // Check the disk space again. @@ -791,7 +791,7 @@ bool FileCache::ClearAll() { base::FileEnumerator::FILES); for (base::FilePath file = enumerator.Next(); !file.empty(); file = enumerator.Next()) - file_util::Delete(file, false /* recursive */); + base::Delete(file, false /* recursive */); return true; } @@ -832,7 +832,7 @@ bool FileCache::ImportOldDB(const base::FilePath& old_db_path) { } // Delete old DB. - file_util::Delete(old_db_path, true /* recursive */ ); + base::Delete(old_db_path, true /* recursive */ ); return imported; } diff --git a/chrome/browser/chromeos/drive/file_cache_metadata.cc b/chrome/browser/chromeos/drive/file_cache_metadata.cc index 7fc206d..b421b43 100644 --- a/chrome/browser/chromeos/drive/file_cache_metadata.cc +++ b/chrome/browser/chromeos/drive/file_cache_metadata.cc @@ -110,7 +110,7 @@ FileCacheMetadata::InitializeResult FileCacheMetadata::Initialize( LOG(WARNING) << "Cache db failed to open: " << db_status.ToString(); uma_status = db_status.IsCorruption() ? DB_OPEN_FAILURE_CORRUPTION : DB_OPEN_FAILURE_OTHER; - const bool deleted = file_util::Delete(db_path, true); + const bool deleted = base::Delete(db_path, true); DCHECK(deleted); db_status = leveldb::DB::Open(options, db_path.value(), &level_db); if (!db_status.ok()) { diff --git a/chrome/browser/chromeos/drive/file_cache_unittest.cc b/chrome/browser/chromeos/drive/file_cache_unittest.cc index dbfc68e..be18599 100644 --- a/chrome/browser/chromeos/drive/file_cache_unittest.cc +++ b/chrome/browser/chromeos/drive/file_cache_unittest.cc @@ -938,7 +938,7 @@ TEST_F(FileCacheTest, ScanCacheFile) { // Remove the existing DB. const base::FilePath metadata_directory = temp_dir_.path().Append(util::kMetadataDirectory); - ASSERT_TRUE(file_util::Delete(metadata_directory, true /* recursive */)); + ASSERT_TRUE(base::Delete(metadata_directory, true /* recursive */)); // Put an empty file with the same name as old DB. // This file cannot be opened by ImportOldDB() and will be dismissed. diff --git a/chrome/browser/chromeos/drive/file_system/download_operation.cc b/chrome/browser/chromeos/drive/file_system/download_operation.cc index 8689ebd..06b821f 100644 --- a/chrome/browser/chromeos/drive/file_system/download_operation.cc +++ b/chrome/browser/chromeos/drive/file_system/download_operation.cc @@ -196,7 +196,7 @@ FileError UpdateLocalStateForDownloadFile( FileError error = util::GDataToFileError(gdata_error); if (error != FILE_ERROR_OK) { - file_util::Delete(downloaded_file_path, false /* recursive */); + base::Delete(downloaded_file_path, false /* recursive */); return error; } @@ -204,7 +204,7 @@ FileError UpdateLocalStateForDownloadFile( error = cache->Store(resource_id, md5, downloaded_file_path, internal::FileCache::FILE_OPERATION_MOVE); if (error != FILE_ERROR_OK) { - file_util::Delete(downloaded_file_path, false /* recursive */); + base::Delete(downloaded_file_path, false /* recursive */); return error; } diff --git a/chrome/browser/chromeos/drive/file_system_util.cc b/chrome/browser/chromeos/drive/file_system_util.cc index 9d3ebd2..45c3074 100644 --- a/chrome/browser/chromeos/drive/file_system_util.cc +++ b/chrome/browser/chromeos/drive/file_system_util.cc @@ -323,7 +323,7 @@ void MigrateCacheFilesFromOldDirectories( // Move all files inside "persistent" to "files". MoveAllFilesFromDirectory(persistent_directory, cache_file_directory); - file_util::Delete(persistent_directory, true /* recursive */); + base::Delete(persistent_directory, true /* recursive */); // Move all files inside "tmp" to "files". MoveAllFilesFromDirectory(tmp_directory, cache_file_directory); diff --git a/chrome/browser/chromeos/drive/resource_metadata_storage.cc b/chrome/browser/chromeos/drive/resource_metadata_storage.cc index 898a8e1..b7a6264 100644 --- a/chrome/browser/chromeos/drive/resource_metadata_storage.cc +++ b/chrome/browser/chromeos/drive/resource_metadata_storage.cc @@ -217,7 +217,7 @@ bool ResourceMetadataStorage::Initialize() { // Remove unused child map DB. const base::FilePath child_map_path = directory_path_.Append(kChildMapDBName); - file_util::Delete(child_map_path, true /* recursive */); + base::Delete(child_map_path, true /* recursive */); resource_map_.reset(); @@ -267,7 +267,7 @@ bool ResourceMetadataStorage::Initialize() { // Clean up the destination. const bool kRecursive = true; - file_util::Delete(resource_map_path, kRecursive); + base::Delete(resource_map_path, kRecursive); // Create DB. options.create_if_missing = true; diff --git a/chrome/browser/chromeos/imageburner/burn_manager.cc b/chrome/browser/chromeos/imageburner/burn_manager.cc index 7f39517..9d3ab26 100644 --- a/chrome/browser/chromeos/imageburner/burn_manager.cc +++ b/chrome/browser/chromeos/imageburner/burn_manager.cc @@ -238,7 +238,7 @@ BurnManager::BurnManager( BurnManager::~BurnManager() { if (image_dir_created_) { - file_util::Delete(image_dir_, true); + base::Delete(image_dir_, true); } if (NetworkHandler::IsInitialized()) { NetworkHandler::Get()->network_state_handler()->RemoveObserver( diff --git a/chrome/browser/chromeos/login/user_image_manager_impl.cc b/chrome/browser/chromeos/login/user_image_manager_impl.cc index c989f24..f22a8d4 100644 --- a/chrome/browser/chromeos/login/user_image_manager_impl.cc +++ b/chrome/browser/chromeos/login/user_image_manager_impl.cc @@ -145,7 +145,7 @@ void DeleteImageFile(const std::string& image_path) { BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind(base::IgnoreResult(&file_util::Delete), + base::Bind(base::IgnoreResult(&base::Delete), fp, /* recursive= */ false)); } diff --git a/chrome/browser/chromeos/login/wallpaper_manager.cc b/chrome/browser/chromeos/login/wallpaper_manager.cc index 4fdcece..875d61b 100644 --- a/chrome/browser/chromeos/login/wallpaper_manager.cc +++ b/chrome/browser/chromeos/login/wallpaper_manager.cc @@ -393,7 +393,7 @@ void WallpaperManager::ResizeAndSaveWallpaper(const UserImage& wallpaper, if (layout == ash::WALLPAPER_LAYOUT_CENTER) { // TODO(bshe): Generates cropped custom wallpaper for CENTER layout. if (file_util::PathExists(path)) - file_util::Delete(path, false); + base::Delete(path, false); return; } scoped_refptr<base::RefCountedBytes> data; @@ -675,7 +675,7 @@ void WallpaperManager::DeleteAllExcept(const base::FilePath& path) { for (base::FilePath current = files.Next(); !current.empty(); current = files.Next()) { if (current != path) - file_util::Delete(current, false); + base::Delete(current, false); } } } @@ -687,8 +687,8 @@ void WallpaperManager::DeleteWallpaperInList( base::FilePath path = *it; // Some users may still have legacy wallpapers with png extension. We need // to delete these wallpapers too. - if (!file_util::Delete(path, true) && - !file_util::Delete(path.AddExtension(".png"), false)) { + if (!base::Delete(path, true) && + !base::Delete(path.AddExtension(".png"), false)) { LOG(ERROR) << "Failed to remove user wallpaper at " << path.value(); } } diff --git a/chrome/browser/chromeos/policy/app_pack_updater.cc b/chrome/browser/chromeos/policy/app_pack_updater.cc index 74bb18d..d700ca0 100644 --- a/chrome/browser/chromeos/policy/app_pack_updater.cc +++ b/chrome/browser/chromeos/policy/app_pack_updater.cc @@ -261,7 +261,7 @@ void AppPackUpdater::BlockingCheckCacheInternal( if (info.IsDirectory() || file_util::IsLink(info.GetName())) { LOG(ERROR) << "Erasing bad file in AppPack directory: " << basename; - file_util::Delete(path, true /* recursive */); + base::Delete(path, true /* recursive */); continue; } @@ -294,7 +294,7 @@ void AppPackUpdater::BlockingCheckCacheInternal( if (id.empty() || version.empty()) { LOG(ERROR) << "Invalid file in AppPack cache, erasing: " << basename; - file_util::Delete(path, true /* recursive */); + base::Delete(path, true /* recursive */); continue; } @@ -313,10 +313,10 @@ void AppPackUpdater::BlockingCheckCacheInternal( DCHECK(vEntry.IsValid()); DCHECK(vCurrent.IsValid()); if (vEntry.CompareTo(vCurrent) < 0) { - file_util::Delete(base::FilePath(entry.path), true /* recursive */); + base::Delete(base::FilePath(entry.path), true /* recursive */); entry.path = path.value(); } else { - file_util::Delete(path, true /* recursive */); + base::Delete(path, true /* recursive */); } continue; } @@ -470,7 +470,7 @@ void AppPackUpdater::BlockingInstallCacheEntry( if (!version_validator.IsValid()) { LOG(ERROR) << "AppPack downloaded extension " << id << " but got bad " << "version: " << version; - file_util::Delete(path, true /* recursive */); + base::Delete(path, true /* recursive */); return; } @@ -481,7 +481,7 @@ void AppPackUpdater::BlockingInstallCacheEntry( if (file_util::PathExists(cached_crx_path)) { LOG(WARNING) << "AppPack downloaded a crx whose filename will overwrite " << "an existing cached crx."; - file_util::Delete(cached_crx_path, true /* recursive */); + base::Delete(cached_crx_path, true /* recursive */); } if (!file_util::DirectoryExists(cache_dir)) { @@ -489,7 +489,7 @@ void AppPackUpdater::BlockingInstallCacheEntry( << cache_dir.value(); if (!file_util::CreateDirectory(cache_dir)) { LOG(ERROR) << "Failed to create the AppPack cache dir!"; - file_util::Delete(path, true /* recursive */); + base::Delete(path, true /* recursive */); return; } } @@ -497,7 +497,7 @@ void AppPackUpdater::BlockingInstallCacheEntry( if (!file_util::Move(path, cached_crx_path)) { LOG(ERROR) << "Failed to move AppPack crx from " << path.value() << " to " << cached_crx_path.value(); - file_util::Delete(path, true /* recursive */); + base::Delete(path, true /* recursive */); return; } @@ -539,7 +539,7 @@ void AppPackUpdater::OnDamagedFileDetected(const base::FilePath& path) { // The file will be downloaded again on the next restart. BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind(base::IgnoreResult(file_util::Delete), path, true)); + base::Bind(base::IgnoreResult(base::Delete), path, true)); // Don't try to DownloadMissingExtensions() from here, // since it can cause a fail/retry loop. diff --git a/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.cc b/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.cc index 884cda0..ae9b79c 100644 --- a/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.cc +++ b/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.cc @@ -409,7 +409,7 @@ void UserCloudPolicyStoreChromeOS::InstallLegacyTokens( // static void UserCloudPolicyStoreChromeOS::RemoveLegacyCacheDir( const base::FilePath& dir) { - if (file_util::PathExists(dir) && !file_util::Delete(dir, true)) + if (file_util::PathExists(dir) && !base::Delete(dir, true)) LOG(ERROR) << "Failed to remove cache dir " << dir.value(); } diff --git a/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos_unittest.cc b/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos_unittest.cc index 9cb2b9c..ec73418 100644 --- a/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos_unittest.cc +++ b/chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos_unittest.cc @@ -239,7 +239,7 @@ class UserCloudPolicyStoreChromeOSTest : public testing::Test { TEST_F(UserCloudPolicyStoreChromeOSTest, InitialStore) { // Start without any public key to trigger the initial key checks. - ASSERT_TRUE(file_util::Delete(user_policy_key_file(), false)); + ASSERT_TRUE(base::Delete(user_policy_key_file(), false)); // Make the policy blob contain a new public key. policy_.set_new_signing_key(PolicyBuilder::CreateTestNewSigningKey()); policy_.Build(); @@ -383,7 +383,7 @@ TEST_F(UserCloudPolicyStoreChromeOSTest, LoadValidationError) { TEST_F(UserCloudPolicyStoreChromeOSTest, LoadNoKey) { // The loaded policy can't be verified without the public key. - ASSERT_TRUE(file_util::Delete(user_policy_key_file(), false)); + ASSERT_TRUE(base::Delete(user_policy_key_file(), false)); ExpectError(CloudPolicyStore::STATUS_VALIDATION_ERROR); ASSERT_NO_FATAL_FAILURE(PerformPolicyLoad(policy_.GetBlob())); VerifyStoreHasValidationError(); @@ -480,7 +480,7 @@ TEST_F(UserCloudPolicyStoreChromeOSTest, MigrationNoPolicy) { TEST_F(UserCloudPolicyStoreChromeOSTest, MigrationAndStoreNew) { // Start without an existing public key. - ASSERT_TRUE(file_util::Delete(user_policy_key_file(), false)); + ASSERT_TRUE(base::Delete(user_policy_key_file(), false)); std::string data; em::CachedCloudPolicyResponse cached_policy; diff --git a/chrome/browser/chromeos/system/syslogs_provider.cc b/chrome/browser/chromeos/system/syslogs_provider.cc index 1c7e06a..643d355 100644 --- a/chrome/browser/chromeos/system/syslogs_provider.cc +++ b/chrome/browser/chromeos/system/syslogs_provider.cc @@ -146,7 +146,7 @@ LogDictionaryType* GetSystemLogs(base::FilePath* zip_file_name, &data); // if we were using an internal temp file, the user does not need the // logs to stay past the ReadFile call - delete the file - file_util::Delete(temp_filename, false); + base::Delete(temp_filename, false); if (!read_success) return NULL; @@ -321,7 +321,7 @@ void SyslogsProviderImpl::ReadSyslogs( // Load compressed logs. zip_content = new std::string(); LoadCompressedLogs(zip_file, zip_content); - file_util::Delete(zip_file, false); + base::Delete(zip_file, false); } // Include dbus statistics summary diff --git a/chrome/browser/chromeos/system/timezone_settings.cc b/chrome/browser/chromeos/system/timezone_settings.cc index 54170ee..c46e1b2 100644 --- a/chrome/browser/chromeos/system/timezone_settings.cc +++ b/chrome/browser/chromeos/system/timezone_settings.cc @@ -208,7 +208,7 @@ void SetTimezoneIDFromString(const std::string& id) { } // Delete old symlink2 if it exists. - file_util::Delete(timezone_symlink2, false); + base::Delete(timezone_symlink2, false); // Create new symlink2. if (symlink(timezone_file.value().c_str(), diff --git a/chrome/browser/component_updater/component_unpacker.cc b/chrome/browser/component_updater/component_unpacker.cc index 341df22..de7cfcb 100644 --- a/chrome/browser/component_updater/component_unpacker.cc +++ b/chrome/browser/component_updater/component_unpacker.cc @@ -110,7 +110,7 @@ base::DictionaryValue* ReadManifest(const base::FilePath& unpack_path) { // being inserted into the target directory by another process or thread. bool MakeEmptyDirectory(const base::FilePath& path) { if (file_util::PathExists(path)) { - if (!file_util::Delete(path, true)) + if (!base::Delete(path, true)) return false; } if (!file_util::CreateDirectory(path)) @@ -186,7 +186,7 @@ ComponentUnpacker::ComponentUnpacker(const std::vector<uint8>& pk_hash, patcher, installer, &extended_error_); - file_util::Delete(unpack_diff_path, true); + base::Delete(unpack_diff_path, true); unpack_diff_path.clear(); error_ = result; if (error_ != kNone) { @@ -223,5 +223,5 @@ ComponentUnpacker::ComponentUnpacker(const std::vector<uint8>& pk_hash, ComponentUnpacker::~ComponentUnpacker() { if (!unpack_path_.empty()) - file_util::Delete(unpack_path_, true); + base::Delete(unpack_path_, true); } diff --git a/chrome/browser/component_updater/component_updater_service.cc b/chrome/browser/component_updater/component_updater_service.cc index 6ceb452..8048855 100644 --- a/chrome/browser/component_updater/component_updater_service.cc +++ b/chrome/browser/component_updater/component_updater_service.cc @@ -929,7 +929,7 @@ void CrxUpdateService::Install(const CRXContext* context, context->fingerprint, component_patcher_.get(), context->installer); - if (!file_util::Delete(crx_path, false)) + if (!base::Delete(crx_path, false)) NOTREACHED() << crx_path.value(); // Why unretained? See comment at top of file. BrowserThread::PostDelayedTask( diff --git a/chrome/browser/component_updater/pepper_flash_component_installer.cc b/chrome/browser/component_updater/pepper_flash_component_installer.cc index 009afa0..2b07c40 100644 --- a/chrome/browser/component_updater/pepper_flash_component_installer.cc +++ b/chrome/browser/component_updater/pepper_flash_component_installer.cc @@ -385,7 +385,7 @@ void StartPepperFlashUpdateRegistration(ComponentUpdateService* cus) { // Remove older versions of Pepper Flash. for (std::vector<base::FilePath>::iterator iter = older_dirs.begin(); iter != older_dirs.end(); ++iter) { - file_util::Delete(*iter, true); + base::Delete(*iter, true); } } #endif // defined(GOOGLE_CHROME_BUILD) && !defined(OS_LINUX) diff --git a/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc b/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc index adfde80..c608c35 100644 --- a/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc +++ b/chrome/browser/component_updater/pnacl/pnacl_component_installer.cc @@ -415,7 +415,7 @@ void StartPnaclUpdateRegistration(PnaclComponentInstaller* pci) { // Remove older versions of PNaCl. for (std::vector<base::FilePath>::iterator iter = older_dirs.begin(); iter != older_dirs.end(); ++iter) { - file_util::Delete(*iter, true); + base::Delete(*iter, true); } } diff --git a/chrome/browser/component_updater/swiftshader_component_installer.cc b/chrome/browser/component_updater/swiftshader_component_installer.cc index 5c2eca8..b4a4650 100644 --- a/chrome/browser/component_updater/swiftshader_component_installer.cc +++ b/chrome/browser/component_updater/swiftshader_component_installer.cc @@ -230,7 +230,7 @@ void RegisterSwiftShaderPath(ComponentUpdateService* cus) { // Remove older versions of SwiftShader. for (std::vector<base::FilePath>::iterator iter = older_dirs.begin(); iter != older_dirs.end(); ++iter) { - file_util::Delete(*iter, true); + base::Delete(*iter, true); } } diff --git a/chrome/browser/component_updater/test/test_installer.cc b/chrome/browser/component_updater/test/test_installer.cc index 9a4098c..2dc2913 100644 --- a/chrome/browser/component_updater/test/test_installer.cc +++ b/chrome/browser/component_updater/test/test_installer.cc @@ -19,7 +19,7 @@ void TestInstaller::OnUpdateError(int error) { bool TestInstaller::Install(const base::DictionaryValue& manifest, const base::FilePath& unpack_path) { ++install_count_; - return file_util::Delete(unpack_path, true); + return base::Delete(unpack_path, true); } bool TestInstaller::GetInstalledFile(const std::string& file, @@ -52,7 +52,7 @@ VersionedTestInstaller::VersionedTestInstaller() { } VersionedTestInstaller::~VersionedTestInstaller() { - file_util::Delete(install_directory_, true); + base::Delete(install_directory_, true); } diff --git a/chrome/browser/component_updater/widevine_cdm_component_installer.cc b/chrome/browser/component_updater/widevine_cdm_component_installer.cc index a9c084c..0b1c1b0 100644 --- a/chrome/browser/component_updater/widevine_cdm_component_installer.cc +++ b/chrome/browser/component_updater/widevine_cdm_component_installer.cc @@ -302,7 +302,7 @@ void StartWidevineCdmUpdateRegistration(ComponentUpdateService* cus) { BrowserThread::UI, FROM_HERE, base::Bind(&RegisterWidevineCdmWithChrome, adapter_path, version)); } else { - file_util::Delete(latest_dir, true); + base::Delete(latest_dir, true); version = base::Version(kNullVersion); } } @@ -314,7 +314,7 @@ void StartWidevineCdmUpdateRegistration(ComponentUpdateService* cus) { // Remove older versions of Widevine CDM. for (std::vector<base::FilePath>::iterator iter = older_dirs.begin(); iter != older_dirs.end(); ++iter) { - file_util::Delete(*iter, true); + base::Delete(*iter, true); } } diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc index 2f9700c..505c42a 100644 --- a/chrome/browser/download/download_browsertest.cc +++ b/chrome/browser/download/download_browsertest.cc @@ -899,7 +899,7 @@ class DownloadTest : public InProcessBrowserTest { base::FilePath destination_folder = GetDownloadDirectory(browser()); base::FilePath my_downloaded_file = item->GetTargetFilePath(); EXPECT_TRUE(file_util::PathExists(my_downloaded_file)); - EXPECT_TRUE(file_util::Delete(my_downloaded_file, false)); + EXPECT_TRUE(base::Delete(my_downloaded_file, false)); EXPECT_EQ(download_info.should_redirect_to_documents ? std::string::npos : diff --git a/chrome/browser/extensions/activity_log/activity_database_unittest.cc b/chrome/browser/extensions/activity_log/activity_database_unittest.cc index 85f1e19..56ac824 100644 --- a/chrome/browser/extensions/activity_log/activity_database_unittest.cc +++ b/chrome/browser/extensions/activity_log/activity_database_unittest.cc @@ -75,7 +75,7 @@ TEST_F(ActivityDatabaseTest, Init) { base::FilePath db_file; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); db_file = temp_dir.path().AppendASCII("ActivityInit.db"); - file_util::Delete(db_file, false); + base::Delete(db_file, false); ActivityDatabase* activity_db = new ActivityDatabase(); activity_db->Init(db_file); @@ -96,7 +96,7 @@ TEST_F(ActivityDatabaseTest, RecordAPIAction) { base::FilePath db_file; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); db_file = temp_dir.path().AppendASCII("ActivityRecord.db"); - file_util::Delete(db_file, false); + base::Delete(db_file, false); ActivityDatabase* activity_db = new ActivityDatabase(); activity_db->Init(db_file); @@ -132,7 +132,7 @@ TEST_F(ActivityDatabaseTest, RecordDOMAction) { base::FilePath db_file; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); db_file = temp_dir.path().AppendASCII("ActivityRecord.db"); - file_util::Delete(db_file, false); + base::Delete(db_file, false); ActivityDatabase* activity_db = new ActivityDatabase(); activity_db->Init(db_file); @@ -177,7 +177,7 @@ TEST_F(ActivityDatabaseTest, RecordBlockedAction) { base::FilePath db_file; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); db_file = temp_dir.path().AppendASCII("ActivityRecord.db"); - file_util::Delete(db_file, false); + base::Delete(db_file, false); ActivityDatabase* activity_db = new ActivityDatabase(); activity_db->Init(db_file); @@ -213,7 +213,7 @@ TEST_F(ActivityDatabaseTest, GetTodaysActions) { base::FilePath db_file; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); db_file = temp_dir.path().AppendASCII("ActivityRecord.db"); - file_util::Delete(db_file, false); + base::Delete(db_file, false); // Use a mock clock to ensure that events are not recorded on the wrong day // when the test is run close to local midnight. @@ -273,7 +273,7 @@ TEST_F(ActivityDatabaseTest, GetOlderActions) { base::FilePath db_file; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); db_file = temp_dir.path().AppendASCII("ActivityRecord.db"); - file_util::Delete(db_file, false); + base::Delete(db_file, false); // Use a mock clock to ensure that events are not recorded on the wrong day // when the test is run close to local midnight. @@ -343,7 +343,7 @@ TEST_F(ActivityDatabaseTest, BatchModeOff) { base::FilePath db_file; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); db_file = temp_dir.path().AppendASCII("ActivityRecord.db"); - file_util::Delete(db_file, false); + base::Delete(db_file, false); // Use a mock clock to ensure that events are not recorded on the wrong day // when the test is run close to local midnight. @@ -377,7 +377,7 @@ TEST_F(ActivityDatabaseTest, BatchModeOn) { base::FilePath db_file; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); db_file = temp_dir.path().AppendASCII("ActivityRecord.db"); - file_util::Delete(db_file, false); + base::Delete(db_file, false); // Use a mock clock to set the time, and a special timer to control the // timing and skip ahead in time. @@ -421,7 +421,7 @@ TEST_F(ActivityDatabaseTest, InitFailure) { base::FilePath db_file; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); db_file = temp_dir.path().AppendASCII("ActivityRecord.db"); - file_util::Delete(db_file, false); + base::Delete(db_file, false); ActivityDatabase* activity_db = new ActivityDatabase(); scoped_refptr<APIAction> action = new APIAction( diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.cc b/chrome/browser/extensions/api/developer_private/developer_private_api.cc index c54017b..54d4db5 100644 --- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc +++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc @@ -920,7 +920,7 @@ bool DeveloperPrivateExportSyncfsFolderToLocalfsFunction::RunImpl() { void DeveloperPrivateExportSyncfsFolderToLocalfsFunction:: ClearPrexistingDirectoryContent(const base::FilePath& project_path) { - if (!file_util::Delete(project_path, true/*recursive*/)) { + if (!base::Delete(project_path, true/*recursive*/)) { SetError("Error in copying files from sync filesystem."); content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, base::Bind(&DeveloperPrivateExportSyncfsFolderToLocalfsFunction:: diff --git a/chrome/browser/extensions/api/record/record_api_test.cc b/chrome/browser/extensions/api/record/record_api_test.cc index f20dfea..4548501 100644 --- a/chrome/browser/extensions/api/record/record_api_test.cc +++ b/chrome/browser/extensions/api/record/record_api_test.cc @@ -188,7 +188,7 @@ class RecordApiTest : public InProcessBrowserTest { InProcessBrowserTest::CleanUpOnMainThread(); for (std::vector<base::FilePath>::const_iterator it = temp_files_.begin(); it != temp_files_.end(); ++it) { - if (!file_util::Delete(*it, false)) + if (!base::Delete(*it, false)) NOTREACHED(); } } diff --git a/chrome/browser/extensions/api/storage/storage_schema_manifest_handler_unittest.cc b/chrome/browser/extensions/api/storage/storage_schema_manifest_handler_unittest.cc index 1d0a7bb..a7fd429 100644 --- a/chrome/browser/extensions/api/storage/storage_schema_manifest_handler_unittest.cc +++ b/chrome/browser/extensions/api/storage/storage_schema_manifest_handler_unittest.cc @@ -48,7 +48,7 @@ class StorageSchemaManifestHandlerTest : public testing::Test { return NULL; base::FilePath schema_path = temp_dir_.path().AppendASCII("schema.json"); if (schema.empty()) { - file_util::Delete(schema_path, false); + base::Delete(schema_path, false); } else { if (file_util::WriteFile(schema_path, schema.data(), schema.size()) != static_cast<int>(schema.size())) { diff --git a/chrome/browser/extensions/api/system_info_storage/storage_info_provider_linux_unittest.cc b/chrome/browser/extensions/api/system_info_storage/storage_info_provider_linux_unittest.cc index 24bd8d8..46a013d 100644 --- a/chrome/browser/extensions/api/system_info_storage/storage_info_provider_linux_unittest.cc +++ b/chrome/browser/extensions/api/system_info_storage/storage_info_provider_linux_unittest.cc @@ -109,7 +109,7 @@ class StorageInfoProviderLinuxTest : public testing::Test { } virtual void TearDown() OVERRIDE { - file_util::Delete(mtab_file_, false); + base::Delete(mtab_file_, false); } scoped_refptr<StorageInfoProviderLinuxWrapper> storage_info_provider_; diff --git a/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc b/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc index b7ce523..ad7dfbe 100644 --- a/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc +++ b/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc @@ -191,7 +191,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallAccepted) { base::ScopedTempDir temp_dir; EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); base::FilePath missing_directory = temp_dir.Take(); - EXPECT_TRUE(file_util::Delete(missing_directory, true)); + EXPECT_TRUE(base::Delete(missing_directory, true)); WebstoreInstaller::SetDownloadDirectoryForTests(&missing_directory); // Now run the install test, which should succeed. @@ -199,7 +199,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallAccepted) { // Cleanup. if (file_util::DirectoryExists(missing_directory)) - EXPECT_TRUE(file_util::Delete(missing_directory, true)); + EXPECT_TRUE(base::Delete(missing_directory, true)); } // Tests passing a localized name. diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc index 126f27b..07fb324 100644 --- a/chrome/browser/extensions/extension_browsertest.cc +++ b/chrome/browser/extensions/extension_browsertest.cc @@ -239,7 +239,7 @@ const Extension* ExtensionBrowserTest::LoadExtensionAsComponent( base::FilePath ExtensionBrowserTest::PackExtension( const base::FilePath& dir_path) { base::FilePath crx_path = temp_dir_.path().AppendASCII("temp.crx"); - if (!file_util::Delete(crx_path, false)) { + if (!base::Delete(crx_path, false)) { ADD_FAILURE() << "Failed to delete crx: " << crx_path.value(); return base::FilePath(); } @@ -252,7 +252,7 @@ base::FilePath ExtensionBrowserTest::PackExtension( if (!file_util::PathExists(pem_path)) { pem_path = base::FilePath(); pem_path_out = crx_path.DirName().AppendASCII("temp.pem"); - if (!file_util::Delete(pem_path_out, false)) { + if (!base::Delete(pem_path_out, false)) { ADD_FAILURE() << "Failed to delete pem: " << pem_path_out.value(); return base::FilePath(); } diff --git a/chrome/browser/extensions/extension_creator.cc b/chrome/browser/extensions/extension_creator.cc index 8aa03013..cedc048 100644 --- a/chrome/browser/extensions/extension_creator.cc +++ b/chrome/browser/extensions/extension_creator.cc @@ -237,7 +237,7 @@ bool ExtensionCreator::WriteCRX(const base::FilePath& zip_path, const std::vector<uint8>& signature, const base::FilePath& crx_path) { if (file_util::PathExists(crx_path)) - file_util::Delete(crx_path, false); + base::Delete(crx_path, false); ScopedStdioHandle crx_handle(file_util::OpenFile(crx_path, "wb")); if (!crx_handle.get()) { error_message_ = l10n_util::GetStringUTF8(IDS_EXTENSION_SHARING_VIOLATION); @@ -322,7 +322,7 @@ bool ExtensionCreator::Run(const base::FilePath& extension_dir, result = true; } - file_util::Delete(zip_path, false); + base::Delete(zip_path, false); return result; } diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc index 7765a85..6a5de4b 100644 --- a/chrome/browser/extensions/extension_service_unittest.cc +++ b/chrome/browser/extensions/extension_service_unittest.cc @@ -510,13 +510,13 @@ void ExtensionServiceTestBase::InitializeInstalledExtensionService( ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); base::FilePath path = temp_dir_.path(); path = path.Append(FILE_PATH_LITERAL("TestingExtensionsPath")); - file_util::Delete(path, true); + base::Delete(path, true); file_util::CreateDirectory(path); base::FilePath temp_prefs = path.Append(FILE_PATH_LITERAL("Preferences")); file_util::CopyFile(prefs_file, temp_prefs); extensions_install_dir_ = path.Append(FILE_PATH_LITERAL("Extensions")); - file_util::Delete(extensions_install_dir_, true); + base::Delete(extensions_install_dir_, true); file_util::CopyDirectory(source_install_dir, extensions_install_dir_, true); ExtensionServiceInitParams params; @@ -546,12 +546,12 @@ void ExtensionServiceTestBase::InitializeExtensionServiceHelper( ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); base::FilePath path = temp_dir_.path(); path = path.Append(FILE_PATH_LITERAL("TestingExtensionsPath")); - file_util::Delete(path, true); + base::Delete(path, true); file_util::CreateDirectory(path); base::FilePath prefs_filename = path.Append(FILE_PATH_LITERAL("TestPreferences")); extensions_install_dir_ = path.Append(FILE_PATH_LITERAL("Extensions")); - file_util::Delete(extensions_install_dir_, true); + base::Delete(extensions_install_dir_, true); file_util::CreateDirectory(extensions_install_dir_); ExtensionServiceInitParams params; @@ -658,7 +658,7 @@ class ExtensionServiceTest ASSERT_TRUE(file_util::PathExists(pem_path)); } - ASSERT_TRUE(file_util::Delete(crx_path, false)); + ASSERT_TRUE(base::Delete(crx_path, false)); scoped_ptr<ExtensionCreator> creator(new ExtensionCreator()); ASSERT_TRUE(creator->Run(dir_path, @@ -2038,7 +2038,7 @@ TEST_F(ExtensionServiceTest, PackExtension) { // Repeat the run with the pem file gone, and no special flags // Should refuse to overwrite the existing crx. - file_util::Delete(privkey_path, false); + base::Delete(privkey_path, false); ASSERT_FALSE(creator->Run(input_directory, crx_path, base::FilePath(), privkey_path, ExtensionCreator::kNoRunFlags)); @@ -2175,7 +2175,7 @@ TEST_F(ExtensionServiceTest, PackExtensionContainingKeyFails) { ASSERT_TRUE(file_util::PathExists(crx_path)); ASSERT_TRUE(file_util::PathExists(privkey_path)); - file_util::Delete(crx_path, false); + base::Delete(crx_path, false); // Move the pem file into the extension. file_util::Move(privkey_path, input_directory.AppendASCII("privkey.pem")); @@ -2278,7 +2278,7 @@ TEST_F(ExtensionServiceTest, LoadLocalizedTheme) { // directory, and we don't want to copy the whole extension for a unittest. base::FilePath theme_file = extension_path.Append(chrome::kThemePackFilename); ASSERT_TRUE(file_util::PathExists(theme_file)); - ASSERT_TRUE(file_util::Delete(theme_file, false)); // Not recursive. + ASSERT_TRUE(base::Delete(theme_file, false)); // Not recursive. } // Tests that we can change the ID of an unpacked extension by adding a key diff --git a/chrome/browser/extensions/extension_startup_browsertest.cc b/chrome/browser/extensions/extension_startup_browsertest.cc index ada7f89..43519a9 100644 --- a/chrome/browser/extensions/extension_startup_browsertest.cc +++ b/chrome/browser/extensions/extension_startup_browsertest.cc @@ -79,11 +79,11 @@ class ExtensionStartupTestBase : public InProcessBrowserTest { } virtual void TearDown() { - EXPECT_TRUE(file_util::Delete(preferences_file_, false)); + EXPECT_TRUE(base::Delete(preferences_file_, false)); // TODO(phajdan.jr): Check return values of the functions below, carefully. - file_util::Delete(user_scripts_dir_, true); - file_util::Delete(extensions_dir_, true); + base::Delete(user_scripts_dir_, true); + base::Delete(extensions_dir_, true); InProcessBrowserTest::TearDown(); } diff --git a/chrome/browser/extensions/sandboxed_unpacker.cc b/chrome/browser/extensions/sandboxed_unpacker.cc index 80241b7..91b4cbc 100644 --- a/chrome/browser/extensions/sandboxed_unpacker.cc +++ b/chrome/browser/extensions/sandboxed_unpacker.cc @@ -141,7 +141,7 @@ bool VerifyJunctionFreeLocation(base::FilePath* temp_dir) { *temp_dir = normalized_temp_file.DirName(); } // Clean up the temp file. - file_util::Delete(temp_file, false); + base::Delete(temp_file, false); return normalized; } @@ -661,7 +661,7 @@ bool SandboxedUnpacker::RewriteImageFiles() { ASCIIToUTF16("INVALID_PATH_FOR_BROWSER_IMAGE"))); return false; } - if (!file_util::Delete(extension_root_.Append(path), false)) { + if (!base::Delete(extension_root_.Append(path), false)) { // Error removing old image file. ReportFailure( ERROR_REMOVING_OLD_IMAGE_FILE, diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc index 335b6fe..960660a 100644 --- a/chrome/browser/first_run/first_run.cc +++ b/chrome/browser/first_run/first_run.cc @@ -506,7 +506,7 @@ bool RemoveSentinel() { base::FilePath first_run_sentinel; if (!internal::GetFirstRunSentinelFilePath(&first_run_sentinel)) return false; - return file_util::Delete(first_run_sentinel, false); + return base::Delete(first_run_sentinel, false); } bool SetShowFirstRunBubblePref(FirstRunBubbleOptions show_bubble_option) { diff --git a/chrome/browser/first_run/first_run_browsertest.cc b/chrome/browser/first_run/first_run_browsertest.cc index 5dd2c6e..567913d 100644 --- a/chrome/browser/first_run/first_run_browsertest.cc +++ b/chrome/browser/first_run/first_run_browsertest.cc @@ -93,7 +93,7 @@ class FirstRunMasterPrefsBrowserTestBase : public InProcessBrowserTest { } virtual void TearDown() OVERRIDE { - EXPECT_TRUE(file_util::Delete(prefs_file_, false)); + EXPECT_TRUE(base::Delete(prefs_file_, false)); InProcessBrowserTest::TearDown(); } diff --git a/chrome/browser/google/google_update_settings_posix.cc b/chrome/browser/google/google_update_settings_posix.cc index 0bced14..c4bd2cd 100644 --- a/chrome/browser/google/google_update_settings_posix.cc +++ b/chrome/browser/google/google_update_settings_posix.cc @@ -51,7 +51,7 @@ bool GoogleUpdateSettings::SetCollectStatsConsent(bool consented) { } } else { google_update::posix_guid().clear(); - return file_util::Delete(consent_file, false); + return base::Delete(consent_file, false); } return true; } diff --git a/chrome/browser/google_apis/base_requests_server_unittest.cc b/chrome/browser/google_apis/base_requests_server_unittest.cc index b6a27dd..fc160f9 100644 --- a/chrome/browser/google_apis/base_requests_server_unittest.cc +++ b/chrome/browser/google_apis/base_requests_server_unittest.cc @@ -102,7 +102,7 @@ TEST_F(BaseRequestsServerTest, DownloadFileRequest_ValidFile) { std::string contents; file_util::ReadFileToString(temp_file, &contents); - file_util::Delete(temp_file, false); + base::Delete(temp_file, false); EXPECT_EQ(HTTP_SUCCESS, result_code); EXPECT_EQ(net::test_server::METHOD_GET, http_request_.method); diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc index 2eb75e9..65d2781 100644 --- a/chrome/browser/history/history_backend_unittest.cc +++ b/chrome/browser/history/history_backend_unittest.cc @@ -391,7 +391,7 @@ class HistoryBackendTest : public testing::Test { backend_->Closing(); backend_ = NULL; mem_backend_.reset(); - file_util::Delete(test_dir_, true); + base::Delete(test_dir_, true); base::RunLoop().RunUntilIdle(); } @@ -1275,7 +1275,7 @@ TEST_F(HistoryBackendTest, MigrationVisitSource) { // Copy history database file to current directory so that it will be deleted // in Teardown. base::FilePath new_history_path(getTestDir()); - file_util::Delete(new_history_path, true); + base::Delete(new_history_path, true); file_util::CreateDirectory(new_history_path); base::FilePath new_history_file = new_history_path.Append(chrome::kHistoryFilename); @@ -2514,7 +2514,7 @@ TEST_F(HistoryBackendTest, MigrationVisitDuration) { // Copy history database file to current directory so that it will be deleted // in Teardown. base::FilePath new_history_path(getTestDir()); - file_util::Delete(new_history_path, true); + base::Delete(new_history_path, true); file_util::CreateDirectory(new_history_path); base::FilePath new_history_file = new_history_path.Append(chrome::kHistoryFilename); diff --git a/chrome/browser/history/in_memory_url_index.cc b/chrome/browser/history/in_memory_url_index.cc index 50098cd..e0f4462 100644 --- a/chrome/browser/history/in_memory_url_index.cc +++ b/chrome/browser/history/in_memory_url_index.cc @@ -31,7 +31,7 @@ namespace history { // there is no private data to save. Runs on the FILE thread. void DeleteCacheFile(const base::FilePath& path) { DCHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); - file_util::Delete(path, false); + base::Delete(path, false); } // Initializes a whitelist of URL schemes. diff --git a/chrome/browser/history/text_database_manager_unittest.cc b/chrome/browser/history/text_database_manager_unittest.cc index eccd7a8..fa5a1f3 100644 --- a/chrome/browser/history/text_database_manager_unittest.cc +++ b/chrome/browser/history/text_database_manager_unittest.cc @@ -161,7 +161,7 @@ class TextDatabaseManagerTest : public testing::Test { } virtual void TearDown() { - file_util::Delete(dir_, true); + base::Delete(dir_, true); } base::MessageLoop message_loop_; diff --git a/chrome/browser/importer/firefox_importer_browsertest.cc b/chrome/browser/importer/firefox_importer_browsertest.cc index d211fe3..8f1b3d5 100644 --- a/chrome/browser/importer/firefox_importer_browsertest.cc +++ b/chrome/browser/importer/firefox_importer_browsertest.cc @@ -220,7 +220,7 @@ class FirefoxProfileImporterBrowserTest : public InProcessBrowserTest { // Creates a new profile in a new subdirectory in the temp directory. ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); base::FilePath test_path = temp_dir_.path().AppendASCII("ImporterTest"); - file_util::Delete(test_path, true); + base::Delete(test_path, true); file_util::CreateDirectory(test_path); profile_path_ = test_path.AppendASCII("profile"); app_path_ = test_path.AppendASCII("app"); diff --git a/chrome/browser/importer/firefox_profile_lock_posix.cc b/chrome/browser/importer/firefox_profile_lock_posix.cc index 2b24187..dd00b70 100644 --- a/chrome/browser/importer/firefox_profile_lock_posix.cc +++ b/chrome/browser/importer/firefox_profile_lock_posix.cc @@ -78,7 +78,7 @@ void FirefoxProfileLock::Unlock() { return; close(lock_fd_); lock_fd_ = -1; - file_util::Delete(old_lock_file_, false); + base::Delete(old_lock_file_, false); } bool FirefoxProfileLock::HasAcquired() { diff --git a/chrome/browser/jumplist_win.cc b/chrome/browser/jumplist_win.cc index d78a9fd..a419c12 100644 --- a/chrome/browser/jumplist_win.cc +++ b/chrome/browser/jumplist_win.cc @@ -736,7 +736,7 @@ void JumpList::RunUpdate() { // icon files. base::FilePath icon_dir_old(icon_dir_.value() + L"Old"); if (file_util::PathExists(icon_dir_old)) - file_util::Delete(icon_dir_old, true); + base::Delete(icon_dir_old, true); file_util::Move(icon_dir_, icon_dir_old); file_util::CreateDirectory(icon_dir_); diff --git a/chrome/browser/media_galleries/fileapi/native_media_file_util_unittest.cc b/chrome/browser/media_galleries/fileapi/native_media_file_util_unittest.cc index 04e958c..71f752f 100644 --- a/chrome/browser/media_galleries/fileapi/native_media_file_util_unittest.cc +++ b/chrome/browser/media_galleries/fileapi/native_media_file_util_unittest.cc @@ -288,7 +288,7 @@ TEST_F(NativeMediaFileUtilTest, CopySourceFiltering) { for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { // Always start with an empty destination directory. // Copying to a non-empty destination directory is an invalid operation. - ASSERT_TRUE(file_util::Delete(dest_path, true)); + ASSERT_TRUE(base::Delete(dest_path, true)); ASSERT_TRUE(file_util::CreateDirectory(dest_path)); FileSystemURL root_url = CreateURL(FPL("")); @@ -318,7 +318,7 @@ TEST_F(NativeMediaFileUtilTest, CopyDestFiltering) { if (loop_count == 1) { // Reset the test directory between the two loops to remove old // directories and create new ones that should pre-exist. - ASSERT_TRUE(file_util::Delete(root_path(), true)); + ASSERT_TRUE(base::Delete(root_path(), true)); ASSERT_TRUE(file_util::CreateDirectory(root_path())); PopulateDirectoryWithTestCases(root_path(), kFilteringTestCases, @@ -387,7 +387,7 @@ TEST_F(NativeMediaFileUtilTest, MoveSourceFiltering) { for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) { // Always start with an empty destination directory. // Moving to a non-empty destination directory is an invalid operation. - ASSERT_TRUE(file_util::Delete(dest_path, true)); + ASSERT_TRUE(base::Delete(dest_path, true)); ASSERT_TRUE(file_util::CreateDirectory(dest_path)); FileSystemURL root_url = CreateURL(FPL("")); @@ -417,7 +417,7 @@ TEST_F(NativeMediaFileUtilTest, MoveDestFiltering) { if (loop_count == 1) { // Reset the test directory between the two loops to remove old // directories and create new ones that should pre-exist. - ASSERT_TRUE(file_util::Delete(root_path(), true)); + ASSERT_TRUE(base::Delete(root_path(), true)); ASSERT_TRUE(file_util::CreateDirectory(root_path())); PopulateDirectoryWithTestCases(root_path(), kFilteringTestCases, diff --git a/chrome/browser/nacl_host/nacl_browser.cc b/chrome/browser/nacl_host/nacl_browser.cc index 101a7de..832ebee 100644 --- a/chrome/browser/nacl_host/nacl_browser.cc +++ b/chrome/browser/nacl_host/nacl_browser.cc @@ -101,7 +101,7 @@ void WriteCache(const base::FilePath& filename, const Pickle* pickle) { void RemoveCache(const base::FilePath& filename, const base::Closure& callback) { - file_util::Delete(filename, false); + base::Delete(filename, false); content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, callback); } diff --git a/chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc b/chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc index 7f36426..6e1c074 100644 --- a/chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc +++ b/chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc @@ -57,12 +57,12 @@ class NaClGdbTest : public PPAPINaClNewlibTest { EXPECT_TRUE(file_util::ReadFileToString(mock_nacl_gdb_file, &content)); EXPECT_STREQ("PASS", content.c_str()); - EXPECT_TRUE(file_util::Delete(mock_nacl_gdb_file, false)); + EXPECT_TRUE(base::Delete(mock_nacl_gdb_file, false)); content.clear(); EXPECT_TRUE(file_util::ReadFileToString(script_, &content)); EXPECT_STREQ("PASS", content.c_str()); - EXPECT_TRUE(file_util::Delete(script_, false)); + EXPECT_TRUE(base::Delete(script_, false)); } private: diff --git a/chrome/browser/net/net_log_temp_file_unittest.cc b/chrome/browser/net/net_log_temp_file_unittest.cc index 553c820..e77ecc5 100644 --- a/chrome/browser/net/net_log_temp_file_unittest.cc +++ b/chrome/browser/net/net_log_temp_file_unittest.cc @@ -79,7 +79,7 @@ class NetLogTempFileTest : public ::testing::Test { virtual void TearDown() OVERRIDE { // Delete the temporary file we have created. - ASSERT_TRUE(file_util::Delete(net_export_log_, false)); + ASSERT_TRUE(base::Delete(net_export_log_, false)); } std::string GetStateString() const { diff --git a/chrome/browser/net/url_fixer_upper_unittest.cc b/chrome/browser/net/url_fixer_upper_unittest.cc index 706418a..3b4fd1d 100644 --- a/chrome/browser/net/url_fixer_upper_unittest.cc +++ b/chrome/browser/net/url_fixer_upper_unittest.cc @@ -459,7 +459,7 @@ TEST(URLFixerUpperTest, FixupFile) { file_cases[i].desired_tld).possibly_invalid_spec()); } - EXPECT_TRUE(file_util::Delete(original, false)); + EXPECT_TRUE(base::Delete(original, false)); } TEST(URLFixerUpperTest, FixupRelativeFile) { @@ -483,7 +483,7 @@ TEST(URLFixerUpperTest, FixupRelativeFile) { // are no backslashes EXPECT_TRUE(IsMatchingFileURL(URLFixerUpper::FixupRelativeFile(dir, file_part).possibly_invalid_spec(), full_path)); - EXPECT_TRUE(file_util::Delete(full_path, false)); + EXPECT_TRUE(base::Delete(full_path, false)); // create a filename we know doesn't exist and make sure it doesn't get // fixed up to a file URL @@ -527,8 +527,8 @@ TEST(URLFixerUpperTest, FixupRelativeFile) { base::FilePath(relative_file_str)).possibly_invalid_spec(), full_path)); // done with the subdir - EXPECT_TRUE(file_util::Delete(full_path, false)); - EXPECT_TRUE(file_util::Delete(new_dir, true)); + EXPECT_TRUE(base::Delete(full_path, false)); + EXPECT_TRUE(base::Delete(new_dir, true)); // Test that an obvious HTTP URL isn't accidentally treated as an absolute // file path (on account of system-specific craziness). diff --git a/chrome/browser/page_cycler/page_cycler.cc b/chrome/browser/page_cycler/page_cycler.cc index 4912fe7..0d10e08 100644 --- a/chrome/browser/page_cycler/page_cycler.cc +++ b/chrome/browser/page_cycler/page_cycler.cc @@ -222,7 +222,7 @@ void PageCycler::WriteResultsOnBackgroundThread(const std::string& output) { error_.size()); } else if (file_util::PathExists(errors_file_)) { // If there is an old error file, delete it to avoid confusion. - file_util::Delete(errors_file_, false); + base::Delete(errors_file_, false); } } if (aborted_) { diff --git a/chrome/browser/pepper_flash_settings_manager.cc b/chrome/browser/pepper_flash_settings_manager.cc index fbf0c84..5f0e953 100644 --- a/chrome/browser/pepper_flash_settings_manager.cc +++ b/chrome/browser/pepper_flash_settings_manager.cc @@ -461,7 +461,7 @@ void PepperFlashSettingsManager::Core::DeauthorizeContentLicensesOnBlockingPool( // Wipe that file. const base::FilePath& device_id_path = chrome::DeviceIDFetcher::GetLegacyDeviceIDPath(profile_path); - bool success = file_util::Delete(device_id_path, false); + bool success = base::Delete(device_id_path, false); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, diff --git a/chrome/browser/policy/cloud/resource_cache.cc b/chrome/browser/policy/cloud/resource_cache.cc index 74323ce..094edb4 100644 --- a/chrome/browser/policy/cloud/resource_cache.cc +++ b/chrome/browser/policy/cloud/resource_cache.cc @@ -36,7 +36,7 @@ ResourceCache::ResourceCache(const base::FilePath& cache_path) { LOG(WARNING) << "Failed to open leveldb at " << cache_path.AsUTF8Unsafe() << ": " << status.ToString(); // Maybe the database is busted; drop everything and try to create it again. - file_util::Delete(cache_path, true); + base::Delete(cache_path, true); status = leveldb::DB::Open(options, cache_path.AsUTF8Unsafe(), &db); if (!status.ok()) diff --git a/chrome/browser/policy/cloud/user_cloud_policy_store.cc b/chrome/browser/policy/cloud/user_cloud_policy_store.cc index cef3adb..1381d98 100644 --- a/chrome/browser/policy/cloud/user_cloud_policy_store.cc +++ b/chrome/browser/policy/cloud/user_cloud_policy_store.cc @@ -122,7 +122,7 @@ void UserCloudPolicyStore::LoadImmediately() { void UserCloudPolicyStore::Clear() { content::BrowserThread::PostTask( content::BrowserThread::FILE, FROM_HERE, - base::Bind(base::IgnoreResult(&file_util::Delete), + base::Bind(base::IgnoreResult(&base::Delete), backing_file_path_, false)); policy_.reset(); diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc index 9f16cee..984a4e7 100644 --- a/chrome/browser/printing/print_dialog_cloud.cc +++ b/chrome/browser/printing/print_dialog_cloud.cc @@ -682,7 +682,7 @@ void CreateDialogForFileImpl(content::BrowserContext* browser_context, browser_context, modal_parent, data, print_job_title, print_ticket, file_type)); if (delete_on_close) - file_util::Delete(path_to_file, false); + base::Delete(path_to_file, false); } } // namespace internal_cloud_print_helpers diff --git a/chrome/browser/printing/print_dialog_gtk.cc b/chrome/browser/printing/print_dialog_gtk.cc index e4a6e5d..a7bf21c 100644 --- a/chrome/browser/printing/print_dialog_gtk.cc +++ b/chrome/browser/printing/print_dialog_gtk.cc @@ -275,7 +275,7 @@ void PrintDialogGtk::PrintDocument(const printing::Metafile* metafile, if (!error && !metafile->SaveTo(path_to_pdf_)) { LOG(ERROR) << "Saving metafile failed"; - file_util::Delete(path_to_pdf_, false); + base::Delete(path_to_pdf_, false); error = true; } diff --git a/chrome/browser/printing/printing_layout_browsertest.cc b/chrome/browser/printing/printing_layout_browsertest.cc index 696cfa7..5ba5b83 100644 --- a/chrome/browser/printing/printing_layout_browsertest.cc +++ b/chrome/browser/printing/printing_layout_browsertest.cc @@ -53,7 +53,7 @@ class PrintingLayoutTest : public PrintingTest<InProcessBrowserTest>, virtual void TearDown() OVERRIDE { InProcessBrowserTest::TearDown(); - file_util::Delete(emf_path_, true); + base::Delete(emf_path_, true); } virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { @@ -221,7 +221,7 @@ class PrintingLayoutTest : public PrintingTest<InProcessBrowserTest>, "\" when looking for \"" << verification_name << "\""; prn_file = file.value(); found_prn = true; - file_util::Delete(file, false); + base::Delete(file, false); continue; } EXPECT_TRUE(false); diff --git a/chrome/browser/profiles/profile_info_cache.cc b/chrome/browser/profiles/profile_info_cache.cc index f189844..92398d8 100644 --- a/chrome/browser/profiles/profile_info_cache.cc +++ b/chrome/browser/profiles/profile_info_cache.cc @@ -165,7 +165,7 @@ void ReadBitmap(const base::FilePath& image_path, void DeleteBitmap(const base::FilePath& image_path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); - file_util::Delete(image_path, false); + base::Delete(image_path, false); } } // namespace diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc index 84d0a1b..7be5e41 100644 --- a/chrome/browser/profiles/profile_manager.cc +++ b/chrome/browser/profiles/profile_manager.cc @@ -202,8 +202,8 @@ void ProfileManager::NukeDeletedProfilesFromDisk() { // Delete both the profile directory and its corresponding cache. base::FilePath cache_path; chrome::GetUserCacheDirectory(*it, &cache_path); - file_util::Delete(*it, true); - file_util::Delete(cache_path, true); + base::Delete(*it, true); + base::Delete(cache_path, true); } ProfilesToDelete().clear(); } diff --git a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc index c918574..fb66c05 100644 --- a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc +++ b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc @@ -391,7 +391,7 @@ TEST_F(ProfileShortcutManagerTest, DeleteSecondToLastProfileWithoutShortcut) { GetDefaultShortcutPathForProfile(profile_2_name_); // Delete the shortcut for the first profile, but keep the one for the 2nd. - ASSERT_TRUE(file_util::Delete(profile_1_shortcut_path, false)); + ASSERT_TRUE(base::Delete(profile_1_shortcut_path, false)); ASSERT_FALSE(file_util::PathExists(profile_1_shortcut_path)); ASSERT_TRUE(file_util::PathExists(profile_2_shortcut_path)); @@ -415,7 +415,7 @@ TEST_F(ProfileShortcutManagerTest, DeleteSecondToLastProfileWithShortcut) { GetDefaultShortcutPathForProfile(profile_2_name_); // Delete the shortcut for the first profile, but keep the one for the 2nd. - ASSERT_TRUE(file_util::Delete(profile_1_shortcut_path, false)); + ASSERT_TRUE(base::Delete(profile_1_shortcut_path, false)); ASSERT_FALSE(file_util::PathExists(profile_1_shortcut_path)); ASSERT_TRUE(file_util::PathExists(profile_2_shortcut_path)); @@ -444,8 +444,8 @@ TEST_F(ProfileShortcutManagerTest, DeleteOnlyProfileWithShortcuts) { GetDefaultShortcutPathForProfile(profile_3_name_); // Delete shortcuts for the first two profiles. - ASSERT_TRUE(file_util::Delete(profile_1_shortcut_path, false)); - ASSERT_TRUE(file_util::Delete(profile_2_shortcut_path, false)); + ASSERT_TRUE(base::Delete(profile_1_shortcut_path, false)); + ASSERT_TRUE(base::Delete(profile_2_shortcut_path, false)); // Only the shortcut to the third profile should exist. ASSERT_FALSE(file_util::PathExists(profile_1_shortcut_path)); @@ -503,7 +503,7 @@ TEST_F(ProfileShortcutManagerTest, RenamedDesktopShortcuts) { profile_2_path_); // Delete the renamed shortcut and try to create it again, which should work. - ASSERT_TRUE(file_util::Delete(profile_2_shortcut_path_2, false)); + ASSERT_TRUE(base::Delete(profile_2_shortcut_path_2, false)); EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path_2)); profile_shortcut_manager_->CreateProfileShortcut(profile_2_path_); RunPendingTasks(); @@ -574,7 +574,7 @@ TEST_F(ProfileShortcutManagerTest, UpdateShortcutWithNoFlags) { // Delete the shortcut that got created for this profile and instead make // a new one without any command-line flags. - ASSERT_TRUE(file_util::Delete(GetDefaultShortcutPathForProfile(string16()), + ASSERT_TRUE(base::Delete(GetDefaultShortcutPathForProfile(string16()), false)); const base::FilePath regular_shortcut_path = CreateRegularShortcutWithName(FROM_HERE, @@ -592,7 +592,7 @@ TEST_F(ProfileShortcutManagerTest, UpdateTwoShortcutsWithNoFlags) { // Delete the shortcut that got created for this profile and instead make // two new ones without any command-line flags. - ASSERT_TRUE(file_util::Delete(GetDefaultShortcutPathForProfile(string16()), + ASSERT_TRUE(base::Delete(GetDefaultShortcutPathForProfile(string16()), false)); const base::FilePath regular_shortcut_path = CreateRegularShortcutWithName(FROM_HERE, @@ -664,7 +664,7 @@ TEST_F(ProfileShortcutManagerTest, HasProfileShortcuts) { // Delete the shortcut and check that the function returns false. const base::FilePath profile_2_shortcut_path = GetDefaultShortcutPathForProfile(profile_2_name_); - ASSERT_TRUE(file_util::Delete(profile_2_shortcut_path, false)); + ASSERT_TRUE(base::Delete(profile_2_shortcut_path, false)); EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path)); profile_shortcut_manager_->HasProfileShortcuts(profile_2_path_, callback); RunPendingTasks(); @@ -752,7 +752,7 @@ TEST_F(ProfileShortcutManagerTest, GetDefaultShortcutPathForProfile(profile_2_name_); // Delete the shortcut for the first profile, but keep the one for the 2nd. - ASSERT_TRUE(file_util::Delete(profile_1_shortcut_path, false)); + ASSERT_TRUE(base::Delete(profile_1_shortcut_path, false)); ASSERT_FALSE(file_util::PathExists(profile_1_shortcut_path)); ASSERT_TRUE(file_util::PathExists(profile_2_shortcut_path)); diff --git a/chrome/browser/profiles/profile_shortcut_manager_win.cc b/chrome/browser/profiles/profile_shortcut_manager_win.cc index e3e0c3c..754e5d6 100644 --- a/chrome/browser/profiles/profile_shortcut_manager_win.cc +++ b/chrome/browser/profiles/profile_shortcut_manager_win.cc @@ -292,7 +292,7 @@ void RenameChromeDesktopShortcutForProfile( const base::FilePath possible_new_system_shortcut = system_shortcuts_directory.Append(new_shortcut_filename); if (file_util::PathExists(possible_new_system_shortcut)) - file_util::Delete(old_shortcut_path, false); + base::Delete(old_shortcut_path, false); else if (!RenameDesktopShortcut(old_shortcut_path, new_shortcut_path)) DLOG(ERROR) << "Could not rename Windows profile desktop shortcut."; } else { @@ -437,9 +437,9 @@ void DeleteDesktopShortcutsAndIconFile(const base::FilePath& profile_path, BrowserDistribution* distribution = BrowserDistribution::GetDistribution(); for (size_t i = 0; i < shortcuts.size(); ++i) { - // Use file_util::Delete() instead of ShellUtil::RemoveShortcut(), as the + // Use base::Delete() instead of ShellUtil::RemoveShortcut(), as the // latter causes non-profile taskbar shortcuts to be unpinned. - file_util::Delete(shortcuts[i], false); + base::Delete(shortcuts[i], false); // Notify the shell that the shortcut was deleted to ensure desktop refresh. SHChangeNotify(SHCNE_DELETE, SHCNF_PATH, shortcuts[i].value().c_str(), NULL); @@ -447,7 +447,7 @@ void DeleteDesktopShortcutsAndIconFile(const base::FilePath& profile_path, const base::FilePath icon_path = profile_path.AppendASCII(profiles::internal::kProfileIconFileName); - file_util::Delete(icon_path, false); + base::Delete(icon_path, false); // If |ensure_shortcuts_remain| is true and deleting this profile caused the // last shortcuts to be removed, re-create a regular non-profile shortcut. diff --git a/chrome/browser/safe_browsing/safe_browsing_database.cc b/chrome/browser/safe_browsing/safe_browsing_database.cc index fca21c4..d56d61f 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database.cc +++ b/chrome/browser/safe_browsing/safe_browsing_database.cc @@ -1486,7 +1486,7 @@ void SafeBrowsingDatabaseNew::LoadPrefixSet() { // TODO(shess): Track failure to delete? base::FilePath bloom_filter_filename = BloomFilterForFilename(browse_filename_); - file_util::Delete(bloom_filter_filename, false); + base::Delete(bloom_filter_filename, false); const base::TimeTicks before = base::TimeTicks::Now(); browse_prefix_set_.reset(safe_browsing::PrefixSet::LoadFile( @@ -1522,24 +1522,24 @@ bool SafeBrowsingDatabaseNew::Delete() { base::FilePath bloom_filter_filename = BloomFilterForFilename(browse_filename_); - const bool r5 = file_util::Delete(bloom_filter_filename, false); + const bool r5 = base::Delete(bloom_filter_filename, false); if (!r5) RecordFailure(FAILURE_DATABASE_FILTER_DELETE); - const bool r6 = file_util::Delete(browse_prefix_set_filename_, false); + const bool r6 = base::Delete(browse_prefix_set_filename_, false); if (!r6) RecordFailure(FAILURE_BROWSE_PREFIX_SET_DELETE); - const bool r7 = file_util::Delete(extension_blacklist_filename_, false); + const bool r7 = base::Delete(extension_blacklist_filename_, false); if (!r7) RecordFailure(FAILURE_EXTENSION_BLACKLIST_DELETE); - const bool r8 = file_util::Delete(side_effect_free_whitelist_filename_, + const bool r8 = base::Delete(side_effect_free_whitelist_filename_, false); if (!r8) RecordFailure(FAILURE_SIDE_EFFECT_FREE_WHITELIST_DELETE); - const bool r9 = file_util::Delete( + const bool r9 = base::Delete( side_effect_free_whitelist_prefix_set_filename_, false); if (!r9) diff --git a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc index 9a3b933..44e7b39 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc @@ -1658,7 +1658,7 @@ TEST_F(SafeBrowsingDatabaseTest, FilterFile) { &matching_list, &prefix_hits, &full_hashes, now)); // If there is no filter file, the database cannot find malware urls. - file_util::Delete(filter_file, false); + base::Delete(filter_file, false); ASSERT_FALSE(file_util::PathExists(filter_file)); database_.reset(new SafeBrowsingDatabaseNew); database_->Init(database_filename_); diff --git a/chrome/browser/safe_browsing/safe_browsing_store_file.cc b/chrome/browser/safe_browsing/safe_browsing_store_file.cc index bdc5232..7f35b6f 100644 --- a/chrome/browser/safe_browsing/safe_browsing_store_file.cc +++ b/chrome/browser/safe_browsing/safe_browsing_store_file.cc @@ -186,7 +186,7 @@ void SafeBrowsingStoreFile::CheckForOriginalAndDelete( static_cast<int>(size / 1024)); } - if (file_util::Delete(original_filename, false)) { + if (base::Delete(original_filename, false)) { RecordFormatEvent(FORMAT_EVENT_DELETED_ORIGINAL); } else { RecordFormatEvent(FORMAT_EVENT_DELETED_ORIGINAL_FAILED); @@ -196,7 +196,7 @@ void SafeBrowsingStoreFile::CheckForOriginalAndDelete( // the weeds. const base::FilePath journal_filename( current_filename.DirName().AppendASCII("Safe Browsing-journal")); - file_util::Delete(journal_filename, false); + base::Delete(journal_filename, false); } } @@ -654,7 +654,7 @@ bool SafeBrowsingStoreFile::DoUpdate( // Close the file handle and swizzle the file into place. new_file_.reset(); - if (!file_util::Delete(filename_, false) && + if (!base::Delete(filename_, false) && file_util::PathExists(filename_)) return false; @@ -735,14 +735,14 @@ void SafeBrowsingStoreFile::DeleteSubChunk(int32 chunk_id) { // static bool SafeBrowsingStoreFile::DeleteStore(const base::FilePath& basename) { - if (!file_util::Delete(basename, false) && + if (!base::Delete(basename, false) && file_util::PathExists(basename)) { NOTREACHED(); return false; } const base::FilePath new_filename = TemporaryFileForFilename(basename); - if (!file_util::Delete(new_filename, false) && + if (!base::Delete(new_filename, false) && file_util::PathExists(new_filename)) { NOTREACHED(); return false; @@ -754,7 +754,7 @@ bool SafeBrowsingStoreFile::DeleteStore(const base::FilePath& basename) { const base::FilePath journal_filename( basename.value() + FILE_PATH_LITERAL("-journal")); if (file_util::PathExists(journal_filename)) - file_util::Delete(journal_filename, false); + base::Delete(journal_filename, false); return true; } diff --git a/chrome/browser/sessions/session_backend.cc b/chrome/browser/sessions/session_backend.cc index 9492b75..bc133da 100644 --- a/chrome/browser/sessions/session_backend.cc +++ b/chrome/browser/sessions/session_backend.cc @@ -265,7 +265,7 @@ bool SessionBackend::ReadLastSessionCommandsImpl( void SessionBackend::DeleteLastSession() { Init(); - file_util::Delete(GetLastSessionPath(), false); + base::Delete(GetLastSessionPath(), false); } void SessionBackend::MoveCurrentSessionToLastSession() { @@ -275,7 +275,7 @@ void SessionBackend::MoveCurrentSessionToLastSession() { const base::FilePath current_session_path = GetCurrentSessionPath(); const base::FilePath last_session_path = GetLastSessionPath(); if (file_util::PathExists(last_session_path)) - file_util::Delete(last_session_path, false); + base::Delete(last_session_path, false); if (file_util::PathExists(current_session_path)) { int64 file_size; if (file_util::GetFileSize(current_session_path, &file_size)) { @@ -292,7 +292,7 @@ void SessionBackend::MoveCurrentSessionToLastSession() { } if (file_util::PathExists(current_session_path)) - file_util::Delete(current_session_path, false); + base::Delete(current_session_path, false); // Create and open the file for the current session. ResetFile(); diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc index bb20550..462124f 100644 --- a/chrome/browser/shell_integration_linux.cc +++ b/chrome/browser/shell_integration_linux.cc @@ -170,7 +170,7 @@ bool CreateShortcutOnDesktop(const base::FilePath& shortcut_filename, void DeleteShortcutOnDesktop(const base::FilePath& shortcut_filename) { base::FilePath desktop_path; if (PathService::Get(base::DIR_USER_DESKTOP, &desktop_path)) - file_util::Delete(desktop_path.Append(shortcut_filename), false); + base::Delete(desktop_path.Append(shortcut_filename), false); } // Creates a shortcut with |shortcut_filename| and |contents| in the system diff --git a/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc b/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc index 44a166d..1723293 100644 --- a/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc +++ b/chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc @@ -101,7 +101,7 @@ scoped_ptr<DictionaryFile> OpenDictionaryFile( NULL, NULL); } else { - file_util::Delete(file->path, false); + base::Delete(file->path, false); } return file.Pass(); @@ -148,7 +148,7 @@ bool SaveDictionaryData(scoped_ptr<std::string> data, #endif if (!success) { - file_util::Delete(path, false); + base::Delete(path, false); return false; } } diff --git a/chrome/browser/spellchecker/spellcheck_service_browsertest.cc b/chrome/browser/spellchecker/spellcheck_service_browsertest.cc index cf7b64f..4c42270 100644 --- a/chrome/browser/spellchecker/spellcheck_service_browsertest.cc +++ b/chrome/browser/spellchecker/spellcheck_service_browsertest.cc @@ -80,6 +80,6 @@ IN_PROC_BROWSER_TEST_F(SpellcheckServiceBrowserTest, DeleteCorruptedBDICT) { SpellcheckService::GetStatusEvent()); if (file_util::PathExists(bdict_path)) { ADD_FAILURE(); - EXPECT_TRUE(file_util::Delete(bdict_path, true)); + EXPECT_TRUE(base::Delete(bdict_path, true)); } } diff --git a/chrome/browser/storage_monitor/storage_monitor_linux_unittest.cc b/chrome/browser/storage_monitor/storage_monitor_linux_unittest.cc index 55fc877..a8c82a5 100644 --- a/chrome/browser/storage_monitor/storage_monitor_linux_unittest.cc +++ b/chrome/browser/storage_monitor/storage_monitor_linux_unittest.cc @@ -235,7 +235,7 @@ class StorageMonitorLinuxTest : public testing::Test { void RemoveDCIMDirFromMountPoint(const std::string& dir) { base::FilePath dcim = scoped_temp_dir_.path().AppendASCII(dir).Append(kDCIMDirectoryName); - file_util::Delete(dcim, false); + base::Delete(dcim, false); } MockRemovableStorageObserver& observer() { @@ -558,7 +558,7 @@ TEST_F(StorageMonitorLinuxTest, MultipleMountPointsWithNonDCIMDevices) { MtabTestData test_data5[] = { MtabTestData(kDeviceNoDCIM, test_path_b.value(), kValidFS), }; - file_util::Delete(test_path_b.Append(kDCIMDirectoryName), false); + base::Delete(test_path_b.Append(kDCIMDirectoryName), false); AppendToMtabAndRunLoop(test_data5, arraysize(test_data5)); EXPECT_EQ(4, observer().attach_calls()); EXPECT_EQ(2, observer().detach_calls()); diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc index f39091d..eb1b5ca 100644 --- a/chrome/browser/sync/glue/sync_backend_host.cc +++ b/chrome/browser/sync/glue/sync_backend_host.cc @@ -1386,7 +1386,7 @@ void SyncBackendHost::Core::DoRetryConfiguration( void SyncBackendHost::Core::DeleteSyncDataFolder() { DCHECK_EQ(base::MessageLoop::current(), sync_loop_); if (file_util::DirectoryExists(sync_data_folder_path_)) { - if (!file_util::Delete(sync_data_folder_path_, true)) + if (!base::Delete(sync_data_folder_path_, true)) SLOG(DFATAL) << "Could not delete the Sync Data folder."; } } diff --git a/chrome/browser/ui/app_list/app_list_service_mac.mm b/chrome/browser/ui/app_list/app_list_service_mac.mm index c8230ca..b28d88a 100644 --- a/chrome/browser/ui/app_list/app_list_service_mac.mm +++ b/chrome/browser/ui/app_list/app_list_service_mac.mm @@ -187,7 +187,7 @@ void CheckAppListShimOnFileThread(const base::FilePath& profile_path) { // Sanity check because deleting things recursively is scary. CHECK(install_path.MatchesExtension(".app")); - file_util::Delete(install_path, true /* recursive */); + base::Delete(install_path, true /* recursive */); } void CreateShortcutsInDefaultLocation( diff --git a/chrome/browser/ui/network_profile_bubble.cc b/chrome/browser/ui/network_profile_bubble.cc index ab11720..9152e84 100644 --- a/chrome/browser/ui/network_profile_bubble.cc +++ b/chrome/browser/ui/network_profile_bubble.cc @@ -135,7 +135,7 @@ void NetworkProfileBubble::CheckNetworkProfile( } else { RecordUmaEvent(METRIC_CHECK_IO_FAILED); } - file_util::Delete(temp_file, false); + base::Delete(temp_file, false); } if (profile_on_network) { RecordUmaEvent(METRIC_PROFILE_ON_NETWORK); diff --git a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc index 54f9d66..23cbd68 100644 --- a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc +++ b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc @@ -323,7 +323,7 @@ void CloseDebugLogFile(PassPlatformFile pass_platform_file) { void CloseAndDeleteDebugLogFile(PassPlatformFile pass_platform_file, const base::FilePath& file_path) { CloseDebugLogFile(pass_platform_file); - file_util::Delete(file_path, false); + base::Delete(file_path, false); } // Called upon completion of |WriteDebugLogToFile|. Closes file diff --git a/chrome/browser/value_store/leveldb_value_store.cc b/chrome/browser/value_store/leveldb_value_store.cc index 54fc3c2..d192399 100644 --- a/chrome/browser/value_store/leveldb_value_store.cc +++ b/chrome/browser/value_store/leveldb_value_store.cc @@ -94,7 +94,7 @@ LeveldbValueStore::~LeveldbValueStore() { if (db_ && IsEmpty()) { // Close |db_| now to release any lock on the directory. db_.reset(); - if (!file_util::Delete(db_path_, true)) { + if (!base::Delete(db_path_, true)) { LOG(WARNING) << "Failed to delete LeveldbValueStore database " << db_path_.value(); } diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm index e4e3c0c..8a004eb 100644 --- a/chrome/browser/web_applications/web_app_mac.mm +++ b/chrome/browser/web_applications/web_app_mac.mm @@ -229,10 +229,10 @@ void UpdateAppShortcutsSubdirLocalizedName( void DeletePathAndParentIfEmpty(const base::FilePath& app_path) { DCHECK(!app_path.empty()); - file_util::Delete(app_path, true); + base::Delete(app_path, true); base::FilePath apps_folder = app_path.DirName(); if (file_util::IsDirectoryEmpty(apps_folder)) - file_util::Delete(apps_folder, false); + base::Delete(apps_folder, false); } } // namespace @@ -361,7 +361,7 @@ void WebAppShortcutCreator::DeleteShortcuts() { // In case the user has moved/renamed/copied the app bundle. base::FilePath bundle_path = GetAppBundleById(GetBundleIdentifier()); if (!bundle_path.empty()) - file_util::Delete(bundle_path, true); + base::Delete(bundle_path, true); // Delete the internal one. DeletePathAndParentIfEmpty(app_data_path_.Append(GetShortcutName())); @@ -369,7 +369,7 @@ void WebAppShortcutCreator::DeleteShortcuts() { bool WebAppShortcutCreator::UpdateShortcuts() { std::vector<base::FilePath> paths; - file_util::Delete(app_data_path_.Append(GetShortcutName()), true); + base::Delete(app_data_path_.Append(GetShortcutName()), true); paths.push_back(app_data_path_); base::FilePath dst_path = GetDestinationPath(); @@ -381,7 +381,7 @@ bool WebAppShortcutCreator::UpdateShortcuts() { app_path = GetAppBundleById(GetBundleIdentifier()); if (!app_path.empty()) { - file_util::Delete(app_path, true); + base::Delete(app_path, true); paths.push_back(app_path.DirName()); } diff --git a/chrome/browser/web_applications/web_app_mac_unittest.mm b/chrome/browser/web_applications/web_app_mac_unittest.mm index 09bc976..a96ff4c 100644 --- a/chrome/browser/web_applications/web_app_mac_unittest.mm +++ b/chrome/browser/web_applications/web_app_mac_unittest.mm @@ -139,7 +139,7 @@ TEST(WebAppShortcutCreatorTest, UpdateShortcuts) { shortcut_creator.BuildShortcut(other_folder.Append(app_name)); - EXPECT_TRUE(file_util::Delete( + EXPECT_TRUE(base::Delete( other_folder.Append(app_name).Append("Contents"), true)); EXPECT_TRUE(shortcut_creator.UpdateShortcuts()); @@ -153,7 +153,7 @@ TEST(WebAppShortcutCreatorTest, UpdateShortcuts) { shortcut_creator.BuildShortcut(other_folder.Append(app_name)); - EXPECT_TRUE(file_util::Delete( + EXPECT_TRUE(base::Delete( other_folder.Append(app_name).Append("Contents"), true)); EXPECT_FALSE(shortcut_creator.UpdateShortcuts()); diff --git a/chrome/browser/web_applications/web_app_win.cc b/chrome/browser/web_applications/web_app_win.cc index be49240..e174eb8 100644 --- a/chrome/browser/web_applications/web_app_win.cc +++ b/chrome/browser/web_applications/web_app_win.cc @@ -281,7 +281,7 @@ void GetShortcutLocationsAndDeleteShortcuts( // Any shortcut could have been pinned, either by chrome or the user, so // they are all unpinned. base::win::TaskbarUnpinShortcutLink(j->value().c_str()); - file_util::Delete(*j, false); + base::Delete(*j, false); } } } @@ -419,7 +419,7 @@ void DeletePlatformShortcuts( if (PathService::Get(base::DIR_START_MENU, &chrome_apps_dir)) { chrome_apps_dir = chrome_apps_dir.Append(GetAppShortcutsSubdirName()); if (file_util::IsDirectoryEmpty(chrome_apps_dir)) - file_util::Delete(chrome_apps_dir, false); + base::Delete(chrome_apps_dir, false); } } diff --git a/chrome/common/auto_start_linux.cc b/chrome/common/auto_start_linux.cc index bc8b666..0033aae 100644 --- a/chrome/common/auto_start_linux.cc +++ b/chrome/common/auto_start_linux.cc @@ -50,7 +50,7 @@ bool AutoStart::AddApplication(const std::string& autostart_filename, if (file_util::WriteFile(autostart_file, autostart_file_contents.c_str(), content_length) != static_cast<int>(content_length)) { - file_util::Delete(autostart_file, false); + base::Delete(autostart_file, false); return false; } return true; @@ -61,7 +61,7 @@ bool AutoStart::Remove(const std::string& autostart_filename) { base::FilePath autostart_directory = GetAutostartDirectory(environment.get()); base::FilePath autostart_file = autostart_directory.Append(autostart_filename); - return file_util::Delete(autostart_file, false); + return base::Delete(autostart_file, false); } bool AutoStart::GetAutostartFileContents( diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc index ce529b5..f6f4a14 100644 --- a/chrome/common/extensions/extension_file_util.cc +++ b/chrome/common/extensions/extension_file_util.cc @@ -125,7 +125,7 @@ void UninstallExtension(const base::FilePath& extensions_dir, // We don't care about the return value. If this fails (and it can, due to // plugins that aren't unloaded yet), it will get cleaned up by // ExtensionService::GarbageCollectExtensions. - file_util::Delete(extensions_dir.AppendASCII(id), true); // recursive. + base::Delete(extensions_dir.AppendASCII(id), true); // recursive. } scoped_refptr<Extension> LoadExtension(const base::FilePath& extension_path, @@ -345,7 +345,7 @@ void GarbageCollectExtensions( // Clean up temporary files left if Chrome crashed or quit in the middle // of an extension install. if (basename.value() == kTempDirectoryName) { - file_util::Delete(extension_path, true); // Recursive + base::Delete(extension_path, true); // Recursive continue; } @@ -362,7 +362,7 @@ void GarbageCollectExtensions( "directory: " << basename.value(); DVLOG(1) << "Deleting invalid extension directory " << extension_path.value() << "."; - file_util::Delete(extension_path, true); // Recursive. + base::Delete(extension_path, true); // Recursive. continue; } @@ -375,7 +375,7 @@ void GarbageCollectExtensions( if (iter_pair.first == iter_pair.second) { DVLOG(1) << "Deleting unreferenced install for directory " << extension_path.LossyDisplayName() << "."; - file_util::Delete(extension_path, true); // Recursive. + base::Delete(extension_path, true); // Recursive. continue; } @@ -396,7 +396,7 @@ void GarbageCollectExtensions( if (!knownVersion) { DVLOG(1) << "Deleting old version for directory " << version_dir.LossyDisplayName() << "."; - file_util::Delete(version_dir, true); // Recursive. + base::Delete(version_dir, true); // Recursive. } } } @@ -570,7 +570,7 @@ base::FilePath GetInstallTempDir(const base::FilePath& extensions_dir) { } void DeleteFile(const base::FilePath& path, bool recursive) { - file_util::Delete(path, recursive); + base::Delete(path, recursive); } } // namespace extension_file_util diff --git a/chrome/common/extensions/extension_file_util.h b/chrome/common/extensions/extension_file_util.h index b7ae262..6335355 100644 --- a/chrome/common/extensions/extension_file_util.h +++ b/chrome/common/extensions/extension_file_util.h @@ -143,7 +143,7 @@ base::FilePath ExtensionResourceURLToFilePath(const GURL& url, base::FilePath GetInstallTempDir(const base::FilePath& extensions_dir); // Helper function to delete files. This is used to avoid ugly casts which -// would be necessary with PostMessage since file_util::Delete is overloaded. +// would be necessary with PostMessage since base::Delete is overloaded. // TODO(skerner): Make a version of Delete that is not overloaded in file_util. void DeleteFile(const base::FilePath& path, bool recursive); diff --git a/chrome/common/extensions/extension_file_util_unittest.cc b/chrome/common/extensions/extension_file_util_unittest.cc index b9d567d..ff90cf94 100644 --- a/chrome/common/extensions/extension_file_util_unittest.cc +++ b/chrome/common/extensions/extension_file_util_unittest.cc @@ -339,7 +339,7 @@ TEST_F(ExtensionFileUtilTest, ExtensionResourceURLToFilePath) { " For the path " << url; } // Remove temp files. - ASSERT_TRUE(file_util::Delete(root_path, true)); + ASSERT_TRUE(base::Delete(root_path, true)); } static scoped_refptr<Extension> LoadExtensionManifest( diff --git a/chrome/common/service_process_util_unittest.cc b/chrome/common/service_process_util_unittest.cc index c436cde..3f3d063 100644 --- a/chrome/common/service_process_util_unittest.cc +++ b/chrome/common/service_process_util_unittest.cc @@ -298,7 +298,7 @@ class ServiceProcessStateFileManipulationTest : public ::testing::Test { }; void DeleteFunc(const base::FilePath& file) { - EXPECT_TRUE(file_util::Delete(file, true)); + EXPECT_TRUE(base::Delete(file, true)); } void MoveFunc(const base::FilePath& from, const base::FilePath& to) { @@ -401,7 +401,7 @@ TEST_F(ServiceProcessStateFileManipulationTest, TrashBundle) { ASSERT_TRUE(mock_launchd()->delete_called()); std::string path(base::mac::PathFromFSRef(bundle_ref)); base::FilePath file_path(path); - ASSERT_TRUE(file_util::Delete(file_path, true)); + ASSERT_TRUE(base::Delete(file_path, true)); } TEST_F(ServiceProcessStateFileManipulationTest, ChangeAttr) { diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc index 5c70174..163c6ea 100644 --- a/chrome/installer/setup/install.cc +++ b/chrome/installer/setup/install.cc @@ -257,7 +257,7 @@ void CleanupLegacyShortcuts(const InstallerState& installer_state, shortcut_level, &uninstall_shortcut_path); uninstall_shortcut_path = uninstall_shortcut_path.Append( dist->GetUninstallLinkName() + installer::kLnkExt); - file_util::Delete(uninstall_shortcut_path, false); + base::Delete(uninstall_shortcut_path, false); if (installer_state.system_install()) { ShellUtil::RemoveShortcuts( diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc index 2c60a20..7259c4d 100644 --- a/chrome/installer/setup/setup_main.cc +++ b/chrome/installer/setup/setup_main.cc @@ -940,7 +940,7 @@ installer::InstallStatus InstallProductsHelper( if (cmd_line.HasSwitch(installer::switches::kInstallerData)) { base::FilePath prefs_path(cmd_line.GetSwitchValuePath( installer::switches::kInstallerData)); - if (!file_util::Delete(prefs_path, true)) { + if (!base::Delete(prefs_path, true)) { LOG(ERROR) << "Failed deleting master preferences file " << prefs_path.value() << ", scheduling for deletion after reboot."; diff --git a/chrome/installer/setup/setup_util_unittest.cc b/chrome/installer/setup/setup_util_unittest.cc index 38f33cc..ce3e13c 100644 --- a/chrome/installer/setup/setup_util_unittest.cc +++ b/chrome/installer/setup/setup_util_unittest.cc @@ -124,7 +124,7 @@ TEST_F(SetupUtilTestWithDir, GetMaxVersionFromArchiveDirTest) { installer::GetMaxVersionFromArchiveDir(test_dir_.path())); ASSERT_EQ(version->GetString(), "1.0.0.0"); - file_util::Delete(chrome_dir, true); + base::Delete(chrome_dir, true); ASSERT_FALSE(file_util::PathExists(chrome_dir)); ASSERT_TRUE(installer::GetMaxVersionFromArchiveDir(test_dir_.path()) == NULL); diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc index 1232f19..242fcde 100644 --- a/chrome/installer/setup/uninstall.cc +++ b/chrome/installer/setup/uninstall.cc @@ -270,7 +270,7 @@ bool RemoveInstallerFiles(const base::FilePath& installer_directory, continue; VLOG(1) << "Deleting installer path " << to_delete.value(); - if (!file_util::Delete(to_delete, true)) { + if (!base::Delete(to_delete, true)) { LOG(ERROR) << "Failed to delete path: " << to_delete.value(); success = false; } @@ -402,7 +402,7 @@ DeleteResult DeleteEmptyDir(const base::FilePath& path) { if (!file_util::IsDirectoryEmpty(path)) return DELETE_NOT_EMPTY; - if (file_util::Delete(path, true)) + if (base::Delete(path, true)) return DELETE_SUCCEEDED; LOG(ERROR) << "Failed to delete folder: " << path.value(); @@ -449,7 +449,7 @@ DeleteResult DeleteLocalState( for (size_t i = 0; i < local_state_folders.size(); ++i) { const base::FilePath& user_local_state = local_state_folders[i]; VLOG(1) << "Deleting user profile " << user_local_state.value(); - if (!file_util::Delete(user_local_state, true)) { + if (!base::Delete(user_local_state, true)) { LOG(ERROR) << "Failed to delete user profile dir: " << user_local_state.value(); if (schedule_on_failure) { @@ -543,7 +543,7 @@ DeleteResult DeleteAppHostFilesAndFolders(const InstallerState& installer_state, DeleteResult result = DELETE_SUCCEEDED; base::FilePath app_host_exe(target_path.Append(installer::kChromeAppHostExe)); - if (!file_util::Delete(app_host_exe, false)) { + if (!base::Delete(app_host_exe, false)) { result = DELETE_FAILED; LOG(ERROR) << "Failed to delete path: " << app_host_exe.value(); } @@ -589,7 +589,7 @@ DeleteResult DeleteChromeFilesAndFolders(const InstallerState& installer_state, } VLOG(1) << "Deleting install path " << to_delete.value(); - if (!file_util::Delete(to_delete, true)) { + if (!base::Delete(to_delete, true)) { LOG(ERROR) << "Failed to delete path (1st try): " << to_delete.value(); if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)) { // We don't try killing Chrome processes for Chrome Frame builds since @@ -605,7 +605,7 @@ DeleteResult DeleteChromeFilesAndFolders(const InstallerState& installer_state, // Try closing any running Chrome processes and deleting files once // again. CloseAllChromeProcesses(); - if (!file_util::Delete(to_delete, true)) { + if (!base::Delete(to_delete, true)) { LOG(ERROR) << "Failed to delete path (2nd try): " << to_delete.value(); result = DELETE_FAILED; @@ -1351,7 +1351,7 @@ InstallStatus UninstallProduct(const InstallationState& original_state, // Try and delete the preserved local state once the post-install // operations are complete. if (!backup_state_file.empty()) - file_util::Delete(backup_state_file, false); + base::Delete(backup_state_file, false); return ret; } diff --git a/chrome/installer/test/alternate_version_generator.cc b/chrome/installer/test/alternate_version_generator.cc index 54458fd..44361d5 100644 --- a/chrome/installer/test/alternate_version_generator.cc +++ b/chrome/installer/test/alternate_version_generator.cc @@ -75,7 +75,7 @@ class ScopedTempDirectory { public: ScopedTempDirectory() { } ~ScopedTempDirectory() { - if (!directory_.empty() && !file_util::Delete(directory_, true)) { + if (!directory_.empty() && !base::Delete(directory_, true)) { LOG(DFATAL) << "Failed deleting temporary directory \"" << directory_.value() << "\""; } @@ -602,9 +602,9 @@ bool GenerateAlternateVersion(const base::FilePath& original_installer_path, // Get rid of intermediate files base::FilePath chrome_7z(chrome_7z_name); - if (!file_util::Delete(chrome_7z, false) || - !file_util::Delete(chrome_packed_7z, false) || - !file_util::Delete(setup_ex_, false)) { + if (!base::Delete(chrome_7z, false) || + !base::Delete(chrome_packed_7z, false) || + !base::Delete(setup_ex_, false)) { LOG(DFATAL) << "Failed deleting intermediate files"; return false; } diff --git a/chrome/installer/test/upgrade_test.cc b/chrome/installer/test/upgrade_test.cc index ee02414..7c9f9bd 100644 --- a/chrome/installer/test/upgrade_test.cc +++ b/chrome/installer/test/upgrade_test.cc @@ -32,7 +32,7 @@ class UpgradeTest : public testing::Test { // Clean up by deleting the created newer version of mini_installer.exe. static void TearDownTestCase() { - EXPECT_TRUE(file_util::Delete(next_mini_installer_path_, false)); + EXPECT_TRUE(base::Delete(next_mini_installer_path_, false)); } private: static base::FilePath next_mini_installer_path_; diff --git a/chrome/installer/tools/validate_installation_main.cc b/chrome/installer/tools/validate_installation_main.cc index 453f3443..1fd86de 100644 --- a/chrome/installer/tools/validate_installation_main.cc +++ b/chrome/installer/tools/validate_installation_main.cc @@ -81,7 +81,7 @@ ConsoleLogHelper::~ConsoleLogHelper() { // Delete the log file if it wasn't written to (this is expected). int64 file_size = 0; if (file_util::GetFileSize(log_file_path_, &file_size) && file_size == 0) - file_util::Delete(log_file_path_, false); + base::Delete(log_file_path_, false); } // Returns the path to the log file to create. The file should be empty at diff --git a/chrome/installer/util/copy_tree_work_item.cc b/chrome/installer/util/copy_tree_work_item.cc index 7f82e6a..5f0bd93 100644 --- a/chrome/installer/util/copy_tree_work_item.cc +++ b/chrome/installer/util/copy_tree_work_item.cc @@ -109,7 +109,7 @@ void CopyTreeWorkItem::Rollback() { // If this does happen sometimes, we may consider using Move instead of // Delete here. For now we just log the error and continue with the // rest of rollback operation. - if (copied_to_dest_path_ && !file_util::Delete(dest_path_, true)) { + if (copied_to_dest_path_ && !base::Delete(dest_path_, true)) { LOG(ERROR) << "Can not delete " << dest_path_.value(); } if (moved_to_backup_) { @@ -120,7 +120,7 @@ void CopyTreeWorkItem::Rollback() { } } if (copied_to_alternate_path_ && - !file_util::Delete(alternative_path_, true)) { + !base::Delete(alternative_path_, true)) { LOG(ERROR) << "Can not delete " << alternative_path_.value(); } } diff --git a/chrome/installer/util/copy_tree_work_item_unittest.cc b/chrome/installer/util/copy_tree_work_item_unittest.cc index cd51925..23cc5b3 100644 --- a/chrome/installer/util/copy_tree_work_item_unittest.cc +++ b/chrome/installer/util/copy_tree_work_item_unittest.cc @@ -562,7 +562,7 @@ TEST_F(CopyTreeWorkItemTest, DISABLED_IfNotPresentTest) { EXPECT_FALSE(file_util::PathExists(backup_file)); // Now delete the destination and try copying the file again. - file_util::Delete(file_name_to, true); + base::Delete(file_name_to, true); work_item.reset(WorkItem::CreateCopyTreeWorkItem( file_name_from, file_name_to, temp_dir_.path(), WorkItem::IF_NOT_PRESENT, diff --git a/chrome/installer/util/delete_after_reboot_helper_unittest.cc b/chrome/installer/util/delete_after_reboot_helper_unittest.cc index 02adf5e..02b52a7 100644 --- a/chrome/installer/util/delete_after_reboot_helper_unittest.cc +++ b/chrome/installer/util/delete_after_reboot_helper_unittest.cc @@ -39,7 +39,7 @@ class DeleteAfterRebootHelperTest : public testing::Test { } virtual void TearDown() { // Delete the temporary directory if it's still there. - file_util::Delete(temp_dir_, true); + base::Delete(temp_dir_, true); // Try and restore the pending moves value, if we have one. if (IsUserAnAdmin() && original_pending_moves_.size() > 1) { @@ -228,7 +228,7 @@ TEST_F(DeleteAfterRebootHelperTest, TestFileDeleteSchedulingWithActualDeletes) { } // Delete the temporary directory. - file_util::Delete(temp_dir_, true); + base::Delete(temp_dir_, true); // Test that we can remove the pending deletes. EXPECT_TRUE(RemoveFromMovesPendingReboot(temp_dir_.value().c_str())); diff --git a/chrome/installer/util/delete_tree_work_item.cc b/chrome/installer/util/delete_tree_work_item.cc index 0299a83..4aaf151 100644 --- a/chrome/installer/util/delete_tree_work_item.cc +++ b/chrome/installer/util/delete_tree_work_item.cc @@ -91,7 +91,7 @@ bool DeleteTreeWorkItem::Do() { // We can safely delete the key files now. for (ptrdiff_t i = 0; !abort && i != num_key_files_; ++i) { base::FilePath& key_file = key_paths_[i]; - if (!file_util::Delete(key_file, true)) { + if (!base::Delete(key_file, true)) { // This should not really be possible because of the above. PLOG(DFATAL) << "Unexpectedly could not delete " << key_file.value(); abort = true; @@ -126,7 +126,7 @@ bool DeleteTreeWorkItem::Do() { } } } - if (!file_util::Delete(root_path_, true)) { + if (!base::Delete(root_path_, true)) { LOG(ERROR) << "can not delete " << root_path_.value(); return ignore_failure_; } diff --git a/chrome/installer/util/installer_state.cc b/chrome/installer/util/installer_state.cc index f69d5cd..5fd81bc 100644 --- a/chrome/installer/util/installer_state.cc +++ b/chrome/installer/util/installer_state.cc @@ -665,7 +665,7 @@ void InstallerState::RemoveOldVersionDirectories( LOG(ERROR) << "Deleting old version directory: " << next_version.value(); // Attempt to recursively delete the old version dir. - bool delete_succeeded = file_util::Delete(next_version, true); + bool delete_succeeded = base::Delete(next_version, true); // Note: temporarily log old version deletion at ERROR level to make it // more likely we see this in the installer log. diff --git a/chrome/installer/util/logging_installer.cc b/chrome/installer/util/logging_installer.cc index f31ceac..b6c28b9 100644 --- a/chrome/installer/util/logging_installer.cc +++ b/chrome/installer/util/logging_installer.cc @@ -63,7 +63,7 @@ TruncateResult TruncateLogFileIfNeeded(const base::FilePath& log_file) { result = LOGFILE_TRUNCATED; } } - } else if (file_util::Delete(log_file, false)) { + } else if (base::Delete(log_file, false)) { // Couldn't get sufficient access to the log file, optimistically try to // delete it. result = LOGFILE_DELETED; diff --git a/chrome/installer/util/master_preferences_unittest.cc b/chrome/installer/util/master_preferences_unittest.cc index c2cabae..ec6e1cb 100644 --- a/chrome/installer/util/master_preferences_unittest.cc +++ b/chrome/installer/util/master_preferences_unittest.cc @@ -23,7 +23,7 @@ class MasterPreferencesTest : public testing::Test { } virtual void TearDown() { - EXPECT_TRUE(file_util::Delete(prefs_file_, false)); + EXPECT_TRUE(base::Delete(prefs_file_, false)); } const base::FilePath& prefs_file() const { return prefs_file_; } @@ -41,7 +41,7 @@ struct ExpectedBooleans { } // namespace TEST_F(MasterPreferencesTest, NoFileToParse) { - EXPECT_TRUE(file_util::Delete(prefs_file(), false)); + EXPECT_TRUE(base::Delete(prefs_file(), false)); installer::MasterPreferences prefs(prefs_file()); EXPECT_FALSE(prefs.read_from_file()); } @@ -275,7 +275,7 @@ TEST_F(MasterPreferencesTest, GetInstallPreferencesTest) { } // Delete temporary prefs file. - EXPECT_TRUE(file_util::Delete(prefs_file, false)); + EXPECT_TRUE(base::Delete(prefs_file, false)); // Check that if master prefs doesn't exist, we can still parse the common // prefs. diff --git a/chrome/installer/util/self_cleaning_temp_dir.cc b/chrome/installer/util/self_cleaning_temp_dir.cc index cdb61e8..bb2fd6c 100644 --- a/chrome/installer/util/self_cleaning_temp_dir.cc +++ b/chrome/installer/util/self_cleaning_temp_dir.cc @@ -78,7 +78,7 @@ bool SelfCleaningTempDir::Delete() { // First try to recursively delete the leaf directory managed by our // base::ScopedTempDir. - if (!file_util::Delete(path(), true)) { + if (!base::Delete(path(), true)) { // That failed, so schedule the temp dir and its contents for deletion after // reboot. LOG(WARNING) << "Failed to delete temporary directory " << path().value() diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index 19958c6..4a196ea 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -1200,7 +1200,7 @@ bool ShortcutOpUnpin(const base::FilePath& shortcut_path) { } bool ShortcutOpDelete(const base::FilePath& shortcut_path) { - bool ret = file_util::Delete(shortcut_path, false); + bool ret = base::Delete(shortcut_path, false); LOG_IF(ERROR, !ret) << "Failed to remove " << shortcut_path.value(); return ret; } @@ -1269,7 +1269,7 @@ bool RemoveShortcutFolder(ShellUtil::ShortcutLocation location, LOG(WARNING) << "Cannot find path at location " << location; return false; } - if (!file_util::Delete(shortcut_folder, true)) { + if (!base::Delete(shortcut_folder, true)) { LOG(ERROR) << "Cannot remove folder " << shortcut_folder.value(); return false; } diff --git a/chrome/service/cloud_print/connector_settings_unittest.cc b/chrome/service/cloud_print/connector_settings_unittest.cc index 7616e63..8dcf59b 100644 --- a/chrome/service/cloud_print/connector_settings_unittest.cc +++ b/chrome/service/cloud_print/connector_settings_unittest.cc @@ -56,7 +56,7 @@ class ConnectorSettingsTest : public testing::Test { ServiceProcessPrefs* CreateTestFile(const char* json) { base::FilePath file_name = temp_dir_.path().AppendASCII("file.txt"); - file_util::Delete(file_name, false); + base::Delete(file_name, false); if (json) { std::string content = json; std::replace(content.begin(), content.end(), '\'', '"'); diff --git a/chrome/test/automation/proxy_launcher.cc b/chrome/test/automation/proxy_launcher.cc index 2a81cef..4b40cc1 100644 --- a/chrome/test/automation/proxy_launcher.cc +++ b/chrome/test/automation/proxy_launcher.cc @@ -559,7 +559,7 @@ bool NamedProxyLauncher::InitializeConnection(const LaunchState& state, #if defined(OS_POSIX) // Because we are waiting on the existence of the testing file below, // make sure there isn't one already there before browser launch. - if (!file_util::Delete(base::FilePath(channel_id_), false)) { + if (!base::Delete(base::FilePath(channel_id_), false)) { LOG(ERROR) << "Failed to delete " << channel_id_; return false; } diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc index a5bdae8..5ee917f 100644 --- a/chrome/test/base/testing_profile.cc +++ b/chrome/test/base/testing_profile.cc @@ -269,7 +269,7 @@ void TestingProfile::CreateTempProfileDir() { base::FilePath fallback_dir( system_tmp_dir.AppendASCII("TestingProfilePath")); - file_util::Delete(fallback_dir, true); + base::Delete(fallback_dir, true); file_util::CreateDirectory(fallback_dir); if (!temp_dir_.Set(fallback_dir)) { // That shouldn't happen, but if it does, try to recover. @@ -360,7 +360,7 @@ void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { if (delete_file) { base::FilePath path = GetPath(); path = path.Append(chrome::kHistoryFilename); - file_util::Delete(path, false); + base::Delete(path, false); } // This will create and init the history service. HistoryService* history_service = static_cast<HistoryService*>( @@ -429,7 +429,7 @@ static BrowserContextKeyedService* BuildBookmarkModel( void TestingProfile::CreateBookmarkModel(bool delete_file) { if (delete_file) { base::FilePath path = GetPath().Append(chrome::kBookmarksFileName); - file_util::Delete(path, false); + base::Delete(path, false); } // This will create a bookmark model. BookmarkModel* bookmark_service = static_cast<BookmarkModel*>( diff --git a/chrome/test/gpu/gpu_pixel_browsertest.cc b/chrome/test/gpu/gpu_pixel_browsertest.cc index e7c1c3c..ed4e1ff 100644 --- a/chrome/test/gpu/gpu_pixel_browsertest.cc +++ b/chrome/test/gpu/gpu_pixel_browsertest.cc @@ -268,7 +268,7 @@ class GpuPixelBrowserTest : public InProcessBrowserTest { LOG(ERROR) << "Can't save revision file to: " << rev_path.value(); rt = false; - file_util::Delete(img_path, false); + base::Delete(img_path, false); } else { LOG(INFO) << "Saved revision file to: " << rev_path.value(); @@ -447,7 +447,7 @@ class GpuPixelBrowserTest : public InProcessBrowserTest { } ref_img_revision_ = max_revision; for (size_t i = 0; i < outdated_revs.size(); ++i) - file_util::Delete(outdated_revs[i], false); + base::Delete(outdated_revs[i], false); } DISALLOW_COPY_AND_ASSIGN(GpuPixelBrowserTest); diff --git a/chrome/test/logging/win/test_log_collector.cc b/chrome/test/logging/win/test_log_collector.cc index 86ee24c..4324e26f 100644 --- a/chrome/test/logging/win/test_log_collector.cc +++ b/chrome/test/logging/win/test_log_collector.cc @@ -262,7 +262,7 @@ void TestLogCollector::ProcessSessionForTest( std::cerr.flush(); } - if (!file_util::Delete(log_file_, false)) + if (!base::Delete(log_file_, false)) LOG(ERROR) << "Failed to delete log file " << log_file_.value(); } diff --git a/chrome/test/mini_installer_test/installer_test_util.cc b/chrome/test/mini_installer_test/installer_test_util.cc index cb89e55..2d8e2d5 100644 --- a/chrome/test/mini_installer_test/installer_test_util.cc +++ b/chrome/test/mini_installer_test/installer_test_util.cc @@ -62,7 +62,7 @@ bool DeleteInstallDirectory(bool system_level, if (!has_install_dir || !file_util::PathExists(path)) return false; path = path.AppendASCII(version); - return file_util::Delete(path, true); + return base::Delete(path, true); } bool DeleteRegistryKey(bool system_level, diff --git a/chrome/test/mini_installer_test/run_all_unittests.cc b/chrome/test/mini_installer_test/run_all_unittests.cc index 90e947c..d4d69b0 100644 --- a/chrome/test/mini_installer_test/run_all_unittests.cc +++ b/chrome/test/mini_installer_test/run_all_unittests.cc @@ -33,7 +33,7 @@ void BackUpProfile(bool chrome_frame) { // Will check if User Data is already backed up. // If yes, will delete and create new one. if (file_util::PathExists(backup_path)) - file_util::Delete(backup_path, true); + base::Delete(backup_path, true); file_util::CopyDirectory(path, backup_path, true); } else { printf("Chrome is not installed. Will not take any backup\n"); diff --git a/chrome/test/perf/generate_profile.cc b/chrome/test/perf/generate_profile.cc index d45dc38..b07f174 100644 --- a/chrome/test/perf/generate_profile.cc +++ b/chrome/test/perf/generate_profile.cc @@ -256,7 +256,7 @@ bool GenerateProfile(GenerateProfileTypes types, base::FilePath path = file_iterator.Next(); while (!path.empty()) { base::FilePath dst_file = dst_dir.Append(path.BaseName()); - file_util::Delete(dst_file, false); + base::Delete(dst_file, false); if (!file_util::CopyFile(path, dst_file)) { PLOG(ERROR) << "Copying file failed"; return false; diff --git a/chrome/test/perf/memory_test.cc b/chrome/test/perf/memory_test.cc index fae4a8c..af9564a 100644 --- a/chrome/test/perf/memory_test.cc +++ b/chrome/test/perf/memory_test.cc @@ -39,7 +39,7 @@ class MemoryTest : public UIPerfTest { virtual ~MemoryTest() { // Cleanup our temporary directory. if (cleanup_temp_dir_on_exit_) - file_util::Delete(temp_dir_, true); + base::Delete(temp_dir_, true); } // Called from SetUp() to determine the user data dir to copy. diff --git a/chrome/test/webdriver/webdriver_automation.cc b/chrome/test/webdriver/webdriver_automation.cc index 2c2f13d..418e0b2 100644 --- a/chrome/test/webdriver/webdriver_automation.cc +++ b/chrome/test/webdriver/webdriver_automation.cc @@ -440,7 +440,7 @@ void Automation::Init( #elif defined(OS_POSIX) base::FilePath temp_file; if (!file_util::CreateTemporaryFile(&temp_file) || - !file_util::Delete(temp_file, false /* recursive */)) { + !base::Delete(temp_file, false /* recursive */)) { *error = new Error(kUnknownError, "Could not create temporary filename"); return; } diff --git a/chrome/tools/convert_dict/convert_dict_unittest.cc b/chrome/tools/convert_dict/convert_dict_unittest.cc index fa51f4f..91658d1 100644 --- a/chrome/tools/convert_dict/convert_dict_unittest.cc +++ b/chrome/tools/convert_dict/convert_dict_unittest.cc @@ -130,8 +130,8 @@ void RunDictionaryTest(const char* codepage, // Deletes the temporary files. // We need to delete them after the above AffReader and DicReader are deleted // since they close the input files in their destructors. - file_util::Delete(aff_file, false); - file_util::Delete(dic_file, false); + base::Delete(aff_file, false); + base::Delete(dic_file, false); } } // namespace diff --git a/chrome/utility/media_galleries/pmp_test_helper.cc b/chrome/utility/media_galleries/pmp_test_helper.cc index bc15c4f..eb707be 100644 --- a/chrome/utility/media_galleries/pmp_test_helper.cc +++ b/chrome/utility/media_galleries/pmp_test_helper.cc @@ -134,7 +134,7 @@ bool PmpTestHelper::InitColumnReaderFromBytes( bool read_success = reader->ReadFile(platform_file, expected_type); base::ClosePlatformFile(platform_file); - file_util::Delete(temp_path, false /* recursive */); + base::Delete(temp_path, false /* recursive */); return read_success; } diff --git a/chrome_frame/crash_reporting/minidump_test.cc b/chrome_frame/crash_reporting/minidump_test.cc index bbb4637..8475b9b 100644 --- a/chrome_frame/crash_reporting/minidump_test.cc +++ b/chrome_frame/crash_reporting/minidump_test.cc @@ -75,7 +75,7 @@ class MinidumpTest: public testing::Test { } dump_file_handle_.Close(); - EXPECT_TRUE(file_util::Delete(dump_file_, false)); + EXPECT_TRUE(base::Delete(dump_file_, false)); } void EnsureDumpMapped() { diff --git a/chrome_frame/test/chrome_frame_test_utils.cc b/chrome_frame/test/chrome_frame_test_utils.cc index 40f4c1a..80db1b3 100644 --- a/chrome_frame/test/chrome_frame_test_utils.cc +++ b/chrome_frame/test/chrome_frame_test_utils.cc @@ -702,7 +702,7 @@ void ClearIESessionHistory() { session_history_path = session_history_path.AppendASCII("Microsoft"); session_history_path = session_history_path.AppendASCII("Internet Explorer"); session_history_path = session_history_path.AppendASCII("Recovery"); - file_util::Delete(session_history_path, true); + base::Delete(session_history_path, true); } std::string GetLocalIPv4Address() { diff --git a/chrome_frame/test/net/fake_external_tab.cc b/chrome_frame/test/net/fake_external_tab.cc index 90ef166..13f3c45 100644 --- a/chrome_frame/test/net/fake_external_tab.cc +++ b/chrome_frame/test/net/fake_external_tab.cc @@ -478,7 +478,7 @@ FakeExternalTab::FakeExternalTab() { if (file_util::PathExists(user_data_dir_)) { VLOG(1) << __FUNCTION__ << " deleting IE Profile user data directory " << user_data_dir_.value(); - bool deleted = file_util::Delete(user_data_dir_, true); + bool deleted = base::Delete(user_data_dir_, true); LOG_IF(ERROR, !deleted) << "Failed to delete user data directory directory " << user_data_dir_.value(); } @@ -892,7 +892,7 @@ void CFUrlRequestUnittestRunner::StopFileLogger(bool print) { } } - if (!log_file_.empty() && !file_util::Delete(log_file_, false)) + if (!log_file_.empty() && !base::Delete(log_file_, false)) LOG(ERROR) << "Failed to delete log file " << log_file_.value(); log_file_.clear(); diff --git a/chrome_frame/test/perf/chrome_frame_perftest.cc b/chrome_frame/test/perf/chrome_frame_perftest.cc index 6db4e01..04f9a52 100644 --- a/chrome_frame/test/perf/chrome_frame_perftest.cc +++ b/chrome_frame/test/perf/chrome_frame_perftest.cc @@ -1329,7 +1329,7 @@ class EtwPerfSession { } ~EtwPerfSession() { - file_util::Delete(etl_log_file_, false); + base::Delete(etl_log_file_, false); } void Start() { diff --git a/chrome_frame/test/test_scrubber.cc b/chrome_frame/test/test_scrubber.cc index 4bf6014..9699a17 100644 --- a/chrome_frame/test/test_scrubber.cc +++ b/chrome_frame/test/test_scrubber.cc @@ -115,7 +115,7 @@ void TestScrubber::CleanUpFromTestRun() { VLOG_IF(1, file_util::PathExists(data_directory)) << __FUNCTION__ << " deleting user data directory " << data_directory.value(); - bool deleted = file_util::Delete(data_directory, true); + bool deleted = base::Delete(data_directory, true); LOG_IF(ERROR, !deleted) << "Failed to delete user data directory directory " << data_directory.value(); diff --git a/chrome_frame/test/test_with_web_server.cc b/chrome_frame/test/test_with_web_server.cc index 38e8709..15e16f2 100644 --- a/chrome_frame/test/test_with_web_server.cc +++ b/chrome_frame/test/test_with_web_server.cc @@ -136,8 +136,8 @@ void ChromeFrameTestWithWebServer::TearDownTestCase() { local_address_.clear(); delete loop_; loop_ = NULL; - file_util::Delete(CFInstall_path_, false); - file_util::Delete(CFInstance_path_, false); + base::Delete(CFInstall_path_, false); + base::Delete(CFInstance_path_, false); if (temp_dir_.IsValid()) EXPECT_TRUE(temp_dir_.Delete()); } diff --git a/chromeos/dbus/cros_disks_client.cc b/chromeos/dbus/cros_disks_client.cc index 915e4ec..733aae6 100644 --- a/chromeos/dbus/cros_disks_client.cc +++ b/chromeos/dbus/cros_disks_client.cc @@ -461,7 +461,7 @@ class CrosDisksClientStubImpl : public CrosDisksClient { // Remove the directory created in Mount(). base::WorkerPool::PostTaskAndReply( FROM_HERE, - base::Bind(base::IgnoreResult(&file_util::Delete), + base::Bind(base::IgnoreResult(&base::Delete), base::FilePath::FromUTF8Unsafe(device_path), true /* recursive */), base::Bind(callback, device_path), diff --git a/chromeos/dbus/session_manager_client.cc b/chromeos/dbus/session_manager_client.cc index f610275..ac7a9a7 100644 --- a/chromeos/dbus/session_manager_client.cc +++ b/chromeos/dbus/session_manager_client.cc @@ -512,7 +512,7 @@ class SessionManagerClientStubImpl : public SessionManagerClient { &user_policy_key_dir)) { base::WorkerPool::PostTask( FROM_HERE, - base::Bind(base::IgnoreResult(&file_util::Delete), + base::Bind(base::IgnoreResult(&base::Delete), user_policy_key_dir, true), false); } diff --git a/cloud_print/service/win/installer.cc b/cloud_print/service/win/installer.cc index 57b4771..9d0de9e 100644 --- a/cloud_print/service/win/installer.cc +++ b/cloud_print/service/win/installer.cc @@ -64,9 +64,9 @@ void DeleteShortcut(int dir_key, bool with_subdir) { if (path.empty()) return; if (with_subdir) - file_util::Delete(path.DirName(), true); + base::Delete(path.DirName(), true); else - file_util::Delete(path, false); + base::Delete(path, false); } void DeleteShortcuts() { @@ -95,7 +95,7 @@ HRESULT ProcessInstallerSwitches() { if (!old_location.empty() && cloud_print::IsProgramsFilesParent(old_location) && old_location != cloud_print::GetInstallLocation(kGoogleUpdateId)) { - file_util::Delete(old_location, true); + base::Delete(old_location, true); } cloud_print::SetGoogleUpdateKeys( @@ -120,7 +120,7 @@ HRESULT ProcessInstallerSwitches() { base::FilePath delete_path = command_line.GetSwitchValuePath(kDeleteSwitch); if (!delete_path.empty() && cloud_print::IsProgramsFilesParent(delete_path)) { - file_util::Delete(delete_path, true); + base::Delete(delete_path, true); } return S_OK; } diff --git a/cloud_print/service/win/service_listener.cc b/cloud_print/service/win/service_listener.cc index 1d8cbf5..51d9c93 100644 --- a/cloud_print/service/win/service_listener.cc +++ b/cloud_print/service/win/service_listener.cc @@ -43,7 +43,7 @@ std::string GetEnvironment(const base::FilePath& user_data_dir) { DCHECK(file_util::PathExists(temp_file)); environment.SetString(SetupListener::kUserDataDirJsonValueName, user_data_dir.value()); - file_util::Delete(temp_file, false); + base::Delete(temp_file, false); } } diff --git a/cloud_print/virtual_driver/win/install/setup.cc b/cloud_print/virtual_driver/win/install/setup.cc index 26fc32f..f1b870a 100644 --- a/cloud_print/virtual_driver/win/install/setup.cc +++ b/cloud_print/virtual_driver/win/install/setup.cc @@ -156,9 +156,9 @@ HRESULT RegisterPortMonitor(bool install, const base::FilePath& install_path) { return HRESULT_FROM_WIN32(exit_code); } } else { - if (!file_util::Delete(target_path, false)) { + if (!base::Delete(target_path, false)) { SpoolerServiceCommand("stop"); - bool deleted = file_util::Delete(target_path, false); + bool deleted = base::Delete(target_path, false); SpoolerServiceCommand("start"); if(!deleted) { @@ -480,7 +480,7 @@ HRESULT DoDelete(const base::FilePath& install_path) { if (!file_util::DirectoryExists(install_path)) return S_FALSE; Sleep(5000); // Give parent some time to exit. - return file_util::Delete(install_path, true) ? S_OK : E_FAIL; + return base::Delete(install_path, true) ? S_OK : E_FAIL; } HRESULT DoInstall(const base::FilePath& install_path) { @@ -493,7 +493,7 @@ HRESULT DoInstall(const base::FilePath& install_path) { if (!old_install_path.value().empty() && install_path != old_install_path) { if (file_util::DirectoryExists(old_install_path)) - file_util::Delete(old_install_path, true); + base::Delete(old_install_path, true); } CreateUninstallKey(kUninstallId, LoadLocalString(IDS_DRIVER_NAME), kUninstallSwitch); diff --git a/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc b/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc index 084816e..657cfef 100644 --- a/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc +++ b/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc @@ -125,7 +125,7 @@ void DeleteLeakedFiles(const base::FilePath& dir) { for (base::FilePath file_path = enumerator.Next(); !file_path.empty(); file_path = enumerator.Next()) { if (enumerator.GetInfo().GetLastModifiedTime() < delete_before) - file_util::Delete(file_path, false); + base::Delete(file_path, false); } } @@ -503,7 +503,7 @@ BOOL WINAPI Monitor2EndDocPort(HANDLE port_handle) { } } if (delete_file) - file_util::Delete(port_data->file_path, false); + base::Delete(port_data->file_path, false); } if (port_data->printer_handle != NULL) { // Tell the spooler that the job is complete. diff --git a/cloud_print/virtual_driver/win/port_monitor/port_monitor_unittest.cc b/cloud_print/virtual_driver/win/port_monitor/port_monitor_unittest.cc index 1ab8a36..985b386 100644 --- a/cloud_print/virtual_driver/win/port_monitor/port_monitor_unittest.cc +++ b/cloud_print/virtual_driver/win/port_monitor/port_monitor_unittest.cc @@ -74,10 +74,10 @@ class PortMonitorTest : public testing::Test { base::FilePath path; PathService::Get(base::DIR_LOCAL_APP_DATA, &path); base::FilePath main_path = path.Append(kChromeExePath); - ASSERT_TRUE(file_util::Delete(main_path, true)); + ASSERT_TRUE(base::Delete(main_path, true)); PathService::Get(base::DIR_LOCAL_APP_DATA, &path); base::FilePath alternate_path = path.Append(kAlternateChromeExePath); - ASSERT_TRUE(file_util::Delete(alternate_path, true)); + ASSERT_TRUE(base::Delete(alternate_path, true)); } protected: diff --git a/components/visitedlink/test/visitedlink_perftest.cc b/components/visitedlink/test/visitedlink_perftest.cc index 540b19f..6ebc0eb 100644 --- a/components/visitedlink/test/visitedlink_perftest.cc +++ b/components/visitedlink/test/visitedlink_perftest.cc @@ -66,7 +66,7 @@ class VisitedLink : public testing::Test { ASSERT_TRUE(file_util::CreateTemporaryFile(&db_path_)); } virtual void TearDown() { - file_util::Delete(db_path_, false); + base::Delete(db_path_, false); } }; diff --git a/content/browser/download/base_file.cc b/content/browser/download/base_file.cc index 2f479cd..0fa352f 100644 --- a/content/browser/download/base_file.cc +++ b/content/browser/download/base_file.cc @@ -198,7 +198,7 @@ void BaseFile::Cancel() { if (!full_path_.empty()) { bound_net_log_.AddEvent(net::NetLog::TYPE_DOWNLOAD_FILE_DELETED); - file_util::Delete(full_path_, false); + base::Delete(full_path_, false); } } diff --git a/content/browser/download/download_browsertest.cc b/content/browser/download/download_browsertest.cc index 9275a7a..bc256ce 100644 --- a/content/browser/download/download_browsertest.cc +++ b/content/browser/download/download_browsertest.cc @@ -1210,7 +1210,7 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeWithDeletedFile) { base::FilePath(FILE_PATH_LITERAL("rangereset.crdownload"))); // Delete the intermediate file. - file_util::Delete(download->GetFullPath(), false); + base::Delete(download->GetFullPath(), false); DownloadUpdatedObserver completion_observer( download, base::Bind(DownloadCompleteFilter)); diff --git a/content/browser/download/download_item_impl.cc b/content/browser/download/download_item_impl.cc index ec8f8f1..126e673 100644 --- a/content/browser/download/download_item_impl.cc +++ b/content/browser/download/download_item_impl.cc @@ -62,7 +62,7 @@ void DeleteDownloadedFile(const base::FilePath& path) { // Make sure we only delete files. if (!file_util::DirectoryExists(path)) - file_util::Delete(path, false); + base::Delete(path, false); } // Wrapper around DownloadFile::Detach and DownloadFile::Cancel that diff --git a/content/browser/download/save_file_manager.cc b/content/browser/download/save_file_manager.cc index 06802e3..e137c57 100644 --- a/content/browser/download/save_file_manager.cc +++ b/content/browser/download/save_file_manager.cc @@ -411,7 +411,7 @@ void SaveFileManager::CancelSave(int save_id) { // We've won a race with the UI thread--we finished the file before // the UI thread cancelled it on us. Unfortunately, in this situation // the cancel wins, so we need to delete the now detached file. - file_util::Delete(save_file->FullPath(), false); + base::Delete(save_file->FullPath(), false); } else if (save_file->save_source() == SaveFileCreateInfo::SAVE_FILE_FROM_NET) { // If the data comes from the net IO thread and hasn't completed @@ -461,7 +461,7 @@ void SaveFileManager::SaveLocalFile(const GURL& original_file_url, // final name later. bool success = file_util::CopyFile(file_path, save_file->FullPath()); if (!success) - file_util::Delete(save_file->FullPath(), false); + base::Delete(save_file->FullPath(), false); SaveFinished(save_id, original_file_url, render_process_id, success); } @@ -470,7 +470,7 @@ void SaveFileManager::OnDeleteDirectoryOrFile(const base::FilePath& full_path, DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); DCHECK(!full_path.empty()); - file_util::Delete(full_path, is_dir); + base::Delete(full_path, is_dir); } void SaveFileManager::RenameAllFiles( @@ -524,7 +524,7 @@ void SaveFileManager::RemoveSavedFileFromFileMap( if (it != save_file_map_.end()) { SaveFile* save_file = it->second; DCHECK(!save_file->InProgress()); - file_util::Delete(save_file->FullPath(), false); + base::Delete(save_file->FullPath(), false); delete save_file; save_file_map_.erase(it); } diff --git a/content/browser/gpu/gpu_pixel_browsertest.cc b/content/browser/gpu/gpu_pixel_browsertest.cc index a80cc4e..eebc157 100644 --- a/content/browser/gpu/gpu_pixel_browsertest.cc +++ b/content/browser/gpu/gpu_pixel_browsertest.cc @@ -259,7 +259,7 @@ class GpuPixelBrowserTest : public ContentBrowserTest { LOG(ERROR) << "Can't save revision file to: " << rev_path.value(); rt = false; - file_util::Delete(img_path, false); + base::Delete(img_path, false); } else { LOG(INFO) << "Saved revision file to: " << rev_path.value(); @@ -429,7 +429,7 @@ class GpuPixelBrowserTest : public ContentBrowserTest { } ref_img_revision_ = max_revision; for (size_t i = 0; i < outdated_revs.size(); ++i) - file_util::Delete(outdated_revs[i], false); + base::Delete(outdated_revs[i], false); } DISALLOW_COPY_AND_ASSIGN(GpuPixelBrowserTest); diff --git a/content/browser/in_process_webkit/browser_webkitplatformsupport_impl.cc b/content/browser/in_process_webkit/browser_webkitplatformsupport_impl.cc index 69b7fb3..c5e0eef 100644 --- a/content/browser/in_process_webkit/browser_webkitplatformsupport_impl.cc +++ b/content/browser/in_process_webkit/browser_webkitplatformsupport_impl.cc @@ -95,7 +95,7 @@ void BrowserWebKitPlatformSupportImpl::getPluginList(bool refresh, int BrowserWebKitPlatformSupportImpl::databaseDeleteFile( const WebKit::WebString& vfs_file_name, bool sync_dir) { const base::FilePath& path = base::FilePath::FromUTF16Unsafe(vfs_file_name); - return file_util::Delete(path, false) ? 0 : 1; + return base::Delete(path, false) ? 0 : 1; } long long BrowserWebKitPlatformSupportImpl::availableDiskSpaceInBytes( diff --git a/content/browser/indexed_db/indexed_db_context_impl.cc b/content/browser/indexed_db/indexed_db_context_impl.cc index 27c9eb2..2156d35 100644 --- a/content/browser/indexed_db/indexed_db_context_impl.cc +++ b/content/browser/indexed_db/indexed_db_context_impl.cc @@ -83,7 +83,7 @@ void ClearSessionOnlyOrigins( continue; if (special_storage_policy->IsStorageProtected(*iter)) continue; - file_util::Delete(*file_path_iter, true); + base::Delete(*file_path_iter, true); } } @@ -175,7 +175,7 @@ void IndexedDBContextImpl::DeleteForOrigin(const GURL& origin_url) { base::FilePath idb_directory = GetFilePath(origin_url); EnsureDiskUsageCacheInitialized(origin_url); const bool recursive = true; - bool deleted = file_util::Delete(idb_directory, recursive); + bool deleted = base::Delete(idb_directory, recursive); QueryDiskAndUpdateQuotaUsage(origin_url); if (deleted) { diff --git a/content/browser/net/sqlite_persistent_cookie_store.cc b/content/browser/net/sqlite_persistent_cookie_store.cc index 8d3c38a..d74e60d 100644 --- a/content/browser/net/sqlite_persistent_cookie_store.cc +++ b/content/browser/net/sqlite_persistent_cookie_store.cc @@ -831,7 +831,7 @@ bool SQLitePersistentCookieStore::Backend::EnsureDatabaseVersion() { meta_table_.Reset(); db_.reset(new sql::Connection); - if (!file_util::Delete(path_, false) || + if (!base::Delete(path_, false) || !db_->Open(path_) || !meta_table_.Init( db_.get(), kCurrentVersionNumber, kCompatibleVersionNumber)) { diff --git a/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc b/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc index 130cf08..8c8b5c5 100644 --- a/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_flash_file_message_filter.cc @@ -173,7 +173,7 @@ int32_t PepperFlashFileMessageFilter::OnDeleteFileOrDir( base::PLATFORM_FILE_ERROR_ACCESS_DENIED); } - bool result = file_util::Delete(full_path, recursive); + bool result = base::Delete(full_path, recursive); return ppapi::PlatformFileErrorToPepperError(result ? base::PLATFORM_FILE_OK : base::PLATFORM_FILE_ERROR_ACCESS_DENIED); } diff --git a/content/browser/storage_partition_impl_map.cc b/content/browser/storage_partition_impl_map.cc index a8b41cc..6a90f8a 100644 --- a/content/browser/storage_partition_impl_map.cc +++ b/content/browser/storage_partition_impl_map.cc @@ -233,7 +233,7 @@ void ObliterateOneDirectory(const base::FilePath& current_dir, switch (action) { case kDelete: - file_util::Delete(to_delete, true); + base::Delete(to_delete, true); break; case kEnqueue: @@ -285,7 +285,7 @@ void BlockingObliteratePath( // root and be done with it. Otherwise, signal garbage collection and do // a best-effort delete of the on-disk structures. if (valid_paths_to_keep.empty()) { - file_util::Delete(root, true); + base::Delete(root, true); return; } closure_runner->PostTask(FROM_HERE, on_gc_required); @@ -343,8 +343,7 @@ void BlockingGarbageCollect( file_access_runner->PostTask( FROM_HERE, - base::Bind(base::IgnoreResult(&file_util::Delete), trash_directory, - true)); + base::Bind(base::IgnoreResult(&base::Delete), trash_directory, true)); } } // namespace diff --git a/content/browser/web_contents/navigation_controller_impl_unittest.cc b/content/browser/web_contents/navigation_controller_impl_unittest.cc index be9d6ad..6fb3062 100644 --- a/content/browser/web_contents/navigation_controller_impl_unittest.cc +++ b/content/browser/web_contents/navigation_controller_impl_unittest.cc @@ -3767,7 +3767,7 @@ class NavigationControllerHistoryTest : public NavigationControllerTest { // Do normal cleanup before deleting the profile directory below. NavigationControllerTest::TearDown(); - ASSERT_TRUE(file_util::Delete(test_dir_, true)); + ASSERT_TRUE(base::Delete(test_dir_, true)); ASSERT_FALSE(file_util::PathExists(test_dir_)); } diff --git a/content/common/sandbox_mac_diraccess_unittest.mm b/content/common/sandbox_mac_diraccess_unittest.mm index 4884391..2619ae6 100644 --- a/content/common/sandbox_mac_diraccess_unittest.mm +++ b/content/common/sandbox_mac_diraccess_unittest.mm @@ -135,7 +135,7 @@ class ScopedDirectoryDelete { public: inline void operator()(base::FilePath* x) const { if (x) { - file_util::Delete(*x, true); + base::Delete(*x, true); } } }; diff --git a/content/common/sandbox_mac_fontloading_unittest.mm b/content/common/sandbox_mac_fontloading_unittest.mm index 155e3c3..b4a4743 100644 --- a/content/common/sandbox_mac_fontloading_unittest.mm +++ b/content/common/sandbox_mac_fontloading_unittest.mm @@ -122,7 +122,7 @@ TEST_F(MacSandboxTest, FontLoadingTest) { ASSERT_TRUE(RunTestInSandbox(SANDBOX_TYPE_RENDERER, "FontLoadingTestCase", temp_file_path.value().c_str())); temp_file_closer.reset(); - ASSERT_TRUE(file_util::Delete(temp_file_path, false)); + ASSERT_TRUE(base::Delete(temp_file_path, false)); } } // namespace content diff --git a/ipc/ipc_channel_posix_unittest.cc b/ipc/ipc_channel_posix_unittest.cc index 68cb377..2c6e53e 100644 --- a/ipc/ipc_channel_posix_unittest.cc +++ b/ipc/ipc_channel_posix_unittest.cc @@ -375,7 +375,7 @@ TEST_F(IPCChannelPosixTest, IsNamedServerInitialized) { const std::string& connection_socket_name = GetConnectionSocketName(); IPCChannelPosixTestListener listener(false); IPC::ChannelHandle chan_handle(connection_socket_name); - ASSERT_TRUE(file_util::Delete(base::FilePath(connection_socket_name), false)); + ASSERT_TRUE(base::Delete(base::FilePath(connection_socket_name), false)); ASSERT_FALSE(IPC::Channel::IsNamedServerInitialized( connection_socket_name)); IPC::Channel channel(chan_handle, IPC::Channel::MODE_NAMED_SERVER, &listener); diff --git a/net/base/file_stream_unittest.cc b/net/base/file_stream_unittest.cc index 89b6dbd..02f0072 100644 --- a/net/base/file_stream_unittest.cc +++ b/net/base/file_stream_unittest.cc @@ -44,7 +44,7 @@ class FileStreamTest : public PlatformTest { file_util::WriteFile(temp_file_path_, kTestData, kTestDataSize); } virtual void TearDown() { - EXPECT_TRUE(file_util::Delete(temp_file_path_, false)); + EXPECT_TRUE(base::Delete(temp_file_path_, false)); PlatformTest::TearDown(); } @@ -116,7 +116,7 @@ TEST_F(FileStreamTest, UseFileHandle) { read_stream.reset(); // 2. Test writing with a file handle. - file_util::Delete(temp_file_path(), false); + base::Delete(temp_file_path(), false); flags = base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE; file = base::CreatePlatformFile(temp_file_path(), flags, &created, NULL); diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc index 9c2583a..6597340 100644 --- a/net/disk_cache/backend_unittest.cc +++ b/net/disk_cache/backend_unittest.cc @@ -270,7 +270,7 @@ TEST_F(DiskCacheTest, CreateBackend) { TEST_F(DiskCacheBackendTest, CreateBackend_MissingFile) { ASSERT_TRUE(CopyTestCache("bad_entry")); base::FilePath filename = cache_path_.AppendASCII("data_1"); - file_util::Delete(filename, false); + base::Delete(filename, false); base::Thread cache_thread("CacheThread"); ASSERT_TRUE(cache_thread.StartWithOptions( base::Thread::Options(base::MessageLoop::TYPE_IO, 0))); @@ -2782,7 +2782,7 @@ TEST_F(DiskCacheBackendTest, FileSharing) { EXPECT_TRUE(file2.IsValid()); #endif - EXPECT_TRUE(file_util::Delete(name, false)); + EXPECT_TRUE(base::Delete(name, false)); // We should be able to use the file. const int kSize = 200; diff --git a/net/disk_cache/cache_util_posix.cc b/net/disk_cache/cache_util_posix.cc index ee60bf7..db1a4ac 100644 --- a/net/disk_cache/cache_util_posix.cc +++ b/net/disk_cache/cache_util_posix.cc @@ -45,14 +45,14 @@ void DeleteCache(const base::FilePath& path, bool remove_folder) { base::FileEnumerator::FILES); for (base::FilePath file = iter.Next(); !file.value().empty(); file = iter.Next()) { - if (!file_util::Delete(file, /* recursive */ false)) { + if (!base::Delete(file, /* recursive */ false)) { LOG(WARNING) << "Unable to delete cache."; return; } } if (remove_folder) { - if (!file_util::Delete(path, /* recursive */ false)) { + if (!base::Delete(path, /* recursive */ false)) { LOG(WARNING) << "Unable to delete cache folder."; return; } @@ -60,7 +60,7 @@ void DeleteCache(const base::FilePath& path, bool remove_folder) { } bool DeleteCacheFile(const base::FilePath& name) { - return file_util::Delete(name, false); + return base::Delete(name, false); } } // namespace disk_cache diff --git a/net/disk_cache/cache_util_unittest.cc b/net/disk_cache/cache_util_unittest.cc index 4485204..74ae365 100644 --- a/net/disk_cache/cache_util_unittest.cc +++ b/net/disk_cache/cache_util_unittest.cc @@ -65,7 +65,7 @@ TEST_F(CacheUtilTest, MoveCache) { TEST_F(CacheUtilTest, DeleteCache) { // DeleteCache won't delete subdirs, so let's not start with this // one around. - file_util::Delete(dir1_, false); + base::Delete(dir1_, false); disk_cache::DeleteCache(cache_dir_, false); EXPECT_TRUE(file_util::PathExists(cache_dir_)); // cache dir stays EXPECT_FALSE(file_util::PathExists(file1_)); @@ -75,7 +75,7 @@ TEST_F(CacheUtilTest, DeleteCache) { TEST_F(CacheUtilTest, DeleteCacheAndDir) { // DeleteCache won't delete subdirs, so let's not start with this // one around. - file_util::Delete(dir1_, false); + base::Delete(dir1_, false); disk_cache::DeleteCache(cache_dir_, true); EXPECT_FALSE(file_util::PathExists(cache_dir_)); // cache dir is gone EXPECT_FALSE(file_util::PathExists(file1_)); diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc index e93eb7b..2261773 100644 --- a/net/disk_cache/entry_unittest.cc +++ b/net/disk_cache/entry_unittest.cc @@ -1538,7 +1538,7 @@ TEST_F(DiskCacheEntryTest, MissingData) { disk_cache::Addr address(0x80000001); base::FilePath name = cache_impl_->GetFileName(address); - EXPECT_TRUE(file_util::Delete(name, false)); + EXPECT_TRUE(base::Delete(name, false)); // Attempt to read the data. ASSERT_EQ(net::OK, OpenEntry(key, &entry)); diff --git a/net/disk_cache/simple/simple_index_file.cc b/net/disk_cache/simple/simple_index_file.cc index 3193520..39bbe8b 100644 --- a/net/disk_cache/simple/simple_index_file.cc +++ b/net/disk_cache/simple/simple_index_file.cc @@ -51,7 +51,7 @@ void WriteToDiskInternal(const base::FilePath& index_filename, // TODO(felipeg): Add better error handling. LOG(ERROR) << "Could not write Simple Cache index to temporary file: " << temp_filename.value(); - file_util::Delete(temp_filename, /* recursive = */ false); + base::Delete(temp_filename, /* recursive = */ false); } else { // Swap temp and index_file. bool result = file_util::ReplaceFile(temp_filename, index_filename); @@ -178,14 +178,14 @@ scoped_ptr<SimpleIndex::EntrySet> SimpleIndexFile::LoadFromDisk( std::string contents; if (!file_util::ReadFileToString(index_filename, &contents)) { LOG(WARNING) << "Could not read Simple Index file."; - file_util::Delete(index_filename, false); + base::Delete(index_filename, false); return scoped_ptr<SimpleIndex::EntrySet>(); } scoped_ptr<SimpleIndex::EntrySet> entries = SimpleIndexFile::Deserialize(contents.data(), contents.size()); if (!entries) { - file_util::Delete(index_filename, false); + base::Delete(index_filename, false); return scoped_ptr<SimpleIndex::EntrySet>(); } @@ -331,7 +331,7 @@ scoped_ptr<SimpleIndex::EntrySet> SimpleIndexFile::RestoreFromDisk( const base::FilePath& index_file_path) { LOG(INFO) << "Simple Cache Index is being restored from disk."; - file_util::Delete(index_file_path, /* recursive = */ false); + base::Delete(index_file_path, /* recursive = */ false); scoped_ptr<SimpleIndex::EntrySet> index_file_entries( new SimpleIndex::EntrySet()); diff --git a/net/disk_cache/simple/simple_synchronous_entry.cc b/net/disk_cache/simple/simple_synchronous_entry.cc index d8d89bf..f757b9f 100644 --- a/net/disk_cache/simple/simple_synchronous_entry.cc +++ b/net/disk_cache/simple/simple_synchronous_entry.cc @@ -187,7 +187,7 @@ bool SimpleSynchronousEntry::DeleteFilesForEntryHash( for (int i = 0; i < kSimpleEntryFileCount; ++i) { FilePath to_delete = path.AppendASCII( GetFilenameFromEntryHashAndIndex(entry_hash, i)); - if (!file_util::Delete(to_delete, false)) { + if (!base::Delete(to_delete, false)) { result = false; DLOG(ERROR) << "Could not delete " << to_delete.MaybeAsASCII(); } diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc index db008b8..5c53148 100644 --- a/net/http/http_cache.cc +++ b/net/http/http_cache.cc @@ -45,7 +45,7 @@ namespace { // Adaptor to delete a file on a worker thread. void DeletePath(base::FilePath path) { - file_util::Delete(path, false); + base::Delete(path, false); } } // namespace diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index d0daf3f..0c256aa 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -7611,7 +7611,7 @@ TEST_P(HttpNetworkTransactionTest, UploadFileSmallerThanLength) { EXPECT_EQ(OK, rv); EXPECT_EQ("hello world", response_data); - file_util::Delete(temp_file_path, false); + base::Delete(temp_file_path, false); } TEST_P(HttpNetworkTransactionTest, UploadUnreadableFile) { @@ -7671,7 +7671,7 @@ TEST_P(HttpNetworkTransactionTest, UploadUnreadableFile) { EXPECT_TRUE(response->headers.get() != NULL); EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); - file_util::Delete(temp_file, false); + base::Delete(temp_file, false); } TEST_P(HttpNetworkTransactionTest, UnreadableUploadFileAfterAuthRestart) { @@ -7762,7 +7762,7 @@ TEST_P(HttpNetworkTransactionTest, UnreadableUploadFileAfterAuthRestart) { EXPECT_TRUE(response->auth_challenge.get() == NULL); EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); - file_util::Delete(temp_file, false); + base::Delete(temp_file, false); } // Tests that changes to Auth realms are treated like auth rejections. diff --git a/net/proxy/proxy_config_service_linux_unittest.cc b/net/proxy/proxy_config_service_linux_unittest.cc index 8f1ca8c..45f6ae3 100644 --- a/net/proxy/proxy_config_service_linux_unittest.cc +++ b/net/proxy/proxy_config_service_linux_unittest.cc @@ -371,7 +371,7 @@ class ProxyConfigServiceLinuxTest : public PlatformTest { virtual void TearDown() OVERRIDE { // Delete the temporary KDE home directory. - file_util::Delete(user_home_, true); + base::Delete(user_home_, true); PlatformTest::TearDown(); } diff --git a/net/socket/unix_domain_socket_posix_unittest.cc b/net/socket/unix_domain_socket_posix_unittest.cc index f49e683..cc1f83a 100644 --- a/net/socket/unix_domain_socket_posix_unittest.cc +++ b/net/socket/unix_domain_socket_posix_unittest.cc @@ -183,7 +183,7 @@ class UnixDomainSocketTestHelper : public testing::Test { void DeleteSocketFile() { ASSERT_FALSE(file_path_.empty()); - file_util::Delete(file_path_, false /* not recursive */); + base::Delete(file_path_, false /* not recursive */); } SocketDescriptor CreateClientSocket() { diff --git a/net/url_request/url_fetcher_response_writer.cc b/net/url_request/url_fetcher_response_writer.cc index 057296c..5e32f98 100644 --- a/net/url_request/url_fetcher_response_writer.cc +++ b/net/url_request/url_fetcher_response_writer.cc @@ -130,7 +130,7 @@ void URLFetcherFileWriter::CloseAndDeleteFile() { file_stream_.reset(); DisownFile(); file_task_runner_->PostTask(FROM_HERE, - base::Bind(base::IgnoreResult(&file_util::Delete), + base::Bind(base::IgnoreResult(&base::Delete), file_path_, false /* recursive */)); } diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index 099c5fc..02878b0 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -765,7 +765,7 @@ TEST_F(URLRequestTest, FileTestFullSpecifiedRange) { EXPECT_TRUE(partial_buffer_string == d.data_received()); } - EXPECT_TRUE(file_util::Delete(temp_path, false)); + EXPECT_TRUE(base::Delete(temp_path, false)); } TEST_F(URLRequestTest, FileTestHalfSpecifiedRange) { @@ -808,7 +808,7 @@ TEST_F(URLRequestTest, FileTestHalfSpecifiedRange) { EXPECT_TRUE(partial_buffer_string == d.data_received()); } - EXPECT_TRUE(file_util::Delete(temp_path, false)); + EXPECT_TRUE(base::Delete(temp_path, false)); } TEST_F(URLRequestTest, FileTestMultipleRanges) { @@ -839,7 +839,7 @@ TEST_F(URLRequestTest, FileTestMultipleRanges) { EXPECT_TRUE(d.request_failed()); } - EXPECT_TRUE(file_util::Delete(temp_path, false)); + EXPECT_TRUE(base::Delete(temp_path, false)); } TEST_F(URLRequestTest, InvalidUrlTest) { diff --git a/printing/backend/cups_helper.cc b/printing/backend/cups_helper.cc index 2159aaf..b6ce99f 100644 --- a/printing/backend/cups_helper.cc +++ b/printing/backend/cups_helper.cc @@ -350,7 +350,7 @@ bool parsePpdCapabilities( ppd_file_path, printer_capabilities.data(), data_size)) { - file_util::Delete(ppd_file_path, false); + base::Delete(ppd_file_path, false); return false; } @@ -387,7 +387,7 @@ bool parsePpdCapabilities( caps.color_default = is_color; ppdClose(ppd); - file_util::Delete(ppd_file_path, false); + base::Delete(ppd_file_path, false); *printer_info = caps; return true; diff --git a/printing/backend/print_backend_cups.cc b/printing/backend/print_backend_cups.cc index 1f40e59..5330db8 100644 --- a/printing/backend/print_backend_cups.cc +++ b/printing/backend/print_backend_cups.cc @@ -246,7 +246,7 @@ bool PrintBackendCUPS::GetPrinterCapsAndDefaults( std::string content; bool res = file_util::ReadFileToString(ppd_path, &content); - file_util::Delete(ppd_path, false); + base::Delete(ppd_path, false); if (res) { printer_info->printer_capabilities.swap(content); @@ -368,7 +368,7 @@ base::FilePath PrintBackendCUPS::GetPPD(const char* name) { << ", name: " << name << ", CUPS error: " << static_cast<int>(error_code) << ", HTTP error: " << http_error; - file_util::Delete(ppd_path, false); + base::Delete(ppd_path, false); ppd_path.clear(); } } diff --git a/remoting/host/config_file_watcher_unittest.cc b/remoting/host/config_file_watcher_unittest.cc index 060c1ab..7901da3 100644 --- a/remoting/host/config_file_watcher_unittest.cc +++ b/remoting/host/config_file_watcher_unittest.cc @@ -89,7 +89,7 @@ void ConfigFileWatcherTest::SetUp() { void ConfigFileWatcherTest::TearDown() { // Delete the test file. if (!config_file_.empty()) - file_util::Delete(config_file_, false); + base::Delete(config_file_, false); } // Verifies that the initial notification is delivered. diff --git a/remoting/host/pairing_registry_delegate_linux_unittest.cc b/remoting/host/pairing_registry_delegate_linux_unittest.cc index dc5b9fb..d89a8e9 100644 --- a/remoting/host/pairing_registry_delegate_linux_unittest.cc +++ b/remoting/host/pairing_registry_delegate_linux_unittest.cc @@ -70,7 +70,7 @@ TEST_F(PairingRegistryDelegateLinuxTest, SaveAndLoad) { run_loop.Run(); - file_util::Delete(temp_dir, true); + base::Delete(temp_dir, true); }; } // namespace remoting diff --git a/sql/connection.cc b/sql/connection.cc index e99b6bc..a11bc72 100644 --- a/sql/connection.cc +++ b/sql/connection.cc @@ -394,9 +394,9 @@ bool Connection::Delete(const base::FilePath& path) { base::FilePath journal_path(path.value() + FILE_PATH_LITERAL("-journal")); base::FilePath wal_path(path.value() + FILE_PATH_LITERAL("-wal")); - file_util::Delete(journal_path, false); - file_util::Delete(wal_path, false); - file_util::Delete(path, false); + base::Delete(journal_path, false); + base::Delete(wal_path, false); + base::Delete(path, false); return !file_util::PathExists(journal_path) && !file_util::PathExists(wal_path) && diff --git a/sync/syncable/on_disk_directory_backing_store.cc b/sync/syncable/on_disk_directory_backing_store.cc index 08727c3..cffa00f 100644 --- a/sync/syncable/on_disk_directory_backing_store.cc +++ b/sync/syncable/on_disk_directory_backing_store.cc @@ -87,7 +87,7 @@ DirOpenResult OnDiskDirectoryBackingStore::Load( db_->set_exclusive_locking(); db_->set_page_size(4096); db_->set_histogram_tag("SyncDirectory"); - file_util::Delete(backing_filepath_, false); + base::Delete(backing_filepath_, false); result = TryLoad(handles_map, delete_journals, kernel_load_info); if (result == OPENED) { diff --git a/sync/syncable/syncable_unittest.cc b/sync/syncable/syncable_unittest.cc index 0423c41..0ce1fd2 100644 --- a/sync/syncable/syncable_unittest.cc +++ b/sync/syncable/syncable_unittest.cc @@ -1669,7 +1669,7 @@ class OnDiskSyncableDirectoryTest : public SyncableDirectoryTest { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); file_path_ = temp_dir_.path().Append( FILE_PATH_LITERAL("Test.sqlite3")); - file_util::Delete(file_path_, true); + base::Delete(file_path_, true); CreateDirectory(); } @@ -1677,7 +1677,7 @@ class OnDiskSyncableDirectoryTest : public SyncableDirectoryTest { // This also closes file handles. dir_->SaveChanges(); dir_.reset(); - file_util::Delete(file_path_, true); + base::Delete(file_path_, true); } // Creates a new directory. Deletes the old directory, if it exists. @@ -2125,7 +2125,7 @@ TEST_F(SyncableDirectoryManagement, TestFileRelease) { dir.Close(); // Closing the directory should have released the backing database file. - ASSERT_TRUE(file_util::Delete(path, true)); + ASSERT_TRUE(base::Delete(path, true)); } class StressTransactionsDelegate : public base::PlatformThread::Delegate { diff --git a/third_party/leveldatabase/env_chromium.cc b/third_party/leveldatabase/env_chromium.cc index 36aa796..d10ccb6 100644 --- a/third_party/leveldatabase/env_chromium.cc +++ b/third_party/leveldatabase/env_chromium.cc @@ -619,7 +619,7 @@ Status ChromiumEnv::GetChildren(const std::string& dir, Status ChromiumEnv::DeleteFile(const std::string& fname) { Status result; // TODO(jorlow): Should we assert this is a file? - if (!::file_util::Delete(CreateFilePath(fname), false)) { + if (!::base::Delete(CreateFilePath(fname), false)) { result = MakeIOError(fname, "Could not delete file.", kDeleteFile); RecordErrorAt(kDeleteFile); } @@ -642,7 +642,7 @@ Status ChromiumEnv::CreateDir(const std::string& name) { Status ChromiumEnv::DeleteDir(const std::string& name) { Status result; // TODO(jorlow): Should we assert this is a directory? - if (!::file_util::Delete(CreateFilePath(name), false)) { + if (!::base::Delete(CreateFilePath(name), false)) { result = MakeIOError(name, "Could not delete directory.", kDeleteDir); RecordErrorAt(kDeleteDir); } diff --git a/webkit/browser/appcache/appcache_database.cc b/webkit/browser/appcache/appcache_database.cc index 47b2c85..5f507d1 100644 --- a/webkit/browser/appcache/appcache_database.cc +++ b/webkit/browser/appcache/appcache_database.cc @@ -1186,7 +1186,7 @@ bool AppCacheDatabase::DeleteExistingAndCreateNewDatabase() { // This also deletes the disk cache data. base::FilePath directory = db_file_path_.DirName(); - if (!file_util::Delete(directory, true) || + if (!base::Delete(directory, true) || !file_util::CreateDirectory(directory)) { return false; } diff --git a/webkit/browser/appcache/appcache_storage_impl.cc b/webkit/browser/appcache/appcache_storage_impl.cc index a22e62c..e516c10 100644 --- a/webkit/browser/appcache/appcache_storage_impl.cc +++ b/webkit/browser/appcache/appcache_storage_impl.cc @@ -1811,7 +1811,7 @@ void AppCacheStorageImpl::OnDiskCacheInitialized(int rv) { if (!is_incognito_) { VLOG(1) << "Deleting existing appcache data and starting over."; db_thread_->PostTask( - FROM_HERE, base::Bind(base::IgnoreResult(&file_util::Delete), + FROM_HERE, base::Bind(base::IgnoreResult(&base::Delete), cache_directory_, true)); } } diff --git a/webkit/browser/database/database_tracker.cc b/webkit/browser/database/database_tracker.cc index 810d133..5adb3bf 100644 --- a/webkit/browser/database/database_tracker.cc +++ b/webkit/browser/database/database_tracker.cc @@ -416,8 +416,8 @@ bool DatabaseTracker::DeleteOrigin(const std::string& origin_identifier, base::FilePath new_file = new_origin_dir.Append(database.BaseName()); file_util::Move(database, new_file); } - file_util::Delete(origin_dir, true); - file_util::Delete(new_origin_dir, true); // might fail on windows. + base::Delete(origin_dir, true); + base::Delete(new_origin_dir, true); // might fail on windows. databases_table_->DeleteOriginIdentifier(origin_identifier); @@ -459,7 +459,7 @@ bool DatabaseTracker::LazyInit() { kTemporaryDirectoryPattern); for (base::FilePath directory = directories.Next(); !directory.empty(); directory = directories.Next()) { - file_util::Delete(directory, true); + base::Delete(directory, true); } } @@ -472,7 +472,7 @@ bool DatabaseTracker::LazyInit() { (!db_->Open(kTrackerDatabaseFullPath) || !sql::MetaTable::DoesTableExist(db_.get()))) { db_->Close(); - if (!file_util::Delete(db_dir_, true)) + if (!base::Delete(db_dir_, true)) return false; } @@ -798,7 +798,7 @@ void DatabaseTracker::DeleteIncognitoDBDirectory() { base::FilePath incognito_db_dir = profile_path_.Append(kIncognitoDatabaseDirectoryName); if (file_util::DirectoryExists(incognito_db_dir)) - file_util::Delete(incognito_db_dir, true); + base::Delete(incognito_db_dir, true); } void DatabaseTracker::ClearSessionOnlyOrigins() { diff --git a/webkit/browser/database/vfs_backend.cc b/webkit/browser/database/vfs_backend.cc index 041c44b..109664d 100644 --- a/webkit/browser/database/vfs_backend.cc +++ b/webkit/browser/database/vfs_backend.cc @@ -122,7 +122,7 @@ void VfsBackend::OpenTempFileInDirectory( int VfsBackend::DeleteFile(const base::FilePath& file_path, bool sync_dir) { if (!file_util::PathExists(file_path)) return SQLITE_OK; - if (!file_util::Delete(file_path, false)) + if (!base::Delete(file_path, false)) return SQLITE_IOERR_DELETE; int error_code = SQLITE_OK; diff --git a/webkit/browser/dom_storage/session_storage_database.cc b/webkit/browser/dom_storage/session_storage_database.cc index 9fc4f62..f7eaba6 100644 --- a/webkit/browser/dom_storage/session_storage_database.cc +++ b/webkit/browser/dom_storage/session_storage_database.cc @@ -296,7 +296,7 @@ bool SessionStorageDatabase::LazyOpen(bool create_if_needed) { DCHECK(db == NULL); // Clear the directory and try again. - file_util::Delete(file_path_, true); + base::Delete(file_path_, true); s = TryToOpen(&db); if (!s.ok()) { LOG(WARNING) << "Failed to open leveldb in " << file_path_.value() diff --git a/webkit/browser/fileapi/file_system_usage_cache.cc b/webkit/browser/fileapi/file_system_usage_cache.cc index a049f3d..b466f26 100644 --- a/webkit/browser/fileapi/file_system_usage_cache.cc +++ b/webkit/browser/fileapi/file_system_usage_cache.cc @@ -155,7 +155,7 @@ bool FileSystemUsageCache::Delete(const base::FilePath& usage_file_path) { TRACE_EVENT0("FileSystem", "UsageCache::Delete"); DCHECK(CalledOnValidThread()); CloseCacheFiles(); - return file_util::Delete(usage_file_path, true); + return base::Delete(usage_file_path, true); } void FileSystemUsageCache::CloseCacheFiles() { diff --git a/webkit/browser/fileapi/native_file_util.cc b/webkit/browser/fileapi/native_file_util.cc index 1bf4f57..1f6a2e8 100644 --- a/webkit/browser/fileapi/native_file_util.cc +++ b/webkit/browser/fileapi/native_file_util.cc @@ -242,7 +242,7 @@ PlatformFileError NativeFileUtil::DeleteFile(const base::FilePath& path) { return base::PLATFORM_FILE_ERROR_NOT_FOUND; if (file_util::DirectoryExists(path)) return base::PLATFORM_FILE_ERROR_NOT_A_FILE; - if (!file_util::Delete(path, false)) + if (!base::Delete(path, false)) return base::PLATFORM_FILE_ERROR_FAILED; return base::PLATFORM_FILE_OK; } @@ -254,7 +254,7 @@ PlatformFileError NativeFileUtil::DeleteDirectory(const base::FilePath& path) { return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; if (!file_util::IsDirectoryEmpty(path)) return base::PLATFORM_FILE_ERROR_NOT_EMPTY; - if (!file_util::Delete(path, false)) + if (!base::Delete(path, false)) return base::PLATFORM_FILE_ERROR_FAILED; return base::PLATFORM_FILE_OK; } diff --git a/webkit/browser/fileapi/obfuscated_file_util.cc b/webkit/browser/fileapi/obfuscated_file_util.cc index d3a680882..a5e5ab3 100644 --- a/webkit/browser/fileapi/obfuscated_file_util.cc +++ b/webkit/browser/fileapi/obfuscated_file_util.cc @@ -901,7 +901,7 @@ bool ObfuscatedFileUtil::DeleteDirectoryForOriginAndType( // implementation. // Information about failure would be useful for debugging. DestroyDirectoryDatabase(origin, type); - if (!file_util::Delete(origin_type_path, true /* recursive */)) + if (!base::Delete(origin_type_path, true /* recursive */)) return false; } @@ -935,7 +935,7 @@ bool ObfuscatedFileUtil::DeleteDirectoryForOriginAndType( origin_database_->RemovePathForOrigin( webkit_database::GetIdentifierFromOrigin(origin)); } - if (!file_util::Delete(origin_path, true /* recursive */)) + if (!base::Delete(origin_path, true /* recursive */)) return false; return true; @@ -1104,7 +1104,7 @@ PlatformFileError ObfuscatedFileUtil::CreateFile( created = true; } else { if (file_util::PathExists(dest_local_path)) { - if (!file_util::Delete(dest_local_path, true /* recursive */)) { + if (!base::Delete(dest_local_path, true /* recursive */)) { NOTREACHED(); return base::PLATFORM_FILE_ERROR_FAILED; } @@ -1129,7 +1129,7 @@ PlatformFileError ObfuscatedFileUtil::CreateFile( if (handle) { DCHECK_NE(base::kInvalidPlatformFileValue, *handle); base::ClosePlatformFile(*handle); - file_util::Delete(dest_local_path, false /* recursive */); + base::Delete(dest_local_path, false /* recursive */); } return base::PLATFORM_FILE_ERROR_FAILED; } @@ -1145,7 +1145,7 @@ PlatformFileError ObfuscatedFileUtil::CreateFile( DCHECK_NE(base::kInvalidPlatformFileValue, *handle); base::ClosePlatformFile(*handle); } - file_util::Delete(dest_local_path, false /* recursive */); + base::Delete(dest_local_path, false /* recursive */); return base::PLATFORM_FILE_ERROR_FAILED; } TouchDirectory(db, dest_file_info->parent_id); @@ -1240,7 +1240,7 @@ base::FilePath ObfuscatedFileUtil::GetDirectoryForOrigin( base::FilePath path = file_system_directory_.Append(directory_name); bool exists_in_fs = file_util::DirectoryExists(path); if (!exists_in_db && exists_in_fs) { - if (!file_util::Delete(path, true)) { + if (!base::Delete(path, true)) { if (error_code) *error_code = base::PLATFORM_FILE_ERROR_FAILED; return base::FilePath(); diff --git a/webkit/browser/fileapi/obfuscated_file_util_unittest.cc b/webkit/browser/fileapi/obfuscated_file_util_unittest.cc index 10a818c..ec87a49 100644 --- a/webkit/browser/fileapi/obfuscated_file_util_unittest.cc +++ b/webkit/browser/fileapi/obfuscated_file_util_unittest.cc @@ -867,7 +867,7 @@ TEST_F(ObfuscatedFileUtilTest, TestQuotaOnTruncation) { UnlimitedContext().get(), url, &local_path)); ASSERT_FALSE(local_path.empty()); - ASSERT_TRUE(file_util::Delete(local_path, false)); + ASSERT_TRUE(base::Delete(local_path, false)); EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, ofu()->Truncate( @@ -1670,7 +1670,7 @@ TEST_F(ObfuscatedFileUtilTest, TestIncompleteDirectoryReading) { base::FilePath local_path; EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->GetLocalFilePath(context.get(), kPath[0], &local_path)); - EXPECT_TRUE(file_util::Delete(local_path, false)); + EXPECT_TRUE(base::Delete(local_path, false)); entries.clear(); EXPECT_EQ(base::PLATFORM_FILE_OK, diff --git a/webkit/browser/fileapi/sandbox_database_test_helper.cc b/webkit/browser/fileapi/sandbox_database_test_helper.cc index b44ba6a..18babdb 100644 --- a/webkit/browser/fileapi/sandbox_database_test_helper.cc +++ b/webkit/browser/fileapi/sandbox_database_test_helper.cc @@ -90,7 +90,7 @@ void DeleteDatabaseFile(const base::FilePath& db_path, EXPECT_TRUE(leveldb::ParseFileName(FilePathToString(file_path.BaseName()), &number, &file_type)); if (file_type == type) { - file_util::Delete(file_path, false); + base::Delete(file_path, false); // We may have multiple files for the same type, so don't break here. } } diff --git a/webkit/browser/fileapi/sandbox_directory_database.cc b/webkit/browser/fileapi/sandbox_directory_database.cc index 9b6d070..41cc429 100644 --- a/webkit/browser/fileapi/sandbox_directory_database.cc +++ b/webkit/browser/fileapi/sandbox_directory_database.cc @@ -309,7 +309,7 @@ bool DatabaseCheckHelper::ScanDirectory() { std::set<base::FilePath>::iterator itr = files_in_db_.find(relative_file_path); if (itr == files_in_db_.end()) { - if (!file_util::Delete(absolute_file_path, false)) + if (!base::Delete(absolute_file_path, false)) return false; } else { files_in_db_.erase(itr); @@ -748,7 +748,7 @@ bool SandboxDirectoryDatabase::Init(RecoveryOption recovery_option) { // fall through case DELETE_ON_CORRUPTION: LOG(WARNING) << "Clearing SandboxDirectoryDatabase."; - if (!file_util::Delete(filesystem_data_directory_, true)) + if (!base::Delete(filesystem_data_directory_, true)) return false; if (!file_util::CreateDirectory(filesystem_data_directory_)) return false; diff --git a/webkit/browser/fileapi/sandbox_directory_database_unittest.cc b/webkit/browser/fileapi/sandbox_directory_database_unittest.cc index f38a5b4..e163c8b 100644 --- a/webkit/browser/fileapi/sandbox_directory_database_unittest.cc +++ b/webkit/browser/fileapi/sandbox_directory_database_unittest.cc @@ -100,7 +100,7 @@ class SandboxDirectoryDatabaseTest : public testing::Test { void ClearDatabaseAndDirectory() { db_.reset(); - ASSERT_TRUE(file_util::Delete(path(), true /* recursive */)); + ASSERT_TRUE(base::Delete(path(), true /* recursive */)); ASSERT_TRUE(file_util::CreateDirectory(path())); db_.reset(new SandboxDirectoryDatabase(path())); } @@ -535,7 +535,7 @@ TEST_F(SandboxDirectoryDatabaseTest, CreateFile(0, FPL("foo"), kBackingFileName, NULL); EXPECT_TRUE(db()->IsFileSystemConsistent()); - ASSERT_TRUE(file_util::Delete(path().Append(kBackingFileName), false)); + ASSERT_TRUE(base::Delete(path().Append(kBackingFileName), false)); CreateFile(0, FPL("bar"), kBackingFileName, NULL); EXPECT_FALSE(db()->IsFileSystemConsistent()); } @@ -545,7 +545,7 @@ TEST_F(SandboxDirectoryDatabaseTest, TestConsistencyCheck_FileLost) { CreateFile(0, FPL("foo"), kBackingFileName, NULL); EXPECT_TRUE(db()->IsFileSystemConsistent()); - ASSERT_TRUE(file_util::Delete(path().Append(kBackingFileName), false)); + ASSERT_TRUE(base::Delete(path().Append(kBackingFileName), false)); EXPECT_TRUE(db()->IsFileSystemConsistent()); } diff --git a/webkit/browser/fileapi/sandbox_isolated_origin_database.cc b/webkit/browser/fileapi/sandbox_isolated_origin_database.cc index f382cf4..1f15573 100644 --- a/webkit/browser/fileapi/sandbox_isolated_origin_database.cc +++ b/webkit/browser/fileapi/sandbox_isolated_origin_database.cc @@ -73,7 +73,7 @@ void SandboxIsolatedOriginDatabase::MigrateDatabaseIfNeeded() { base::FilePath to_path = file_system_directory_.Append(kOriginDirectory); if (file_util::PathExists(to_path)) - file_util::Delete(to_path, true /* recursive */); + base::Delete(to_path, true /* recursive */); file_util::Move(from_path, to_path); } diff --git a/webkit/browser/fileapi/sandbox_origin_database.cc b/webkit/browser/fileapi/sandbox_origin_database.cc index 02c5a3a..0d7d3ef 100644 --- a/webkit/browser/fileapi/sandbox_origin_database.cc +++ b/webkit/browser/fileapi/sandbox_origin_database.cc @@ -108,7 +108,7 @@ bool SandboxOriginDatabase::Init(InitOption init_option, DB_REPAIR_FAILED, DB_REPAIR_MAX); // fall through case DELETE_ON_CORRUPTION: - if (!file_util::Delete(file_system_directory_, true)) + if (!base::Delete(file_system_directory_, true)) return false; if (!file_util::CreateDirectory(file_system_directory_)) return false; @@ -167,7 +167,7 @@ bool SandboxOriginDatabase::RepairDatabase(const std::string& db_path) { for (std::set<base::FilePath>::iterator dir_itr = directories.begin(); dir_itr != directories.end(); ++dir_itr) { - if (!file_util::Delete(file_system_directory_.Append(*dir_itr), + if (!base::Delete(file_system_directory_.Append(*dir_itr), true /* recursive */)) { DropDatabase(); return false; @@ -301,7 +301,7 @@ base::FilePath SandboxOriginDatabase::GetDatabasePath() const { void SandboxOriginDatabase::RemoveDatabase() { DropDatabase(); - file_util::Delete(GetDatabasePath(), true /* recursive */); + base::Delete(GetDatabasePath(), true /* recursive */); } bool SandboxOriginDatabase::GetLastPathNumber(int* number) { diff --git a/webkit/plugins/npapi/plugin_instance.cc b/webkit/plugins/npapi/plugin_instance.cc index beabcd6..d4d74aa 100644 --- a/webkit/plugins/npapi/plugin_instance.cc +++ b/webkit/plugins/npapi/plugin_instance.cc @@ -243,7 +243,7 @@ void PluginInstance::NPP_Destroy() { for (unsigned int file_index = 0; file_index < files_created_.size(); file_index++) { - file_util::Delete(files_created_[file_index], false); + base::Delete(files_created_[file_index], false); } // Ensure that no timer callbacks are invoked after NPP_Destroy. diff --git a/webkit/plugins/npapi/plugin_stream_posix.cc b/webkit/plugins/npapi/plugin_stream_posix.cc index 775974c..7b02968 100644 --- a/webkit/plugins/npapi/plugin_stream_posix.cc +++ b/webkit/plugins/npapi/plugin_stream_posix.cc @@ -38,7 +38,7 @@ bool PluginStream::OpenTempFile() { temp_file_ = file_util::OpenFile(temp_file_path_, "a"); if (!temp_file_) { - file_util::Delete(temp_file_path_, false); + base::Delete(temp_file_path_, false); ResetTempFileName(); return false; } diff --git a/webkit/support/simple_database_system.cc b/webkit/support/simple_database_system.cc new file mode 100644 index 0000000..91f7c4f --- /dev/null +++ b/webkit/support/simple_database_system.cc @@ -0,0 +1,319 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/support/simple_database_system.h" + +#include "base/auto_reset.h" +#include "base/bind.h" +#include "base/bind_helpers.h" +#include "base/file_util.h" +#include "base/message_loop.h" +#include "base/message_loop/message_loop_proxy.h" +#include "base/strings/utf_string_conversions.h" +#include "base/synchronization/waitable_event.h" +#include "base/threading/platform_thread.h" +#include "third_party/WebKit/public/platform/WebCString.h" +#include "third_party/WebKit/public/platform/WebString.h" +#include "third_party/WebKit/public/web/WebDatabase.h" +#include "third_party/sqlite/sqlite3.h" +#include "webkit/browser/database/database_util.h" +#include "webkit/browser/database/vfs_backend.h" + +using webkit_database::DatabaseTracker; +using webkit_database::DatabaseUtil; +using webkit_database::OriginInfo; +using webkit_database::VfsBackend; + +SimpleDatabaseSystem* SimpleDatabaseSystem::instance_ = NULL; + +SimpleDatabaseSystem* SimpleDatabaseSystem::GetInstance() { + DCHECK(instance_); + return instance_; +} + +SimpleDatabaseSystem::SimpleDatabaseSystem() + : db_thread_("SimpleDBThread"), + quota_per_origin_(5 * 1024 * 1024), + open_connections_(new webkit_database::DatabaseConnectionsWrapper) { + DCHECK(!instance_); + instance_ = this; + CHECK(temp_dir_.CreateUniqueTempDir()); + db_tracker_ = + new DatabaseTracker(temp_dir_.path(), false, NULL, NULL, NULL); + db_tracker_->AddObserver(this); + db_thread_.Start(); + db_thread_proxy_ = db_thread_.message_loop_proxy(); +} + +SimpleDatabaseSystem::~SimpleDatabaseSystem() { + base::WaitableEvent done_event(false, false); + db_thread_proxy_->PostTask( + FROM_HERE, + base::Bind(&SimpleDatabaseSystem::ThreadCleanup, + base::Unretained(this), &done_event)); + done_event.Wait(); + instance_ = NULL; +} + +void SimpleDatabaseSystem::databaseOpened(const WebKit::WebDatabase& database) { + std::string origin_identifier = + database.securityOrigin().databaseIdentifier().utf8(); + base::string16 database_name = database.name(); + open_connections_->AddOpenConnection(origin_identifier, database_name); + db_thread_proxy_->PostTask( + FROM_HERE, + base::Bind(&SimpleDatabaseSystem::DatabaseOpened, + base::Unretained(this), + origin_identifier, + database_name, database.displayName(), + database.estimatedSize())); +} + +void SimpleDatabaseSystem::databaseModified( + const WebKit::WebDatabase& database) { + db_thread_proxy_->PostTask( + FROM_HERE, + base::Bind(&SimpleDatabaseSystem::DatabaseModified, + base::Unretained(this), + database.securityOrigin().databaseIdentifier().utf8(), + database.name())); +} + +void SimpleDatabaseSystem::databaseClosed(const WebKit::WebDatabase& database) { + std::string origin_identifier = + database.securityOrigin().databaseIdentifier().utf8(); + base::string16 database_name = database.name(); + db_thread_proxy_->PostTask( + FROM_HERE, + base::Bind(&SimpleDatabaseSystem::DatabaseClosed, + base::Unretained(this), origin_identifier, database_name)); +} + +base::PlatformFile SimpleDatabaseSystem::OpenFile( + const base::string16& vfs_file_name, int desired_flags) { + base::PlatformFile result = base::kInvalidPlatformFileValue; + base::WaitableEvent done_event(false, false); + db_thread_proxy_->PostTask( + FROM_HERE, + base::Bind(&SimpleDatabaseSystem::VfsOpenFile, + base::Unretained(this), + vfs_file_name, desired_flags, + &result, &done_event)); + done_event.Wait(); + return result; +} + +int SimpleDatabaseSystem::DeleteFile( + const base::string16& vfs_file_name, bool sync_dir) { + int result = SQLITE_OK; + base::WaitableEvent done_event(false, false); + db_thread_proxy_->PostTask( + FROM_HERE, + base::Bind(&SimpleDatabaseSystem::VfsDeleteFile, + base::Unretained(this), + vfs_file_name, sync_dir, + &result, &done_event)); + done_event.Wait(); + return result; +} + +uint32 SimpleDatabaseSystem::GetFileAttributes( + const base::string16& vfs_file_name) { + uint32 result = 0; + base::WaitableEvent done_event(false, false); + db_thread_proxy_->PostTask( + FROM_HERE, + base::Bind(&SimpleDatabaseSystem::VfsGetFileAttributes, + base::Unretained(this), vfs_file_name, &result, &done_event)); + done_event.Wait(); + return result; +} + +int64 SimpleDatabaseSystem::GetFileSize(const base::string16& vfs_file_name) { + int64 result = 0; + base::WaitableEvent done_event(false, false); + db_thread_proxy_->PostTask( + FROM_HERE, + base::Bind(&SimpleDatabaseSystem::VfsGetFileSize, + base::Unretained(this), vfs_file_name, &result, &done_event)); + done_event.Wait(); + return result; +} + +int64 SimpleDatabaseSystem::GetSpaceAvailable( + const std::string& origin_identifier) { + int64 result = 0; + base::WaitableEvent done_event(false, false); + db_thread_proxy_->PostTask( + FROM_HERE, + base::Bind(&SimpleDatabaseSystem::VfsGetSpaceAvailable, + base::Unretained(this), origin_identifier, + &result, &done_event)); + done_event.Wait(); + return result; +} + +void SimpleDatabaseSystem::ClearAllDatabases() { + open_connections_->WaitForAllDatabasesToClose(); + db_thread_proxy_->PostTask( + FROM_HERE, + base::Bind(&SimpleDatabaseSystem::ResetTracker, base::Unretained(this))); +} + +void SimpleDatabaseSystem::SetDatabaseQuota(int64 quota) { + if (!db_thread_proxy_->BelongsToCurrentThread()) { + db_thread_proxy_->PostTask( + FROM_HERE, + base::Bind(&SimpleDatabaseSystem::SetDatabaseQuota, + base::Unretained(this), quota)); + return; + } + quota_per_origin_ = quota; +} + +void SimpleDatabaseSystem::DatabaseOpened( + const std::string& origin_identifier, + const base::string16& database_name, + const base::string16& description, + int64 estimated_size) { + DCHECK(db_thread_proxy_->BelongsToCurrentThread()); + int64 database_size = 0; + db_tracker_->DatabaseOpened( + origin_identifier, database_name, description, + estimated_size, &database_size); + OnDatabaseSizeChanged(origin_identifier, database_name, + database_size); +} + +void SimpleDatabaseSystem::DatabaseModified( + const std::string& origin_identifier, + const base::string16& database_name) { + DCHECK(db_thread_proxy_->BelongsToCurrentThread()); + db_tracker_->DatabaseModified(origin_identifier, database_name); +} + +void SimpleDatabaseSystem::DatabaseClosed( + const std::string& origin_identifier, + const base::string16& database_name) { + DCHECK(db_thread_proxy_->BelongsToCurrentThread()); + db_tracker_->DatabaseClosed(origin_identifier, database_name); + open_connections_->RemoveOpenConnection(origin_identifier, database_name); +} + +void SimpleDatabaseSystem::OnDatabaseSizeChanged( + const std::string& origin_identifier, + const base::string16& database_name, + int64 database_size) { + DCHECK(db_thread_proxy_->BelongsToCurrentThread()); + // We intentionally call into webkit on our background db_thread_ + // to better emulate what happens in chrome where this method is + // invoked on the background ipc thread. + WebKit::WebDatabase::updateDatabaseSize( + WebKit::WebString::fromUTF8(origin_identifier), + database_name, database_size); +} + +void SimpleDatabaseSystem::OnDatabaseScheduledForDeletion( + const std::string& origin_identifier, + const base::string16& database_name) { + DCHECK(db_thread_proxy_->BelongsToCurrentThread()); + // We intentionally call into webkit on our background db_thread_ + // to better emulate what happens in chrome where this method is + // invoked on the background ipc thread. + WebKit::WebDatabase::closeDatabaseImmediately( + WebKit::WebString::fromUTF8(origin_identifier), database_name); +} + +void SimpleDatabaseSystem::VfsOpenFile( + const base::string16& vfs_file_name, int desired_flags, + base::PlatformFile* file_handle, base::WaitableEvent* done_event ) { + DCHECK(db_thread_proxy_->BelongsToCurrentThread()); + base::FilePath file_name = GetFullFilePathForVfsFile(vfs_file_name); + if (file_name.empty()) { + VfsBackend::OpenTempFileInDirectory( + db_tracker_->DatabaseDirectory(), desired_flags, file_handle); + } else { + VfsBackend::OpenFile(file_name, desired_flags, file_handle); + } + done_event->Signal(); +} + +void SimpleDatabaseSystem::VfsDeleteFile( + const base::string16& vfs_file_name, bool sync_dir, + int* result, base::WaitableEvent* done_event) { + DCHECK(db_thread_proxy_->BelongsToCurrentThread()); + // We try to delete the file multiple times, because that's what the default + // VFS does (apparently deleting a file can sometimes fail on Windows). + // We sleep for 10ms between retries for the same reason. + const int kNumDeleteRetries = 3; + int num_retries = 0; + *result = SQLITE_OK; + base::FilePath file_name = GetFullFilePathForVfsFile(vfs_file_name); + do { + *result = VfsBackend::DeleteFile(file_name, sync_dir); + } while ((++num_retries < kNumDeleteRetries) && + (*result == SQLITE_IOERR_DELETE) && + (base::PlatformThread::Sleep( + base::TimeDelta::FromMilliseconds(10)), + 1)); + + done_event->Signal(); +} + +void SimpleDatabaseSystem::VfsGetFileAttributes( + const base::string16& vfs_file_name, + uint32* result, base::WaitableEvent* done_event) { + DCHECK(db_thread_proxy_->BelongsToCurrentThread()); + *result = VfsBackend::GetFileAttributes( + GetFullFilePathForVfsFile(vfs_file_name)); + done_event->Signal(); +} + +void SimpleDatabaseSystem::VfsGetFileSize( + const base::string16& vfs_file_name, + int64* result, base::WaitableEvent* done_event) { + DCHECK(db_thread_proxy_->BelongsToCurrentThread()); + *result = VfsBackend::GetFileSize(GetFullFilePathForVfsFile(vfs_file_name)); + done_event->Signal(); +} + +void SimpleDatabaseSystem::VfsGetSpaceAvailable( + const std::string& origin_identifier, + int64* result, base::WaitableEvent* done_event) { + DCHECK(db_thread_proxy_->BelongsToCurrentThread()); + // This method isn't actually part of the "vfs" interface, but it is + // used from within webcore and handled here in the same fashion. + OriginInfo info; + if (db_tracker_->GetOriginInfo(origin_identifier, &info)) { + int64 space_available = quota_per_origin_ - info.TotalSize(); + *result = space_available < 0 ? 0 : space_available; + } else { + NOTREACHED(); + *result = 0; + } + done_event->Signal(); +} + +base::FilePath SimpleDatabaseSystem::GetFullFilePathForVfsFile( + const base::string16& vfs_file_name) { + DCHECK(db_thread_proxy_->BelongsToCurrentThread()); + if (vfs_file_name.empty()) // temp file, used for vacuuming + return base::FilePath(); + return DatabaseUtil::GetFullFilePathForVfsFile( + db_tracker_.get(), vfs_file_name); +} + +void SimpleDatabaseSystem::ResetTracker() { + DCHECK(db_thread_proxy_->BelongsToCurrentThread()); + db_tracker_->CloseTrackerDatabaseAndClearCaches(); + base::Delete(db_tracker_->DatabaseDirectory(), true); +} + +void SimpleDatabaseSystem::ThreadCleanup(base::WaitableEvent* done_event) { + ResetTracker(); + db_tracker_->RemoveObserver(this); + db_tracker_ = NULL; + done_event->Signal(); +} + |