| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 #include "third_party/WebKit/public/web/WebView.h" | 150 #include "third_party/WebKit/public/web/WebView.h" |
| 151 #include "third_party/icu/source/i18n/unicode/timezone.h" | 151 #include "third_party/icu/source/i18n/unicode/timezone.h" |
| 152 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" | 152 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" |
| 153 #include "third_party/skia/include/core/SkGraphics.h" | 153 #include "third_party/skia/include/core/SkGraphics.h" |
| 154 #include "ui/base/layout.h" | 154 #include "ui/base/layout.h" |
| 155 #include "ui/base/ui_base_switches.h" | 155 #include "ui/base/ui_base_switches.h" |
| 156 #include "v8/include/v8.h" | 156 #include "v8/include/v8.h" |
| 157 | 157 |
| 158 #if defined(OS_ANDROID) | 158 #if defined(OS_ANDROID) |
| 159 #include <cpu-features.h> | 159 #include <cpu-features.h> |
| 160 #include "content/renderer/android/synchronous_compositor_external_begin_frame_s
ource.h" |
| 160 #include "content/renderer/android/synchronous_compositor_factory.h" | 161 #include "content/renderer/android/synchronous_compositor_factory.h" |
| 162 #include "content/renderer/android/synchronous_compositor_filter.h" |
| 161 #include "content/renderer/media/android/renderer_demuxer_android.h" | 163 #include "content/renderer/media/android/renderer_demuxer_android.h" |
| 162 #endif | 164 #endif |
| 163 | 165 |
| 164 #if defined(OS_MACOSX) | 166 #if defined(OS_MACOSX) |
| 165 #include "base/mac/mac_util.h" | 167 #include "base/mac/mac_util.h" |
| 166 #include "content/renderer/theme_helper_mac.h" | 168 #include "content/renderer/theme_helper_mac.h" |
| 167 #include "content/renderer/webscrollbarbehavior_impl_mac.h" | 169 #include "content/renderer/webscrollbarbehavior_impl_mac.h" |
| 168 #endif | 170 #endif |
| 169 | 171 |
| 170 #if defined(OS_POSIX) | 172 #if defined(OS_POSIX) |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 | 811 |
| 810 // Shutdown the file thread if it's running. | 812 // Shutdown the file thread if it's running. |
| 811 if (file_thread_) | 813 if (file_thread_) |
| 812 file_thread_->Stop(); | 814 file_thread_->Stop(); |
| 813 | 815 |
| 814 if (compositor_message_filter_.get()) { | 816 if (compositor_message_filter_.get()) { |
| 815 RemoveFilter(compositor_message_filter_.get()); | 817 RemoveFilter(compositor_message_filter_.get()); |
| 816 compositor_message_filter_ = NULL; | 818 compositor_message_filter_ = NULL; |
| 817 } | 819 } |
| 818 | 820 |
| 821 #if defined(OS_ANDROID) |
| 822 if (sync_compositor_message_filter_.get()) { |
| 823 RemoveFilter(sync_compositor_message_filter_.get()); |
| 824 sync_compositor_message_filter_ = NULL; |
| 825 } |
| 826 #endif |
| 827 |
| 819 media_thread_.reset(); | 828 media_thread_.reset(); |
| 820 | 829 |
| 821 compositor_thread_.reset(); | 830 compositor_thread_.reset(); |
| 822 | 831 |
| 823 // AudioMessageFilter may be accessed on |media_thread_|, so shutdown after. | 832 // AudioMessageFilter may be accessed on |media_thread_|, so shutdown after. |
| 824 RemoveFilter(audio_message_filter_.get()); | 833 RemoveFilter(audio_message_filter_.get()); |
| 825 audio_message_filter_ = NULL; | 834 audio_message_filter_ = NULL; |
| 826 | 835 |
| 827 raster_worker_pool_->Shutdown(); | 836 raster_worker_pool_->Shutdown(); |
| 828 | 837 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 | 1090 |
| 1082 main_input_callback_.Reset( | 1091 main_input_callback_.Reset( |
| 1083 base::Bind(base::IgnoreResult(&RenderThreadImpl::OnMessageReceived), | 1092 base::Bind(base::IgnoreResult(&RenderThreadImpl::OnMessageReceived), |
| 1084 base::Unretained(this))); | 1093 base::Unretained(this))); |
| 1085 | 1094 |
| 1086 SetResourceDispatchTaskQueue(renderer_scheduler_->LoadingTaskRunner()); | 1095 SetResourceDispatchTaskQueue(renderer_scheduler_->LoadingTaskRunner()); |
| 1087 | 1096 |
| 1088 bool enable = !command_line.HasSwitch(switches::kDisableThreadedCompositing); | 1097 bool enable = !command_line.HasSwitch(switches::kDisableThreadedCompositing); |
| 1089 if (enable) { | 1098 if (enable) { |
| 1090 #if defined(OS_ANDROID) | 1099 #if defined(OS_ANDROID) |
| 1091 if (SynchronousCompositorFactory* factory = | 1100 SynchronousCompositorFactory* sync_compositor_factory = |
| 1092 SynchronousCompositorFactory::GetInstance()) | 1101 SynchronousCompositorFactory::GetInstance(); |
| 1093 compositor_task_runner_ = factory->GetCompositorTaskRunner(); | 1102 bool using_ipc_sync_compositing = |
| 1103 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1104 switches::kIPCSyncCompositing); |
| 1105 DCHECK(!sync_compositor_factory || !using_ipc_sync_compositing); |
| 1106 |
| 1107 if (sync_compositor_factory) { |
| 1108 compositor_task_runner_ = |
| 1109 sync_compositor_factory->GetCompositorTaskRunner(); |
| 1110 } |
| 1094 #endif | 1111 #endif |
| 1095 if (!compositor_task_runner_.get()) { | 1112 if (!compositor_task_runner_.get()) { |
| 1096 compositor_thread_.reset(new base::Thread("Compositor")); | 1113 compositor_thread_.reset(new base::Thread("Compositor")); |
| 1097 base::Thread::Options compositor_thread_options; | 1114 base::Thread::Options compositor_thread_options; |
| 1098 #if defined(OS_ANDROID) | 1115 #if defined(OS_ANDROID) |
| 1099 compositor_thread_options.priority = base::ThreadPriority::DISPLAY; | 1116 compositor_thread_options.priority = base::ThreadPriority::DISPLAY; |
| 1100 #endif | 1117 #endif |
| 1101 compositor_thread_->StartWithOptions(compositor_thread_options); | 1118 compositor_thread_->StartWithOptions(compositor_thread_options); |
| 1102 compositor_task_runner_ = compositor_thread_->task_runner(); | 1119 compositor_task_runner_ = compositor_thread_->task_runner(); |
| 1103 compositor_task_runner_->PostTask( | 1120 compositor_task_runner_->PostTask( |
| 1104 FROM_HERE, | 1121 FROM_HERE, |
| 1105 base::Bind(base::IgnoreResult(&ThreadRestrictions::SetIOAllowed), | 1122 base::Bind(base::IgnoreResult(&ThreadRestrictions::SetIOAllowed), |
| 1106 false)); | 1123 false)); |
| 1107 } | 1124 } |
| 1108 | 1125 |
| 1109 InputHandlerManagerClient* input_handler_manager_client = NULL; | 1126 InputHandlerManagerClient* input_handler_manager_client = NULL; |
| 1110 #if defined(OS_ANDROID) | 1127 #if defined(OS_ANDROID) |
| 1111 if (SynchronousCompositorFactory* factory = | 1128 if (using_ipc_sync_compositing) { |
| 1112 SynchronousCompositorFactory::GetInstance()) { | 1129 sync_compositor_message_filter_ = |
| 1113 input_handler_manager_client = factory->GetInputHandlerManagerClient(); | 1130 new SynchronousCompositorFilter(compositor_task_runner_); |
| 1131 AddFilter(sync_compositor_message_filter_.get()); |
| 1132 input_handler_manager_client = sync_compositor_message_filter_.get(); |
| 1133 } else if (sync_compositor_factory) { |
| 1134 input_handler_manager_client = |
| 1135 sync_compositor_factory->GetInputHandlerManagerClient(); |
| 1114 } | 1136 } |
| 1115 #endif | 1137 #endif |
| 1116 if (!input_handler_manager_client) { | 1138 if (!input_handler_manager_client) { |
| 1117 scoped_refptr<InputEventFilter> compositor_input_event_filter( | 1139 scoped_refptr<InputEventFilter> compositor_input_event_filter( |
| 1118 new InputEventFilter(main_input_callback_.callback(), | 1140 new InputEventFilter(main_input_callback_.callback(), |
| 1119 main_thread_compositor_task_runner_, | 1141 main_thread_compositor_task_runner_, |
| 1120 compositor_task_runner_)); | 1142 compositor_task_runner_)); |
| 1121 input_handler_manager_client = compositor_input_event_filter.get(); | 1143 input_handler_manager_client = compositor_input_event_filter.get(); |
| 1122 input_event_filter_ = compositor_input_event_filter; | 1144 input_event_filter_ = compositor_input_event_filter; |
| 1123 } | 1145 } |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 | 1518 |
| 1497 cc::ContextProvider* RenderThreadImpl::GetSharedMainThreadContextProvider() { | 1519 cc::ContextProvider* RenderThreadImpl::GetSharedMainThreadContextProvider() { |
| 1498 return SharedMainThreadContextProvider().get(); | 1520 return SharedMainThreadContextProvider().get(); |
| 1499 } | 1521 } |
| 1500 | 1522 |
| 1501 scoped_ptr<cc::BeginFrameSource> | 1523 scoped_ptr<cc::BeginFrameSource> |
| 1502 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) { | 1524 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) { |
| 1503 #if defined(OS_ANDROID) | 1525 #if defined(OS_ANDROID) |
| 1504 if (SynchronousCompositorFactory* factory = | 1526 if (SynchronousCompositorFactory* factory = |
| 1505 SynchronousCompositorFactory::GetInstance()) { | 1527 SynchronousCompositorFactory::GetInstance()) { |
| 1528 DCHECK(!sync_compositor_message_filter_.get()); |
| 1506 return factory->CreateExternalBeginFrameSource(routing_id); | 1529 return factory->CreateExternalBeginFrameSource(routing_id); |
| 1530 } else if (sync_compositor_message_filter_.get()) { |
| 1531 return make_scoped_ptr(new SynchronousCompositorExternalBeginFrameSource( |
| 1532 routing_id, sync_compositor_message_filter_.get())); |
| 1507 } | 1533 } |
| 1508 #endif | 1534 #endif |
| 1509 return make_scoped_ptr(new CompositorExternalBeginFrameSource( | 1535 return make_scoped_ptr(new CompositorExternalBeginFrameSource( |
| 1510 compositor_message_filter_.get(), sync_message_filter(), routing_id)); | 1536 compositor_message_filter_.get(), sync_message_filter(), routing_id)); |
| 1511 } | 1537 } |
| 1512 | 1538 |
| 1513 cc::TaskGraphRunner* RenderThreadImpl::GetTaskGraphRunner() { | 1539 cc::TaskGraphRunner* RenderThreadImpl::GetTaskGraphRunner() { |
| 1514 return raster_worker_pool_->GetTaskGraphRunner(); | 1540 return raster_worker_pool_->GetTaskGraphRunner(); |
| 1515 } | 1541 } |
| 1516 | 1542 |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1965 } | 1991 } |
| 1966 | 1992 |
| 1967 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 1993 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
| 1968 size_t erased = | 1994 size_t erased = |
| 1969 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 1995 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
| 1970 routing_id_); | 1996 routing_id_); |
| 1971 DCHECK_EQ(1u, erased); | 1997 DCHECK_EQ(1u, erased); |
| 1972 } | 1998 } |
| 1973 | 1999 |
| 1974 } // namespace content | 2000 } // namespace content |
| OLD | NEW |