Commit 1e701e32 authored by morlovich's avatar morlovich Committed by Commit Bot

Provide base::EvictFileFromSystemCache on Android on ARM32

This is needed to be able to run disk_cache_perftest on the platform.

This just uses the Linux implementation, but provides a syscall wrapper
since NDK won't provide one at the API level we build for.

BUG=722885

Review-Url: https://codereview.chromium.org/2885423002
Cr-Commit-Position: refs/heads/master@{#476281}
parent 370841f2
...@@ -196,6 +196,9 @@ static_library("test_support") { ...@@ -196,6 +196,9 @@ static_library("test_support") {
} }
if (is_android) { if (is_android) {
set_sources_assignment_filter([])
sources += [ "test_file_util_linux.cc" ]
set_sources_assignment_filter(sources_assignment_filter)
deps += [ deps += [
":base_unittests_jni_headers", ":base_unittests_jni_headers",
":test_support_jni_headers", ":test_support_jni_headers",
......
...@@ -9,11 +9,42 @@ ...@@ -9,11 +9,42 @@
#include <sys/types.h> #include <sys/types.h>
#include <unistd.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/file_path.h"
#include "base/files/scoped_file.h" #include "base/files/scoped_file.h"
namespace base { 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
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) { bool EvictFileFromSystemCache(const FilePath& file) {
ScopedFD fd(open(file.value().c_str(), O_RDONLY)); ScopedFD fd(open(file.value().c_str(), O_RDONLY));
if (!fd.is_valid()) if (!fd.is_valid())
......
...@@ -79,7 +79,7 @@ bool DieFileDie(const FilePath& file, bool recurse) { ...@@ -79,7 +79,7 @@ bool DieFileDie(const FilePath& file, bool recurse) {
return DeleteFile(file, recurse); return DeleteFile(file, recurse);
} }
#if !defined(OS_LINUX) && !defined(OS_MACOSX) #if !defined(OS_LINUX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
bool EvictFileFromSystemCache(const FilePath& file) { bool EvictFileFromSystemCache(const FilePath& file) {
// There doesn't seem to be a POSIX way to cool the disk cache. // There doesn't seem to be a POSIX way to cool the disk cache.
NOTIMPLEMENTED(); NOTIMPLEMENTED();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment