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" | |
12 #include "base/bind.h" | 11 #include "base/bind.h" |
13 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
14 #include "base/location.h" | 13 #include "base/location.h" |
15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
17 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
18 #include "base/metrics/sparse_histogram.h" | 17 #include "base/metrics/sparse_histogram.h" |
19 #include "base/process/process_metrics.h" | |
20 #include "base/rand_util.h" | 18 #include "base/rand_util.h" |
21 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
22 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
23 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
24 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
25 #include "base/synchronization/lock.h" | 23 #include "base/synchronization/lock.h" |
26 #include "base/synchronization/waitable_event.h" | 24 #include "base/synchronization/waitable_event.h" |
27 #include "base/sys_info.h" | 25 #include "base/sys_info.h" |
28 #include "base/thread_task_runner_handle.h" | 26 #include "base/thread_task_runner_handle.h" |
29 #include "base/threading/platform_thread.h" | 27 #include "base/threading/platform_thread.h" |
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 } | 1242 } |
1245 | 1243 |
1246 bool BlinkPlatformImpl::isLowEndDeviceMode() { | 1244 bool BlinkPlatformImpl::isLowEndDeviceMode() { |
1247 return base::SysInfo::IsLowEndDevice(); | 1245 return base::SysInfo::IsLowEndDevice(); |
1248 } | 1246 } |
1249 | 1247 |
1250 size_t BlinkPlatformImpl::numberOfProcessors() { | 1248 size_t BlinkPlatformImpl::numberOfProcessors() { |
1251 return static_cast<size_t>(base::SysInfo::NumberOfProcessors()); | 1249 return static_cast<size_t>(base::SysInfo::NumberOfProcessors()); |
1252 } | 1250 } |
1253 | 1251 |
1254 bool BlinkPlatformImpl::processMemorySizesInBytes( | |
1255 size_t* private_bytes, | |
1256 size_t* shared_bytes) { | |
1257 scoped_ptr<base::ProcessMetrics> current_process_metrics( | |
1258 base::ProcessMetrics::CreateCurrentProcessMetrics()); | |
1259 return current_process_metrics->GetMemoryBytes(private_bytes, shared_bytes); | |
1260 } | |
1261 | |
1262 bool BlinkPlatformImpl::memoryAllocatorWasteInBytes(size_t* size) { | |
1263 return base::allocator::GetAllocatorWasteSize(size); | |
1264 } | |
1265 | |
1266 blink::WebDiscardableMemory* | 1252 blink::WebDiscardableMemory* |
1267 BlinkPlatformImpl::allocateAndLockDiscardableMemory(size_t bytes) { | 1253 BlinkPlatformImpl::allocateAndLockDiscardableMemory(size_t bytes) { |
1268 return content::WebDiscardableMemoryImpl::CreateLockedMemory(bytes).release(); | 1254 return content::WebDiscardableMemoryImpl::CreateLockedMemory(bytes).release(); |
1269 } | 1255 } |
1270 | 1256 |
1271 size_t BlinkPlatformImpl::maxDecodedImageBytes() { | 1257 size_t BlinkPlatformImpl::maxDecodedImageBytes() { |
1272 #if defined(OS_ANDROID) | 1258 #if defined(OS_ANDROID) |
1273 if (base::SysInfo::IsLowEndDevice()) { | 1259 if (base::SysInfo::IsLowEndDevice()) { |
1274 // Limit image decoded size to 3M pixels on low end devices. | 1260 // Limit image decoded size to 3M pixels on low end devices. |
1275 // 4 is maximum number of bytes per pixel. | 1261 // 4 is maximum number of bytes per pixel. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString( | 1299 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString( |
1314 static_cast<ui::DomKey>(dom_key))); | 1300 static_cast<ui::DomKey>(dom_key))); |
1315 } | 1301 } |
1316 | 1302 |
1317 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) { | 1303 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) { |
1318 return static_cast<int>( | 1304 return static_cast<int>( |
1319 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8())); | 1305 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8())); |
1320 } | 1306 } |
1321 | 1307 |
1322 } // namespace content | 1308 } // namespace content |
OLD | NEW |