OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/render_thread_impl.h" | 5 #include "content/renderer/render_thread_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 bool enable = command_line.HasSwitch(switches::kEnableThreadedCompositing); | 662 bool enable = command_line.HasSwitch(switches::kEnableThreadedCompositing); |
663 if (enable) { | 663 if (enable) { |
664 #if defined(OS_ANDROID) | 664 #if defined(OS_ANDROID) |
665 if (SynchronousCompositorFactory* factory = | 665 if (SynchronousCompositorFactory* factory = |
666 SynchronousCompositorFactory::GetInstance()) | 666 SynchronousCompositorFactory::GetInstance()) |
667 compositor_message_loop_proxy_ = | 667 compositor_message_loop_proxy_ = |
668 factory->GetCompositorMessageLoop(); | 668 factory->GetCompositorMessageLoop(); |
669 #endif | 669 #endif |
670 if (!compositor_message_loop_proxy_.get()) { | 670 if (!compositor_message_loop_proxy_.get()) { |
671 compositor_thread_.reset(new base::Thread("Compositor")); | 671 compositor_thread_.reset(new base::Thread("Compositor")); |
| 672 #if defined(OS_POSIX) |
| 673 // Workaround for crbug.com/293736 |
| 674 // On Posix, MessagePumpDefault uses system time, so delayed tasks (for |
| 675 // compositor scheduling) work incorrectly across system time changes |
| 676 // (e.g. tlsdate). So instead, use an IO loop, which uses libevent, that |
| 677 // uses monotonic time (immune to these problems). |
| 678 base::Thread::Options options; |
| 679 options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 680 compositor_thread_->StartWithOptions(options); |
| 681 #else |
672 compositor_thread_->Start(); | 682 compositor_thread_->Start(); |
| 683 #endif |
673 #if defined(OS_ANDROID) | 684 #if defined(OS_ANDROID) |
674 compositor_thread_->SetPriority(base::kThreadPriority_Display); | 685 compositor_thread_->SetPriority(base::kThreadPriority_Display); |
675 #endif | 686 #endif |
676 compositor_message_loop_proxy_ = | 687 compositor_message_loop_proxy_ = |
677 compositor_thread_->message_loop_proxy(); | 688 compositor_thread_->message_loop_proxy(); |
678 compositor_message_loop_proxy_->PostTask( | 689 compositor_message_loop_proxy_->PostTask( |
679 FROM_HERE, | 690 FROM_HERE, |
680 base::Bind(base::IgnoreResult(&ThreadRestrictions::SetIOAllowed), | 691 base::Bind(base::IgnoreResult(&ThreadRestrictions::SetIOAllowed), |
681 false)); | 692 false)); |
682 } | 693 } |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 file_thread_->Start(); | 1298 file_thread_->Start(); |
1288 } | 1299 } |
1289 return file_thread_->message_loop_proxy(); | 1300 return file_thread_->message_loop_proxy(); |
1290 } | 1301 } |
1291 | 1302 |
1292 scoped_refptr<base::MessageLoopProxy> | 1303 scoped_refptr<base::MessageLoopProxy> |
1293 RenderThreadImpl::GetMediaThreadMessageLoopProxy() { | 1304 RenderThreadImpl::GetMediaThreadMessageLoopProxy() { |
1294 DCHECK(message_loop() == base::MessageLoop::current()); | 1305 DCHECK(message_loop() == base::MessageLoop::current()); |
1295 if (!media_thread_) { | 1306 if (!media_thread_) { |
1296 media_thread_.reset(new base::Thread("Media")); | 1307 media_thread_.reset(new base::Thread("Media")); |
| 1308 #if defined(OS_POSIX) |
| 1309 // Workaround for crbug.com/293736 |
| 1310 // On Posix, MessagePumpDefault uses system time, so delayed tasks (for |
| 1311 // compositor scheduling) work incorrectly across system time changes |
| 1312 // (e.g. tlsdate). So instead, use an IO loop, which uses libevent, that |
| 1313 // uses monotonic time (immune to these problems). |
| 1314 base::Thread::Options options; |
| 1315 options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 1316 media_thread_->StartWithOptions(options); |
| 1317 #else |
1297 media_thread_->Start(); | 1318 media_thread_->Start(); |
| 1319 #endif |
1298 } | 1320 } |
1299 return media_thread_->message_loop_proxy(); | 1321 return media_thread_->message_loop_proxy(); |
1300 } | 1322 } |
1301 | 1323 |
1302 void RenderThreadImpl::SetFlingCurveParameters( | 1324 void RenderThreadImpl::SetFlingCurveParameters( |
1303 const std::vector<float>& new_touchpad, | 1325 const std::vector<float>& new_touchpad, |
1304 const std::vector<float>& new_touchscreen) { | 1326 const std::vector<float>& new_touchscreen) { |
1305 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, | 1327 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, |
1306 new_touchscreen); | 1328 new_touchscreen); |
1307 | 1329 |
1308 } | 1330 } |
1309 | 1331 |
1310 void RenderThreadImpl::SampleGamepads(WebKit::WebGamepads* data) { | 1332 void RenderThreadImpl::SampleGamepads(WebKit::WebGamepads* data) { |
1311 if (!gamepad_shared_memory_reader_) | 1333 if (!gamepad_shared_memory_reader_) |
1312 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); | 1334 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); |
1313 gamepad_shared_memory_reader_->SampleGamepads(*data); | 1335 gamepad_shared_memory_reader_->SampleGamepads(*data); |
1314 } | 1336 } |
1315 | 1337 |
1316 } // namespace content | 1338 } // namespace content |
OLD | NEW |