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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 // RenderProcessHosts. | 341 // RenderProcessHosts. |
331 static void AddExpectedNavigationToSite( | 342 static void AddExpectedNavigationToSite( |
332 BrowserContext* browser_context, | 343 BrowserContext* browser_context, |
333 RenderProcessHost* render_process_host, | 344 RenderProcessHost* render_process_host, |
334 const GURL& site_url); | 345 const GURL& site_url); |
335 static void RemoveExpectedNavigationToSite( | 346 static void RemoveExpectedNavigationToSite( |
336 BrowserContext* browser_context, | 347 BrowserContext* browser_context, |
337 RenderProcessHost* render_process_host, | 348 RenderProcessHost* render_process_host, |
338 const GURL& site_url); | 349 const GURL& site_url); |
339 | 350 |
351 // Return the spare RenderProcessHost, if it exists. There is at most one | |
352 // globally-used spare RenderProcessHost at any time. | |
353 static RenderProcessHost* GetSpareRenderProcessHostForTesting(); | |
354 | |
355 // Return true if the host has not been used. This is stronger than IsUnused() | |
356 // in that it checks if this RPH has ever been used to render at all, rather | |
357 // than just no being suitable to host a URL that requires a dedicated | |
358 // process. | |
359 bool HostHasNotBeenUsed(); | |
Charlie Reis
2017/06/30 21:42:16
Hmm, it's unfortunate to have this name be effecti
alexmos
2017/07/01 00:47:17
I'd need to check this more carefully, but I'm gue
mattcary
2017/07/03 08:03:02
Done. I assigned the TODO to you, alex, to be cons
| |
360 | |
340 protected: | 361 protected: |
341 // A proxy for our IPC::Channel that lives on the IO thread. | 362 // A proxy for our IPC::Channel that lives on the IO thread. |
342 std::unique_ptr<IPC::ChannelProxy> channel_; | 363 std::unique_ptr<IPC::ChannelProxy> channel_; |
343 | 364 |
344 // True if fast shutdown has been performed on this RPH. | 365 // True if fast shutdown has been performed on this RPH. |
345 bool fast_shutdown_started_; | 366 bool fast_shutdown_started_; |
346 | 367 |
347 // True if we've posted a DeleteTask and will be deleted soon. | 368 // True if we've posted a DeleteTask and will be deleted soon. |
348 bool deleting_soon_; | 369 bool deleting_soon_; |
349 | 370 |
350 #ifndef NDEBUG | 371 #ifndef NDEBUG |
351 // True if this object has deleted itself. | 372 // True if this object has deleted itself. |
352 bool is_self_deleted_; | 373 bool is_self_deleted_; |
353 #endif | 374 #endif |
354 | 375 |
355 // The count of currently swapped out but pending RenderViews. We have | 376 // 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 | 377 // started to swap these in, so the renderer process should not exit if |
357 // this count is non-zero. | 378 // this count is non-zero. |
358 int32_t pending_views_; | 379 int32_t pending_views_; |
359 | 380 |
360 private: | 381 private: |
361 friend class ChildProcessLauncherBrowserTest_ChildSpawnFail_Test; | 382 friend class ChildProcessLauncherBrowserTest_ChildSpawnFail_Test; |
362 friend class VisitRelayingRenderProcessHost; | 383 friend class VisitRelayingRenderProcessHost; |
363 class ConnectionFilterController; | 384 class ConnectionFilterController; |
364 class ConnectionFilterImpl; | 385 class ConnectionFilterImpl; |
365 | 386 |
387 // Use CreateRenderProcessHost() instead of calling this constructor | |
388 // directly. | |
389 RenderProcessHostImpl(BrowserContext* browser_context, | |
390 StoragePartitionImpl* storage_partition_impl, | |
391 bool is_for_guests_only); | |
392 | |
366 // Initializes a new IPC::ChannelProxy in |channel_|, which will be connected | 393 // Initializes a new IPC::ChannelProxy in |channel_|, which will be connected |
367 // to the next child process launched for this host, if any. | 394 // to the next child process launched for this host, if any. |
368 void InitializeChannelProxy(); | 395 void InitializeChannelProxy(); |
369 | 396 |
370 // Resets |channel_|, removing it from the attachment broker if necessary. | 397 // Resets |channel_|, removing it from the attachment broker if necessary. |
371 // Always call this in lieu of directly resetting |channel_|. | 398 // Always call this in lieu of directly resetting |channel_|. |
372 void ResetChannelProxy(); | 399 void ResetChannelProxy(); |
373 | 400 |
374 // Creates and adds the IO thread message filters. | 401 // Creates and adds the IO thread message filters. |
375 void CreateMessageFilters(); | 402 void CreateMessageFilters(); |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
713 FrameSinkProviderImpl frame_sink_provider_; | 740 FrameSinkProviderImpl frame_sink_provider_; |
714 | 741 |
715 base::WeakPtrFactory<RenderProcessHostImpl> weak_factory_; | 742 base::WeakPtrFactory<RenderProcessHostImpl> weak_factory_; |
716 | 743 |
717 DISALLOW_COPY_AND_ASSIGN(RenderProcessHostImpl); | 744 DISALLOW_COPY_AND_ASSIGN(RenderProcessHostImpl); |
718 }; | 745 }; |
719 | 746 |
720 } // namespace content | 747 } // namespace content |
721 | 748 |
722 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ | 749 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ |
OLD | NEW |