Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(709)

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 2118903002: scheduler: Move the Blink scheduler into Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Really fixed the test failure this time Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 #include "net/base/port_util.h" 140 #include "net/base/port_util.h"
145 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 141 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
146 #include "net/base/url_util.h" 142 #include "net/base/url_util.h"
147 #include "services/shell/public/cpp/interface_provider.h" 143 #include "services/shell/public/cpp/interface_provider.h"
148 #include "services/shell/public/cpp/interface_registry.h" 144 #include "services/shell/public/cpp/interface_registry.h"
149 #include "skia/ext/event_tracer_impl.h" 145 #include "skia/ext/event_tracer_impl.h"
150 #include "skia/ext/skia_memory_dump_provider.h" 146 #include "skia/ext/skia_memory_dump_provider.h"
151 #include "third_party/WebKit/public/platform/WebImageGenerator.h" 147 #include "third_party/WebKit/public/platform/WebImageGenerator.h"
152 #include "third_party/WebKit/public/platform/WebString.h" 148 #include "third_party/WebKit/public/platform/WebString.h"
153 #include "third_party/WebKit/public/platform/WebThread.h" 149 #include "third_party/WebKit/public/platform/WebThread.h"
150 #include "third_party/WebKit/public/platform/scheduler/child/compositor_worker_s cheduler.h"
151 #include "third_party/WebKit/public/platform/scheduler/child/webthread_impl_for_ worker_scheduler.h"
152 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul er.h"
154 #include "third_party/WebKit/public/web/WebCache.h" 153 #include "third_party/WebKit/public/web/WebCache.h"
155 #include "third_party/WebKit/public/web/WebDatabase.h" 154 #include "third_party/WebKit/public/web/WebDatabase.h"
156 #include "third_party/WebKit/public/web/WebDocument.h" 155 #include "third_party/WebKit/public/web/WebDocument.h"
157 #include "third_party/WebKit/public/web/WebFrame.h" 156 #include "third_party/WebKit/public/web/WebFrame.h"
158 #include "third_party/WebKit/public/web/WebKit.h" 157 #include "third_party/WebKit/public/web/WebKit.h"
159 #include "third_party/WebKit/public/web/WebMemoryCoordinator.h" 158 #include "third_party/WebKit/public/web/WebMemoryCoordinator.h"
160 #include "third_party/WebKit/public/web/WebNetworkStateNotifier.h" 159 #include "third_party/WebKit/public/web/WebNetworkStateNotifier.h"
161 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 160 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
162 #include "third_party/WebKit/public/web/WebScriptController.h" 161 #include "third_party/WebKit/public/web/WebScriptController.h"
163 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" 162 #include "third_party/WebKit/public/web/WebSecurityPolicy.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 213
215 using base::ThreadRestrictions; 214 using base::ThreadRestrictions;
216 using blink::WebDocument; 215 using blink::WebDocument;
217 using blink::WebFrame; 216 using blink::WebFrame;
218 using blink::WebNetworkStateNotifier; 217 using blink::WebNetworkStateNotifier;
219 using blink::WebRuntimeFeatures; 218 using blink::WebRuntimeFeatures;
220 using blink::WebScriptController; 219 using blink::WebScriptController;
221 using blink::WebSecurityPolicy; 220 using blink::WebSecurityPolicy;
222 using blink::WebString; 221 using blink::WebString;
223 using blink::WebView; 222 using blink::WebView;
224 using scheduler::WebThreadImplForWorkerScheduler; 223 using blink::scheduler::WebThreadImplForWorkerScheduler;
225 224
226 namespace content { 225 namespace content {
227 226
228 namespace { 227 namespace {
229 228
230 const int64_t kInitialIdleHandlerDelayMs = 1000; 229 const int64_t kInitialIdleHandlerDelayMs = 1000;
231 const int64_t kLongIdleHandlerDelayMs = 30 * 1000; 230 const int64_t kLongIdleHandlerDelayMs = 30 * 1000;
232 231
233 #if defined(OS_ANDROID) 232 #if defined(OS_ANDROID)
234 // 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
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 class WebThreadForCompositor : public WebThreadImplForWorkerScheduler { 281 class WebThreadForCompositor : public WebThreadImplForWorkerScheduler {
283 public: 282 public:
284 explicit WebThreadForCompositor(base::Thread::Options options) 283 explicit WebThreadForCompositor(base::Thread::Options options)
285 : WebThreadImplForWorkerScheduler("Compositor", options) { 284 : WebThreadImplForWorkerScheduler("Compositor", options) {
286 Init(); 285 Init();
287 } 286 }
288 ~WebThreadForCompositor() override {} 287 ~WebThreadForCompositor() override {}
289 288
290 private: 289 private:
291 // WebThreadImplForWorkerScheduler: 290 // WebThreadImplForWorkerScheduler:
292 std::unique_ptr<scheduler::WorkerScheduler> CreateWorkerScheduler() override { 291 std::unique_ptr<blink::scheduler::WorkerScheduler> CreateWorkerScheduler()
293 return base::WrapUnique(new scheduler::CompositorWorkerScheduler(thread())); 292 override {
293 return base::WrapUnique(
294 new blink::scheduler::CompositorWorkerScheduler(thread()));
294 } 295 }
295 296
296 DISALLOW_COPY_AND_ASSIGN(WebThreadForCompositor); 297 DISALLOW_COPY_AND_ASSIGN(WebThreadForCompositor);
297 }; 298 };
298 299
299 void* CreateHistogram( 300 void* CreateHistogram(
300 const char *name, int min, int max, size_t buckets) { 301 const char *name, int min, int max, size_t buckets) {
301 if (min <= 0) 302 if (min <= 0)
302 min = 1; 303 min = 1;
303 std::string histogram_name; 304 std::string histogram_name;
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 return true; 568 return true;
568 } 569 }
569 } 570 }
570 } 571 }
571 return false; 572 return false;
572 } 573 }
573 574
574 // static 575 // static
575 RenderThreadImpl* RenderThreadImpl::Create( 576 RenderThreadImpl* RenderThreadImpl::Create(
576 const InProcessChildThreadParams& params) { 577 const InProcessChildThreadParams& params) {
577 std::unique_ptr<scheduler::RendererScheduler> renderer_scheduler = 578 std::unique_ptr<blink::scheduler::RendererScheduler> renderer_scheduler =
578 scheduler::RendererScheduler::Create(); 579 blink::scheduler::RendererScheduler::Create();
579 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter; 580 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter;
580 return new RenderThreadImpl( 581 return new RenderThreadImpl(
581 params, std::move(renderer_scheduler), test_task_counter); 582 params, std::move(renderer_scheduler), test_task_counter);
582 } 583 }
583 584
584 // static 585 // static
585 RenderThreadImpl* RenderThreadImpl::Create( 586 RenderThreadImpl* RenderThreadImpl::Create(
586 std::unique_ptr<base::MessageLoop> main_message_loop, 587 std::unique_ptr<base::MessageLoop> main_message_loop,
587 std::unique_ptr<scheduler::RendererScheduler> renderer_scheduler) { 588 std::unique_ptr<blink::scheduler::RendererScheduler> renderer_scheduler) {
588 return new RenderThreadImpl(std::move(main_message_loop), 589 return new RenderThreadImpl(std::move(main_message_loop),
589 std::move(renderer_scheduler)); 590 std::move(renderer_scheduler));
590 } 591 }
591 592
592 RenderThreadImpl* RenderThreadImpl::current() { 593 RenderThreadImpl* RenderThreadImpl::current() {
593 return lazy_tls.Pointer()->Get(); 594 return lazy_tls.Pointer()->Get();
594 } 595 }
595 596
596 RenderThreadImpl::RenderThreadImpl( 597 RenderThreadImpl::RenderThreadImpl(
597 const InProcessChildThreadParams& params, 598 const InProcessChildThreadParams& params,
598 std::unique_ptr<scheduler::RendererScheduler> scheduler, 599 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler,
599 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) 600 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue)
600 : ChildThreadImpl(Options::Builder() 601 : ChildThreadImpl(Options::Builder()
601 .InBrowserProcess(params) 602 .InBrowserProcess(params)
602 .UseMojoChannel(true) 603 .UseMojoChannel(true)
603 .AutoStartMojoShellConnection(false) 604 .AutoStartMojoShellConnection(false)
604 .ConnectToBrowser(true) 605 .ConnectToBrowser(true)
605 .Build()), 606 .Build()),
606 renderer_scheduler_(std::move(scheduler)), 607 renderer_scheduler_(std::move(scheduler)),
607 categorized_worker_pool_(new CategorizedWorkerPool()) { 608 categorized_worker_pool_(new CategorizedWorkerPool()) {
608 Init(resource_task_queue); 609 Init(resource_task_queue);
609 } 610 }
610 611
611 // When we run plugins in process, we actually run them on the render thread, 612 // When we run plugins in process, we actually run them on the render thread,
612 // which means that we need to make the render thread pump UI events. 613 // which means that we need to make the render thread pump UI events.
613 RenderThreadImpl::RenderThreadImpl( 614 RenderThreadImpl::RenderThreadImpl(
614 std::unique_ptr<base::MessageLoop> main_message_loop, 615 std::unique_ptr<base::MessageLoop> main_message_loop,
615 std::unique_ptr<scheduler::RendererScheduler> scheduler) 616 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler)
616 : ChildThreadImpl(Options::Builder() 617 : ChildThreadImpl(Options::Builder()
617 .UseMojoChannel(true) 618 .UseMojoChannel(true)
618 .AutoStartMojoShellConnection(false) 619 .AutoStartMojoShellConnection(false)
619 .ConnectToBrowser(true) 620 .ConnectToBrowser(true)
620 .Build()), 621 .Build()),
621 renderer_scheduler_(std::move(scheduler)), 622 renderer_scheduler_(std::move(scheduler)),
622 main_message_loop_(std::move(main_message_loop)), 623 main_message_loop_(std::move(main_message_loop)),
623 categorized_worker_pool_(new CategorizedWorkerPool()) { 624 categorized_worker_pool_(new CategorizedWorkerPool()) {
624 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter; 625 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter;
625 Init(test_task_counter); 626 Init(test_task_counter);
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
2241 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) 2242 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical)
2242 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; 2243 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate;
2243 2244
2244 blink::mainThreadIsolate()->MemoryPressureNotification( 2245 blink::mainThreadIsolate()->MemoryPressureNotification(
2245 v8_memory_pressure_level); 2246 v8_memory_pressure_level);
2246 blink::MemoryPressureNotificationToWorkerThreadIsolates( 2247 blink::MemoryPressureNotificationToWorkerThreadIsolates(
2247 v8_memory_pressure_level); 2248 v8_memory_pressure_level);
2248 } 2249 }
2249 2250
2250 } // namespace content 2251 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698