OLD | NEW |
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/time/time.h" | 28 #include "base/time/time.h" |
28 #include "content/public/common/webplugininfo.h" | 29 #include "content/public/common/webplugininfo.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" |
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 size_t* shared_bytes) { | 883 size_t* shared_bytes) { |
883 return CurrentProcessMetrics()->GetMemoryBytes(private_bytes, shared_bytes); | 884 return CurrentProcessMetrics()->GetMemoryBytes(private_bytes, shared_bytes); |
884 } | 885 } |
885 | 886 |
886 bool WebKitPlatformSupportImpl::memoryAllocatorWasteInBytes(size_t* size) { | 887 bool WebKitPlatformSupportImpl::memoryAllocatorWasteInBytes(size_t* size) { |
887 return base::allocator::GetAllocatorWasteSize(size); | 888 return base::allocator::GetAllocatorWasteSize(size); |
888 } | 889 } |
889 | 890 |
890 size_t WebKitPlatformSupportImpl::maxDecodedImageBytes() { | 891 size_t WebKitPlatformSupportImpl::maxDecodedImageBytes() { |
891 #if defined(OS_ANDROID) | 892 #if defined(OS_ANDROID) |
892 // Limit image decoded size to 3M pixels on low end devices. | 893 if (base::android::SysUtils::IsLowEndDevice()) { |
893 if (base::android::SysUtils::IsLowEndDevice()) | 894 // Limit image decoded size to 3M pixels on low end devices. |
894 return 3 * 1024 * 1024 * 4; // 4 is maximum number of bytes per pixel. | 895 // 4 is maximum number of bytes per pixel. |
| 896 return 3 * 1024 * 1024 * 4; |
| 897 } |
| 898 // For other devices, limit decoded image size based on the amount of physical |
| 899 // memory. For a device with 2GB physical memory the limit is 16M pixels. |
| 900 return base::SysInfo::AmountOfPhysicalMemory() / 32; |
| 901 #else |
| 902 return noDecodedImageByteLimit; |
895 #endif | 903 #endif |
896 return noDecodedImageByteLimit; | |
897 } | 904 } |
898 | 905 |
899 void WebKitPlatformSupportImpl::SuspendSharedTimer() { | 906 void WebKitPlatformSupportImpl::SuspendSharedTimer() { |
900 ++shared_timer_suspended_; | 907 ++shared_timer_suspended_; |
901 } | 908 } |
902 | 909 |
903 void WebKitPlatformSupportImpl::ResumeSharedTimer() { | 910 void WebKitPlatformSupportImpl::ResumeSharedTimer() { |
904 // The shared timer may have fired or been adjusted while we were suspended. | 911 // The shared timer may have fired or been adjusted while we were suspended. |
905 if (--shared_timer_suspended_ == 0 && | 912 if (--shared_timer_suspended_ == 0 && |
906 (!shared_timer_.IsRunning() || | 913 (!shared_timer_.IsRunning() || |
907 shared_timer_fire_time_was_set_while_suspended_)) { | 914 shared_timer_fire_time_was_set_while_suspended_)) { |
908 shared_timer_fire_time_was_set_while_suspended_ = false; | 915 shared_timer_fire_time_was_set_while_suspended_ = false; |
909 setSharedTimerFireInterval( | 916 setSharedTimerFireInterval( |
910 shared_timer_fire_time_ - monotonicallyIncreasingTime()); | 917 shared_timer_fire_time_ - monotonicallyIncreasingTime()); |
911 } | 918 } |
912 } | 919 } |
913 | 920 |
914 } // namespace webkit_glue | 921 } // namespace webkit_glue |
OLD | NEW |