diff options
| author | Ben Murdoch <benm@google.com> | 2011-08-10 13:17:08 +0100 |
|---|---|---|
| committer | Ben Murdoch <benm@google.com> | 2011-08-12 17:26:30 +0100 |
| commit | 3e556736c899f74f2ccc010a8bc7401c36e9a1a0 (patch) | |
| tree | d4938bc18892148a044ca7bf4715bdd040053946 /Source/WebKit/android/WebCoreSupport | |
| parent | 6a94579dab1dca12e6555b01602efeb5debda17a (diff) | |
| download | external_webkit-3e556736c899f74f2ccc010a8bc7401c36e9a1a0.zip external_webkit-3e556736c899f74f2ccc010a8bc7401c36e9a1a0.tar.gz external_webkit-3e556736c899f74f2ccc010a8bc7401c36e9a1a0.tar.bz2 | |
Check the available memory when allocating an ImageBuffer.
The ImageBuffers used by canvas can eat a ton of memory quickly, so
be mindful of the available memory on the device before allocating
them.
See also frameworks/base change
I3d0f85075497c2a374cd866b0223eecaaa4b5f46
Bug: 5142892
Change-Id: I74d243ef9d0d63aac168c16653e9aae0430dfa21
Diffstat (limited to 'Source/WebKit/android/WebCoreSupport')
| -rw-r--r-- | Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp b/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp index 8d8d809..27fe208 100644 --- a/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp +++ b/Source/WebKit/android/WebCoreSupport/PlatformBridge.cpp @@ -30,6 +30,7 @@ #include "Document.h" #include "FileSystemClient.h" #include "FrameView.h" +#include "JNIUtility.h" #include "JavaSharedClient.h" #include "KeyGeneratorClient.h" #include "MemoryUsage.h" @@ -229,6 +230,17 @@ int PlatformBridge::actualMemoryUsageMB() return MemoryUsage::memoryUsageMb(true); } +bool PlatformBridge::canSatisfyMemoryAllocation(long bytes) +{ + JNIEnv* env = JSC::Bindings::getJNIEnv(); + jclass bridgeClass = env->FindClass("android/webkit/JniUtil"); + jmethodID method = env->GetStaticMethodID(bridgeClass, "canSatisfyMemoryAllocation", "(J)Z"); + jboolean canAllocate = env->CallStaticBooleanMethod(bridgeClass, method, static_cast<jlong>(bytes)); + env->DeleteLocalRef(bridgeClass); + + return canAllocate == JNI_TRUE; +} + } // namespace WebCore |
