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 |
(...skipping 12 matching lines...) Expand all Loading... |
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/thread_task_runner_handle.h" | 28 #include "base/thread_task_runner_handle.h" |
29 #include "base/threading/platform_thread.h" | 29 #include "base/threading/platform_thread.h" |
30 #include "base/time/time.h" | 30 #include "base/time/time.h" |
31 #include "base/trace_event/memory_allocator_dump_guid.h" | 31 #include "base/trace_event/memory_allocator_dump_guid.h" |
32 #include "base/trace_event/memory_dump_manager.h" | 32 #include "base/trace_event/memory_dump_manager.h" |
| 33 #include "base/trace_event/trace_event.h" |
33 #include "blink/public/resources/grit/blink_image_resources.h" | 34 #include "blink/public/resources/grit/blink_image_resources.h" |
34 #include "blink/public/resources/grit/blink_resources.h" | 35 #include "blink/public/resources/grit/blink_resources.h" |
35 #include "components/mime_util/mime_util.h" | 36 #include "components/mime_util/mime_util.h" |
36 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h" | 37 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h" |
37 #include "content/app/resources/grit/content_resources.h" | 38 #include "content/app/resources/grit/content_resources.h" |
38 #include "content/app/strings/grit/content_strings.h" | 39 #include "content/app/strings/grit/content_strings.h" |
39 #include "content/child/background_sync/background_sync_provider.h" | 40 #include "content/child/background_sync/background_sync_provider.h" |
40 #include "content/child/background_sync/background_sync_provider_thread_proxy.h" | 41 #include "content/child/background_sync/background_sync_provider_thread_proxy.h" |
41 #include "content/child/bluetooth/web_bluetooth_impl.h" | 42 #include "content/child/bluetooth/web_bluetooth_impl.h" |
42 #include "content/child/child_thread_impl.h" | 43 #include "content/child/child_thread_impl.h" |
(...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 // be reserved for direct use by certain hardware. Thus, we set the limit so | 1298 // be reserved for direct use by certain hardware. Thus, we set the limit so |
1298 // that 1.6GB of reported physical memory on a 2GB device is enough to set the | 1299 // that 1.6GB of reported physical memory on a 2GB device is enough to set the |
1299 // limit at 16M pixels, which is a desirable value since 4K*4K is a relatively | 1300 // limit at 16M pixels, which is a desirable value since 4K*4K is a relatively |
1300 // common texture size. | 1301 // common texture size. |
1301 return base::SysInfo::AmountOfPhysicalMemory() / 25; | 1302 return base::SysInfo::AmountOfPhysicalMemory() / 25; |
1302 #else | 1303 #else |
1303 return noDecodedImageByteLimit; | 1304 return noDecodedImageByteLimit; |
1304 #endif | 1305 #endif |
1305 } | 1306 } |
1306 | 1307 |
| 1308 uint32_t BlinkPlatformImpl::getUniqueIdForProcess() { |
| 1309 // TODO(rickyz): Replace this with base::GetUniqueIdForProcess when that's |
| 1310 // ready. |
| 1311 return base::trace_event::TraceLog::GetInstance()->process_id(); |
| 1312 } |
| 1313 |
1307 scoped_refptr<base::SingleThreadTaskRunner> | 1314 scoped_refptr<base::SingleThreadTaskRunner> |
1308 BlinkPlatformImpl::MainTaskRunnerForCurrentThread() { | 1315 BlinkPlatformImpl::MainTaskRunnerForCurrentThread() { |
1309 if (main_thread_task_runner_.get() && | 1316 if (main_thread_task_runner_.get() && |
1310 main_thread_task_runner_->BelongsToCurrentThread()) { | 1317 main_thread_task_runner_->BelongsToCurrentThread()) { |
1311 return main_thread_task_runner_; | 1318 return main_thread_task_runner_; |
1312 } else { | 1319 } else { |
1313 return base::ThreadTaskRunnerHandle::Get(); | 1320 return base::ThreadTaskRunnerHandle::Get(); |
1314 } | 1321 } |
1315 } | 1322 } |
1316 | 1323 |
1317 bool BlinkPlatformImpl::IsMainThread() const { | 1324 bool BlinkPlatformImpl::IsMainThread() const { |
1318 return main_thread_task_runner_.get() && | 1325 return main_thread_task_runner_.get() && |
1319 main_thread_task_runner_->BelongsToCurrentThread(); | 1326 main_thread_task_runner_->BelongsToCurrentThread(); |
1320 } | 1327 } |
1321 | 1328 |
1322 WebString BlinkPlatformImpl::domCodeStringFromEnum(int dom_code) { | 1329 WebString BlinkPlatformImpl::domCodeStringFromEnum(int dom_code) { |
1323 return WebString::fromUTF8(ui::KeycodeConverter::DomCodeToCodeString( | 1330 return WebString::fromUTF8(ui::KeycodeConverter::DomCodeToCodeString( |
1324 static_cast<ui::DomCode>(dom_code))); | 1331 static_cast<ui::DomCode>(dom_code))); |
1325 } | 1332 } |
1326 | 1333 |
1327 int BlinkPlatformImpl::domEnumFromCodeString(const WebString& code) { | 1334 int BlinkPlatformImpl::domEnumFromCodeString(const WebString& code) { |
1328 return static_cast<int>(ui::KeycodeConverter::CodeStringToDomCode( | 1335 return static_cast<int>(ui::KeycodeConverter::CodeStringToDomCode( |
1329 code.utf8().data())); | 1336 code.utf8().data())); |
1330 } | 1337 } |
1331 | 1338 |
1332 } // namespace content | 1339 } // namespace content |
OLD | NEW |