OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/test/test_file_util.h" | 5 #include "base/test/test_file_util.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <aclapi.h> | 8 #include <aclapi.h> |
9 #include <shlwapi.h> | 9 #include <shlwapi.h> |
10 | 10 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } | 112 } |
113 | 113 |
114 } // namespace | 114 } // namespace |
115 | 115 |
116 bool DieFileDie(const base::FilePath& file, bool recurse) { | 116 bool DieFileDie(const base::FilePath& file, bool recurse) { |
117 // It turns out that to not induce flakiness a long timeout is needed. | 117 // It turns out that to not induce flakiness a long timeout is needed. |
118 const int kIterations = 25; | 118 const int kIterations = 25; |
119 const base::TimeDelta kTimeout = base::TimeDelta::FromSeconds(10) / | 119 const base::TimeDelta kTimeout = base::TimeDelta::FromSeconds(10) / |
120 kIterations; | 120 kIterations; |
121 | 121 |
122 if (!file_util::PathExists(file)) | 122 if (!base::PathExists(file)) |
123 return true; | 123 return true; |
124 | 124 |
125 // Sometimes Delete fails, so try a few more times. Divide the timeout | 125 // Sometimes Delete fails, so try a few more times. Divide the timeout |
126 // into short chunks, so that if a try succeeds, we won't delay the test | 126 // into short chunks, so that if a try succeeds, we won't delay the test |
127 // for too long. | 127 // for too long. |
128 for (int i = 0; i < kIterations; ++i) { | 128 for (int i = 0; i < kIterations; ++i) { |
129 if (base::Delete(file, recurse)) | 129 if (base::Delete(file, recurse)) |
130 return true; | 130 return true; |
131 base::PlatformThread::Sleep(kTimeout); | 131 base::PlatformThread::Sleep(kTimeout); |
132 } | 132 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 DCHECK(info_ != NULL); | 282 DCHECK(info_ != NULL); |
283 DCHECK_NE(0u, length_); | 283 DCHECK_NE(0u, length_); |
284 } | 284 } |
285 | 285 |
286 PermissionRestorer::~PermissionRestorer() { | 286 PermissionRestorer::~PermissionRestorer() { |
287 if (!RestorePermissionInfo(path_, info_, length_)) | 287 if (!RestorePermissionInfo(path_, info_, length_)) |
288 NOTREACHED(); | 288 NOTREACHED(); |
289 } | 289 } |
290 | 290 |
291 } // namespace file_util | 291 } // namespace file_util |
OLD | NEW |