| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 #include "third_party/WebKit/public/web/WebView.h" | 152 #include "third_party/WebKit/public/web/WebView.h" |
| 153 #include "third_party/icu/source/i18n/unicode/timezone.h" | 153 #include "third_party/icu/source/i18n/unicode/timezone.h" |
| 154 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" | 154 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" |
| 155 #include "third_party/skia/include/core/SkGraphics.h" | 155 #include "third_party/skia/include/core/SkGraphics.h" |
| 156 #include "ui/base/layout.h" | 156 #include "ui/base/layout.h" |
| 157 #include "ui/base/ui_base_switches.h" | 157 #include "ui/base/ui_base_switches.h" |
| 158 #include "v8/include/v8.h" | 158 #include "v8/include/v8.h" |
| 159 | 159 |
| 160 #if defined(OS_ANDROID) | 160 #if defined(OS_ANDROID) |
| 161 #include <cpu-features.h> | 161 #include <cpu-features.h> |
| 162 #include "content/renderer/android/synchronous_compositor_external_begin_frame_s
ource.h" |
| 162 #include "content/renderer/android/synchronous_compositor_factory.h" | 163 #include "content/renderer/android/synchronous_compositor_factory.h" |
| 164 #include "content/renderer/android/synchronous_compositor_filter.h" |
| 163 #include "content/renderer/media/android/renderer_demuxer_android.h" | 165 #include "content/renderer/media/android/renderer_demuxer_android.h" |
| 164 #endif | 166 #endif |
| 165 | 167 |
| 166 #if defined(OS_MACOSX) | 168 #if defined(OS_MACOSX) |
| 167 #include "base/mac/mac_util.h" | 169 #include "base/mac/mac_util.h" |
| 168 #include "content/renderer/theme_helper_mac.h" | 170 #include "content/renderer/theme_helper_mac.h" |
| 169 #include "content/renderer/webscrollbarbehavior_impl_mac.h" | 171 #include "content/renderer/webscrollbarbehavior_impl_mac.h" |
| 170 #endif | 172 #endif |
| 171 | 173 |
| 172 #if defined(OS_POSIX) | 174 #if defined(OS_POSIX) |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 | 852 |
| 851 // Shutdown the file thread if it's running. | 853 // Shutdown the file thread if it's running. |
| 852 if (file_thread_) | 854 if (file_thread_) |
| 853 file_thread_->Stop(); | 855 file_thread_->Stop(); |
| 854 | 856 |
| 855 if (compositor_message_filter_.get()) { | 857 if (compositor_message_filter_.get()) { |
| 856 RemoveFilter(compositor_message_filter_.get()); | 858 RemoveFilter(compositor_message_filter_.get()); |
| 857 compositor_message_filter_ = NULL; | 859 compositor_message_filter_ = NULL; |
| 858 } | 860 } |
| 859 | 861 |
| 862 #if defined(OS_ANDROID) |
| 863 if (sync_compositor_message_filter_.get()) { |
| 864 RemoveFilter(sync_compositor_message_filter_.get()); |
| 865 sync_compositor_message_filter_ = NULL; |
| 866 } |
| 867 #endif |
| 868 |
| 860 media_thread_.reset(); | 869 media_thread_.reset(); |
| 861 | 870 |
| 862 compositor_thread_.reset(); | 871 compositor_thread_.reset(); |
| 863 | 872 |
| 864 // AudioMessageFilter may be accessed on |media_thread_|, so shutdown after. | 873 // AudioMessageFilter may be accessed on |media_thread_|, so shutdown after. |
| 865 RemoveFilter(audio_message_filter_.get()); | 874 RemoveFilter(audio_message_filter_.get()); |
| 866 audio_message_filter_ = NULL; | 875 audio_message_filter_ = NULL; |
| 867 | 876 |
| 868 raster_worker_pool_->Shutdown(); | 877 raster_worker_pool_->Shutdown(); |
| 869 | 878 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 | 1131 |
| 1123 main_input_callback_.Reset( | 1132 main_input_callback_.Reset( |
| 1124 base::Bind(base::IgnoreResult(&RenderThreadImpl::OnMessageReceived), | 1133 base::Bind(base::IgnoreResult(&RenderThreadImpl::OnMessageReceived), |
| 1125 base::Unretained(this))); | 1134 base::Unretained(this))); |
| 1126 | 1135 |
| 1127 SetResourceDispatchTaskQueue(renderer_scheduler_->LoadingTaskRunner()); | 1136 SetResourceDispatchTaskQueue(renderer_scheduler_->LoadingTaskRunner()); |
| 1128 | 1137 |
| 1129 bool enable = !command_line.HasSwitch(switches::kDisableThreadedCompositing); | 1138 bool enable = !command_line.HasSwitch(switches::kDisableThreadedCompositing); |
| 1130 if (enable) { | 1139 if (enable) { |
| 1131 #if defined(OS_ANDROID) | 1140 #if defined(OS_ANDROID) |
| 1132 if (SynchronousCompositorFactory* factory = | 1141 SynchronousCompositorFactory* sync_compositor_factory = |
| 1133 SynchronousCompositorFactory::GetInstance()) | 1142 SynchronousCompositorFactory::GetInstance(); |
| 1134 compositor_task_runner_ = factory->GetCompositorTaskRunner(); | 1143 bool using_ipc_sync_compositing = |
| 1144 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1145 switches::kIPCSyncCompositing); |
| 1146 DCHECK(!sync_compositor_factory || !using_ipc_sync_compositing); |
| 1147 |
| 1148 if (sync_compositor_factory) { |
| 1149 compositor_task_runner_ = |
| 1150 sync_compositor_factory->GetCompositorTaskRunner(); |
| 1151 } |
| 1135 #endif | 1152 #endif |
| 1136 if (!compositor_task_runner_.get()) { | 1153 if (!compositor_task_runner_.get()) { |
| 1137 compositor_thread_.reset(new base::Thread("Compositor")); | 1154 compositor_thread_.reset(new base::Thread("Compositor")); |
| 1138 base::Thread::Options compositor_thread_options; | 1155 base::Thread::Options compositor_thread_options; |
| 1139 #if defined(OS_ANDROID) | 1156 #if defined(OS_ANDROID) |
| 1140 compositor_thread_options.priority = base::ThreadPriority::DISPLAY; | 1157 compositor_thread_options.priority = base::ThreadPriority::DISPLAY; |
| 1141 #endif | 1158 #endif |
| 1142 compositor_thread_->StartWithOptions(compositor_thread_options); | 1159 compositor_thread_->StartWithOptions(compositor_thread_options); |
| 1143 compositor_task_runner_ = compositor_thread_->task_runner(); | 1160 compositor_task_runner_ = compositor_thread_->task_runner(); |
| 1144 compositor_task_runner_->PostTask( | 1161 compositor_task_runner_->PostTask( |
| 1145 FROM_HERE, | 1162 FROM_HERE, |
| 1146 base::Bind(base::IgnoreResult(&ThreadRestrictions::SetIOAllowed), | 1163 base::Bind(base::IgnoreResult(&ThreadRestrictions::SetIOAllowed), |
| 1147 false)); | 1164 false)); |
| 1148 } | 1165 } |
| 1149 | 1166 |
| 1150 InputHandlerManagerClient* input_handler_manager_client = NULL; | 1167 InputHandlerManagerClient* input_handler_manager_client = NULL; |
| 1151 #if defined(OS_ANDROID) | 1168 #if defined(OS_ANDROID) |
| 1152 if (SynchronousCompositorFactory* factory = | 1169 if (using_ipc_sync_compositing) { |
| 1153 SynchronousCompositorFactory::GetInstance()) { | 1170 sync_compositor_message_filter_ = |
| 1154 input_handler_manager_client = factory->GetInputHandlerManagerClient(); | 1171 new SynchronousCompositorFilter(compositor_task_runner_); |
| 1172 AddFilter(sync_compositor_message_filter_.get()); |
| 1173 input_handler_manager_client = sync_compositor_message_filter_.get(); |
| 1174 } else if (sync_compositor_factory) { |
| 1175 input_handler_manager_client = |
| 1176 sync_compositor_factory->GetInputHandlerManagerClient(); |
| 1155 } | 1177 } |
| 1156 #endif | 1178 #endif |
| 1157 if (!input_handler_manager_client) { | 1179 if (!input_handler_manager_client) { |
| 1158 scoped_refptr<InputEventFilter> compositor_input_event_filter( | 1180 scoped_refptr<InputEventFilter> compositor_input_event_filter( |
| 1159 new InputEventFilter(main_input_callback_.callback(), | 1181 new InputEventFilter(main_input_callback_.callback(), |
| 1160 main_thread_compositor_task_runner_, | 1182 main_thread_compositor_task_runner_, |
| 1161 compositor_task_runner_)); | 1183 compositor_task_runner_)); |
| 1162 input_handler_manager_client = compositor_input_event_filter.get(); | 1184 input_handler_manager_client = compositor_input_event_filter.get(); |
| 1163 input_event_filter_ = compositor_input_event_filter; | 1185 input_event_filter_ = compositor_input_event_filter; |
| 1164 } | 1186 } |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1537 | 1559 |
| 1538 cc::ContextProvider* RenderThreadImpl::GetSharedMainThreadContextProvider() { | 1560 cc::ContextProvider* RenderThreadImpl::GetSharedMainThreadContextProvider() { |
| 1539 return SharedMainThreadContextProvider().get(); | 1561 return SharedMainThreadContextProvider().get(); |
| 1540 } | 1562 } |
| 1541 | 1563 |
| 1542 scoped_ptr<cc::BeginFrameSource> | 1564 scoped_ptr<cc::BeginFrameSource> |
| 1543 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) { | 1565 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) { |
| 1544 #if defined(OS_ANDROID) | 1566 #if defined(OS_ANDROID) |
| 1545 if (SynchronousCompositorFactory* factory = | 1567 if (SynchronousCompositorFactory* factory = |
| 1546 SynchronousCompositorFactory::GetInstance()) { | 1568 SynchronousCompositorFactory::GetInstance()) { |
| 1569 DCHECK(!sync_compositor_message_filter_.get()); |
| 1547 return factory->CreateExternalBeginFrameSource(routing_id); | 1570 return factory->CreateExternalBeginFrameSource(routing_id); |
| 1571 } else if (sync_compositor_message_filter_.get()) { |
| 1572 return make_scoped_ptr(new SynchronousCompositorExternalBeginFrameSource( |
| 1573 routing_id, sync_compositor_message_filter_.get())); |
| 1548 } | 1574 } |
| 1549 #endif | 1575 #endif |
| 1550 return make_scoped_ptr(new CompositorExternalBeginFrameSource( | 1576 return make_scoped_ptr(new CompositorExternalBeginFrameSource( |
| 1551 compositor_message_filter_.get(), sync_message_filter(), routing_id)); | 1577 compositor_message_filter_.get(), sync_message_filter(), routing_id)); |
| 1552 } | 1578 } |
| 1553 | 1579 |
| 1554 cc::TaskGraphRunner* RenderThreadImpl::GetTaskGraphRunner() { | 1580 cc::TaskGraphRunner* RenderThreadImpl::GetTaskGraphRunner() { |
| 1555 return raster_worker_pool_->GetTaskGraphRunner(); | 1581 return raster_worker_pool_->GetTaskGraphRunner(); |
| 1556 } | 1582 } |
| 1557 | 1583 |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2006 } | 2032 } |
| 2007 | 2033 |
| 2008 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 2034 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
| 2009 size_t erased = | 2035 size_t erased = |
| 2010 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 2036 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
| 2011 routing_id_); | 2037 routing_id_); |
| 2012 DCHECK_EQ(1u, erased); | 2038 DCHECK_EQ(1u, erased); |
| 2013 } | 2039 } |
| 2014 | 2040 |
| 2015 } // namespace content | 2041 } // namespace content |
| OLD | NEW |