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

Side by Side Diff: content/child/blink_platform_impl.cc

Issue 258663002: Expose a low-end device mode override flags for non-android OSs as well (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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 unified diff | Download patch
OLDNEW
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 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 BlinkPlatformImpl::allocateAndLockDiscardableMemory(size_t bytes) { 1050 BlinkPlatformImpl::allocateAndLockDiscardableMemory(size_t bytes) {
1051 base::DiscardableMemoryType type = 1051 base::DiscardableMemoryType type =
1052 base::DiscardableMemory::GetPreferredType(); 1052 base::DiscardableMemory::GetPreferredType();
1053 if (type == base::DISCARDABLE_MEMORY_TYPE_EMULATED) 1053 if (type == base::DISCARDABLE_MEMORY_TYPE_EMULATED)
1054 return NULL; 1054 return NULL;
1055 return content::WebDiscardableMemoryImpl::CreateLockedMemory(bytes).release(); 1055 return content::WebDiscardableMemoryImpl::CreateLockedMemory(bytes).release();
1056 } 1056 }
1057 1057
1058 size_t BlinkPlatformImpl::maxDecodedImageBytes() { 1058 size_t BlinkPlatformImpl::maxDecodedImageBytes() {
1059 #if defined(OS_ANDROID) 1059 #if defined(OS_ANDROID)
1060 if (base::android::SysUtils::IsLowEndDevice()) { 1060 if (base::SysUtils::IsLowEndDevice()) {
1061 // Limit image decoded size to 3M pixels on low end devices. 1061 // Limit image decoded size to 3M pixels on low end devices.
1062 // 4 is maximum number of bytes per pixel. 1062 // 4 is maximum number of bytes per pixel.
1063 return 3 * 1024 * 1024 * 4; 1063 return 3 * 1024 * 1024 * 4;
1064 } 1064 }
1065 // For other devices, limit decoded image size based on the amount of physical 1065 // For other devices, limit decoded image size based on the amount of physical
1066 // memory. 1066 // memory.
1067 // In some cases all physical memory is not accessible by Chromium, as it can 1067 // In some cases all physical memory is not accessible by Chromium, as it can
1068 // be reserved for direct use by certain hardware. Thus, we set the limit so 1068 // be reserved for direct use by certain hardware. Thus, we set the limit so
1069 // that 1.6GB of reported physical memory on a 2GB device is enough to set the 1069 // that 1.6GB of reported physical memory on a 2GB device is enough to set the
1070 // limit at 16M pixels, which is a desirable value since 4K*4K is a relatively 1070 // limit at 16M pixels, which is a desirable value since 4K*4K is a relatively
(...skipping 28 matching lines...) Expand all
1099 } 1099 }
1100 1100
1101 // static 1101 // static
1102 void BlinkPlatformImpl::DestroyCurrentThread(void* thread) { 1102 void BlinkPlatformImpl::DestroyCurrentThread(void* thread) {
1103 WebThreadImplForMessageLoop* impl = 1103 WebThreadImplForMessageLoop* impl =
1104 static_cast<WebThreadImplForMessageLoop*>(thread); 1104 static_cast<WebThreadImplForMessageLoop*>(thread);
1105 delete impl; 1105 delete impl;
1106 } 1106 }
1107 1107
1108 } // namespace content 1108 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698