diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-30 21:27:01 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-30 21:27:01 +0000 |
commit | 23cc9a18ab9c4893e3cad94c3683e7ffecefcbf0 (patch) | |
tree | d446ad54b3e2ee91a4309243310e0a36d48299e6 /base/test_file_util_win.cc | |
parent | ee12b724955c00af4f29b054fea44dca986b2396 (diff) | |
download | chromium_src-23cc9a18ab9c4893e3cad94c3683e7ffecefcbf0.zip chromium_src-23cc9a18ab9c4893e3cad94c3683e7ffecefcbf0.tar.gz chromium_src-23cc9a18ab9c4893e3cad94c3683e7ffecefcbf0.tar.bz2 |
Remove duplication of DieFileDie, and move it to proper location.
TEST=none
http://crbug.com/18085
Review URL: http://codereview.chromium.org/159658
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22103 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/test_file_util_win.cc')
-rw-r--r-- | base/test_file_util_win.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/base/test_file_util_win.cc b/base/test_file_util_win.cc index f6a5bec..600f30a 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( |