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/location.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
16 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
17 #include "base/metrics/sparse_histogram.h" | 18 #include "base/metrics/sparse_histogram.h" |
18 #include "base/process/process_metrics.h" | 19 #include "base/process/process_metrics.h" |
19 #include "base/rand_util.h" | 20 #include "base/rand_util.h" |
| 21 #include "base/single_thread_task_runner.h" |
20 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
21 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
22 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
23 #include "base/synchronization/lock.h" | 25 #include "base/synchronization/lock.h" |
24 #include "base/synchronization/waitable_event.h" | 26 #include "base/synchronization/waitable_event.h" |
25 #include "base/sys_info.h" | 27 #include "base/sys_info.h" |
26 #include "base/thread_task_runner_handle.h" | 28 #include "base/thread_task_runner_handle.h" |
27 #include "base/threading/platform_thread.h" | 29 #include "base/threading/platform_thread.h" |
28 #include "base/time/time.h" | 30 #include "base/time/time.h" |
29 #include "base/trace_event/memory_dump_manager.h" | 31 #include "base/trace_event/memory_dump_manager.h" |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 // This "default:" line exists to avoid compile warnings about enum | 419 // This "default:" line exists to avoid compile warnings about enum |
418 // coverage when we add a new symbol to WebLocalizedString.h in WebKit. | 420 // coverage when we add a new symbol to WebLocalizedString.h in WebKit. |
419 // After a planned WebKit patch is landed, we need to add a case statement | 421 // After a planned WebKit patch is landed, we need to add a case statement |
420 // for the added symbol here. | 422 // for the added symbol here. |
421 default: | 423 default: |
422 break; | 424 break; |
423 } | 425 } |
424 return -1; | 426 return -1; |
425 } | 427 } |
426 | 428 |
| 429 // TODO(skyostil): Ensure that we always have an active task runner when |
| 430 // constructing the platform. |
427 BlinkPlatformImpl::BlinkPlatformImpl() | 431 BlinkPlatformImpl::BlinkPlatformImpl() |
428 : main_thread_task_runner_(base::MessageLoopProxy::current()), | 432 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::IsSet() |
| 433 ? base::ThreadTaskRunnerHandle::Get() |
| 434 : nullptr), |
429 shared_timer_func_(NULL), | 435 shared_timer_func_(NULL), |
430 shared_timer_fire_time_(0.0), | 436 shared_timer_fire_time_(0.0), |
431 shared_timer_fire_time_was_set_while_suspended_(false), | 437 shared_timer_fire_time_was_set_while_suspended_(false), |
432 shared_timer_suspended_(0) { | 438 shared_timer_suspended_(0) { |
433 InternalInit(); | 439 InternalInit(); |
434 } | 440 } |
435 | 441 |
436 BlinkPlatformImpl::BlinkPlatformImpl( | 442 BlinkPlatformImpl::BlinkPlatformImpl( |
437 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner) | 443 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner) |
438 : main_thread_task_runner_(main_thread_task_runner), | 444 : main_thread_task_runner_(main_thread_task_runner), |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 shared_timer_fire_time_ - monotonicallyIncreasingTime()); | 1364 shared_timer_fire_time_ - monotonicallyIncreasingTime()); |
1359 } | 1365 } |
1360 } | 1366 } |
1361 | 1367 |
1362 scoped_refptr<base::SingleThreadTaskRunner> | 1368 scoped_refptr<base::SingleThreadTaskRunner> |
1363 BlinkPlatformImpl::MainTaskRunnerForCurrentThread() { | 1369 BlinkPlatformImpl::MainTaskRunnerForCurrentThread() { |
1364 if (main_thread_task_runner_.get() && | 1370 if (main_thread_task_runner_.get() && |
1365 main_thread_task_runner_->BelongsToCurrentThread()) { | 1371 main_thread_task_runner_->BelongsToCurrentThread()) { |
1366 return main_thread_task_runner_; | 1372 return main_thread_task_runner_; |
1367 } else { | 1373 } else { |
1368 return base::MessageLoopProxy::current(); | 1374 return base::ThreadTaskRunnerHandle::Get(); |
1369 } | 1375 } |
1370 } | 1376 } |
1371 | 1377 |
1372 bool BlinkPlatformImpl::IsMainThread() const { | 1378 bool BlinkPlatformImpl::IsMainThread() const { |
1373 return main_thread_task_runner_.get() && | 1379 return main_thread_task_runner_.get() && |
1374 main_thread_task_runner_->BelongsToCurrentThread(); | 1380 main_thread_task_runner_->BelongsToCurrentThread(); |
1375 } | 1381 } |
1376 | 1382 |
1377 WebString BlinkPlatformImpl::domCodeStringFromEnum(int dom_code) { | 1383 WebString BlinkPlatformImpl::domCodeStringFromEnum(int dom_code) { |
1378 return WebString::fromUTF8(ui::KeycodeConverter::DomCodeToCodeString( | 1384 return WebString::fromUTF8(ui::KeycodeConverter::DomCodeToCodeString( |
1379 static_cast<ui::DomCode>(dom_code))); | 1385 static_cast<ui::DomCode>(dom_code))); |
1380 } | 1386 } |
1381 | 1387 |
1382 int BlinkPlatformImpl::domEnumFromCodeString(const WebString& code) { | 1388 int BlinkPlatformImpl::domEnumFromCodeString(const WebString& code) { |
1383 return static_cast<int>(ui::KeycodeConverter::CodeStringToDomCode( | 1389 return static_cast<int>(ui::KeycodeConverter::CodeStringToDomCode( |
1384 code.utf8().data())); | 1390 code.utf8().data())); |
1385 } | 1391 } |
1386 | 1392 |
1387 } // namespace content | 1393 } // namespace content |
OLD | NEW |