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

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

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 #ifndef CONTENT_RENDERER_RENDER_THREAD_IMPL_H_ 5 #ifndef CONTENT_RENDERER_RENDER_THREAD_IMPL_H_
6 #define CONTENT_RENDERER_RENDER_THREAD_IMPL_H_ 6 #define CONTENT_RENDERER_RENDER_THREAD_IMPL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/cancelable_callback.h" 15 #include "base/cancelable_callback.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/memory_pressure_listener.h" 17 #include "base/memory/memory_pressure_listener.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/metrics/user_metrics_action.h" 19 #include "base/metrics/user_metrics_action.h"
20 #include "base/observer_list.h" 20 #include "base/observer_list.h"
21 #include "base/strings/string16.h" 21 #include "base/strings/string16.h"
22 #include "base/threading/thread_checker.h" 22 #include "base/threading/thread_checker.h"
23 #include "base/timer/timer.h" 23 #include "base/timer/timer.h"
24 #include "build/build_config.h" 24 #include "build/build_config.h"
25 #include "components/scheduler/renderer/renderer_scheduler.h"
26 #include "content/child/child_thread_impl.h" 25 #include "content/child/child_thread_impl.h"
27 #include "content/common/content_export.h" 26 #include "content/common/content_export.h"
28 #include "content/common/frame.mojom.h" 27 #include "content/common/frame.mojom.h"
29 #include "content/common/frame_replication_state.h" 28 #include "content/common/frame_replication_state.h"
30 #include "content/common/gpu_process_launch_causes.h" 29 #include "content/common/gpu_process_launch_causes.h"
31 #include "content/common/render_frame_message_filter.mojom.h" 30 #include "content/common/render_frame_message_filter.mojom.h"
32 #include "content/common/storage_partition_service.mojom.h" 31 #include "content/common/storage_partition_service.mojom.h"
33 #include "content/public/renderer/render_thread.h" 32 #include "content/public/renderer/render_thread.h"
34 #include "content/renderer/gpu/compositor_dependencies.h" 33 #include "content/renderer/gpu/compositor_dependencies.h"
35 #include "content/renderer/layout_test_dependencies.h" 34 #include "content/renderer/layout_test_dependencies.h"
36 #include "gpu/ipc/client/gpu_channel_host.h" 35 #include "gpu/ipc/client/gpu_channel_host.h"
37 #include "net/base/network_change_notifier.h" 36 #include "net/base/network_change_notifier.h"
38 #include "third_party/WebKit/public/platform/WebConnectionType.h" 37 #include "third_party/WebKit/public/platform/WebConnectionType.h"
38 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul er.h"
39 #include "ui/gfx/native_widget_types.h" 39 #include "ui/gfx/native_widget_types.h"
40 40
41 #if defined(OS_MACOSX) 41 #if defined(OS_MACOSX)
42 #include "third_party/WebKit/public/web/mac/WebScrollbarTheme.h" 42 #include "third_party/WebKit/public/web/mac/WebScrollbarTheme.h"
43 #endif 43 #endif
44 44
45 class GrContext; 45 class GrContext;
46 class SkBitmap; 46 class SkBitmap;
47 struct FrameMsg_NewFrame_Params; 47 struct FrameMsg_NewFrame_Params;
48 struct ViewMsg_New_Params; 48 struct ViewMsg_New_Params;
49 struct ViewMsg_UpdateScrollbarTheme_Params; 49 struct ViewMsg_UpdateScrollbarTheme_Params;
50 struct WorkerProcessMsg_CreateWorker_Params; 50 struct WorkerProcessMsg_CreateWorker_Params;
51 51
52 namespace blink { 52 namespace blink {
53 namespace scheduler {
54 class WebThreadBase;
55 }
53 class WebGamepads; 56 class WebGamepads;
54 class WebMediaStreamCenter; 57 class WebMediaStreamCenter;
55 class WebMediaStreamCenterClient; 58 class WebMediaStreamCenterClient;
56 } 59 }
57 60
58 namespace base { 61 namespace base {
59 class SingleThreadTaskRunner; 62 class SingleThreadTaskRunner;
60 class Thread; 63 class Thread;
61 } 64 }
62 65
(...skipping 14 matching lines...) Expand all
77 80
78 namespace media { 81 namespace media {
79 class AudioHardwareConfig; 82 class AudioHardwareConfig;
80 class GpuVideoAcceleratorFactories; 83 class GpuVideoAcceleratorFactories;
81 } 84 }
82 85
83 namespace memory_coordinator { 86 namespace memory_coordinator {
84 class ChildMemoryCoordinatorImpl; 87 class ChildMemoryCoordinatorImpl;
85 } 88 }
86 89
87 namespace scheduler {
88 class WebThreadBase;
89 }
90
91 namespace v8 { 90 namespace v8 {
92 class Extension; 91 class Extension;
93 } 92 }
94 93
95 namespace content { 94 namespace content {
96 95
97 class AppCacheDispatcher; 96 class AppCacheDispatcher;
98 class AecDumpMessageFilter; 97 class AecDumpMessageFilter;
99 class AudioInputMessageFilter; 98 class AudioInputMessageFilter;
100 class AudioMessageFilter; 99 class AudioMessageFilter;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // Likewise, it provides an API for the RenderViews to talk back to the main 143 // Likewise, it provides an API for the RenderViews to talk back to the main
145 // process (i.e., their corresponding WebContentsImpl). 144 // process (i.e., their corresponding WebContentsImpl).
146 // 145 //
147 // Most of the communication occurs in the form of IPC messages. They are 146 // Most of the communication occurs in the form of IPC messages. They are
148 // routed to the RenderThread according to the routing IDs of the messages. 147 // routed to the RenderThread according to the routing IDs of the messages.
149 // The routing IDs correspond to RenderView instances. 148 // The routing IDs correspond to RenderView instances.
150 class CONTENT_EXPORT RenderThreadImpl 149 class CONTENT_EXPORT RenderThreadImpl
151 : public RenderThread, 150 : public RenderThread,
152 public ChildThreadImpl, 151 public ChildThreadImpl,
153 public gpu::GpuChannelHostFactory, 152 public gpu::GpuChannelHostFactory,
154 public scheduler::RendererScheduler::RAILModeObserver, 153 public blink::scheduler::RendererScheduler::RAILModeObserver,
155 NON_EXPORTED_BASE(public CompositorDependencies) { 154 NON_EXPORTED_BASE(public CompositorDependencies) {
156 public: 155 public:
157 static RenderThreadImpl* Create(const InProcessChildThreadParams& params); 156 static RenderThreadImpl* Create(const InProcessChildThreadParams& params);
158 static RenderThreadImpl* Create( 157 static RenderThreadImpl* Create(
159 std::unique_ptr<base::MessageLoop> main_message_loop, 158 std::unique_ptr<base::MessageLoop> main_message_loop,
160 std::unique_ptr<scheduler::RendererScheduler> renderer_scheduler); 159 std::unique_ptr<blink::scheduler::RendererScheduler> renderer_scheduler);
161 static RenderThreadImpl* current(); 160 static RenderThreadImpl* current();
162 161
163 ~RenderThreadImpl() override; 162 ~RenderThreadImpl() override;
164 void Shutdown() override; 163 void Shutdown() override;
165 164
166 // When initializing WebKit, ensure that any schemes needed for the content 165 // When initializing WebKit, ensure that any schemes needed for the content
167 // module are registered properly. Static to allow sharing with tests. 166 // module are registered properly. Static to allow sharing with tests.
168 static void RegisterSchemes(); 167 static void RegisterSchemes();
169 168
170 // Notify V8 that the date/time configuration of the system might have 169 // Notify V8 that the date/time configuration of the system might have
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 bool IsZeroCopyEnabled() override; 209 bool IsZeroCopyEnabled() override;
211 bool IsPartialRasterEnabled() override; 210 bool IsPartialRasterEnabled() override;
212 bool IsGpuMemoryBufferCompositorResourcesEnabled() override; 211 bool IsGpuMemoryBufferCompositorResourcesEnabled() override;
213 bool IsElasticOverscrollEnabled() override; 212 bool IsElasticOverscrollEnabled() override;
214 const cc::BufferToTextureTargetMap& GetBufferToTextureTargetMap() override; 213 const cc::BufferToTextureTargetMap& GetBufferToTextureTargetMap() override;
215 scoped_refptr<base::SingleThreadTaskRunner> 214 scoped_refptr<base::SingleThreadTaskRunner>
216 GetCompositorMainThreadTaskRunner() override; 215 GetCompositorMainThreadTaskRunner() override;
217 scoped_refptr<base::SingleThreadTaskRunner> 216 scoped_refptr<base::SingleThreadTaskRunner>
218 GetCompositorImplThreadTaskRunner() override; 217 GetCompositorImplThreadTaskRunner() override;
219 gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override; 218 gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
220 scheduler::RendererScheduler* GetRendererScheduler() override; 219 blink::scheduler::RendererScheduler* GetRendererScheduler() override;
221 std::unique_ptr<cc::BeginFrameSource> CreateExternalBeginFrameSource( 220 std::unique_ptr<cc::BeginFrameSource> CreateExternalBeginFrameSource(
222 int routing_id) override; 221 int routing_id) override;
223 cc::ImageSerializationProcessor* GetImageSerializationProcessor() override; 222 cc::ImageSerializationProcessor* GetImageSerializationProcessor() override;
224 cc::TaskGraphRunner* GetTaskGraphRunner() override; 223 cc::TaskGraphRunner* GetTaskGraphRunner() override;
225 bool AreImageDecodeTasksEnabled() override; 224 bool AreImageDecodeTasksEnabled() override;
226 bool IsThreadedAnimationEnabled() override; 225 bool IsThreadedAnimationEnabled() override;
227 226
228 // scheduler::RendererScheduler::RAILModeObserver implementation. 227 // blink::scheduler::RendererScheduler::RAILModeObserver implementation.
229 void OnRAILModeChanged(v8::RAILMode rail_mode) override; 228 void OnRAILModeChanged(v8::RAILMode rail_mode) override;
230 229
231 // Synchronously establish a channel to the GPU plugin if not previously 230 // Synchronously establish a channel to the GPU plugin if not previously
232 // established or if it has been lost (for example if the GPU plugin crashed). 231 // established or if it has been lost (for example if the GPU plugin crashed).
233 // If there is a pending asynchronous request, it will be completed by the 232 // If there is a pending asynchronous request, it will be completed by the
234 // time this routine returns. 233 // time this routine returns.
235 scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannelSync(CauseForGpuLaunch); 234 scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannelSync(CauseForGpuLaunch);
236 235
237 std::unique_ptr<cc::OutputSurface> CreateCompositorOutputSurface( 236 std::unique_ptr<cc::OutputSurface> CreateCompositorOutputSurface(
238 bool use_software, 237 bool use_software,
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 453
455 void RegisterPendingFrameCreate(int routing_id, 454 void RegisterPendingFrameCreate(int routing_id,
456 mojom::FrameRequest frame, 455 mojom::FrameRequest frame,
457 mojom::FrameHostPtr host); 456 mojom::FrameHostPtr host);
458 457
459 mojom::StoragePartitionService* GetStoragePartitionService(); 458 mojom::StoragePartitionService* GetStoragePartitionService();
460 459
461 protected: 460 protected:
462 RenderThreadImpl( 461 RenderThreadImpl(
463 const InProcessChildThreadParams& params, 462 const InProcessChildThreadParams& params,
464 std::unique_ptr<scheduler::RendererScheduler> scheduler, 463 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler,
465 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue); 464 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue);
466 RenderThreadImpl(std::unique_ptr<base::MessageLoop> main_message_loop, 465 RenderThreadImpl(
467 std::unique_ptr<scheduler::RendererScheduler> scheduler); 466 std::unique_ptr<base::MessageLoop> main_message_loop,
467 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler);
468 468
469 private: 469 private:
470 // IPC::Listener 470 // IPC::Listener
471 void OnChannelError() override; 471 void OnChannelError() override;
472 472
473 // ChildThread 473 // ChildThread
474 bool OnControlMessageReceived(const IPC::Message& msg) override; 474 bool OnControlMessageReceived(const IPC::Message& msg) override;
475 void OnProcessBackgrounded(bool backgrounded) override; 475 void OnProcessBackgrounded(bool backgrounded) override;
476 void OnProcessPurgeAndSuspend() override; 476 void OnProcessPurgeAndSuspend() override;
477 void RecordAction(const base::UserMetricsAction& action) override; 477 void RecordAction(const base::UserMetricsAction& action) override;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 526
527 void ReleaseFreeMemory(); 527 void ReleaseFreeMemory();
528 528
529 void OnSyncMemoryPressure( 529 void OnSyncMemoryPressure(
530 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); 530 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
531 531
532 // These objects live solely on the render thread. 532 // These objects live solely on the render thread.
533 std::unique_ptr<AppCacheDispatcher> appcache_dispatcher_; 533 std::unique_ptr<AppCacheDispatcher> appcache_dispatcher_;
534 std::unique_ptr<DomStorageDispatcher> dom_storage_dispatcher_; 534 std::unique_ptr<DomStorageDispatcher> dom_storage_dispatcher_;
535 std::unique_ptr<IndexedDBDispatcher> main_thread_indexed_db_dispatcher_; 535 std::unique_ptr<IndexedDBDispatcher> main_thread_indexed_db_dispatcher_;
536 std::unique_ptr<scheduler::RendererScheduler> renderer_scheduler_; 536 std::unique_ptr<blink::scheduler::RendererScheduler> renderer_scheduler_;
537 std::unique_ptr<RendererBlinkPlatformImpl> blink_platform_impl_; 537 std::unique_ptr<RendererBlinkPlatformImpl> blink_platform_impl_;
538 std::unique_ptr<ResourceDispatchThrottler> resource_dispatch_throttler_; 538 std::unique_ptr<ResourceDispatchThrottler> resource_dispatch_throttler_;
539 std::unique_ptr<CacheStorageDispatcher> main_thread_cache_storage_dispatcher_; 539 std::unique_ptr<CacheStorageDispatcher> main_thread_cache_storage_dispatcher_;
540 std::unique_ptr<EmbeddedWorkerDispatcher> embedded_worker_dispatcher_; 540 std::unique_ptr<EmbeddedWorkerDispatcher> embedded_worker_dispatcher_;
541 541
542 // Used on the render thread and deleted by WebKit at shutdown. 542 // Used on the render thread and deleted by WebKit at shutdown.
543 blink::WebMediaStreamCenter* media_stream_center_; 543 blink::WebMediaStreamCenter* media_stream_center_;
544 544
545 // Used on the renderer and IPC threads. 545 // Used on the renderer and IPC threads.
546 scoped_refptr<BlobMessageFilter> blob_message_filter_; 546 scoped_refptr<BlobMessageFilter> blob_message_filter_;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 605
606 // The message loop of the renderer main thread. 606 // The message loop of the renderer main thread.
607 // This message loop should be destructed before the RenderThreadImpl 607 // This message loop should be destructed before the RenderThreadImpl
608 // shuts down Blink. 608 // shuts down Blink.
609 std::unique_ptr<base::MessageLoop> main_message_loop_; 609 std::unique_ptr<base::MessageLoop> main_message_loop_;
610 610
611 // A lazily initiated thread on which file operations are run. 611 // A lazily initiated thread on which file operations are run.
612 std::unique_ptr<base::Thread> file_thread_; 612 std::unique_ptr<base::Thread> file_thread_;
613 613
614 // May be null if overridden by ContentRendererClient. 614 // May be null if overridden by ContentRendererClient.
615 std::unique_ptr<scheduler::WebThreadBase> compositor_thread_; 615 std::unique_ptr<blink::scheduler::WebThreadBase> compositor_thread_;
616 616
617 // Utility class to provide GPU functionalities to media. 617 // Utility class to provide GPU functionalities to media.
618 // TODO(dcastagna): This should be just one scoped_ptr once 618 // TODO(dcastagna): This should be just one scoped_ptr once
619 // http://crbug.com/580386 is fixed. 619 // http://crbug.com/580386 is fixed.
620 // NOTE(dcastagna): At worst this accumulates a few bytes per context lost. 620 // NOTE(dcastagna): At worst this accumulates a few bytes per context lost.
621 ScopedVector<content::RendererGpuVideoAcceleratorFactories> gpu_factories_; 621 ScopedVector<content::RendererGpuVideoAcceleratorFactories> gpu_factories_;
622 622
623 // Thread for running multimedia operations (e.g., video decoding). 623 // Thread for running multimedia operations (e.g., video decoding).
624 std::unique_ptr<base::Thread> media_thread_; 624 std::unique_ptr<base::Thread> media_thread_;
625 625
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 DISALLOW_COPY_AND_ASSIGN(RenderThreadImpl); 712 DISALLOW_COPY_AND_ASSIGN(RenderThreadImpl);
713 }; 713 };
714 714
715 #if defined(COMPILER_MSVC) 715 #if defined(COMPILER_MSVC)
716 #pragma warning(pop) 716 #pragma warning(pop)
717 #endif 717 #endif
718 718
719 } // namespace content 719 } // namespace content
720 720
721 #endif // CONTENT_RENDERER_RENDER_THREAD_IMPL_H_ 721 #endif // CONTENT_RENDERER_RENDER_THREAD_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698