Index: chrome/browser/component_updater/component_updater_utils.cc |
diff --git a/chrome/browser/component_updater/component_updater_utils.cc b/chrome/browser/component_updater/component_updater_utils.cc |
index e86f72c8a998807080881fc2d0254850bad66545..2378f52fb0bde1fc84aed97edcdd10f51f8c03bf 100644 |
--- a/chrome/browser/component_updater/component_updater_utils.cc |
+++ b/chrome/browser/component_updater/component_updater_utils.cc |
@@ -3,6 +3,8 @@ |
// found in the LICENSE file. |
#include "chrome/browser/component_updater/component_updater_utils.h" |
+#include "base/file_util.h" |
+#include "base/files/file_path.h" |
#include "base/guid.h" |
#include "base/strings/stringprintf.h" |
#include "base/sys_info.h" |
@@ -102,10 +104,20 @@ int GetFetchError(const net::URLFetcher& fetcher) { |
} |
} |
- |
bool IsHttpServerError(int status_code) { |
return 500 <= status_code && status_code < 600; |
} |
+bool DeleteFileAndParentDirectoryIfEmpty(const base::FilePath& filepath) { |
+ if (!base::DeleteFile(filepath, false)) |
+ return false; |
+ |
+ const base::FilePath dirname(filepath.DirName()); |
+ if (!base::IsDirectoryEmpty(dirname)) |
+ return false; |
+ |
+ return base::DeleteFile(dirname, false); |
+} |
+ |
} // namespace component_updater |