| 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 28 matching lines...) Expand all Loading... |
| 39 #include "build/build_config.h" | 39 #include "build/build_config.h" |
| 40 #include "cc/base/histograms.h" | 40 #include "cc/base/histograms.h" |
| 41 #include "cc/base/switches.h" | 41 #include "cc/base/switches.h" |
| 42 #include "cc/blink/web_external_bitmap_impl.h" | 42 #include "cc/blink/web_external_bitmap_impl.h" |
| 43 #include "cc/blink/web_layer_impl.h" | 43 #include "cc/blink/web_layer_impl.h" |
| 44 #include "cc/output/output_surface.h" | 44 #include "cc/output/output_surface.h" |
| 45 #include "cc/output/vulkan_in_process_context_provider.h" | 45 #include "cc/output/vulkan_in_process_context_provider.h" |
| 46 #include "cc/raster/task_graph_runner.h" | 46 #include "cc/raster/task_graph_runner.h" |
| 47 #include "cc/trees/layer_tree_host_common.h" | 47 #include "cc/trees/layer_tree_host_common.h" |
| 48 #include "cc/trees/layer_tree_settings.h" | 48 #include "cc/trees/layer_tree_settings.h" |
| 49 #include "components/scheduler/child/compositor_worker_scheduler.h" | |
| 50 #include "components/scheduler/child/webthread_base.h" | |
| 51 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h" | |
| 52 #include "components/scheduler/renderer/renderer_scheduler.h" | |
| 53 #include "content/child/appcache/appcache_dispatcher.h" | 49 #include "content/child/appcache/appcache_dispatcher.h" |
| 54 #include "content/child/appcache/appcache_frontend_impl.h" | 50 #include "content/child/appcache/appcache_frontend_impl.h" |
| 55 #include "content/child/blob_storage/blob_message_filter.h" | 51 #include "content/child/blob_storage/blob_message_filter.h" |
| 56 #include "content/child/child_discardable_shared_memory_manager.h" | 52 #include "content/child/child_discardable_shared_memory_manager.h" |
| 57 #include "content/child/child_gpu_memory_buffer_manager.h" | 53 #include "content/child/child_gpu_memory_buffer_manager.h" |
| 58 #include "content/child/child_histogram_message_filter.h" | 54 #include "content/child/child_histogram_message_filter.h" |
| 59 #include "content/child/child_resource_message_filter.h" | 55 #include "content/child/child_resource_message_filter.h" |
| 60 #include "content/child/child_shared_bitmap_manager.h" | 56 #include "content/child/child_shared_bitmap_manager.h" |
| 61 #include "content/child/content_child_helpers.h" | 57 #include "content/child/content_child_helpers.h" |
| 62 #include "content/child/db_message_filter.h" | 58 #include "content/child/db_message_filter.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 #include "mojo/public/cpp/bindings/strong_binding.h" | 136 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 141 #include "net/base/net_errors.h" | 137 #include "net/base/net_errors.h" |
| 142 #include "net/base/port_util.h" | 138 #include "net/base/port_util.h" |
| 143 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 139 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 144 #include "net/base/url_util.h" | 140 #include "net/base/url_util.h" |
| 145 #include "skia/ext/event_tracer_impl.h" | 141 #include "skia/ext/event_tracer_impl.h" |
| 146 #include "skia/ext/skia_memory_dump_provider.h" | 142 #include "skia/ext/skia_memory_dump_provider.h" |
| 147 #include "third_party/WebKit/public/platform/WebImageGenerator.h" | 143 #include "third_party/WebKit/public/platform/WebImageGenerator.h" |
| 148 #include "third_party/WebKit/public/platform/WebString.h" | 144 #include "third_party/WebKit/public/platform/WebString.h" |
| 149 #include "third_party/WebKit/public/platform/WebThread.h" | 145 #include "third_party/WebKit/public/platform/WebThread.h" |
| 146 #include "third_party/WebKit/public/platform/scheduler/child/compositor_worker_s
cheduler.h" |
| 147 #include "third_party/WebKit/public/platform/scheduler/child/webthread_impl_for_
worker_scheduler.h" |
| 148 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul
er.h" |
| 150 #include "third_party/WebKit/public/web/WebCache.h" | 149 #include "third_party/WebKit/public/web/WebCache.h" |
| 151 #include "third_party/WebKit/public/web/WebDatabase.h" | 150 #include "third_party/WebKit/public/web/WebDatabase.h" |
| 152 #include "third_party/WebKit/public/web/WebDocument.h" | 151 #include "third_party/WebKit/public/web/WebDocument.h" |
| 153 #include "third_party/WebKit/public/web/WebFrame.h" | 152 #include "third_party/WebKit/public/web/WebFrame.h" |
| 154 #include "third_party/WebKit/public/web/WebKit.h" | 153 #include "third_party/WebKit/public/web/WebKit.h" |
| 155 #include "third_party/WebKit/public/web/WebMemoryCoordinator.h" | 154 #include "third_party/WebKit/public/web/WebMemoryCoordinator.h" |
| 156 #include "third_party/WebKit/public/web/WebNetworkStateNotifier.h" | 155 #include "third_party/WebKit/public/web/WebNetworkStateNotifier.h" |
| 157 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 156 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 158 #include "third_party/WebKit/public/web/WebScriptController.h" | 157 #include "third_party/WebKit/public/web/WebScriptController.h" |
| 159 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 158 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 209 |
| 211 using base::ThreadRestrictions; | 210 using base::ThreadRestrictions; |
| 212 using blink::WebDocument; | 211 using blink::WebDocument; |
| 213 using blink::WebFrame; | 212 using blink::WebFrame; |
| 214 using blink::WebNetworkStateNotifier; | 213 using blink::WebNetworkStateNotifier; |
| 215 using blink::WebRuntimeFeatures; | 214 using blink::WebRuntimeFeatures; |
| 216 using blink::WebScriptController; | 215 using blink::WebScriptController; |
| 217 using blink::WebSecurityPolicy; | 216 using blink::WebSecurityPolicy; |
| 218 using blink::WebString; | 217 using blink::WebString; |
| 219 using blink::WebView; | 218 using blink::WebView; |
| 220 using scheduler::WebThreadImplForWorkerScheduler; | 219 using blink::scheduler::WebThreadImplForWorkerScheduler; |
| 221 | 220 |
| 222 namespace content { | 221 namespace content { |
| 223 | 222 |
| 224 namespace { | 223 namespace { |
| 225 | 224 |
| 226 const int64_t kInitialIdleHandlerDelayMs = 1000; | 225 const int64_t kInitialIdleHandlerDelayMs = 1000; |
| 227 const int64_t kLongIdleHandlerDelayMs = 30 * 1000; | 226 const int64_t kLongIdleHandlerDelayMs = 30 * 1000; |
| 228 | 227 |
| 229 #if defined(OS_ANDROID) | 228 #if defined(OS_ANDROID) |
| 230 // On Android, resource messages can each take ~1.5ms to dispatch on the browser | 229 // On Android, resource messages can each take ~1.5ms to dispatch on the browser |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 class WebThreadForCompositor : public WebThreadImplForWorkerScheduler { | 277 class WebThreadForCompositor : public WebThreadImplForWorkerScheduler { |
| 279 public: | 278 public: |
| 280 explicit WebThreadForCompositor(base::Thread::Options options) | 279 explicit WebThreadForCompositor(base::Thread::Options options) |
| 281 : WebThreadImplForWorkerScheduler("Compositor", options) { | 280 : WebThreadImplForWorkerScheduler("Compositor", options) { |
| 282 Init(); | 281 Init(); |
| 283 } | 282 } |
| 284 ~WebThreadForCompositor() override {} | 283 ~WebThreadForCompositor() override {} |
| 285 | 284 |
| 286 private: | 285 private: |
| 287 // WebThreadImplForWorkerScheduler: | 286 // WebThreadImplForWorkerScheduler: |
| 288 std::unique_ptr<scheduler::WorkerScheduler> CreateWorkerScheduler() override { | 287 std::unique_ptr<blink::scheduler::WorkerScheduler> CreateWorkerScheduler() |
| 289 return base::WrapUnique(new scheduler::CompositorWorkerScheduler(thread())); | 288 override { |
| 289 return base::WrapUnique( |
| 290 new blink::scheduler::CompositorWorkerScheduler(thread())); |
| 290 } | 291 } |
| 291 | 292 |
| 292 DISALLOW_COPY_AND_ASSIGN(WebThreadForCompositor); | 293 DISALLOW_COPY_AND_ASSIGN(WebThreadForCompositor); |
| 293 }; | 294 }; |
| 294 | 295 |
| 295 void* CreateHistogram( | 296 void* CreateHistogram( |
| 296 const char *name, int min, int max, size_t buckets) { | 297 const char *name, int min, int max, size_t buckets) { |
| 297 if (min <= 0) | 298 if (min <= 0) |
| 298 min = 1; | 299 min = 1; |
| 299 std::string histogram_name; | 300 std::string histogram_name; |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 return true; | 572 return true; |
| 572 } | 573 } |
| 573 } | 574 } |
| 574 } | 575 } |
| 575 return false; | 576 return false; |
| 576 } | 577 } |
| 577 | 578 |
| 578 // static | 579 // static |
| 579 RenderThreadImpl* RenderThreadImpl::Create( | 580 RenderThreadImpl* RenderThreadImpl::Create( |
| 580 const InProcessChildThreadParams& params) { | 581 const InProcessChildThreadParams& params) { |
| 581 std::unique_ptr<scheduler::RendererScheduler> renderer_scheduler = | 582 std::unique_ptr<blink::scheduler::RendererScheduler> renderer_scheduler = |
| 582 scheduler::RendererScheduler::Create(); | 583 blink::scheduler::RendererScheduler::Create(); |
| 583 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter; | 584 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter; |
| 584 return new RenderThreadImpl( | 585 return new RenderThreadImpl( |
| 585 params, std::move(renderer_scheduler), test_task_counter); | 586 params, std::move(renderer_scheduler), test_task_counter); |
| 586 } | 587 } |
| 587 | 588 |
| 588 // static | 589 // static |
| 589 RenderThreadImpl* RenderThreadImpl::Create( | 590 RenderThreadImpl* RenderThreadImpl::Create( |
| 590 std::unique_ptr<base::MessageLoop> main_message_loop, | 591 std::unique_ptr<base::MessageLoop> main_message_loop, |
| 591 std::unique_ptr<scheduler::RendererScheduler> renderer_scheduler) { | 592 std::unique_ptr<blink::scheduler::RendererScheduler> renderer_scheduler) { |
| 592 return new RenderThreadImpl(std::move(main_message_loop), | 593 return new RenderThreadImpl(std::move(main_message_loop), |
| 593 std::move(renderer_scheduler)); | 594 std::move(renderer_scheduler)); |
| 594 } | 595 } |
| 595 | 596 |
| 596 RenderThreadImpl* RenderThreadImpl::current() { | 597 RenderThreadImpl* RenderThreadImpl::current() { |
| 597 return lazy_tls.Pointer()->Get(); | 598 return lazy_tls.Pointer()->Get(); |
| 598 } | 599 } |
| 599 | 600 |
| 600 RenderThreadImpl::RenderThreadImpl( | 601 RenderThreadImpl::RenderThreadImpl( |
| 601 const InProcessChildThreadParams& params, | 602 const InProcessChildThreadParams& params, |
| 602 std::unique_ptr<scheduler::RendererScheduler> scheduler, | 603 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler, |
| 603 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) | 604 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) |
| 604 : ChildThreadImpl(Options::Builder() | 605 : ChildThreadImpl(Options::Builder() |
| 605 .InBrowserProcess(params) | 606 .InBrowserProcess(params) |
| 606 .UseMojoChannel(true) | 607 .UseMojoChannel(true) |
| 607 .Build()), | 608 .Build()), |
| 608 renderer_scheduler_(std::move(scheduler)), | 609 renderer_scheduler_(std::move(scheduler)), |
| 609 categorized_worker_pool_(new CategorizedWorkerPool()) { | 610 categorized_worker_pool_(new CategorizedWorkerPool()) { |
| 610 Init(resource_task_queue); | 611 Init(resource_task_queue); |
| 611 } | 612 } |
| 612 | 613 |
| 613 // When we run plugins in process, we actually run them on the render thread, | 614 // When we run plugins in process, we actually run them on the render thread, |
| 614 // which means that we need to make the render thread pump UI events. | 615 // which means that we need to make the render thread pump UI events. |
| 615 RenderThreadImpl::RenderThreadImpl( | 616 RenderThreadImpl::RenderThreadImpl( |
| 616 std::unique_ptr<base::MessageLoop> main_message_loop, | 617 std::unique_ptr<base::MessageLoop> main_message_loop, |
| 617 std::unique_ptr<scheduler::RendererScheduler> scheduler) | 618 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler) |
| 618 : ChildThreadImpl(Options::Builder().UseMojoChannel(true).Build()), | 619 : ChildThreadImpl(Options::Builder().UseMojoChannel(true).Build()), |
| 619 renderer_scheduler_(std::move(scheduler)), | 620 renderer_scheduler_(std::move(scheduler)), |
| 620 main_message_loop_(std::move(main_message_loop)), | 621 main_message_loop_(std::move(main_message_loop)), |
| 621 categorized_worker_pool_(new CategorizedWorkerPool()) { | 622 categorized_worker_pool_(new CategorizedWorkerPool()) { |
| 622 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter; | 623 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter; |
| 623 Init(test_task_counter); | 624 Init(test_task_counter); |
| 624 } | 625 } |
| 625 | 626 |
| 626 void RenderThreadImpl::Init( | 627 void RenderThreadImpl::Init( |
| 627 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) { | 628 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) { |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1606 | 1607 |
| 1607 scoped_refptr<base::SingleThreadTaskRunner> | 1608 scoped_refptr<base::SingleThreadTaskRunner> |
| 1608 RenderThreadImpl::GetCompositorImplThreadTaskRunner() { | 1609 RenderThreadImpl::GetCompositorImplThreadTaskRunner() { |
| 1609 return compositor_task_runner_; | 1610 return compositor_task_runner_; |
| 1610 } | 1611 } |
| 1611 | 1612 |
| 1612 gpu::GpuMemoryBufferManager* RenderThreadImpl::GetGpuMemoryBufferManager() { | 1613 gpu::GpuMemoryBufferManager* RenderThreadImpl::GetGpuMemoryBufferManager() { |
| 1613 return gpu_memory_buffer_manager(); | 1614 return gpu_memory_buffer_manager(); |
| 1614 } | 1615 } |
| 1615 | 1616 |
| 1616 scheduler::RendererScheduler* RenderThreadImpl::GetRendererScheduler() { | 1617 blink::scheduler::RendererScheduler* RenderThreadImpl::GetRendererScheduler() { |
| 1617 return renderer_scheduler_.get(); | 1618 return renderer_scheduler_.get(); |
| 1618 } | 1619 } |
| 1619 | 1620 |
| 1620 std::unique_ptr<cc::BeginFrameSource> | 1621 std::unique_ptr<cc::BeginFrameSource> |
| 1621 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) { | 1622 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) { |
| 1622 return base::WrapUnique(new CompositorExternalBeginFrameSource( | 1623 return base::WrapUnique(new CompositorExternalBeginFrameSource( |
| 1623 compositor_message_filter_.get(), sync_message_filter(), routing_id)); | 1624 compositor_message_filter_.get(), sync_message_filter(), routing_id)); |
| 1624 } | 1625 } |
| 1625 | 1626 |
| 1626 cc::ImageSerializationProcessor* | 1627 cc::ImageSerializationProcessor* |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2222 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) | 2223 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) |
| 2223 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; | 2224 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; |
| 2224 | 2225 |
| 2225 blink::mainThreadIsolate()->MemoryPressureNotification( | 2226 blink::mainThreadIsolate()->MemoryPressureNotification( |
| 2226 v8_memory_pressure_level); | 2227 v8_memory_pressure_level); |
| 2227 blink::MemoryPressureNotificationToWorkerThreadIsolates( | 2228 blink::MemoryPressureNotificationToWorkerThreadIsolates( |
| 2228 v8_memory_pressure_level); | 2229 v8_memory_pressure_level); |
| 2229 } | 2230 } |
| 2230 | 2231 |
| 2231 } // namespace content | 2232 } // namespace content |
| OLD | NEW |