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

Side by Side Diff: webkit/child/webkitplatformsupport_impl.cc

Issue 119493005: Expose a low-end device mode override flags for non-android OSs as well (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/child/webkitplatformsupport_impl.h" 5 #include "webkit/child/webkitplatformsupport_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/allocator/allocator_extension.h" 11 #include "base/allocator/allocator_extension.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/singleton.h" 15 #include "base/memory/singleton.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
18 #include "base/metrics/sparse_histogram.h" 18 #include "base/metrics/sparse_histogram.h"
19 #include "base/metrics/stats_counters.h" 19 #include "base/metrics/stats_counters.h"
20 #include "base/platform_file.h" 20 #include "base/platform_file.h"
21 #include "base/process/process_metrics.h" 21 #include "base/process/process_metrics.h"
22 #include "base/rand_util.h" 22 #include "base/rand_util.h"
23 #include "base/strings/string_number_conversions.h" 23 #include "base/strings/string_number_conversions.h"
24 #include "base/strings/string_util.h" 24 #include "base/strings/string_util.h"
25 #include "base/strings/utf_string_conversions.h" 25 #include "base/strings/utf_string_conversions.h"
26 #include "base/synchronization/lock.h" 26 #include "base/synchronization/lock.h"
27 #include "base/sys_info.h" 27 #include "base/sys_info.h"
28 #include "base/sys_utils.h"
28 #include "base/time/time.h" 29 #include "base/time/time.h"
29 #include "grit/blink_resources.h" 30 #include "grit/blink_resources.h"
30 #include "grit/webkit_resources.h" 31 #include "grit/webkit_resources.h"
31 #include "grit/webkit_strings.h" 32 #include "grit/webkit_strings.h"
32 #include "net/base/data_url.h" 33 #include "net/base/data_url.h"
33 #include "net/base/mime_util.h" 34 #include "net/base/mime_util.h"
34 #include "net/base/net_errors.h" 35 #include "net/base/net_errors.h"
35 #include "third_party/WebKit/public/platform/WebCookie.h" 36 #include "third_party/WebKit/public/platform/WebCookie.h"
36 #include "third_party/WebKit/public/platform/WebData.h" 37 #include "third_party/WebKit/public/platform/WebData.h"
37 #include "third_party/WebKit/public/platform/WebDiscardableMemory.h" 38 #include "third_party/WebKit/public/platform/WebDiscardableMemory.h"
38 #include "third_party/WebKit/public/platform/WebGestureCurve.h" 39 #include "third_party/WebKit/public/platform/WebGestureCurve.h"
39 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" 40 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h"
40 #include "third_party/WebKit/public/platform/WebScreenInfo.h" 41 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
41 #include "third_party/WebKit/public/platform/WebString.h" 42 #include "third_party/WebKit/public/platform/WebString.h"
42 #include "third_party/WebKit/public/platform/WebURL.h" 43 #include "third_party/WebKit/public/platform/WebURL.h"
43 #include "third_party/WebKit/public/platform/WebVector.h" 44 #include "third_party/WebKit/public/platform/WebVector.h"
44 #include "third_party/WebKit/public/web/WebFrameClient.h" 45 #include "third_party/WebKit/public/web/WebFrameClient.h"
45 #include "third_party/WebKit/public/web/WebInputEvent.h" 46 #include "third_party/WebKit/public/web/WebInputEvent.h"
46 #include "ui/base/layout.h" 47 #include "ui/base/layout.h"
47 #include "webkit/child/webkit_child_helpers.h" 48 #include "webkit/child/webkit_child_helpers.h"
48 #include "webkit/child/websocketstreamhandle_impl.h" 49 #include "webkit/child/websocketstreamhandle_impl.h"
49 #include "webkit/child/weburlloader_impl.h" 50 #include "webkit/child/weburlloader_impl.h"
50 #include "webkit/common/user_agent/user_agent.h" 51 #include "webkit/common/user_agent/user_agent.h"
51 52
52 #if defined(OS_ANDROID)
53 #include "base/android/sys_utils.h"
54 #endif
55
56 #if !defined(NO_TCMALLOC) && defined(USE_TCMALLOC) && !defined(OS_WIN) 53 #if !defined(NO_TCMALLOC) && defined(USE_TCMALLOC) && !defined(OS_WIN)
57 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" 54 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h"
58 #endif 55 #endif
59 56
60 using blink::WebAudioBus; 57 using blink::WebAudioBus;
61 using blink::WebCookie; 58 using blink::WebCookie;
62 using blink::WebData; 59 using blink::WebData;
63 using blink::WebLocalizedString; 60 using blink::WebLocalizedString;
64 using blink::WebPluginListBuilder; 61 using blink::WebPluginListBuilder;
65 using blink::WebString; 62 using blink::WebString;
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 size_t* private_bytes, 905 size_t* private_bytes,
909 size_t* shared_bytes) { 906 size_t* shared_bytes) {
910 return CurrentProcessMetrics()->GetMemoryBytes(private_bytes, shared_bytes); 907 return CurrentProcessMetrics()->GetMemoryBytes(private_bytes, shared_bytes);
911 } 908 }
912 909
913 bool WebKitPlatformSupportImpl::memoryAllocatorWasteInBytes(size_t* size) { 910 bool WebKitPlatformSupportImpl::memoryAllocatorWasteInBytes(size_t* size) {
914 return base::allocator::GetAllocatorWasteSize(size); 911 return base::allocator::GetAllocatorWasteSize(size);
915 } 912 }
916 913
917 size_t WebKitPlatformSupportImpl::maxDecodedImageBytes() { 914 size_t WebKitPlatformSupportImpl::maxDecodedImageBytes() {
918 #if defined(OS_ANDROID) 915 if (base::SysUtils::IsLowEndDevice()) {
919 if (base::android::SysUtils::IsLowEndDevice()) {
920 // Limit image decoded size to 3M pixels on low end devices. 916 // Limit image decoded size to 3M pixels on low end devices.
921 // 4 is maximum number of bytes per pixel. 917 // 4 is maximum number of bytes per pixel.
922 return 3 * 1024 * 1024 * 4; 918 return 3 * 1024 * 1024 * 4;
923 } 919 }
920 #if defined(OS_ANDROID)
924 // For other devices, limit decoded image size based on the amount of physical 921 // For other devices, limit decoded image size based on the amount of physical
925 // memory. For a device with 2GB physical memory the limit is 16M pixels. 922 // memory. For a device with 2GB physical memory the limit is 16M pixels.
926 return base::SysInfo::AmountOfPhysicalMemory() / 32; 923 return base::SysInfo::AmountOfPhysicalMemory() / 32;
927 #else 924 #else
928 return noDecodedImageByteLimit; 925 return noDecodedImageByteLimit;
929 #endif 926 #endif
930 } 927 }
931 928
932 void WebKitPlatformSupportImpl::SuspendSharedTimer() { 929 void WebKitPlatformSupportImpl::SuspendSharedTimer() {
933 ++shared_timer_suspended_; 930 ++shared_timer_suspended_;
934 } 931 }
935 932
936 void WebKitPlatformSupportImpl::ResumeSharedTimer() { 933 void WebKitPlatformSupportImpl::ResumeSharedTimer() {
937 // The shared timer may have fired or been adjusted while we were suspended. 934 // The shared timer may have fired or been adjusted while we were suspended.
938 if (--shared_timer_suspended_ == 0 && 935 if (--shared_timer_suspended_ == 0 &&
939 (!shared_timer_.IsRunning() || 936 (!shared_timer_.IsRunning() ||
940 shared_timer_fire_time_was_set_while_suspended_)) { 937 shared_timer_fire_time_was_set_while_suspended_)) {
941 shared_timer_fire_time_was_set_while_suspended_ = false; 938 shared_timer_fire_time_was_set_while_suspended_ = false;
942 setSharedTimerFireInterval( 939 setSharedTimerFireInterval(
943 shared_timer_fire_time_ - monotonicallyIncreasingTime()); 940 shared_timer_fire_time_ - monotonicallyIncreasingTime());
944 } 941 }
945 } 942 }
946 943
947 } // namespace webkit_glue 944 } // namespace webkit_glue
OLDNEW
« content/renderer/renderer_main.cc ('K') | « ui/gl/gl_context_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698