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/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/threading/platform_thread.h" |
28 #include "base/time/time.h" | 29 #include "base/time/time.h" |
29 #include "blink/public/resources/grit/blink_resources.h" | 30 #include "blink/public/resources/grit/blink_resources.h" |
30 #include "content/app/resources/grit/content_resources.h" | 31 #include "content/app/resources/grit/content_resources.h" |
31 #include "content/app/strings/grit/content_strings.h" | 32 #include "content/app/strings/grit/content_strings.h" |
32 #include "content/child/child_thread.h" | 33 #include "content/child/child_thread.h" |
33 #include "content/child/content_child_helpers.h" | 34 #include "content/child/content_child_helpers.h" |
34 #include "content/child/fling_curve_configuration.h" | 35 #include "content/child/fling_curve_configuration.h" |
35 #include "content/child/web_discardable_memory_impl.h" | 36 #include "content/child/web_discardable_memory_impl.h" |
36 #include "content/child/web_socket_stream_handle_impl.h" | 37 #include "content/child/web_socket_stream_handle_impl.h" |
37 #include "content/child/web_url_loader_impl.h" | 38 #include "content/child/web_url_loader_impl.h" |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 scoped_refptr<base::MessageLoopProxy> message_loop = | 488 scoped_refptr<base::MessageLoopProxy> message_loop = |
488 base::MessageLoopProxy::current(); | 489 base::MessageLoopProxy::current(); |
489 if (!message_loop.get()) | 490 if (!message_loop.get()) |
490 return NULL; | 491 return NULL; |
491 | 492 |
492 thread = new WebThreadImplForMessageLoop(message_loop.get()); | 493 thread = new WebThreadImplForMessageLoop(message_loop.get()); |
493 current_thread_slot_.Set(thread); | 494 current_thread_slot_.Set(thread); |
494 return thread; | 495 return thread; |
495 } | 496 } |
496 | 497 |
| 498 void BlinkPlatformImpl::yieldCurrentThread() { |
| 499 base::PlatformThread::YieldCurrentThread(); |
| 500 } |
| 501 |
497 blink::WebWaitableEvent* BlinkPlatformImpl::createWaitableEvent() { | 502 blink::WebWaitableEvent* BlinkPlatformImpl::createWaitableEvent() { |
498 return new WebWaitableEventImpl(); | 503 return new WebWaitableEventImpl(); |
499 } | 504 } |
500 | 505 |
501 blink::WebWaitableEvent* BlinkPlatformImpl::waitMultipleEvents( | 506 blink::WebWaitableEvent* BlinkPlatformImpl::waitMultipleEvents( |
502 const blink::WebVector<blink::WebWaitableEvent*>& web_events) { | 507 const blink::WebVector<blink::WebWaitableEvent*>& web_events) { |
503 std::vector<base::WaitableEvent*> events; | 508 std::vector<base::WaitableEvent*> events; |
504 for (size_t i = 0; i < web_events.size(); ++i) | 509 for (size_t i = 0; i < web_events.size(); ++i) |
505 events.push_back(static_cast<WebWaitableEventImpl*>(web_events[i])->impl()); | 510 events.push_back(static_cast<WebWaitableEventImpl*>(web_events[i])->impl()); |
506 size_t idx = base::WaitableEvent::WaitMany( | 511 size_t idx = base::WaitableEvent::WaitMany( |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 } | 1208 } |
1204 | 1209 |
1205 // static | 1210 // static |
1206 void BlinkPlatformImpl::DestroyCurrentThread(void* thread) { | 1211 void BlinkPlatformImpl::DestroyCurrentThread(void* thread) { |
1207 WebThreadImplForMessageLoop* impl = | 1212 WebThreadImplForMessageLoop* impl = |
1208 static_cast<WebThreadImplForMessageLoop*>(thread); | 1213 static_cast<WebThreadImplForMessageLoop*>(thread); |
1209 delete impl; | 1214 delete impl; |
1210 } | 1215 } |
1211 | 1216 |
1212 } // namespace content | 1217 } // namespace content |
OLD | NEW |