| 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 11 matching lines...) Expand all Loading... |
| 22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 23 #include "content/browser/child_process_launcher.h" | 23 #include "content/browser/child_process_launcher.h" |
| 24 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 24 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
| 25 #include "content/browser/power_monitor_message_broadcaster.h" | 25 #include "content/browser/power_monitor_message_broadcaster.h" |
| 26 #include "content/browser/webrtc/webrtc_eventlog_host.h" | 26 #include "content/browser/webrtc/webrtc_eventlog_host.h" |
| 27 #include "content/common/content_export.h" | 27 #include "content/common/content_export.h" |
| 28 #include "content/public/browser/render_process_host.h" | 28 #include "content/public/browser/render_process_host.h" |
| 29 #include "content/public/common/mojo_shell_connection.h" | 29 #include "content/public/common/mojo_shell_connection.h" |
| 30 #include "ipc/ipc_channel_proxy.h" | 30 #include "ipc/ipc_channel_proxy.h" |
| 31 #include "ipc/ipc_platform_file.h" | 31 #include "ipc/ipc_platform_file.h" |
| 32 #include "mojo/public/cpp/bindings/associated_binding.h" |
| 33 #include "mojo/public/cpp/bindings/associated_binding_set.h" |
| 32 #include "mojo/public/cpp/bindings/interface_ptr.h" | 34 #include "mojo/public/cpp/bindings/interface_ptr.h" |
| 33 #include "services/shell/public/cpp/interface_registry.h" | 35 #include "services/shell/public/cpp/interface_registry.h" |
| 34 #include "services/shell/public/interfaces/service.mojom.h" | 36 #include "services/shell/public/interfaces/service.mojom.h" |
| 35 #include "ui/gfx/gpu_memory_buffer.h" | 37 #include "ui/gfx/gpu_memory_buffer.h" |
| 36 #include "ui/gl/gpu_switching_observer.h" | 38 #include "ui/gl/gpu_switching_observer.h" |
| 37 | 39 |
| 38 #if defined(OS_ANDROID) | 40 #if defined(OS_ANDROID) |
| 39 #include "content/public/browser/android/interface_registry_android.h" | 41 #include "content/public/browser/android/interface_registry_android.h" |
| 40 #endif | 42 #endif |
| 41 | 43 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // are correlated with IDs. This way, the Views and the corresponding ViewHosts | 101 // are correlated with IDs. This way, the Views and the corresponding ViewHosts |
| 100 // communicate through the two process objects. | 102 // communicate through the two process objects. |
| 101 // | 103 // |
| 102 // A RenderProcessHost is also associated with one and only one | 104 // A RenderProcessHost is also associated with one and only one |
| 103 // StoragePartition. This allows us to implement strong storage isolation | 105 // StoragePartition. This allows us to implement strong storage isolation |
| 104 // because all the IPCs from the RenderViews (renderer) will only ever be able | 106 // because all the IPCs from the RenderViews (renderer) will only ever be able |
| 105 // to access the partition they are assigned to. | 107 // to access the partition they are assigned to. |
| 106 class CONTENT_EXPORT RenderProcessHostImpl | 108 class CONTENT_EXPORT RenderProcessHostImpl |
| 107 : public RenderProcessHost, | 109 : public RenderProcessHost, |
| 108 public ChildProcessLauncher::Client, | 110 public ChildProcessLauncher::Client, |
| 109 public ui::GpuSwitchingObserver { | 111 public ui::GpuSwitchingObserver, |
| 112 public NON_EXPORTED_BASE(mojom::RouteProvider), |
| 113 public NON_EXPORTED_BASE(mojom::AssociatedInterfaceProvider) { |
| 110 public: | 114 public: |
| 111 RenderProcessHostImpl(BrowserContext* browser_context, | 115 RenderProcessHostImpl(BrowserContext* browser_context, |
| 112 StoragePartitionImpl* storage_partition_impl, | 116 StoragePartitionImpl* storage_partition_impl, |
| 113 bool is_for_guests_only); | 117 bool is_for_guests_only); |
| 114 ~RenderProcessHostImpl() override; | 118 ~RenderProcessHostImpl() override; |
| 115 | 119 |
| 116 // RenderProcessHost implementation (public portion). | 120 // RenderProcessHost implementation (public portion). |
| 117 void EnableSendQueue() override; | 121 void EnableSendQueue() override; |
| 118 bool Init() override; | 122 bool Init() override; |
| 119 int GetNextRoutingID() override; | 123 int GetNextRoutingID() override; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 base::Callback<void(const std::string&)> callback) override; | 162 base::Callback<void(const std::string&)> callback) override; |
| 159 void ClearWebRtcLogMessageCallback() override; | 163 void ClearWebRtcLogMessageCallback() override; |
| 160 WebRtcStopRtpDumpCallback StartRtpDump( | 164 WebRtcStopRtpDumpCallback StartRtpDump( |
| 161 bool incoming, | 165 bool incoming, |
| 162 bool outgoing, | 166 bool outgoing, |
| 163 const WebRtcRtpPacketCallback& packet_callback) override; | 167 const WebRtcRtpPacketCallback& packet_callback) override; |
| 164 #endif | 168 #endif |
| 165 void ResumeDeferredNavigation(const GlobalRequestID& request_id) override; | 169 void ResumeDeferredNavigation(const GlobalRequestID& request_id) override; |
| 166 void NotifyTimezoneChange(const std::string& timezone) override; | 170 void NotifyTimezoneChange(const std::string& timezone) override; |
| 167 shell::InterfaceProvider* GetRemoteInterfaces() override; | 171 shell::InterfaceProvider* GetRemoteInterfaces() override; |
| 172 mojom::RouteProvider* GetRemoteRouteProvider() override; |
| 168 std::unique_ptr<base::SharedPersistentMemoryAllocator> TakeMetricsAllocator() | 173 std::unique_ptr<base::SharedPersistentMemoryAllocator> TakeMetricsAllocator() |
| 169 override; | 174 override; |
| 170 const base::TimeTicks& GetInitTimeForNavigationMetrics() const override; | 175 const base::TimeTicks& GetInitTimeForNavigationMetrics() const override; |
| 171 #if defined(ENABLE_BROWSER_CDMS) | 176 #if defined(ENABLE_BROWSER_CDMS) |
| 172 scoped_refptr<media::MediaKeys> GetCdm(int render_frame_id, | 177 scoped_refptr<media::MediaKeys> GetCdm(int render_frame_id, |
| 173 int cdm_id) const override; | 178 int cdm_id) const override; |
| 174 #endif | 179 #endif |
| 175 bool IsProcessBackgrounded() const override; | 180 bool IsProcessBackgrounded() const override; |
| 176 void IncrementServiceWorkerRefCount() override; | 181 void IncrementServiceWorkerRefCount() override; |
| 177 void DecrementServiceWorkerRefCount() override; | 182 void DecrementServiceWorkerRefCount() override; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 325 |
| 321 std::unique_ptr<IPC::ChannelProxy> CreateChannelProxy( | 326 std::unique_ptr<IPC::ChannelProxy> CreateChannelProxy( |
| 322 const std::string& channel_id); | 327 const std::string& channel_id); |
| 323 | 328 |
| 324 // Creates and adds the IO thread message filters. | 329 // Creates and adds the IO thread message filters. |
| 325 void CreateMessageFilters(); | 330 void CreateMessageFilters(); |
| 326 | 331 |
| 327 // Registers Mojo interfaces to be exposed to the renderer. | 332 // Registers Mojo interfaces to be exposed to the renderer. |
| 328 void RegisterMojoInterfaces(); | 333 void RegisterMojoInterfaces(); |
| 329 | 334 |
| 335 // mojom::RouteProvider: |
| 336 void GetRoute( |
| 337 int32_t routing_id, |
| 338 mojom::AssociatedInterfaceProviderAssociatedRequest request) override; |
| 339 |
| 340 // mojom::AssociatedInterfaceProvider: |
| 341 void GetAssociatedInterface( |
| 342 const std::string& name, |
| 343 mojom::AssociatedInterfaceAssociatedRequest request) override; |
| 344 |
| 330 void CreateStoragePartitionService( | 345 void CreateStoragePartitionService( |
| 331 mojo::InterfaceRequest<mojom::StoragePartitionService> request); | 346 mojo::InterfaceRequest<mojom::StoragePartitionService> request); |
| 332 | 347 |
| 333 // Control message handlers. | 348 // Control message handlers. |
| 334 void OnShutdownRequest(); | 349 void OnShutdownRequest(); |
| 335 void SuddenTerminationChanged(bool enabled); | 350 void SuddenTerminationChanged(bool enabled); |
| 336 void OnUserMetricsRecordAction(const std::string& action); | 351 void OnUserMetricsRecordAction(const std::string& action); |
| 337 void OnCloseACK(int old_route_id); | 352 void OnCloseACK(int old_route_id); |
| 338 | 353 |
| 339 // Generates a command line to be used to spawn a renderer and appends the | 354 // Generates a command line to be used to spawn a renderer and appends the |
| (...skipping 14 matching lines...) Expand all Loading... |
| 354 | 369 |
| 355 // Creates a PersistentMemoryAllocator and shares it with the renderer | 370 // Creates a PersistentMemoryAllocator and shares it with the renderer |
| 356 // process for it to store histograms from that process. The allocator is | 371 // process for it to store histograms from that process. The allocator is |
| 357 // available for extraction by a SubprocesMetricsProvider in order to | 372 // available for extraction by a SubprocesMetricsProvider in order to |
| 358 // report those histograms to UMA. | 373 // report those histograms to UMA. |
| 359 void CreateSharedRendererHistogramAllocator(); | 374 void CreateSharedRendererHistogramAllocator(); |
| 360 | 375 |
| 361 // Handle termination of our process. | 376 // Handle termination of our process. |
| 362 void ProcessDied(bool already_dead, RendererClosedDetails* known_details); | 377 void ProcessDied(bool already_dead, RendererClosedDetails* known_details); |
| 363 | 378 |
| 379 void OnRouteProviderRequest(mojom::RouteProviderAssociatedRequest request); |
| 380 |
| 364 // GpuSwitchingObserver implementation. | 381 // GpuSwitchingObserver implementation. |
| 365 void OnGpuSwitched() override; | 382 void OnGpuSwitched() override; |
| 366 | 383 |
| 367 #if defined(ENABLE_WEBRTC) | 384 #if defined(ENABLE_WEBRTC) |
| 368 void OnRegisterAecDumpConsumer(int id); | 385 void OnRegisterAecDumpConsumer(int id); |
| 369 void OnUnregisterAecDumpConsumer(int id); | 386 void OnUnregisterAecDumpConsumer(int id); |
| 370 void RegisterAecDumpConsumerOnUIThread(int id); | 387 void RegisterAecDumpConsumerOnUIThread(int id); |
| 371 void UnregisterAecDumpConsumerOnUIThread(int id); | 388 void UnregisterAecDumpConsumerOnUIThread(int id); |
| 372 void EnableAecDumpForId(const base::FilePath& file, int id); | 389 void EnableAecDumpForId(const base::FilePath& file, int id); |
| 373 // Sends |file_for_transit| to the render process. | 390 // Sends |file_for_transit| to the render process. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 std::unique_ptr<InterfaceRegistryAndroid> interface_registry_android_; | 440 std::unique_ptr<InterfaceRegistryAndroid> interface_registry_android_; |
| 424 #endif | 441 #endif |
| 425 | 442 |
| 426 size_t service_worker_ref_count_; | 443 size_t service_worker_ref_count_; |
| 427 size_t shared_worker_ref_count_; | 444 size_t shared_worker_ref_count_; |
| 428 | 445 |
| 429 // The registered IPC listener objects. When this list is empty, we should | 446 // The registered IPC listener objects. When this list is empty, we should |
| 430 // delete ourselves. | 447 // delete ourselves. |
| 431 IDMap<IPC::Listener> listeners_; | 448 IDMap<IPC::Listener> listeners_; |
| 432 | 449 |
| 450 mojo::AssociatedBinding<mojom::RouteProvider> route_provider_binding_; |
| 451 mojo::AssociatedBindingSet<mojom::AssociatedInterfaceProvider> |
| 452 associated_interface_provider_bindings_; |
| 453 |
| 433 // The count of currently visible widgets. Since the host can be a container | 454 // The count of currently visible widgets. Since the host can be a container |
| 434 // for multiple widgets, it uses this count to determine when it should be | 455 // for multiple widgets, it uses this count to determine when it should be |
| 435 // backgrounded. | 456 // backgrounded. |
| 436 int32_t visible_widgets_; | 457 int32_t visible_widgets_; |
| 437 | 458 |
| 438 // Whether this process currently has backgrounded priority. Tracked so that | 459 // Whether this process currently has backgrounded priority. Tracked so that |
| 439 // UpdateProcessPriority() can avoid redundantly setting the priority. | 460 // UpdateProcessPriority() can avoid redundantly setting the priority. |
| 440 bool is_process_backgrounded_; | 461 bool is_process_backgrounded_; |
| 441 | 462 |
| 442 // Used to allow a RenderWidgetHost to intercept various messages on the | 463 // Used to allow a RenderWidgetHost to intercept various messages on the |
| (...skipping 16 matching lines...) Expand all Loading... |
| 459 // also reset that in the case of process termination. | 480 // also reset that in the case of process termination. |
| 460 bool is_initialized_; | 481 bool is_initialized_; |
| 461 | 482 |
| 462 // PlzNavigate | 483 // PlzNavigate |
| 463 // Stores the time at which the first call to Init happened. | 484 // Stores the time at which the first call to Init happened. |
| 464 base::TimeTicks init_time_; | 485 base::TimeTicks init_time_; |
| 465 | 486 |
| 466 // Used to launch and terminate the process without blocking the UI thread. | 487 // Used to launch and terminate the process without blocking the UI thread. |
| 467 std::unique_ptr<ChildProcessLauncher> child_process_launcher_; | 488 std::unique_ptr<ChildProcessLauncher> child_process_launcher_; |
| 468 | 489 |
| 469 // Messages we queue while waiting for the process handle. We queue them here | 490 // Messages we queue before the ChannelProxy is created. |
| 470 // instead of in the channel so that we ensure they're sent after init related | 491 std::queue<std::unique_ptr<IPC::Message>> queued_messages_; |
| 471 // messages that are sent once the process handle is available. This is | |
| 472 // because the queued messages may have dependencies on the init messages. | |
| 473 std::queue<IPC::Message*> queued_messages_; | |
| 474 | 492 |
| 475 // The globally-unique identifier for this RPH. | 493 // The globally-unique identifier for this RPH. |
| 476 const int id_; | 494 const int id_; |
| 477 | 495 |
| 478 // A secondary ID used by the Mojo shell to distinguish different incarnations | 496 // A secondary ID used by the Mojo shell to distinguish different incarnations |
| 479 // of the same RPH from each other. Unlike |id_| this is not globally unique, | 497 // of the same RPH from each other. Unlike |id_| this is not globally unique, |
| 480 // but it is guaranteed to change every time Init() is called. | 498 // but it is guaranteed to change every time Init() is called. |
| 481 int instance_id_ = 1; | 499 int instance_id_ = 1; |
| 482 | 500 |
| 483 BrowserContext* browser_context_; | 501 BrowserContext* browser_context_; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 // UI thread is the source of sync IPCs and all shutdown signals. | 586 // UI thread is the source of sync IPCs and all shutdown signals. |
| 569 // Therefore a proper shutdown event to unblock the UI thread is not | 587 // Therefore a proper shutdown event to unblock the UI thread is not |
| 570 // possible without massive refactoring shutdown code. | 588 // possible without massive refactoring shutdown code. |
| 571 // Luckily Android never performs a clean shutdown. So explicitly | 589 // Luckily Android never performs a clean shutdown. So explicitly |
| 572 // ignore this problem. | 590 // ignore this problem. |
| 573 base::WaitableEvent never_signaled_; | 591 base::WaitableEvent never_signaled_; |
| 574 #endif | 592 #endif |
| 575 | 593 |
| 576 scoped_refptr<ResourceMessageFilter> resource_message_filter_; | 594 scoped_refptr<ResourceMessageFilter> resource_message_filter_; |
| 577 | 595 |
| 596 mojom::RouteProviderAssociatedPtr remote_route_provider_; |
| 597 |
| 578 // A WeakPtrFactory which is reset every time Cleanup() runs. Used to vend | 598 // A WeakPtrFactory which is reset every time Cleanup() runs. Used to vend |
| 579 // WeakPtrs which are invalidated any time the RPHI is recycled. | 599 // WeakPtrs which are invalidated any time the RPHI is recycled. |
| 580 std::unique_ptr<base::WeakPtrFactory<RenderProcessHostImpl>> | 600 std::unique_ptr<base::WeakPtrFactory<RenderProcessHostImpl>> |
| 581 instance_weak_factory_; | 601 instance_weak_factory_; |
| 582 | 602 |
| 583 base::WeakPtrFactory<RenderProcessHostImpl> weak_factory_; | 603 base::WeakPtrFactory<RenderProcessHostImpl> weak_factory_; |
| 584 | 604 |
| 585 DISALLOW_COPY_AND_ASSIGN(RenderProcessHostImpl); | 605 DISALLOW_COPY_AND_ASSIGN(RenderProcessHostImpl); |
| 586 }; | 606 }; |
| 587 | 607 |
| 588 } // namespace content | 608 } // namespace content |
| 589 | 609 |
| 590 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ | 610 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ |
| OLD | NEW |