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_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "content/common/renderer.mojom.h" | 30 #include "content/common/renderer.mojom.h" |
31 #include "content/public/browser/render_process_host.h" | 31 #include "content/public/browser/render_process_host.h" |
32 #include "content/public/common/service_manager_connection.h" | 32 #include "content/public/common/service_manager_connection.h" |
33 #include "ipc/ipc_channel_proxy.h" | 33 #include "ipc/ipc_channel_proxy.h" |
34 #include "ipc/ipc_platform_file.h" | 34 #include "ipc/ipc_platform_file.h" |
35 #include "media/media_features.h" | 35 #include "media/media_features.h" |
36 #include "mojo/edk/embedder/pending_process_connection.h" | 36 #include "mojo/edk/embedder/pending_process_connection.h" |
37 #include "mojo/public/cpp/bindings/associated_binding.h" | 37 #include "mojo/public/cpp/bindings/associated_binding.h" |
38 #include "mojo/public/cpp/bindings/associated_binding_set.h" | 38 #include "mojo/public/cpp/bindings/associated_binding_set.h" |
39 #include "mojo/public/cpp/bindings/interface_ptr.h" | 39 #include "mojo/public/cpp/bindings/interface_ptr.h" |
| 40 #include "services/resource_coordinator/public/cpp/resource_coordinator_interfac
e.h" |
40 #include "services/service_manager/public/cpp/interface_registry.h" | 41 #include "services/service_manager/public/cpp/interface_registry.h" |
41 #include "services/service_manager/public/interfaces/service.mojom.h" | 42 #include "services/service_manager/public/interfaces/service.mojom.h" |
42 #include "services/ui/public/interfaces/gpu.mojom.h" | 43 #include "services/ui/public/interfaces/gpu.mojom.h" |
43 #include "ui/gfx/gpu_memory_buffer.h" | 44 #include "ui/gfx/gpu_memory_buffer.h" |
44 #include "ui/gl/gpu_switching_observer.h" | 45 #include "ui/gl/gpu_switching_observer.h" |
45 | 46 |
46 #if defined(OS_ANDROID) | 47 #if defined(OS_ANDROID) |
47 #include "content/browser/android/synchronous_compositor_browser_filter.h" | 48 #include "content/browser/android/synchronous_compositor_browser_filter.h" |
48 #endif | 49 #endif |
49 | 50 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // communicate through the two process objects. | 98 // communicate through the two process objects. |
98 // | 99 // |
99 // A RenderProcessHost is also associated with one and only one | 100 // A RenderProcessHost is also associated with one and only one |
100 // StoragePartition. This allows us to implement strong storage isolation | 101 // StoragePartition. This allows us to implement strong storage isolation |
101 // because all the IPCs from the RenderViews (renderer) will only ever be able | 102 // because all the IPCs from the RenderViews (renderer) will only ever be able |
102 // to access the partition they are assigned to. | 103 // to access the partition they are assigned to. |
103 class CONTENT_EXPORT RenderProcessHostImpl | 104 class CONTENT_EXPORT RenderProcessHostImpl |
104 : public RenderProcessHost, | 105 : public RenderProcessHost, |
105 public ChildProcessLauncher::Client, | 106 public ChildProcessLauncher::Client, |
106 public ui::GpuSwitchingObserver, | 107 public ui::GpuSwitchingObserver, |
| 108 public resource_coordinator::mojom::PolicyCallback, |
107 public NON_EXPORTED_BASE(mojom::RouteProvider), | 109 public NON_EXPORTED_BASE(mojom::RouteProvider), |
108 public NON_EXPORTED_BASE(mojom::AssociatedInterfaceProvider) { | 110 public NON_EXPORTED_BASE(mojom::AssociatedInterfaceProvider) { |
109 public: | 111 public: |
110 RenderProcessHostImpl(BrowserContext* browser_context, | 112 RenderProcessHostImpl(BrowserContext* browser_context, |
111 StoragePartitionImpl* storage_partition_impl, | 113 StoragePartitionImpl* storage_partition_impl, |
112 bool is_for_guests_only); | 114 bool is_for_guests_only); |
113 ~RenderProcessHostImpl() override; | 115 ~RenderProcessHostImpl() override; |
114 | 116 |
115 // RenderProcessHost implementation (public portion). | 117 // RenderProcessHost implementation (public portion). |
116 bool Init() override; | 118 bool Init() override; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 const std::string& interface_name, | 192 const std::string& interface_name, |
191 mojo::ScopedInterfaceEndpointHandle handle) override; | 193 mojo::ScopedInterfaceEndpointHandle handle) override; |
192 void OnChannelConnected(int32_t peer_pid) override; | 194 void OnChannelConnected(int32_t peer_pid) override; |
193 void OnChannelError() override; | 195 void OnChannelError() override; |
194 void OnBadMessageReceived(const IPC::Message& message) override; | 196 void OnBadMessageReceived(const IPC::Message& message) override; |
195 | 197 |
196 // ChildProcessLauncher::Client implementation. | 198 // ChildProcessLauncher::Client implementation. |
197 void OnProcessLaunched() override; | 199 void OnProcessLaunched() override; |
198 void OnProcessLaunchFailed(int error_code) override; | 200 void OnProcessLaunchFailed(int error_code) override; |
199 | 201 |
| 202 // resource_coordinator::mojom::PolicyCallback implementation. |
| 203 void SetPolicy(resource_coordinator::mojom::PolicyPtr policy) override; |
| 204 |
200 scoped_refptr<AudioRendererHost> audio_renderer_host() const; | 205 scoped_refptr<AudioRendererHost> audio_renderer_host() const; |
201 | 206 |
202 // Call this function when it is evident that the child process is actively | 207 // Call this function when it is evident that the child process is actively |
203 // performing some operation, for example if we just received an IPC message. | 208 // performing some operation, for example if we just received an IPC message. |
204 void mark_child_process_activity_time() { | 209 void mark_child_process_activity_time() { |
205 child_process_activity_time_ = base::TimeTicks::Now(); | 210 child_process_activity_time_ = base::TimeTicks::Now(); |
206 } | 211 } |
207 | 212 |
208 // Used to extend the lifetime of the sessions until the render view | 213 // Used to extend the lifetime of the sessions until the render view |
209 // in the renderer is fully closed. This is static because its also called | 214 // in the renderer is fully closed. This is static because its also called |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | 287 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
283 | 288 |
284 void RecomputeAndUpdateWebKitPreferences(); | 289 void RecomputeAndUpdateWebKitPreferences(); |
285 | 290 |
286 // Called when an audio stream is added or removed and used to determine if | 291 // Called when an audio stream is added or removed and used to determine if |
287 // the process should be backgrounded or not. | 292 // the process should be backgrounded or not. |
288 void OnAudioStreamAdded() override; | 293 void OnAudioStreamAdded() override; |
289 void OnAudioStreamRemoved() override; | 294 void OnAudioStreamRemoved() override; |
290 int get_audio_stream_count_for_testing() const { return audio_stream_count_; } | 295 int get_audio_stream_count_for_testing() const { return audio_stream_count_; } |
291 | 296 |
| 297 resource_coordinator::ResourceCoordinatorInterface* |
| 298 GetProcessResourceCoordinator(); |
| 299 |
292 protected: | 300 protected: |
293 // A proxy for our IPC::Channel that lives on the IO thread. | 301 // A proxy for our IPC::Channel that lives on the IO thread. |
294 std::unique_ptr<IPC::ChannelProxy> channel_; | 302 std::unique_ptr<IPC::ChannelProxy> channel_; |
295 | 303 |
296 // True if fast shutdown has been performed on this RPH. | 304 // True if fast shutdown has been performed on this RPH. |
297 bool fast_shutdown_started_; | 305 bool fast_shutdown_started_; |
298 | 306 |
299 // True if we've posted a DeleteTask and will be deleted soon. | 307 // True if we've posted a DeleteTask and will be deleted soon. |
300 bool deleting_soon_; | 308 bool deleting_soon_; |
301 | 309 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 // Copies applicable command line switches from the given |browser_cmd| line | 366 // Copies applicable command line switches from the given |browser_cmd| line |
359 // flags to the output |renderer_cmd| line flags. Not all switches will be | 367 // flags to the output |renderer_cmd| line flags. Not all switches will be |
360 // copied over. | 368 // copied over. |
361 void PropagateBrowserCommandLineToRenderer( | 369 void PropagateBrowserCommandLineToRenderer( |
362 const base::CommandLine& browser_cmd, | 370 const base::CommandLine& browser_cmd, |
363 base::CommandLine* renderer_cmd); | 371 base::CommandLine* renderer_cmd); |
364 | 372 |
365 // Inspects the current object state and sets/removes background priority if | 373 // Inspects the current object state and sets/removes background priority if |
366 // appropriate. Should be called after any of the involved data members | 374 // appropriate. Should be called after any of the involved data members |
367 // change. | 375 // change. |
368 void UpdateProcessPriority(); | 376 void SetProcessPriority(bool should_background); |
369 | 377 |
370 // Creates a PersistentMemoryAllocator and shares it with the renderer | 378 // Creates a PersistentMemoryAllocator and shares it with the renderer |
371 // process for it to store histograms from that process. The allocator is | 379 // process for it to store histograms from that process. The allocator is |
372 // available for extraction by a SubprocesMetricsProvider in order to | 380 // available for extraction by a SubprocesMetricsProvider in order to |
373 // report those histograms to UMA. | 381 // report those histograms to UMA. |
374 void CreateSharedRendererHistogramAllocator(); | 382 void CreateSharedRendererHistogramAllocator(); |
375 | 383 |
376 // Handle termination of our process. | 384 // Handle termination of our process. |
377 void ProcessDied(bool already_dead, RendererClosedDetails* known_details); | 385 void ProcessDied(bool already_dead, RendererClosedDetails* known_details); |
378 | 386 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 std::unique_ptr<OffscreenCanvasCompositorFrameSinkProviderImpl> | 605 std::unique_ptr<OffscreenCanvasCompositorFrameSinkProviderImpl> |
598 offscreen_canvas_provider_; | 606 offscreen_canvas_provider_; |
599 | 607 |
600 mojom::RouteProviderAssociatedPtr remote_route_provider_; | 608 mojom::RouteProviderAssociatedPtr remote_route_provider_; |
601 mojom::RendererAssociatedPtr renderer_interface_; | 609 mojom::RendererAssociatedPtr renderer_interface_; |
602 | 610 |
603 // Tracks active audio streams within the render process; used to determine if | 611 // Tracks active audio streams within the render process; used to determine if |
604 // if a process should be backgrounded. | 612 // if a process should be backgrounded. |
605 int audio_stream_count_ = 0; | 613 int audio_stream_count_ = 0; |
606 | 614 |
| 615 std::unique_ptr<resource_coordinator::ResourceCoordinatorInterface> |
| 616 process_resource_coordinator_; |
| 617 mojo::Binding<resource_coordinator::mojom::PolicyCallback> |
| 618 resource_coordinator_binding_; |
| 619 |
607 // A WeakPtrFactory which is reset every time Cleanup() runs. Used to vend | 620 // A WeakPtrFactory which is reset every time Cleanup() runs. Used to vend |
608 // WeakPtrs which are invalidated any time the RPHI is recycled. | 621 // WeakPtrs which are invalidated any time the RPHI is recycled. |
609 std::unique_ptr<base::WeakPtrFactory<RenderProcessHostImpl>> | 622 std::unique_ptr<base::WeakPtrFactory<RenderProcessHostImpl>> |
610 instance_weak_factory_; | 623 instance_weak_factory_; |
611 | 624 |
612 base::WeakPtrFactory<RenderProcessHostImpl> weak_factory_; | 625 base::WeakPtrFactory<RenderProcessHostImpl> weak_factory_; |
613 | 626 |
614 DISALLOW_COPY_AND_ASSIGN(RenderProcessHostImpl); | 627 DISALLOW_COPY_AND_ASSIGN(RenderProcessHostImpl); |
615 }; | 628 }; |
616 | 629 |
617 } // namespace content | 630 } // namespace content |
618 | 631 |
619 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ | 632 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ |
OLD | NEW |