| 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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 | 855 |
| 854 // Shutdown the file thread if it's running. | 856 // Shutdown the file thread if it's running. |
| 855 if (file_thread_) | 857 if (file_thread_) |
| 856 file_thread_->Stop(); | 858 file_thread_->Stop(); |
| 857 | 859 |
| 858 if (compositor_message_filter_.get()) { | 860 if (compositor_message_filter_.get()) { |
| 859 RemoveFilter(compositor_message_filter_.get()); | 861 RemoveFilter(compositor_message_filter_.get()); |
| 860 compositor_message_filter_ = NULL; | 862 compositor_message_filter_ = NULL; |
| 861 } | 863 } |
| 862 | 864 |
| 865 #if defined(OS_ANDROID) |
| 866 if (sync_compositor_message_filter_.get()) { |
| 867 RemoveFilter(sync_compositor_message_filter_.get()); |
| 868 sync_compositor_message_filter_ = NULL; |
| 869 } |
| 870 #endif |
| 871 |
| 863 media_thread_.reset(); | 872 media_thread_.reset(); |
| 864 | 873 |
| 865 compositor_thread_.reset(); | 874 compositor_thread_.reset(); |
| 866 | 875 |
| 867 // AudioMessageFilter may be accessed on |media_thread_|, so shutdown after. | 876 // AudioMessageFilter may be accessed on |media_thread_|, so shutdown after. |
| 868 RemoveFilter(audio_message_filter_.get()); | 877 RemoveFilter(audio_message_filter_.get()); |
| 869 audio_message_filter_ = NULL; | 878 audio_message_filter_ = NULL; |
| 870 | 879 |
| 871 raster_worker_pool_->Shutdown(); | 880 raster_worker_pool_->Shutdown(); |
| 872 | 881 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 | 1134 |
| 1126 main_input_callback_.Reset( | 1135 main_input_callback_.Reset( |
| 1127 base::Bind(base::IgnoreResult(&RenderThreadImpl::OnMessageReceived), | 1136 base::Bind(base::IgnoreResult(&RenderThreadImpl::OnMessageReceived), |
| 1128 base::Unretained(this))); | 1137 base::Unretained(this))); |
| 1129 | 1138 |
| 1130 SetResourceDispatchTaskQueue(renderer_scheduler_->LoadingTaskRunner()); | 1139 SetResourceDispatchTaskQueue(renderer_scheduler_->LoadingTaskRunner()); |
| 1131 | 1140 |
| 1132 bool enable = !command_line.HasSwitch(switches::kDisableThreadedCompositing); | 1141 bool enable = !command_line.HasSwitch(switches::kDisableThreadedCompositing); |
| 1133 if (enable) { | 1142 if (enable) { |
| 1134 #if defined(OS_ANDROID) | 1143 #if defined(OS_ANDROID) |
| 1135 if (SynchronousCompositorFactory* factory = | 1144 SynchronousCompositorFactory* sync_compositor_factory = |
| 1136 SynchronousCompositorFactory::GetInstance()) | 1145 SynchronousCompositorFactory::GetInstance(); |
| 1137 compositor_task_runner_ = factory->GetCompositorTaskRunner(); | 1146 bool using_ipc_sync_compositing = |
| 1147 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1148 switches::kIPCSyncCompositing); |
| 1149 DCHECK(!sync_compositor_factory || !using_ipc_sync_compositing); |
| 1150 |
| 1151 if (sync_compositor_factory) { |
| 1152 compositor_task_runner_ = |
| 1153 sync_compositor_factory->GetCompositorTaskRunner(); |
| 1154 } |
| 1138 #endif | 1155 #endif |
| 1139 if (!compositor_task_runner_.get()) { | 1156 if (!compositor_task_runner_.get()) { |
| 1140 compositor_thread_.reset(new base::Thread("Compositor")); | 1157 compositor_thread_.reset(new base::Thread("Compositor")); |
| 1141 base::Thread::Options compositor_thread_options; | 1158 base::Thread::Options compositor_thread_options; |
| 1142 #if defined(OS_ANDROID) | 1159 #if defined(OS_ANDROID) |
| 1143 compositor_thread_options.priority = base::ThreadPriority::DISPLAY; | 1160 compositor_thread_options.priority = base::ThreadPriority::DISPLAY; |
| 1144 #endif | 1161 #endif |
| 1145 compositor_thread_->StartWithOptions(compositor_thread_options); | 1162 compositor_thread_->StartWithOptions(compositor_thread_options); |
| 1146 compositor_task_runner_ = compositor_thread_->task_runner(); | 1163 compositor_task_runner_ = compositor_thread_->task_runner(); |
| 1147 compositor_task_runner_->PostTask( | 1164 compositor_task_runner_->PostTask( |
| 1148 FROM_HERE, | 1165 FROM_HERE, |
| 1149 base::Bind(base::IgnoreResult(&ThreadRestrictions::SetIOAllowed), | 1166 base::Bind(base::IgnoreResult(&ThreadRestrictions::SetIOAllowed), |
| 1150 false)); | 1167 false)); |
| 1151 } | 1168 } |
| 1152 | 1169 |
| 1153 InputHandlerManagerClient* input_handler_manager_client = NULL; | 1170 InputHandlerManagerClient* input_handler_manager_client = NULL; |
| 1154 #if defined(OS_ANDROID) | 1171 #if defined(OS_ANDROID) |
| 1155 if (SynchronousCompositorFactory* factory = | 1172 if (using_ipc_sync_compositing) { |
| 1156 SynchronousCompositorFactory::GetInstance()) { | 1173 sync_compositor_message_filter_ = |
| 1157 input_handler_manager_client = factory->GetInputHandlerManagerClient(); | 1174 new SynchronousCompositorFilter(compositor_task_runner_); |
| 1175 AddFilter(sync_compositor_message_filter_.get()); |
| 1176 input_handler_manager_client = sync_compositor_message_filter_.get(); |
| 1177 } else if (sync_compositor_factory) { |
| 1178 input_handler_manager_client = |
| 1179 sync_compositor_factory->GetInputHandlerManagerClient(); |
| 1158 } | 1180 } |
| 1159 #endif | 1181 #endif |
| 1160 if (!input_handler_manager_client) { | 1182 if (!input_handler_manager_client) { |
| 1161 scoped_refptr<InputEventFilter> compositor_input_event_filter( | 1183 scoped_refptr<InputEventFilter> compositor_input_event_filter( |
| 1162 new InputEventFilter(main_input_callback_.callback(), | 1184 new InputEventFilter(main_input_callback_.callback(), |
| 1163 main_thread_compositor_task_runner_, | 1185 main_thread_compositor_task_runner_, |
| 1164 compositor_task_runner_)); | 1186 compositor_task_runner_)); |
| 1165 input_handler_manager_client = compositor_input_event_filter.get(); | 1187 input_handler_manager_client = compositor_input_event_filter.get(); |
| 1166 input_event_filter_ = compositor_input_event_filter; | 1188 input_event_filter_ = compositor_input_event_filter; |
| 1167 } | 1189 } |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1540 | 1562 |
| 1541 cc::ContextProvider* RenderThreadImpl::GetSharedMainThreadContextProvider() { | 1563 cc::ContextProvider* RenderThreadImpl::GetSharedMainThreadContextProvider() { |
| 1542 return SharedMainThreadContextProvider().get(); | 1564 return SharedMainThreadContextProvider().get(); |
| 1543 } | 1565 } |
| 1544 | 1566 |
| 1545 scoped_ptr<cc::BeginFrameSource> | 1567 scoped_ptr<cc::BeginFrameSource> |
| 1546 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) { | 1568 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) { |
| 1547 #if defined(OS_ANDROID) | 1569 #if defined(OS_ANDROID) |
| 1548 if (SynchronousCompositorFactory* factory = | 1570 if (SynchronousCompositorFactory* factory = |
| 1549 SynchronousCompositorFactory::GetInstance()) { | 1571 SynchronousCompositorFactory::GetInstance()) { |
| 1572 DCHECK(!sync_compositor_message_filter_.get()); |
| 1550 return factory->CreateExternalBeginFrameSource(routing_id); | 1573 return factory->CreateExternalBeginFrameSource(routing_id); |
| 1574 } else if (sync_compositor_message_filter_.get()) { |
| 1575 return make_scoped_ptr(new SynchronousCompositorExternalBeginFrameSource( |
| 1576 routing_id, sync_compositor_message_filter_.get())); |
| 1551 } | 1577 } |
| 1552 #endif | 1578 #endif |
| 1553 return make_scoped_ptr(new CompositorExternalBeginFrameSource( | 1579 return make_scoped_ptr(new CompositorExternalBeginFrameSource( |
| 1554 compositor_message_filter_.get(), sync_message_filter(), routing_id)); | 1580 compositor_message_filter_.get(), sync_message_filter(), routing_id)); |
| 1555 } | 1581 } |
| 1556 | 1582 |
| 1557 cc::TaskGraphRunner* RenderThreadImpl::GetTaskGraphRunner() { | 1583 cc::TaskGraphRunner* RenderThreadImpl::GetTaskGraphRunner() { |
| 1558 return raster_worker_pool_->GetTaskGraphRunner(); | 1584 return raster_worker_pool_->GetTaskGraphRunner(); |
| 1559 } | 1585 } |
| 1560 | 1586 |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2009 } | 2035 } |
| 2010 | 2036 |
| 2011 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 2037 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
| 2012 size_t erased = | 2038 size_t erased = |
| 2013 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 2039 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
| 2014 routing_id_); | 2040 routing_id_); |
| 2015 DCHECK_EQ(1u, erased); | 2041 DCHECK_EQ(1u, erased); |
| 2016 } | 2042 } |
| 2017 | 2043 |
| 2018 } // namespace content | 2044 } // namespace content |
| OLD | NEW |