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

Unified Diff: base/test_file_util_win.cc

Issue 159658: Remove duplication of DieFileDie, and move it to proper location. (Closed)
Patch Set: Created 11 years, 5 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 | « base/test_file_util_posix.cc ('k') | chrome/browser/download/save_page_uitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test_file_util_win.cc
diff --git a/base/test_file_util_win.cc b/base/test_file_util_win.cc
index f6a5becfbd2a4e927d949bef1e0dda215cf4957e..600f30a5d8c62f7e160320d29bf286e4e76afc71 100644
--- a/base/test_file_util_win.cc
+++ b/base/test_file_util_win.cc
@@ -11,6 +11,7 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/logging.h"
+#include "base/platform_thread.h"
#include "base/scoped_handle.h"
namespace file_util {
@@ -19,6 +20,24 @@ namespace file_util {
// our purpose fine since 4K is the page size on x86 as well as x64.
static const ptrdiff_t kPageSize = 4096;
+bool DieFileDie(const FilePath& file, bool recurse) {
+ // It turns out that to not induce flakiness a long timeout is needed.
+ const int kTimeoutMs = 10000;
+
+ if (!file_util::PathExists(file))
+ return true;
+
+ // Sometimes Delete fails, so try a few more times. Divide the timeout
+ // into short chunks, so that if a try succeeds, we won't delay the test
+ // for too long.
+ for (int i = 0; i < 25; ++i) {
+ if (file_util::Delete(file, recurse))
+ return true;
+ PlatformThread::Sleep(kTimeoutMs / 25);
+ }
+ return false;
+}
+
bool EvictFileFromSystemCache(const FilePath& file) {
// Request exclusive access to the file and overwrite it with no buffering.
ScopedHandle file_handle(
« no previous file with comments | « base/test_file_util_posix.cc ('k') | chrome/browser/download/save_page_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698