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 <utility> | 10 #include <utility> |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "base/values.h" | 37 #include "base/values.h" |
38 #include "build/build_config.h" | 38 #include "build/build_config.h" |
39 #include "cc/base/histograms.h" | 39 #include "cc/base/histograms.h" |
40 #include "cc/base/switches.h" | 40 #include "cc/base/switches.h" |
41 #include "cc/blink/web_external_bitmap_impl.h" | 41 #include "cc/blink/web_external_bitmap_impl.h" |
42 #include "cc/blink/web_layer_impl.h" | 42 #include "cc/blink/web_layer_impl.h" |
43 #include "cc/layers/layer_settings.h" | 43 #include "cc/layers/layer_settings.h" |
44 #include "cc/raster/task_graph_runner.h" | 44 #include "cc/raster/task_graph_runner.h" |
45 #include "cc/trees/layer_tree_host_common.h" | 45 #include "cc/trees/layer_tree_host_common.h" |
46 #include "cc/trees/layer_tree_settings.h" | 46 #include "cc/trees/layer_tree_settings.h" |
| 47 #include "components/scheduler/child/compositor_worker_scheduler.h" |
47 #include "components/scheduler/child/webthread_base.h" | 48 #include "components/scheduler/child/webthread_base.h" |
| 49 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h" |
48 #include "components/scheduler/renderer/renderer_scheduler.h" | 50 #include "components/scheduler/renderer/renderer_scheduler.h" |
49 #include "content/child/appcache/appcache_dispatcher.h" | 51 #include "content/child/appcache/appcache_dispatcher.h" |
50 #include "content/child/appcache/appcache_frontend_impl.h" | 52 #include "content/child/appcache/appcache_frontend_impl.h" |
51 #include "content/child/child_discardable_shared_memory_manager.h" | 53 #include "content/child/child_discardable_shared_memory_manager.h" |
52 #include "content/child/child_gpu_memory_buffer_manager.h" | 54 #include "content/child/child_gpu_memory_buffer_manager.h" |
53 #include "content/child/child_histogram_message_filter.h" | 55 #include "content/child/child_histogram_message_filter.h" |
54 #include "content/child/child_resource_message_filter.h" | 56 #include "content/child/child_resource_message_filter.h" |
55 #include "content/child/child_shared_bitmap_manager.h" | 57 #include "content/child/child_shared_bitmap_manager.h" |
56 #include "content/child/content_child_helpers.h" | 58 #include "content/child/content_child_helpers.h" |
57 #include "content/child/db_message_filter.h" | 59 #include "content/child/db_message_filter.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 213 |
212 using base::ThreadRestrictions; | 214 using base::ThreadRestrictions; |
213 using blink::WebDocument; | 215 using blink::WebDocument; |
214 using blink::WebFrame; | 216 using blink::WebFrame; |
215 using blink::WebNetworkStateNotifier; | 217 using blink::WebNetworkStateNotifier; |
216 using blink::WebRuntimeFeatures; | 218 using blink::WebRuntimeFeatures; |
217 using blink::WebScriptController; | 219 using blink::WebScriptController; |
218 using blink::WebSecurityPolicy; | 220 using blink::WebSecurityPolicy; |
219 using blink::WebString; | 221 using blink::WebString; |
220 using blink::WebView; | 222 using blink::WebView; |
| 223 using scheduler::WebThreadImplForWorkerScheduler; |
221 | 224 |
222 namespace content { | 225 namespace content { |
223 | 226 |
224 namespace { | 227 namespace { |
225 | 228 |
226 const int64_t kInitialIdleHandlerDelayMs = 1000; | 229 const int64_t kInitialIdleHandlerDelayMs = 1000; |
227 const int64_t kLongIdleHandlerDelayMs = 30 * 1000; | 230 const int64_t kLongIdleHandlerDelayMs = 30 * 1000; |
228 | 231 |
229 #if defined(OS_ANDROID) | 232 #if defined(OS_ANDROID) |
230 // On Android, resource messages can each take ~1.5ms to dispatch on the browser | 233 // On Android, resource messages can each take ~1.5ms to dispatch on the browser |
231 // IO thread. Limiting the message rate to 3/frame at 60hz ensures that the | 234 // IO thread. Limiting the message rate to 3/frame at 60hz ensures that the |
232 // induced work takes but a fraction (~1/4) of the overall frame budget. | 235 // induced work takes but a fraction (~1/4) of the overall frame budget. |
233 const int kMaxResourceRequestsPerFlushWhenThrottled = 3; | 236 const int kMaxResourceRequestsPerFlushWhenThrottled = 3; |
234 #else | 237 #else |
235 const int kMaxResourceRequestsPerFlushWhenThrottled = 8; | 238 const int kMaxResourceRequestsPerFlushWhenThrottled = 8; |
236 #endif | 239 #endif |
237 const double kThrottledResourceRequestFlushPeriodS = 1. / 60.; | 240 const double kThrottledResourceRequestFlushPeriodS = 1. / 60.; |
238 | 241 |
239 // Maximum allocation size allowed for image scaling filters that | 242 // Maximum allocation size allowed for image scaling filters that |
240 // require pre-scaling. Skia will fallback to a filter that doesn't | 243 // require pre-scaling. Skia will fallback to a filter that doesn't |
241 // require pre-scaling if the default filter would require an | 244 // require pre-scaling if the default filter would require an |
242 // allocation that exceeds this limit. | 245 // allocation that exceeds this limit. |
243 const size_t kImageCacheSingleAllocationByteLimit = 64 * 1024 * 1024; | 246 const size_t kImageCacheSingleAllocationByteLimit = 64 * 1024 * 1024; |
244 | 247 |
245 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access | 248 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access |
246 // incorrectly from the wrong thread. | 249 // incorrectly from the wrong thread. |
247 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > | 250 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > |
248 lazy_tls = LAZY_INSTANCE_INITIALIZER; | 251 lazy_tls = LAZY_INSTANCE_INITIALIZER; |
249 | 252 |
| 253 class WebThreadForCompositor : public WebThreadImplForWorkerScheduler { |
| 254 public: |
| 255 explicit WebThreadForCompositor(base::Thread::Options options) |
| 256 : WebThreadImplForWorkerScheduler("Compositor", options) { |
| 257 Init(); |
| 258 } |
| 259 ~WebThreadForCompositor() override {} |
| 260 |
| 261 private: |
| 262 // WebThreadImplForWorkerScheduler: |
| 263 scoped_ptr<scheduler::WorkerScheduler> CreateWorkerScheduler() override { |
| 264 return make_scoped_ptr(new scheduler::CompositorWorkerScheduler(thread())); |
| 265 } |
| 266 |
| 267 DISALLOW_COPY_AND_ASSIGN(WebThreadForCompositor); |
| 268 }; |
| 269 |
250 class RenderViewZoomer : public RenderViewVisitor { | 270 class RenderViewZoomer : public RenderViewVisitor { |
251 public: | 271 public: |
252 RenderViewZoomer(const std::string& scheme, | 272 RenderViewZoomer(const std::string& scheme, |
253 const std::string& host, | 273 const std::string& host, |
254 double zoom_level) : scheme_(scheme), | 274 double zoom_level) : scheme_(scheme), |
255 host_(host), | 275 host_(host), |
256 zoom_level_(zoom_level) { | 276 zoom_level_(zoom_level) { |
257 } | 277 } |
258 | 278 |
259 bool Visit(RenderView* render_view) override { | 279 bool Visit(RenderView* render_view) override { |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 #if defined(OS_ANDROID) | 906 #if defined(OS_ANDROID) |
887 if (sync_compositor_message_filter_) { | 907 if (sync_compositor_message_filter_) { |
888 RemoveFilter(sync_compositor_message_filter_.get()); | 908 RemoveFilter(sync_compositor_message_filter_.get()); |
889 sync_compositor_message_filter_ = nullptr; | 909 sync_compositor_message_filter_ = nullptr; |
890 } | 910 } |
891 stream_texture_factory_ = nullptr; | 911 stream_texture_factory_ = nullptr; |
892 #endif | 912 #endif |
893 | 913 |
894 media_thread_.reset(); | 914 media_thread_.reset(); |
895 | 915 |
896 blink_platform_impl_->set_compositor_thread(nullptr); | 916 blink_platform_impl_->SetCompositorThread(nullptr); |
897 | 917 |
898 compositor_thread_.reset(); | 918 compositor_thread_.reset(); |
899 | 919 |
900 // AudioMessageFilter may be accessed on |media_thread_|, so shutdown after. | 920 // AudioMessageFilter may be accessed on |media_thread_|, so shutdown after. |
901 RemoveFilter(audio_message_filter_.get()); | 921 RemoveFilter(audio_message_filter_.get()); |
902 audio_message_filter_ = NULL; | 922 audio_message_filter_ = NULL; |
903 | 923 |
904 raster_worker_pool_->Shutdown(); | 924 raster_worker_pool_->Shutdown(); |
905 | 925 |
906 main_input_callback_.Cancel(); | 926 main_input_callback_.Cancel(); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 base::CommandLine::ForCurrentProcess()->HasSwitch( | 1161 base::CommandLine::ForCurrentProcess()->HasSwitch( |
1142 switches::kIPCSyncCompositing); | 1162 switches::kIPCSyncCompositing); |
1143 DCHECK(!sync_compositor_factory || !using_ipc_sync_compositing); | 1163 DCHECK(!sync_compositor_factory || !using_ipc_sync_compositing); |
1144 | 1164 |
1145 if (sync_compositor_factory) { | 1165 if (sync_compositor_factory) { |
1146 compositor_task_runner_ = | 1166 compositor_task_runner_ = |
1147 sync_compositor_factory->GetCompositorTaskRunner(); | 1167 sync_compositor_factory->GetCompositorTaskRunner(); |
1148 } | 1168 } |
1149 #endif | 1169 #endif |
1150 if (!compositor_task_runner_.get()) { | 1170 if (!compositor_task_runner_.get()) { |
1151 | 1171 base::Thread::Options options; |
1152 compositor_thread_.reset(new base::Thread("Compositor")); | |
1153 base::Thread::Options compositor_thread_options; | |
1154 #if defined(OS_ANDROID) | 1172 #if defined(OS_ANDROID) |
1155 compositor_thread_options.priority = base::ThreadPriority::DISPLAY; | 1173 options.priority = base::ThreadPriority::DISPLAY; |
1156 #endif | 1174 #endif |
1157 compositor_thread_->StartWithOptions(compositor_thread_options); | 1175 compositor_thread_.reset(new WebThreadForCompositor(options)); |
1158 compositor_task_runner_ = compositor_thread_->task_runner(); | 1176 blink_platform_impl_->SetCompositorThread(compositor_thread_.get()); |
| 1177 compositor_task_runner_ = compositor_thread_->TaskRunner(); |
1159 compositor_task_runner_->PostTask( | 1178 compositor_task_runner_->PostTask( |
1160 FROM_HERE, | 1179 FROM_HERE, |
1161 base::Bind(base::IgnoreResult(&ThreadRestrictions::SetIOAllowed), | 1180 base::Bind(base::IgnoreResult(&ThreadRestrictions::SetIOAllowed), |
1162 false)); | 1181 false)); |
1163 } | 1182 } |
1164 | 1183 |
1165 InputHandlerManagerClient* input_handler_manager_client = NULL; | 1184 InputHandlerManagerClient* input_handler_manager_client = NULL; |
1166 #if defined(OS_ANDROID) | 1185 #if defined(OS_ANDROID) |
1167 if (using_ipc_sync_compositing) { | 1186 if (using_ipc_sync_compositing) { |
1168 sync_compositor_message_filter_ = | 1187 sync_compositor_message_filter_ = |
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2092 } | 2111 } |
2093 | 2112 |
2094 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 2113 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
2095 size_t erased = | 2114 size_t erased = |
2096 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 2115 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
2097 routing_id_); | 2116 routing_id_); |
2098 DCHECK_EQ(1u, erased); | 2117 DCHECK_EQ(1u, erased); |
2099 } | 2118 } |
2100 | 2119 |
2101 } // namespace content | 2120 } // namespace content |
OLD | NEW |