| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/child/blink_platform_impl.h" | 5 #include "content/child/blink_platform_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/synchronization/waitable_event.h" | 27 #include "base/synchronization/waitable_event.h" |
| 28 #include "base/sys_info.h" | 28 #include "base/sys_info.h" |
| 29 #include "base/sys_utils.h" |
| 29 #include "base/time/time.h" | 30 #include "base/time/time.h" |
| 30 #include "content/child/content_child_helpers.h" | 31 #include "content/child/content_child_helpers.h" |
| 31 #include "content/child/fling_curve_configuration.h" | 32 #include "content/child/fling_curve_configuration.h" |
| 32 #include "content/child/web_discardable_memory_impl.h" | 33 #include "content/child/web_discardable_memory_impl.h" |
| 33 #include "content/child/web_socket_stream_handle_impl.h" | 34 #include "content/child/web_socket_stream_handle_impl.h" |
| 34 #include "content/child/web_url_loader_impl.h" | 35 #include "content/child/web_url_loader_impl.h" |
| 35 #include "content/child/webcrypto/webcrypto_impl.h" | 36 #include "content/child/webcrypto/webcrypto_impl.h" |
| 36 #include "content/child/websocket_bridge.h" | 37 #include "content/child/websocket_bridge.h" |
| 37 #include "content/child/webthread_impl.h" | 38 #include "content/child/webthread_impl.h" |
| 38 #include "content/child/worker_task_runner.h" | 39 #include "content/child/worker_task_runner.h" |
| 39 #include "content/public/common/content_client.h" | 40 #include "content/public/common/content_client.h" |
| 40 #include "grit/blink_resources.h" | 41 #include "grit/blink_resources.h" |
| 41 #include "grit/webkit_resources.h" | 42 #include "grit/webkit_resources.h" |
| 42 #include "grit/webkit_strings.h" | 43 #include "grit/webkit_strings.h" |
| 43 #include "net/base/data_url.h" | 44 #include "net/base/data_url.h" |
| 44 #include "net/base/mime_util.h" | 45 #include "net/base/mime_util.h" |
| 45 #include "net/base/net_errors.h" | 46 #include "net/base/net_errors.h" |
| 46 #include "third_party/WebKit/public/platform/WebConvertableToTraceFormat.h" | 47 #include "third_party/WebKit/public/platform/WebConvertableToTraceFormat.h" |
| 47 #include "third_party/WebKit/public/platform/WebData.h" | 48 #include "third_party/WebKit/public/platform/WebData.h" |
| 48 #include "third_party/WebKit/public/platform/WebString.h" | 49 #include "third_party/WebKit/public/platform/WebString.h" |
| 49 #include "third_party/WebKit/public/platform/WebWaitableEvent.h" | 50 #include "third_party/WebKit/public/platform/WebWaitableEvent.h" |
| 50 #include "third_party/WebKit/public/web/WebInputEvent.h" | 51 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 51 #include "ui/base/layout.h" | 52 #include "ui/base/layout.h" |
| 52 | 53 |
| 53 #if defined(OS_ANDROID) | 54 #if defined(OS_ANDROID) |
| 54 #include "base/android/sys_utils.h" | |
| 55 #include "content/child/fling_animator_impl_android.h" | 55 #include "content/child/fling_animator_impl_android.h" |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 #if !defined(NO_TCMALLOC) && defined(USE_TCMALLOC) && !defined(OS_WIN) | 58 #if !defined(NO_TCMALLOC) && defined(USE_TCMALLOC) && !defined(OS_WIN) |
| 59 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" | 59 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" |
| 60 #endif | 60 #endif |
| 61 | 61 |
| 62 using blink::WebData; | 62 using blink::WebData; |
| 63 using blink::WebFallbackThemeEngine; | 63 using blink::WebFallbackThemeEngine; |
| 64 using blink::WebLocalizedString; | 64 using blink::WebLocalizedString; |
| (...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 BlinkPlatformImpl::allocateAndLockDiscardableMemory(size_t bytes) { | 1048 BlinkPlatformImpl::allocateAndLockDiscardableMemory(size_t bytes) { |
| 1049 base::DiscardableMemoryType type = | 1049 base::DiscardableMemoryType type = |
| 1050 base::DiscardableMemory::GetPreferredType(); | 1050 base::DiscardableMemory::GetPreferredType(); |
| 1051 if (type == base::DISCARDABLE_MEMORY_TYPE_EMULATED) | 1051 if (type == base::DISCARDABLE_MEMORY_TYPE_EMULATED) |
| 1052 return NULL; | 1052 return NULL; |
| 1053 return content::WebDiscardableMemoryImpl::CreateLockedMemory(bytes).release(); | 1053 return content::WebDiscardableMemoryImpl::CreateLockedMemory(bytes).release(); |
| 1054 } | 1054 } |
| 1055 | 1055 |
| 1056 size_t BlinkPlatformImpl::maxDecodedImageBytes() { | 1056 size_t BlinkPlatformImpl::maxDecodedImageBytes() { |
| 1057 #if defined(OS_ANDROID) | 1057 #if defined(OS_ANDROID) |
| 1058 if (base::android::SysUtils::IsLowEndDevice()) { | 1058 if (base::SysUtils::IsLowEndDevice()) { |
| 1059 // Limit image decoded size to 3M pixels on low end devices. | 1059 // Limit image decoded size to 3M pixels on low end devices. |
| 1060 // 4 is maximum number of bytes per pixel. | 1060 // 4 is maximum number of bytes per pixel. |
| 1061 return 3 * 1024 * 1024 * 4; | 1061 return 3 * 1024 * 1024 * 4; |
| 1062 } | 1062 } |
| 1063 // For other devices, limit decoded image size based on the amount of physical | 1063 // For other devices, limit decoded image size based on the amount of physical |
| 1064 // memory. | 1064 // memory. |
| 1065 // In some cases all physical memory is not accessible by Chromium, as it can | 1065 // In some cases all physical memory is not accessible by Chromium, as it can |
| 1066 // be reserved for direct use by certain hardware. Thus, we set the limit so | 1066 // be reserved for direct use by certain hardware. Thus, we set the limit so |
| 1067 // that 1.6GB of reported physical memory on a 2GB device is enough to set the | 1067 // that 1.6GB of reported physical memory on a 2GB device is enough to set the |
| 1068 // limit at 16M pixels, which is a desirable value since 4K*4K is a relatively | 1068 // limit at 16M pixels, which is a desirable value since 4K*4K is a relatively |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1097 } | 1097 } |
| 1098 | 1098 |
| 1099 // static | 1099 // static |
| 1100 void BlinkPlatformImpl::DestroyCurrentThread(void* thread) { | 1100 void BlinkPlatformImpl::DestroyCurrentThread(void* thread) { |
| 1101 WebThreadImplForMessageLoop* impl = | 1101 WebThreadImplForMessageLoop* impl = |
| 1102 static_cast<WebThreadImplForMessageLoop*>(thread); | 1102 static_cast<WebThreadImplForMessageLoop*>(thread); |
| 1103 delete impl; | 1103 delete impl; |
| 1104 } | 1104 } |
| 1105 | 1105 |
| 1106 } // namespace content | 1106 } // namespace content |
| OLD | NEW |