summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsl.ostapenko@samsung.com <sl.ostapenko@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-02 23:27:04 +0000
committersl.ostapenko@samsung.com <sl.ostapenko@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-02 23:27:04 +0000
commit2a79350a2a7c9fc4ec039cb921442518028d6294 (patch)
tree8569456cd4667a7d8e1656ae46c506c0806cbbe5
parentcce34bd6de099e68afdedba4ed8cd5f4e67c4cf8 (diff)
downloadchromium_src-2a79350a2a7c9fc4ec039cb921442518028d6294.zip
chromium_src-2a79350a2a7c9fc4ec039cb921442518028d6294.tar.gz
chromium_src-2a79350a2a7c9fc4ec039cb921442518028d6294.tar.bz2
Cache JNI call results in SysUtils on native side.
BUG=323727 Review URL: https://codereview.chromium.org/89773002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238228 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/android/sys_utils.cc14
-rw-r--r--base/android/sys_utils.h3
2 files changed, 15 insertions, 2 deletions
diff --git a/base/android/sys_utils.cc b/base/android/sys_utils.cc
index 103324d..efd13df 100644
--- a/base/android/sys_utils.cc
+++ b/base/android/sys_utils.cc
@@ -15,16 +15,26 @@ bool SysUtils::Register(JNIEnv* env) {
return RegisterNativesImpl(env);
}
-bool SysUtils::IsLowEndDevice() {
+bool SysUtils::IsLowEndDeviceFromJni() {
JNIEnv* env = AttachCurrentThread();
return Java_SysUtils_isLowEndDevice(env);
}
-size_t SysUtils::AmountOfPhysicalMemoryKB() {
+bool SysUtils::IsLowEndDevice() {
+ static bool is_low_end = IsLowEndDeviceFromJni();
+ return is_low_end;
+}
+
+size_t SysUtils::AmountOfPhysicalMemoryKBFromJni() {
JNIEnv* env = AttachCurrentThread();
return static_cast<size_t>(Java_SysUtils_amountOfPhysicalMemoryKB(env));
}
+size_t SysUtils::AmountOfPhysicalMemoryKB() {
+ static size_t amount_of_ram = AmountOfPhysicalMemoryKBFromJni();
+ return amount_of_ram;
+}
+
SysUtils::SysUtils() { }
} // namespace android
diff --git a/base/android/sys_utils.h b/base/android/sys_utils.h
index 318c75e..9b3152b 100644
--- a/base/android/sys_utils.h
+++ b/base/android/sys_utils.h
@@ -22,6 +22,9 @@ class BASE_EXPORT SysUtils {
private:
SysUtils();
+
+ static bool IsLowEndDeviceFromJni();
+ static size_t AmountOfPhysicalMemoryKBFromJni();
};
} // namespace android