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