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

Unified Diff: webkit/child/webkitplatformsupport_impl.cc

Issue 25938002: Android: limit image decoded size based on amount of physical memory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/child/webkitplatformsupport_impl.cc
diff --git a/webkit/child/webkitplatformsupport_impl.cc b/webkit/child/webkitplatformsupport_impl.cc
index ca82d3e273bb3d9e56f56dd0d30a38ce9513c08f..82b8dd3539ce6e0cd7e9aa47b3a940653267f0ab 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 "content/public/common/webplugininfo.h"
#include "grit/blink_resources.h"
@@ -889,11 +890,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() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698