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

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

Powered by Google App Engine
This is Rietveld 408576698