Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1528)

Unified Diff: base/files/file_util_win.cc

Issue 2854323002: Make TestingProfile delete failures explicitly CHECK-fail.
Patch Set: TEMP: Deliberately crash tests on ~ScopedTempDir, to see logs. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/files/scoped_temp_dir.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_util_win.cc
diff --git a/base/files/file_util_win.cc b/base/files/file_util_win.cc
index 294726a8279089098c812fff6c35738d6dd65660..923514568c350a5af1a4985f5e82232a2820df0f 100644
--- a/base/files/file_util_win.cc
+++ b/base/files/file_util_win.cc
@@ -90,37 +90,58 @@ FilePath MakeAbsoluteFilePath(const FilePath& input) {
}
bool DeleteFile(const FilePath& path, bool recursive) {
+ LOG(WARNING) << "base::DeleteFile: Asserting IO allowed";
ThreadRestrictions::AssertIOAllowed();
- if (path.empty())
+ LOG(WARNING) << "base::DeleteFile: IO allowed assertion is OK";
+ if (path.empty()) {
+ LOG(WARNING) << "base::DeleteFile: Succeeded (path was empty)";
return true;
+ }
- if (path.value().length() >= MAX_PATH)
+ if (path.value().length() >= MAX_PATH) {
+ LOG(WARNING) << "base::DeleteFile: Failed (path was too long)";
return false;
+ }
// Handle any path with wildcards.
if (path.BaseName().value().find_first_of(L"*?") !=
FilePath::StringType::npos) {
- return DeleteFileRecursive(path.DirName(), path.BaseName().value(),
- recursive);
+ bool r =
+ DeleteFileRecursive(path.DirName(), path.BaseName().value(), recursive);
+ LOG(WARNING) << "base::DeleteFile: " << (r ? "succeeded" : "failed")
+ << " due to DeleteFileRecursive.";
+ return r;
}
DWORD attr = GetFileAttributes(path.value().c_str());
// We're done if we can't find the path.
- if (attr == INVALID_FILE_ATTRIBUTES)
+ if (attr == INVALID_FILE_ATTRIBUTES) {
+ LOG(WARNING) << "base::DeleteFile: Succeeded because doesn't exist.";
return true;
+ }
// We may need to clear the read-only bit.
if ((attr & FILE_ATTRIBUTE_READONLY) &&
!SetFileAttributes(path.value().c_str(),
attr & ~FILE_ATTRIBUTE_READONLY)) {
+ LOG(WARNING) << "base::DeleteFile: Failed because read only.";
return false;
}
// Directories are handled differently if they're recursive.
- if (!(attr & FILE_ATTRIBUTE_DIRECTORY))
- return !!::DeleteFile(path.value().c_str());
+ if (!(attr & FILE_ATTRIBUTE_DIRECTORY)) {
+ bool r = !!::DeleteFile(path.value().c_str());
+ LOG(WARNING) << "base::DeleteFile: " << (r ? "succeeded" : "failed")
+ << " due to ::DeleteFile.";
+ return r;
+ }
// Handle a simple, single file delete.
- if (!recursive || DeleteFileRecursive(path, L"*", true))
- return !!RemoveDirectory(path.value().c_str());
+ if (!recursive || DeleteFileRecursive(path, L"*", true)) {
+ bool r = !!RemoveDirectory(path.value().c_str());
+ LOG(WARNING) << "base::DeleteFile: " << (r ? "succeeded" : "failed")
+ << " due to RemoveDirectory.";
+ return r;
+ }
+ LOG(WARNING) << "base::DeleteFile: Failed because ???.";
return false;
}
« no previous file with comments | « no previous file | base/files/scoped_temp_dir.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698