summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorwangxianzhu@chromium.org <wangxianzhu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-04 19:58:39 +0000
committerwangxianzhu@chromium.org <wangxianzhu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-04 19:58:39 +0000
commit16551ed2a89b6c7d44b63945137b8e9eb272c6b9 (patch)
tree955a764252be279fad0a81a3efcefced4b8d9129 /webkit
parent7e7d3f44cc3ffbab93a9d3bcab245df660a4e772 (diff)
downloadchromium_src-16551ed2a89b6c7d44b63945137b8e9eb272c6b9.zip
chromium_src-16551ed2a89b6c7d44b63945137b8e9eb272c6b9.tar.gz
chromium_src-16551ed2a89b6c7d44b63945137b8e9eb272c6b9.tar.bz2
Android: limit image decoded size based on amount of physical memory
The previous change (https://codereview.chromium.org/23600067/) added limit for low end devices (memory <= 512MB). Now limit on all devices to display huge images without crash or displaying as corrupted images. This CL is still Android. The method might be also useful on other platforms but the best parameters may differ (may be affected by the swap memory). BUG=303848 Review URL: https://codereview.chromium.org/25938002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227063 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/child/webkitplatformsupport_impl.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/webkit/child/webkitplatformsupport_impl.cc b/webkit/child/webkitplatformsupport_impl.cc
index 56a442e..baf8a34 100644
--- a/webkit/child/webkitplatformsupport_impl.cc
+++ b/webkit/child/webkitplatformsupport_impl.cc
@@ -24,6 +24,7 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/lock.h"
+#include "base/sys_info.h"
#include "base/time/time.h"
#include "grit/blink_resources.h"
#include "grit/webkit_resources.h"
@@ -888,11 +889,17 @@ bool WebKitPlatformSupportImpl::memoryAllocatorWasteInBytes(size_t* size) {
size_t WebKitPlatformSupportImpl::maxDecodedImageBytes() {
#if defined(OS_ANDROID)
- // Limit image decoded size to 3M pixels on low end devices.
- if (base::android::SysUtils::IsLowEndDevice())
- return 3 * 1024 * 1024 * 4; // 4 is maximum number of bytes per pixel.
-#endif
+ if (base::android::SysUtils::IsLowEndDevice()) {
+ // Limit image decoded size to 3M pixels on low end devices.
+ // 4 is maximum number of bytes per pixel.
+ return 3 * 1024 * 1024 * 4;
+ }
+ // For other devices, limit decoded image size based on the amount of physical
+ // memory. For a device with 2GB physical memory the limit is 16M pixels.
+ return base::SysInfo::AmountOfPhysicalMemory() / 32;
+#else
return noDecodedImageByteLimit;
+#endif
}
void WebKitPlatformSupportImpl::SuspendSharedTimer() {