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 "content/child/child_thread_impl.h" | 25 #include "content/child/child_thread_impl.h" |
26 #include "content/child/memory/child_memory_coordinator_impl.h" | 26 #include "content/child/memory/child_memory_coordinator_impl.h" |
| 27 #include "content/common/associated_interface_registry_impl.h" |
27 #include "content/common/content_export.h" | 28 #include "content/common/content_export.h" |
28 #include "content/common/frame.mojom.h" | 29 #include "content/common/frame.mojom.h" |
29 #include "content/common/frame_replication_state.h" | 30 #include "content/common/frame_replication_state.h" |
30 #include "content/common/render_frame_message_filter.mojom.h" | 31 #include "content/common/render_frame_message_filter.mojom.h" |
31 #include "content/common/render_message_filter.mojom.h" | 32 #include "content/common/render_message_filter.mojom.h" |
| 33 #include "content/common/renderer.mojom.h" |
32 #include "content/common/storage_partition_service.mojom.h" | 34 #include "content/common/storage_partition_service.mojom.h" |
33 #include "content/public/renderer/render_thread.h" | 35 #include "content/public/renderer/render_thread.h" |
34 #include "content/renderer/gpu/compositor_dependencies.h" | 36 #include "content/renderer/gpu/compositor_dependencies.h" |
35 #include "content/renderer/layout_test_dependencies.h" | 37 #include "content/renderer/layout_test_dependencies.h" |
36 #include "device/time_zone_monitor/public/interfaces/time_zone_monitor.mojom.h" | 38 #include "device/time_zone_monitor/public/interfaces/time_zone_monitor.mojom.h" |
37 #include "gpu/ipc/client/gpu_channel_host.h" | 39 #include "gpu/ipc/client/gpu_channel_host.h" |
| 40 #include "mojo/public/cpp/bindings/associated_binding.h" |
38 #include "mojo/public/cpp/bindings/binding.h" | 41 #include "mojo/public/cpp/bindings/binding.h" |
39 #include "net/base/network_change_notifier.h" | 42 #include "net/base/network_change_notifier.h" |
40 #include "third_party/WebKit/public/platform/WebConnectionType.h" | 43 #include "third_party/WebKit/public/platform/WebConnectionType.h" |
41 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul
er.h" | 44 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul
er.h" |
42 #include "ui/gfx/native_widget_types.h" | 45 #include "ui/gfx/native_widget_types.h" |
43 | 46 |
44 #if defined(OS_MACOSX) | 47 #if defined(OS_MACOSX) |
45 #include "third_party/WebKit/public/web/mac/WebScrollbarTheme.h" | 48 #include "third_party/WebKit/public/web/mac/WebScrollbarTheme.h" |
46 #endif | 49 #endif |
47 | 50 |
48 class GrContext; | 51 class GrContext; |
49 class SkBitmap; | 52 class SkBitmap; |
50 struct FrameMsg_NewFrame_Params; | 53 struct FrameMsg_NewFrame_Params; |
51 struct ViewMsg_New_Params; | |
52 struct ViewMsg_UpdateScrollbarTheme_Params; | 54 struct ViewMsg_UpdateScrollbarTheme_Params; |
53 struct WorkerProcessMsg_CreateWorker_Params; | 55 struct WorkerProcessMsg_CreateWorker_Params; |
54 | 56 |
55 namespace blink { | 57 namespace blink { |
56 namespace scheduler { | 58 namespace scheduler { |
57 class WebThreadBase; | 59 class WebThreadBase; |
58 } | 60 } |
59 class WebGamepads; | 61 class WebGamepads; |
60 class WebMediaStreamCenter; | 62 class WebMediaStreamCenter; |
61 class WebMediaStreamCenterClient; | 63 class WebMediaStreamCenterClient; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // | 149 // |
148 // Most of the communication occurs in the form of IPC messages. They are | 150 // Most of the communication occurs in the form of IPC messages. They are |
149 // routed to the RenderThread according to the routing IDs of the messages. | 151 // routed to the RenderThread according to the routing IDs of the messages. |
150 // The routing IDs correspond to RenderView instances. | 152 // The routing IDs correspond to RenderView instances. |
151 class CONTENT_EXPORT RenderThreadImpl | 153 class CONTENT_EXPORT RenderThreadImpl |
152 : public RenderThread, | 154 : public RenderThread, |
153 public ChildThreadImpl, | 155 public ChildThreadImpl, |
154 public gpu::GpuChannelHostFactory, | 156 public gpu::GpuChannelHostFactory, |
155 public blink::scheduler::RendererScheduler::RAILModeObserver, | 157 public blink::scheduler::RendererScheduler::RAILModeObserver, |
156 public ChildMemoryCoordinatorDelegate, | 158 public ChildMemoryCoordinatorDelegate, |
| 159 NON_EXPORTED_BASE(public mojom::Renderer), |
157 // TODO(blundell): Separate this impl out into Blink. | 160 // TODO(blundell): Separate this impl out into Blink. |
158 NON_EXPORTED_BASE(public device::mojom::TimeZoneMonitorClient), | 161 NON_EXPORTED_BASE(public device::mojom::TimeZoneMonitorClient), |
159 NON_EXPORTED_BASE(public CompositorDependencies) { | 162 NON_EXPORTED_BASE(public CompositorDependencies) { |
160 public: | 163 public: |
161 static RenderThreadImpl* Create(const InProcessChildThreadParams& params); | 164 static RenderThreadImpl* Create(const InProcessChildThreadParams& params); |
162 static RenderThreadImpl* Create( | 165 static RenderThreadImpl* Create( |
163 std::unique_ptr<base::MessageLoop> main_message_loop, | 166 std::unique_ptr<base::MessageLoop> main_message_loop, |
164 std::unique_ptr<blink::scheduler::RendererScheduler> renderer_scheduler); | 167 std::unique_ptr<blink::scheduler::RendererScheduler> renderer_scheduler); |
165 static RenderThreadImpl* current(); | 168 static RenderThreadImpl* current(); |
166 static mojom::RenderMessageFilter* current_render_message_filter(); | 169 static mojom::RenderMessageFilter* current_render_message_filter(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 void ScheduleIdleHandler(int64_t initial_delay_ms) override; | 204 void ScheduleIdleHandler(int64_t initial_delay_ms) override; |
202 void IdleHandler() override; | 205 void IdleHandler() override; |
203 int64_t GetIdleNotificationDelayInMs() const override; | 206 int64_t GetIdleNotificationDelayInMs() const override; |
204 void SetIdleNotificationDelayInMs( | 207 void SetIdleNotificationDelayInMs( |
205 int64_t idle_notification_delay_in_ms) override; | 208 int64_t idle_notification_delay_in_ms) override; |
206 void UpdateHistograms(int sequence_number) override; | 209 void UpdateHistograms(int sequence_number) override; |
207 int PostTaskToAllWebWorkers(const base::Closure& closure) override; | 210 int PostTaskToAllWebWorkers(const base::Closure& closure) override; |
208 bool ResolveProxy(const GURL& url, std::string* proxy_list) override; | 211 bool ResolveProxy(const GURL& url, std::string* proxy_list) override; |
209 base::WaitableEvent* GetShutdownEvent() override; | 212 base::WaitableEvent* GetShutdownEvent() override; |
210 | 213 |
| 214 // IPC::Listener implementation via ChildThreadImpl: |
| 215 void OnAssociatedInterfaceRequest( |
| 216 const std::string& name, |
| 217 mojo::ScopedInterfaceEndpointHandle handle) override; |
| 218 |
211 // CompositorDependencies implementation. | 219 // CompositorDependencies implementation. |
212 bool IsGpuRasterizationForced() override; | 220 bool IsGpuRasterizationForced() override; |
213 bool IsGpuRasterizationEnabled() override; | 221 bool IsGpuRasterizationEnabled() override; |
214 bool IsAsyncWorkerContextEnabled() override; | 222 bool IsAsyncWorkerContextEnabled() override; |
215 int GetGpuRasterizationMSAASampleCount() override; | 223 int GetGpuRasterizationMSAASampleCount() override; |
216 bool IsLcdTextEnabled() override; | 224 bool IsLcdTextEnabled() override; |
217 bool IsDistanceFieldTextEnabled() override; | 225 bool IsDistanceFieldTextEnabled() override; |
218 bool IsZeroCopyEnabled() override; | 226 bool IsZeroCopyEnabled() override; |
219 bool IsPartialRasterEnabled() override; | 227 bool IsPartialRasterEnabled() override; |
220 bool IsGpuMemoryBufferCompositorResourcesEnabled() override; | 228 bool IsGpuMemoryBufferCompositorResourcesEnabled() override; |
(...skipping 18 matching lines...) Expand all Loading... |
239 // If there is a pending asynchronous request, it will be completed by the | 247 // If there is a pending asynchronous request, it will be completed by the |
240 // time this routine returns. | 248 // time this routine returns. |
241 scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannelSync(); | 249 scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannelSync(); |
242 | 250 |
243 std::unique_ptr<cc::CompositorFrameSink> CreateCompositorFrameSink( | 251 std::unique_ptr<cc::CompositorFrameSink> CreateCompositorFrameSink( |
244 bool use_software, | 252 bool use_software, |
245 int routing_id, | 253 int routing_id, |
246 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue, | 254 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue, |
247 const GURL& url); | 255 const GURL& url); |
248 | 256 |
| 257 AssociatedInterfaceRegistry* GetAssociatedInterfaceRegistry(); |
| 258 |
249 std::unique_ptr<cc::SwapPromise> RequestCopyOfOutputForLayoutTest( | 259 std::unique_ptr<cc::SwapPromise> RequestCopyOfOutputForLayoutTest( |
250 int32_t routing_id, | 260 int32_t routing_id, |
251 std::unique_ptr<cc::CopyOutputRequest> request); | 261 std::unique_ptr<cc::CopyOutputRequest> request); |
252 | 262 |
253 // True if we are running layout tests. This currently disables forwarding | 263 // True if we are running layout tests. This currently disables forwarding |
254 // various status messages to the console, skips network error pages, and | 264 // various status messages to the console, skips network error pages, and |
255 // short circuits size update and focus events. | 265 // short circuits size update and focus events. |
256 bool layout_test_mode() const { return !!layout_test_deps_; } | 266 bool layout_test_mode() const { return !!layout_test_deps_; } |
257 void set_layout_test_dependencies( | 267 void set_layout_test_dependencies( |
258 std::unique_ptr<LayoutTestDependencies> deps) { | 268 std::unique_ptr<LayoutTestDependencies> deps) { |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 | 505 |
496 void InitializeWebKit( | 506 void InitializeWebKit( |
497 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue); | 507 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue); |
498 | 508 |
499 void OnCreateNewFrame(FrameMsg_NewFrame_Params params); | 509 void OnCreateNewFrame(FrameMsg_NewFrame_Params params); |
500 void OnCreateNewFrameProxy(int routing_id, | 510 void OnCreateNewFrameProxy(int routing_id, |
501 int render_view_routing_id, | 511 int render_view_routing_id, |
502 int opener_routing_id, | 512 int opener_routing_id, |
503 int parent_routing_id, | 513 int parent_routing_id, |
504 const FrameReplicationState& replicated_state); | 514 const FrameReplicationState& replicated_state); |
505 void OnCreateNewView(const ViewMsg_New_Params& params); | |
506 void OnTransferBitmap(const SkBitmap& bitmap, int resource_id); | 515 void OnTransferBitmap(const SkBitmap& bitmap, int resource_id); |
507 #if defined(ENABLE_PLUGINS) | 516 #if defined(ENABLE_PLUGINS) |
508 void OnPurgePluginListCache(bool reload_pages); | 517 void OnPurgePluginListCache(bool reload_pages); |
509 #endif | 518 #endif |
510 void OnNetworkConnectionChanged( | 519 void OnNetworkConnectionChanged( |
511 net::NetworkChangeNotifier::ConnectionType type, | 520 net::NetworkChangeNotifier::ConnectionType type, |
512 double max_bandwidth_mbps); | 521 double max_bandwidth_mbps); |
513 void OnGetAccessibilityTree(); | 522 void OnGetAccessibilityTree(); |
514 | 523 |
| 524 // mojom::Renderer: |
| 525 void CreateView(mojom::CreateViewParamsPtr params) override; |
| 526 |
515 // device::mojom::TimeZoneClient: | 527 // device::mojom::TimeZoneClient: |
516 void OnTimeZoneChange(const std::string& zoneId) override; | 528 void OnTimeZoneChange(const std::string& zoneId) override; |
517 void OnMemoryPressure( | 529 void OnMemoryPressure( |
518 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); | 530 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); |
519 #if defined(OS_ANDROID) | 531 #if defined(OS_ANDROID) |
520 void OnSetWebKitSharedTimersSuspended(bool suspend); | 532 void OnSetWebKitSharedTimersSuspended(bool suspend); |
521 #endif | 533 #endif |
522 #if defined(OS_MACOSX) | 534 #if defined(OS_MACOSX) |
523 void OnUpdateScrollbarTheme( | 535 void OnUpdateScrollbarTheme( |
524 const ViewMsg_UpdateScrollbarTheme_Params& params); | 536 const ViewMsg_UpdateScrollbarTheme_Params& params); |
525 void OnSystemColorsChanged(int aqua_color_variant, | 537 void OnSystemColorsChanged(int aqua_color_variant, |
526 const std::string& highlight_text_color, | 538 const std::string& highlight_text_color, |
527 const std::string& highlight_color); | 539 const std::string& highlight_color); |
528 #endif | 540 #endif |
529 void OnCreateNewSharedWorker( | 541 void OnCreateNewSharedWorker( |
530 const WorkerProcessMsg_CreateWorker_Params& params); | 542 const WorkerProcessMsg_CreateWorker_Params& params); |
531 bool RendererIsHidden() const; | 543 bool RendererIsHidden() const; |
532 void OnRendererHidden(); | 544 void OnRendererHidden(); |
533 void OnRendererVisible(); | 545 void OnRendererVisible(); |
534 | 546 |
535 void ReleaseFreeMemory(); | 547 void ReleaseFreeMemory(); |
536 | 548 |
537 void OnSyncMemoryPressure( | 549 void OnSyncMemoryPressure( |
538 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); | 550 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); |
539 | 551 |
540 std::unique_ptr<cc::BeginFrameSource> CreateExternalBeginFrameSource( | 552 std::unique_ptr<cc::BeginFrameSource> CreateExternalBeginFrameSource( |
541 int routing_id); | 553 int routing_id); |
542 | 554 |
| 555 void OnRendererInterfaceRequest(mojom::RendererAssociatedRequest request); |
| 556 |
543 // These objects live solely on the render thread. | 557 // These objects live solely on the render thread. |
544 std::unique_ptr<AppCacheDispatcher> appcache_dispatcher_; | 558 std::unique_ptr<AppCacheDispatcher> appcache_dispatcher_; |
545 std::unique_ptr<DomStorageDispatcher> dom_storage_dispatcher_; | 559 std::unique_ptr<DomStorageDispatcher> dom_storage_dispatcher_; |
546 std::unique_ptr<IndexedDBDispatcher> main_thread_indexed_db_dispatcher_; | 560 std::unique_ptr<IndexedDBDispatcher> main_thread_indexed_db_dispatcher_; |
547 std::unique_ptr<blink::scheduler::RendererScheduler> renderer_scheduler_; | 561 std::unique_ptr<blink::scheduler::RendererScheduler> renderer_scheduler_; |
548 std::unique_ptr<RendererBlinkPlatformImpl> blink_platform_impl_; | 562 std::unique_ptr<RendererBlinkPlatformImpl> blink_platform_impl_; |
549 std::unique_ptr<ResourceDispatchThrottler> resource_dispatch_throttler_; | 563 std::unique_ptr<ResourceDispatchThrottler> resource_dispatch_throttler_; |
550 std::unique_ptr<CacheStorageDispatcher> main_thread_cache_storage_dispatcher_; | 564 std::unique_ptr<CacheStorageDispatcher> main_thread_cache_storage_dispatcher_; |
551 std::unique_ptr<EmbeddedWorkerDispatcher> embedded_worker_dispatcher_; | 565 std::unique_ptr<EmbeddedWorkerDispatcher> embedded_worker_dispatcher_; |
552 | 566 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 mojom::FrameRequest frame_request_; | 729 mojom::FrameRequest frame_request_; |
716 mojom::FrameHostPtr frame_host_; | 730 mojom::FrameHostPtr frame_host_; |
717 }; | 731 }; |
718 | 732 |
719 using PendingFrameCreateMap = | 733 using PendingFrameCreateMap = |
720 std::map<int, scoped_refptr<PendingFrameCreate>>; | 734 std::map<int, scoped_refptr<PendingFrameCreate>>; |
721 PendingFrameCreateMap pending_frame_creates_; | 735 PendingFrameCreateMap pending_frame_creates_; |
722 | 736 |
723 mojom::StoragePartitionServicePtr storage_partition_service_; | 737 mojom::StoragePartitionServicePtr storage_partition_service_; |
724 | 738 |
| 739 AssociatedInterfaceRegistryImpl associated_interfaces_; |
| 740 |
| 741 mojo::AssociatedBinding<mojom::Renderer> renderer_binding_; |
| 742 |
725 mojom::RenderFrameMessageFilterAssociatedPtr render_frame_message_filter_; | 743 mojom::RenderFrameMessageFilterAssociatedPtr render_frame_message_filter_; |
726 mojom::RenderMessageFilterAssociatedPtr render_message_filter_; | 744 mojom::RenderMessageFilterAssociatedPtr render_message_filter_; |
727 | 745 |
728 bool is_renderer_suspended_; | 746 bool is_renderer_suspended_; |
729 | 747 |
730 DISALLOW_COPY_AND_ASSIGN(RenderThreadImpl); | 748 DISALLOW_COPY_AND_ASSIGN(RenderThreadImpl); |
731 }; | 749 }; |
732 | 750 |
733 #if defined(COMPILER_MSVC) | 751 #if defined(COMPILER_MSVC) |
734 #pragma warning(pop) | 752 #pragma warning(pop) |
735 #endif | 753 #endif |
736 | 754 |
737 } // namespace content | 755 } // namespace content |
738 | 756 |
739 #endif // CONTENT_RENDERER_RENDER_THREAD_IMPL_H_ | 757 #endif // CONTENT_RENDERER_RENDER_THREAD_IMPL_H_ |
OLD | NEW |