| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // because all the IPCs from the RenderViews (renderer) will only ever be able | 107 // because all the IPCs from the RenderViews (renderer) will only ever be able |
| 108 // to access the partition they are assigned to. | 108 // to access the partition they are assigned to. |
| 109 class CONTENT_EXPORT RenderProcessHostImpl | 109 class CONTENT_EXPORT RenderProcessHostImpl |
| 110 : public RenderProcessHost, | 110 : public RenderProcessHost, |
| 111 public ChildProcessLauncher::Client, | 111 public ChildProcessLauncher::Client, |
| 112 public ui::GpuSwitchingObserver, | 112 public ui::GpuSwitchingObserver, |
| 113 public NON_EXPORTED_BASE(mojom::RouteProvider), | 113 public NON_EXPORTED_BASE(mojom::RouteProvider), |
| 114 public NON_EXPORTED_BASE(mojom::AssociatedInterfaceProvider), | 114 public NON_EXPORTED_BASE(mojom::AssociatedInterfaceProvider), |
| 115 public NON_EXPORTED_BASE(mojom::RendererHost) { | 115 public NON_EXPORTED_BASE(mojom::RendererHost) { |
| 116 public: | 116 public: |
| 117 RenderProcessHostImpl(BrowserContext* browser_context, | 117 // Use the spare RenderProcessHost if it exists, or create a new one. This |
| 118 StoragePartitionImpl* storage_partition_impl, | 118 // should be the usual way to get a new RenderProcessHost. |
| 119 bool is_for_guests_only); | 119 static RenderProcessHost* CreateOrUseSpareRenderProcessHost( |
| 120 BrowserContext* browser_context, |
| 121 StoragePartitionImpl* storage_partition_impl, |
| 122 bool is_for_guests_only); |
| 123 |
| 124 // Create a new RenderProcessHost. In most cases |
| 125 // CreateOrUseSpareRenderProcessHost, above, should be used instead. |
| 126 static RenderProcessHost* CreateRenderProcessHost( |
| 127 BrowserContext* browser_context, |
| 128 StoragePartitionImpl* storage_partition_impl, |
| 129 bool is_for_guests_only); |
| 130 |
| 120 ~RenderProcessHostImpl() override; | 131 ~RenderProcessHostImpl() override; |
| 121 | 132 |
| 122 // RenderProcessHost implementation (public portion). | 133 // RenderProcessHost implementation (public portion). |
| 123 bool Init() override; | 134 bool Init() override; |
| 124 void EnableSendQueue() override; | 135 void EnableSendQueue() override; |
| 125 int GetNextRoutingID() override; | 136 int GetNextRoutingID() override; |
| 126 void AddRoute(int32_t routing_id, IPC::Listener* listener) override; | 137 void AddRoute(int32_t routing_id, IPC::Listener* listener) override; |
| 127 void RemoveRoute(int32_t routing_id) override; | 138 void RemoveRoute(int32_t routing_id) override; |
| 128 void AddObserver(RenderProcessHostObserver* observer) override; | 139 void AddObserver(RenderProcessHostObserver* observer) override; |
| 129 void RemoveObserver(RenderProcessHostObserver* observer) override; | 140 void RemoveObserver(RenderProcessHostObserver* observer) override; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 RenderProcessHost* process, | 273 RenderProcessHost* process, |
| 263 const GURL& url); | 274 const GURL& url); |
| 264 | 275 |
| 265 // Returns a suitable RenderProcessHost to use for |site_instance|. Depending | 276 // Returns a suitable RenderProcessHost to use for |site_instance|. Depending |
| 266 // on the SiteInstance's ProcessReusePolicy and its url, this may be an | 277 // on the SiteInstance's ProcessReusePolicy and its url, this may be an |
| 267 // existing RenderProcessHost or a new one. | 278 // existing RenderProcessHost or a new one. |
| 268 static RenderProcessHost* GetProcessHostForSiteInstance( | 279 static RenderProcessHost* GetProcessHostForSiteInstance( |
| 269 BrowserContext* browser_context, | 280 BrowserContext* browser_context, |
| 270 SiteInstanceImpl* site_instance); | 281 SiteInstanceImpl* site_instance); |
| 271 | 282 |
| 283 // Cleanup and remove any spare renderer. This should be used when a |
| 284 // navigation has occurred or will be occurring that will not use the spare |
| 285 // renderer and resources should be cleaned up. |
| 286 static void CleanupSpareRenderProcessHost(); |
| 287 |
| 272 static base::MessageLoop* GetInProcessRendererThreadForTesting(); | 288 static base::MessageLoop* GetInProcessRendererThreadForTesting(); |
| 273 | 289 |
| 274 // This forces a renderer that is running "in process" to shut down. | 290 // This forces a renderer that is running "in process" to shut down. |
| 275 static void ShutDownInProcessRenderer(); | 291 static void ShutDownInProcessRenderer(); |
| 276 | 292 |
| 277 static void RegisterRendererMainThreadFactory( | 293 static void RegisterRendererMainThreadFactory( |
| 278 RendererMainThreadFactoryFunction create); | 294 RendererMainThreadFactoryFunction create); |
| 279 | 295 |
| 280 RenderFrameMessageFilter* render_frame_message_filter_for_testing() const { | 296 RenderFrameMessageFilter* render_frame_message_filter_for_testing() const { |
| 281 return render_frame_message_filter_.get(); | 297 return render_frame_message_filter_.get(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 // RenderProcessHosts. | 346 // RenderProcessHosts. |
| 331 static void AddExpectedNavigationToSite( | 347 static void AddExpectedNavigationToSite( |
| 332 BrowserContext* browser_context, | 348 BrowserContext* browser_context, |
| 333 RenderProcessHost* render_process_host, | 349 RenderProcessHost* render_process_host, |
| 334 const GURL& site_url); | 350 const GURL& site_url); |
| 335 static void RemoveExpectedNavigationToSite( | 351 static void RemoveExpectedNavigationToSite( |
| 336 BrowserContext* browser_context, | 352 BrowserContext* browser_context, |
| 337 RenderProcessHost* render_process_host, | 353 RenderProcessHost* render_process_host, |
| 338 const GURL& site_url); | 354 const GURL& site_url); |
| 339 | 355 |
| 356 // Return the spare RenderProcessHost, if it exists. There is at most one |
| 357 // globally-used spare RenderProcessHost at any time. |
| 358 static RenderProcessHost* GetSpareRenderProcessHostForTesting(); |
| 359 |
| 360 // Return true if the host has not been used. This is stronger than IsUnused() |
| 361 // in that it checks if this RPH has ever been used to render at all, rather |
| 362 // than just no being suitable to host a URL that requires a dedicated |
| 363 // process. |
| 364 // TODO(alexmos): can this be unified with IsUnused()? See also |
| 365 // crbug.com/738634. |
| 366 bool HostHasNotBeenUsed(); |
| 367 |
| 340 protected: | 368 protected: |
| 341 // A proxy for our IPC::Channel that lives on the IO thread. | 369 // A proxy for our IPC::Channel that lives on the IO thread. |
| 342 std::unique_ptr<IPC::ChannelProxy> channel_; | 370 std::unique_ptr<IPC::ChannelProxy> channel_; |
| 343 | 371 |
| 344 // True if fast shutdown has been performed on this RPH. | 372 // True if fast shutdown has been performed on this RPH. |
| 345 bool fast_shutdown_started_; | 373 bool fast_shutdown_started_; |
| 346 | 374 |
| 347 // True if we've posted a DeleteTask and will be deleted soon. | 375 // True if we've posted a DeleteTask and will be deleted soon. |
| 348 bool deleting_soon_; | 376 bool deleting_soon_; |
| 349 | 377 |
| 350 #ifndef NDEBUG | 378 #ifndef NDEBUG |
| 351 // True if this object has deleted itself. | 379 // True if this object has deleted itself. |
| 352 bool is_self_deleted_; | 380 bool is_self_deleted_; |
| 353 #endif | 381 #endif |
| 354 | 382 |
| 355 // The count of currently swapped out but pending RenderViews. We have | 383 // The count of currently swapped out but pending RenderViews. We have |
| 356 // started to swap these in, so the renderer process should not exit if | 384 // started to swap these in, so the renderer process should not exit if |
| 357 // this count is non-zero. | 385 // this count is non-zero. |
| 358 int32_t pending_views_; | 386 int32_t pending_views_; |
| 359 | 387 |
| 360 private: | 388 private: |
| 361 friend class ChildProcessLauncherBrowserTest_ChildSpawnFail_Test; | 389 friend class ChildProcessLauncherBrowserTest_ChildSpawnFail_Test; |
| 362 friend class VisitRelayingRenderProcessHost; | 390 friend class VisitRelayingRenderProcessHost; |
| 363 class ConnectionFilterController; | 391 class ConnectionFilterController; |
| 364 class ConnectionFilterImpl; | 392 class ConnectionFilterImpl; |
| 365 | 393 |
| 394 // Use CreateRenderProcessHost() instead of calling this constructor |
| 395 // directly. |
| 396 RenderProcessHostImpl(BrowserContext* browser_context, |
| 397 StoragePartitionImpl* storage_partition_impl, |
| 398 bool is_for_guests_only); |
| 399 |
| 366 // Initializes a new IPC::ChannelProxy in |channel_|, which will be connected | 400 // Initializes a new IPC::ChannelProxy in |channel_|, which will be connected |
| 367 // to the next child process launched for this host, if any. | 401 // to the next child process launched for this host, if any. |
| 368 void InitializeChannelProxy(); | 402 void InitializeChannelProxy(); |
| 369 | 403 |
| 370 // Resets |channel_|, removing it from the attachment broker if necessary. | 404 // Resets |channel_|, removing it from the attachment broker if necessary. |
| 371 // Always call this in lieu of directly resetting |channel_|. | 405 // Always call this in lieu of directly resetting |channel_|. |
| 372 void ResetChannelProxy(); | 406 void ResetChannelProxy(); |
| 373 | 407 |
| 374 // Creates and adds the IO thread message filters. | 408 // Creates and adds the IO thread message filters. |
| 375 void CreateMessageFilters(); | 409 void CreateMessageFilters(); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 FrameSinkProviderImpl frame_sink_provider_; | 748 FrameSinkProviderImpl frame_sink_provider_; |
| 715 | 749 |
| 716 base::WeakPtrFactory<RenderProcessHostImpl> weak_factory_; | 750 base::WeakPtrFactory<RenderProcessHostImpl> weak_factory_; |
| 717 | 751 |
| 718 DISALLOW_COPY_AND_ASSIGN(RenderProcessHostImpl); | 752 DISALLOW_COPY_AND_ASSIGN(RenderProcessHostImpl); |
| 719 }; | 753 }; |
| 720 | 754 |
| 721 } // namespace content | 755 } // namespace content |
| 722 | 756 |
| 723 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ | 757 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ |
| OLD | NEW |