Index: chrome/test/chromedriver/chrome/scoped_temp_dir_with_retry.cc |
diff --git a/chrome/test/chromedriver/chrome/scoped_temp_dir_with_retry.cc b/chrome/test/chromedriver/chrome/scoped_temp_dir_with_retry.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6d2345d2a99f4ca80d06dc1d73d0b70d061d8ac1 |
--- /dev/null |
+++ b/chrome/test/chromedriver/chrome/scoped_temp_dir_with_retry.cc |
@@ -0,0 +1,21 @@ |
+// Copyright (c) 2017 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 "chrome/test/chromedriver/chrome/scoped_temp_dir_with_retry.h" |
+#include "base/threading/platform_thread.h" |
+ |
+ScopedTempDirWithRetry::~ScopedTempDirWithRetry() { |
+ if (IsValid()) { |
+ int retry = 0; |
+ while (!Delete()) { |
+ // Delete failed. Retry up to 100 times, with 10 ms delay between each |
+ // retry (thus maximum delay is about 1 second). |
+ if (++retry > 100) { |
+ DLOG(WARNING) << "Could not delete temp dir in dtor."; |
stgao
2017/05/03 20:16:50
nit: It's unclear what dtor means.
|
+ break; |
+ } |
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10)); |
+ } |
+ } |
+} |