[go: nahoru, domu]

base: Support retry for GetDeletePathRecursivelyCallback()

Currently GetDeleteFileCallback() supports retry on Windows. However,
GetDeletePathRecursivelyCallback() doesn't support retry. To make the
behavior consistent, this CL updates GetDeletePathRecursivelyCallback()
to also support retry.

A new UMA is added to record the actual retry count.

Bug: 1321695
Change-Id: I34e413b369acbcd58de7662d4077152ae595e7e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3621141
Reviewed-by: Mark Pearson <mpearson@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: David Bienvenu <davidbienvenu@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Reviewed-by: Greg Thompson <grt@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1005784}
diff --git a/base/files/file_util.cc b/base/files/file_util.cc
index 0528ad26..a186a6c 100644
--- a/base/files/file_util.cc
+++ b/base/files/file_util.cc
@@ -37,6 +37,8 @@
 
 namespace base {
 
+#if !BUILDFLAG(IS_WIN)
+
 namespace {
 
 void RunAndReply(OnceCallback<bool()> action_callback,
@@ -48,7 +50,6 @@
 
 }  // namespace
 
-#if !BUILDFLAG(IS_WIN)
 OnceClosure GetDeleteFileCallback(const FilePath& path,
                                   OnceCallback<void(bool)> reply_callback) {
   return BindOnce(&RunAndReply, BindOnce(&DeleteFile, path),
@@ -57,7 +58,6 @@
                       : BindPostTask(SequencedTaskRunnerHandle::Get(),
                                      std::move(reply_callback)));
 }
-#endif  // !BUILDFLAG(IS_WIN)
 
 OnceClosure GetDeletePathRecursivelyCallback(
     const FilePath& path,
@@ -69,6 +69,8 @@
                                      std::move(reply_callback)));
 }
 
+#endif  // !BUILDFLAG(IS_WIN)
+
 int64_t ComputeDirectorySize(const FilePath& root_path) {
   int64_t running_size = 0;
   FileEnumerator file_iter(root_path, true, FileEnumerator::FILES);