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 #ifndef BASE_TEST_TEST_FILE_UTIL_H_ | 5 #ifndef BASE_TEST_TEST_FILE_UTIL_H_ |
6 #define BASE_TEST_TEST_FILE_UTIL_H_ | 6 #define BASE_TEST_TEST_FILE_UTIL_H_ |
7 | 7 |
8 // File utility functions used only by tests. | 8 // File utility functions used only by tests. |
9 | 9 |
10 #include <stddef.h> | 10 #include <stddef.h> |
11 | 11 |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 | 18 |
19 #if defined(OS_ANDROID) | 19 #if defined(OS_ANDROID) |
20 #include <jni.h> | 20 #include <jni.h> |
21 #endif | 21 #endif |
22 | 22 |
23 #if defined(OS_WIN) | |
24 #include <windows.h> | |
25 #endif | |
26 | |
23 namespace base { | 27 namespace base { |
24 | 28 |
25 class FilePath; | 29 class FilePath; |
26 | 30 |
27 // Clear a specific file from the system cache like EvictFileFromSystemCache, | 31 // Clear a specific file from the system cache like EvictFileFromSystemCache, |
28 // but on failure it will sleep and retry. On the Windows buildbots, eviction | 32 // but on failure it will sleep and retry. On the Windows buildbots, eviction |
29 // can fail if the file is marked in use, and this will throw off timings that | 33 // can fail if the file is marked in use, and this will throw off timings that |
30 // rely on uncached files. | 34 // rely on uncached files. |
31 bool EvictFileFromSystemCacheWithRetry(const FilePath& file); | 35 bool EvictFileFromSystemCacheWithRetry(const FilePath& file); |
32 | 36 |
33 // Wrapper over base::Delete. On Windows repeatedly invokes Delete in case | 37 // Wrapper over base::Delete. On Windows repeatedly invokes Delete in case |
34 // of failure to workaround Windows file locking semantics. Returns true on | 38 // of failure to workaround Windows file locking semantics. Returns true on |
35 // success. | 39 // success. |
36 bool DieFileDie(const FilePath& file, bool recurse); | 40 bool DieFileDie(const FilePath& file, bool recurse); |
37 | 41 |
38 // Clear a specific file from the system cache. After this call, trying | 42 // Clear a specific file from the system cache. After this call, trying |
39 // to access this file will result in a cold load from the hard drive. | 43 // to access this file will result in a cold load from the hard drive. |
40 bool EvictFileFromSystemCache(const FilePath& file); | 44 bool EvictFileFromSystemCache(const FilePath& file); |
41 | 45 |
42 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
47 // Deny |permission| on the file |path|, for the current user. | |
Peter Kasting
2016/07/19 21:56:06
Nit: Might want to say something like "|permission
WC Leung
2016/07/27 18:00:05
Does MSDN urls change? BTW, I'm negative about add
| |
48 bool DenyFilePermission(const FilePath& path, DWORD permission); | |
49 | |
43 // Returns true if the volume supports Alternate Data Streams. | 50 // Returns true if the volume supports Alternate Data Streams. |
44 bool VolumeSupportsADS(const FilePath& path); | 51 bool VolumeSupportsADS(const FilePath& path); |
45 | 52 |
46 // Returns true if the ZoneIdentifier is correctly set to "Internet" (3). | 53 // Returns true if the ZoneIdentifier is correctly set to "Internet" (3). |
47 // Note that this function must be called from the same process as | 54 // Note that this function must be called from the same process as |
48 // the one that set the zone identifier. I.e. don't use it in UI/automation | 55 // the one that set the zone identifier. I.e. don't use it in UI/automation |
49 // based tests. | 56 // based tests. |
50 bool HasInternetZoneIdentifier(const FilePath& full_path); | 57 bool HasInternetZoneIdentifier(const FilePath& full_path); |
51 #endif // defined(OS_WIN) | 58 #endif // defined(OS_WIN) |
52 | 59 |
(...skipping 21 matching lines...) Expand all Loading... | |
74 bool RegisterContentUriTestUtils(JNIEnv* env); | 81 bool RegisterContentUriTestUtils(JNIEnv* env); |
75 | 82 |
76 // Insert an image file into the MediaStore, and retrieve the content URI for | 83 // Insert an image file into the MediaStore, and retrieve the content URI for |
77 // testing purpose. | 84 // testing purpose. |
78 FilePath InsertImageIntoMediaStore(const FilePath& path); | 85 FilePath InsertImageIntoMediaStore(const FilePath& path); |
79 #endif // defined(OS_ANDROID) | 86 #endif // defined(OS_ANDROID) |
80 | 87 |
81 } // namespace base | 88 } // namespace base |
82 | 89 |
83 #endif // BASE_TEST_TEST_FILE_UTIL_H_ | 90 #endif // BASE_TEST_TEST_FILE_UTIL_H_ |
OLD | NEW |