Chromium Code Reviews| 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. |permission| is an | |
| 48 // ACCESS_MARK structure, and its possible values can be found by searching | |
|
Peter Kasting
2016/07/28 20:09:49
MARK -> MASK
WC Leung
2016/08/01 18:03:06
Done, and thanks for catching.
| |
| 49 // "file and directory access rights constants". | |
|
Peter Kasting
2016/07/28 20:09:49
Don't say this; "search" implies codesearch.
Link
WC Leung
2016/08/01 18:03:06
Thanks for explanation. I've also included
https:/
| |
| 50 bool DenyFilePermission(const FilePath& path, DWORD permission); | |
| 51 | |
| 43 // Returns true if the volume supports Alternate Data Streams. | 52 // Returns true if the volume supports Alternate Data Streams. |
| 44 bool VolumeSupportsADS(const FilePath& path); | 53 bool VolumeSupportsADS(const FilePath& path); |
| 45 | 54 |
| 46 // Returns true if the ZoneIdentifier is correctly set to "Internet" (3). | 55 // Returns true if the ZoneIdentifier is correctly set to "Internet" (3). |
| 47 // Note that this function must be called from the same process as | 56 // 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 | 57 // the one that set the zone identifier. I.e. don't use it in UI/automation |
| 49 // based tests. | 58 // based tests. |
| 50 bool HasInternetZoneIdentifier(const FilePath& full_path); | 59 bool HasInternetZoneIdentifier(const FilePath& full_path); |
| 51 #endif // defined(OS_WIN) | 60 #endif // defined(OS_WIN) |
| 52 | 61 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 74 bool RegisterContentUriTestUtils(JNIEnv* env); | 83 bool RegisterContentUriTestUtils(JNIEnv* env); |
| 75 | 84 |
| 76 // Insert an image file into the MediaStore, and retrieve the content URI for | 85 // Insert an image file into the MediaStore, and retrieve the content URI for |
| 77 // testing purpose. | 86 // testing purpose. |
| 78 FilePath InsertImageIntoMediaStore(const FilePath& path); | 87 FilePath InsertImageIntoMediaStore(const FilePath& path); |
| 79 #endif // defined(OS_ANDROID) | 88 #endif // defined(OS_ANDROID) |
| 80 | 89 |
| 81 } // namespace base | 90 } // namespace base |
| 82 | 91 |
| 83 #endif // BASE_TEST_TEST_FILE_UTIL_H_ | 92 #endif // BASE_TEST_TEST_FILE_UTIL_H_ |
| OLD | NEW |