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

Unified Diff: base/test/test_file_util_linux.cc

Issue 2885423002: Provide base::EvictFileFromSystemCache on Android on ARM32 (Closed)
Patch Set: Apply review feedback. Created 3 years, 7 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 | « base/test/BUILD.gn ('k') | base/test/test_file_util_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/test_file_util_linux.cc
diff --git a/base/test/test_file_util_linux.cc b/base/test/test_file_util_linux.cc
index 0ef5c0a1571041da64665bbf1673f0cce268396d..cf8b05627297e4daa5b79ff53152b129671f524a 100644
--- a/base/test/test_file_util_linux.cc
+++ b/base/test/test_file_util_linux.cc
@@ -9,11 +9,42 @@
#include <sys/types.h>
#include <unistd.h>
+#if defined(OS_ANDROID)
+#include <asm/unistd.h>
+#include <errno.h>
+#include <linux/fadvise.h>
+#include <sys/syscall.h>
+#endif
+
#include "base/files/file_path.h"
#include "base/files/scoped_file.h"
namespace base {
+// Inconveniently, the NDK doesn't provide for posix_fadvise
+// until native API level = 21, which we don't use yet, so provide a wrapper, at
+// least on ARM32
+#if defined(OS_ANDROID) && __ANDROID_API__ < 21
Paweł Hajdan Jr. 2017/05/31 15:28:13 If this is android-specific, why force a _linux fi
Maks Orlovich 2017/05/31 15:30:25 So I can put it in an anonymous namespace (seems p
+
+namespace {
+int posix_fadvise(int fd, off_t offset, off_t len, int advice) {
+#if defined(ARCH_CPU_ARMEL)
+ // Note that the syscall argument order on ARM is different from the C
+ // function; this is helpfully documented in the Linux posix_fadvise manpage.
+ return syscall(__NR_arm_fadvise64_64, fd, advice,
+ 0, // Upper 32-bits for offset
+ offset,
+ 0, // Upper 32-bits for length
+ len);
+#endif
+ NOTIMPLEMENTED();
+ return ENOSYS;
+}
+
+} // namespace
+
+#endif // OS_ANDROID
+
bool EvictFileFromSystemCache(const FilePath& file) {
ScopedFD fd(open(file.value().c_str(), O_RDONLY));
if (!fd.is_valid())
« no previous file with comments | « base/test/BUILD.gn ('k') | base/test/test_file_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698