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

Unified Diff: chrome/worker/worker_uitest.cc

Issue 155177: Fix the problem that the temp worker directory is not deleted if the http ser... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/worker/worker_uitest.cc
===================================================================
--- chrome/worker/worker_uitest.cc (revision 20044)
+++ chrome/worker/worker_uitest.cc (working copy)
@@ -5,6 +5,7 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/path_service.h"
+#include "base/platform_thread.h"
#include "base/string_util.h"
#include "chrome/browser/worker_host/worker_service.h"
#include "chrome/common/chrome_paths.h"
@@ -63,8 +64,27 @@
}
WorkerTest::~WorkerTest() {
- if (!temp_test_dir_.empty())
- file_util::Delete(temp_test_dir_, true);
+ // The deletion might fail because HTTP server process might not been
+ // completely shut down yet and is still holding certain handle to it.
+ // To work around this problem, we try to repeat the deletion several
+ // times.
+ if (!temp_test_dir_.empty()) {
+ static const int kRetryNum = 10;
+ static const int kRetryDelayTimeMs = 500;
+
+ int retry_time = 0;
+ for (int i = 0; i < kRetryNum; ++i) {
+ file_util::Delete(temp_test_dir_, true);
+ if (!file_util::DirectoryExists(temp_test_dir_))
+ break;
+
+ PlatformThread::Sleep(kRetryDelayTimeMs);
+ retry_time += kRetryDelayTimeMs;
+ }
+
+ if (retry_time)
+ printf("Retrying %d ms to delete temp worker directory.\n", retry_time);
+ }
}
void WorkerTest::RunTest(const std::wstring& test_case) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698