| 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 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 | 854 |
| 853 // Shutdown the file thread if it's running. | 855 // Shutdown the file thread if it's running. |
| 854 if (file_thread_) | 856 if (file_thread_) |
| 855 file_thread_->Stop(); | 857 file_thread_->Stop(); |
| 856 | 858 |
| 857 if (compositor_message_filter_.get()) { | 859 if (compositor_message_filter_.get()) { |
| 858 RemoveFilter(compositor_message_filter_.get()); | 860 RemoveFilter(compositor_message_filter_.get()); |
| 859 compositor_message_filter_ = NULL; | 861 compositor_message_filter_ = NULL; |
| 860 } | 862 } |
| 861 | 863 |
| 864 #if defined(OS_ANDROID) |
| 865 if (sync_compositor_message_filter_) { |
| 866 RemoveFilter(sync_compositor_message_filter_.get()); |
| 867 sync_compositor_message_filter_ = nullptr; |
| 868 } |
| 869 #endif |
| 870 |
| 862 media_thread_.reset(); | 871 media_thread_.reset(); |
| 863 | 872 |
| 864 compositor_thread_.reset(); | 873 compositor_thread_.reset(); |
| 865 | 874 |
| 866 // AudioMessageFilter may be accessed on |media_thread_|, so shutdown after. | 875 // AudioMessageFilter may be accessed on |media_thread_|, so shutdown after. |
| 867 RemoveFilter(audio_message_filter_.get()); | 876 RemoveFilter(audio_message_filter_.get()); |
| 868 audio_message_filter_ = NULL; | 877 audio_message_filter_ = NULL; |
| 869 | 878 |
| 870 raster_worker_pool_->Shutdown(); | 879 raster_worker_pool_->Shutdown(); |
| 871 | 880 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 | 1133 |
| 1125 main_input_callback_.Reset( | 1134 main_input_callback_.Reset( |
| 1126 base::Bind(base::IgnoreResult(&RenderThreadImpl::OnMessageReceived), | 1135 base::Bind(base::IgnoreResult(&RenderThreadImpl::OnMessageReceived), |
| 1127 base::Unretained(this))); | 1136 base::Unretained(this))); |
| 1128 | 1137 |
| 1129 SetResourceDispatchTaskQueue(renderer_scheduler_->LoadingTaskRunner()); | 1138 SetResourceDispatchTaskQueue(renderer_scheduler_->LoadingTaskRunner()); |
| 1130 | 1139 |
| 1131 bool enable = !command_line.HasSwitch(switches::kDisableThreadedCompositing); | 1140 bool enable = !command_line.HasSwitch(switches::kDisableThreadedCompositing); |
| 1132 if (enable) { | 1141 if (enable) { |
| 1133 #if defined(OS_ANDROID) | 1142 #if defined(OS_ANDROID) |
| 1134 if (SynchronousCompositorFactory* factory = | 1143 SynchronousCompositorFactory* sync_compositor_factory = |
| 1135 SynchronousCompositorFactory::GetInstance()) | 1144 SynchronousCompositorFactory::GetInstance(); |
| 1136 compositor_task_runner_ = factory->GetCompositorTaskRunner(); | 1145 bool using_ipc_sync_compositing = |
| 1146 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1147 switches::kIPCSyncCompositing); |
| 1148 DCHECK(!sync_compositor_factory || !using_ipc_sync_compositing); |
| 1149 |
| 1150 if (sync_compositor_factory) { |
| 1151 compositor_task_runner_ = |
| 1152 sync_compositor_factory->GetCompositorTaskRunner(); |
| 1153 } |
| 1137 #endif | 1154 #endif |
| 1138 if (!compositor_task_runner_.get()) { | 1155 if (!compositor_task_runner_) { |
| 1139 compositor_thread_.reset(new base::Thread("Compositor")); | 1156 compositor_thread_.reset(new base::Thread("Compositor")); |
| 1140 base::Thread::Options compositor_thread_options; | 1157 base::Thread::Options compositor_thread_options; |
| 1141 #if defined(OS_ANDROID) | 1158 #if defined(OS_ANDROID) |
| 1142 compositor_thread_options.priority = base::ThreadPriority::DISPLAY; | 1159 compositor_thread_options.priority = base::ThreadPriority::DISPLAY; |
| 1143 #endif | 1160 #endif |
| 1144 compositor_thread_->StartWithOptions(compositor_thread_options); | 1161 compositor_thread_->StartWithOptions(compositor_thread_options); |
| 1145 compositor_task_runner_ = compositor_thread_->task_runner(); | 1162 compositor_task_runner_ = compositor_thread_->task_runner(); |
| 1146 compositor_task_runner_->PostTask( | 1163 compositor_task_runner_->PostTask( |
| 1147 FROM_HERE, | 1164 FROM_HERE, |
| 1148 base::Bind(base::IgnoreResult(&ThreadRestrictions::SetIOAllowed), | 1165 base::Bind(base::IgnoreResult(&ThreadRestrictions::SetIOAllowed), |
| 1149 false)); | 1166 false)); |
| 1150 } | 1167 } |
| 1151 | 1168 |
| 1152 InputHandlerManagerClient* input_handler_manager_client = NULL; | 1169 InputHandlerManagerClient* input_handler_manager_client = NULL; |
| 1153 #if defined(OS_ANDROID) | 1170 #if defined(OS_ANDROID) |
| 1154 if (SynchronousCompositorFactory* factory = | 1171 if (using_ipc_sync_compositing) { |
| 1155 SynchronousCompositorFactory::GetInstance()) { | 1172 sync_compositor_message_filter_ = |
| 1156 input_handler_manager_client = factory->GetInputHandlerManagerClient(); | 1173 new SynchronousCompositorFilter(compositor_task_runner_); |
| 1174 AddFilter(sync_compositor_message_filter_.get()); |
| 1175 input_handler_manager_client = sync_compositor_message_filter_.get(); |
| 1176 } else if (sync_compositor_factory) { |
| 1177 input_handler_manager_client = |
| 1178 sync_compositor_factory->GetInputHandlerManagerClient(); |
| 1157 } | 1179 } |
| 1158 #endif | 1180 #endif |
| 1159 if (!input_handler_manager_client) { | 1181 if (!input_handler_manager_client) { |
| 1160 scoped_refptr<InputEventFilter> compositor_input_event_filter( | 1182 scoped_refptr<InputEventFilter> compositor_input_event_filter( |
| 1161 new InputEventFilter(main_input_callback_.callback(), | 1183 new InputEventFilter(main_input_callback_.callback(), |
| 1162 main_thread_compositor_task_runner_, | 1184 main_thread_compositor_task_runner_, |
| 1163 compositor_task_runner_)); | 1185 compositor_task_runner_)); |
| 1164 input_handler_manager_client = compositor_input_event_filter.get(); | 1186 input_handler_manager_client = compositor_input_event_filter.get(); |
| 1165 input_event_filter_ = compositor_input_event_filter; | 1187 input_event_filter_ = compositor_input_event_filter; |
| 1166 } | 1188 } |
| (...skipping 370 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_); |
| 1547 return factory->CreateExternalBeginFrameSource(routing_id); | 1570 return factory->CreateExternalBeginFrameSource(routing_id); |
| 1571 } else if (sync_compositor_message_filter_) { |
| 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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2008 } | 2034 } |
| 2009 | 2035 |
| 2010 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 2036 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
| 2011 size_t erased = | 2037 size_t erased = |
| 2012 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 2038 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
| 2013 routing_id_); | 2039 routing_id_); |
| 2014 DCHECK_EQ(1u, erased); | 2040 DCHECK_EQ(1u, erased); |
| 2015 } | 2041 } |
| 2016 | 2042 |
| 2017 } // namespace content | 2043 } // namespace content |
| OLD | NEW |