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