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