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

Unified Diff: chrome/test/chromedriver/chrome/scoped_temp_dir_with_retry.cc

Issue 2853953002: [Chromedriver] Retry deleting temp dir when needed (Closed)
Patch Set: Fix warning message Created 3 years, 8 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 | « chrome/test/chromedriver/chrome/scoped_temp_dir_with_retry.h ('k') | chrome/test/chromedriver/session.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e4f5140f562e3940ef52fd1a7d20821230a5417a
--- /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 after retries.";
+ break;
+ }
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
+ }
+ }
+}
« no previous file with comments | « chrome/test/chromedriver/chrome/scoped_temp_dir_with_retry.h ('k') | chrome/test/chromedriver/session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698