| 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 bool enable = command_line.HasSwitch(switches::kEnableThreadedCompositing); | 646 bool enable = command_line.HasSwitch(switches::kEnableThreadedCompositing); |
| 647 if (enable) { | 647 if (enable) { |
| 648 #if defined(OS_ANDROID) | 648 #if defined(OS_ANDROID) |
| 649 if (SynchronousCompositorFactory* factory = | 649 if (SynchronousCompositorFactory* factory = |
| 650 SynchronousCompositorFactory::GetInstance()) | 650 SynchronousCompositorFactory::GetInstance()) |
| 651 compositor_message_loop_proxy_ = | 651 compositor_message_loop_proxy_ = |
| 652 factory->GetCompositorMessageLoop(); | 652 factory->GetCompositorMessageLoop(); |
| 653 #endif | 653 #endif |
| 654 if (!compositor_message_loop_proxy_.get()) { | 654 if (!compositor_message_loop_proxy_.get()) { |
| 655 compositor_thread_.reset(new base::Thread("Compositor")); | 655 compositor_thread_.reset(new base::Thread("Compositor")); |
| 656 #if defined(OS_POSIX) | |
| 657 // Workaround for crbug.com/293736 | |
| 658 // On Posix, MessagePumpDefault uses system time, so delayed tasks (for | |
| 659 // compositor scheduling) work incorrectly across system time changes | |
| 660 // (e.g. tlsdate). So instead, use an IO loop, which uses libevent, that | |
| 661 // uses monotonic time (immune to these problems). | |
| 662 base::Thread::Options options; | |
| 663 options.message_loop_type = base::MessageLoop::TYPE_IO; | |
| 664 compositor_thread_->StartWithOptions(options); | |
| 665 #else | |
| 666 compositor_thread_->Start(); | 656 compositor_thread_->Start(); |
| 667 #endif | |
| 668 #if defined(OS_ANDROID) | 657 #if defined(OS_ANDROID) |
| 669 compositor_thread_->SetPriority(base::kThreadPriority_Display); | 658 compositor_thread_->SetPriority(base::kThreadPriority_Display); |
| 670 #endif | 659 #endif |
| 671 compositor_message_loop_proxy_ = | 660 compositor_message_loop_proxy_ = |
| 672 compositor_thread_->message_loop_proxy(); | 661 compositor_thread_->message_loop_proxy(); |
| 673 compositor_message_loop_proxy_->PostTask( | 662 compositor_message_loop_proxy_->PostTask( |
| 674 FROM_HERE, | 663 FROM_HERE, |
| 675 base::Bind(base::IgnoreResult(&ThreadRestrictions::SetIOAllowed), | 664 base::Bind(base::IgnoreResult(&ThreadRestrictions::SetIOAllowed), |
| 676 false)); | 665 false)); |
| 677 } | 666 } |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 file_thread_->Start(); | 1264 file_thread_->Start(); |
| 1276 } | 1265 } |
| 1277 return file_thread_->message_loop_proxy(); | 1266 return file_thread_->message_loop_proxy(); |
| 1278 } | 1267 } |
| 1279 | 1268 |
| 1280 scoped_refptr<base::MessageLoopProxy> | 1269 scoped_refptr<base::MessageLoopProxy> |
| 1281 RenderThreadImpl::GetMediaThreadMessageLoopProxy() { | 1270 RenderThreadImpl::GetMediaThreadMessageLoopProxy() { |
| 1282 DCHECK(message_loop() == base::MessageLoop::current()); | 1271 DCHECK(message_loop() == base::MessageLoop::current()); |
| 1283 if (!media_thread_) { | 1272 if (!media_thread_) { |
| 1284 media_thread_.reset(new base::Thread("Media")); | 1273 media_thread_.reset(new base::Thread("Media")); |
| 1285 #if defined(OS_POSIX) | |
| 1286 // Workaround for crbug.com/293736 | |
| 1287 // On Posix, MessagePumpDefault uses system time, so delayed tasks (for | |
| 1288 // compositor scheduling) work incorrectly across system time changes | |
| 1289 // (e.g. tlsdate). So instead, use an IO loop, which uses libevent, that | |
| 1290 // uses monotonic time (immune to these problems). | |
| 1291 base::Thread::Options options; | |
| 1292 options.message_loop_type = base::MessageLoop::TYPE_IO; | |
| 1293 media_thread_->StartWithOptions(options); | |
| 1294 #else | |
| 1295 media_thread_->Start(); | 1274 media_thread_->Start(); |
| 1296 #endif | |
| 1297 | 1275 |
| 1298 #if defined(OS_ANDROID) | 1276 #if defined(OS_ANDROID) |
| 1299 renderer_demuxer_ = new RendererDemuxerAndroid(); | 1277 renderer_demuxer_ = new RendererDemuxerAndroid(); |
| 1300 AddFilter(renderer_demuxer_.get()); | 1278 AddFilter(renderer_demuxer_.get()); |
| 1301 #endif | 1279 #endif |
| 1302 } | 1280 } |
| 1303 return media_thread_->message_loop_proxy(); | 1281 return media_thread_->message_loop_proxy(); |
| 1304 } | 1282 } |
| 1305 | 1283 |
| 1306 void RenderThreadImpl::SetFlingCurveParameters( | 1284 void RenderThreadImpl::SetFlingCurveParameters( |
| 1307 const std::vector<float>& new_touchpad, | 1285 const std::vector<float>& new_touchpad, |
| 1308 const std::vector<float>& new_touchscreen) { | 1286 const std::vector<float>& new_touchscreen) { |
| 1309 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, | 1287 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, |
| 1310 new_touchscreen); | 1288 new_touchscreen); |
| 1311 | 1289 |
| 1312 } | 1290 } |
| 1313 | 1291 |
| 1314 void RenderThreadImpl::SampleGamepads(WebKit::WebGamepads* data) { | 1292 void RenderThreadImpl::SampleGamepads(WebKit::WebGamepads* data) { |
| 1315 if (!gamepad_shared_memory_reader_) | 1293 if (!gamepad_shared_memory_reader_) |
| 1316 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); | 1294 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); |
| 1317 gamepad_shared_memory_reader_->SampleGamepads(*data); | 1295 gamepad_shared_memory_reader_->SampleGamepads(*data); |
| 1318 } | 1296 } |
| 1319 | 1297 |
| 1320 } // namespace content | 1298 } // namespace content |
| OLD | NEW |