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 |
340 protected: | 355 protected: |
341 // A proxy for our IPC::Channel that lives on the IO thread. | 356 // A proxy for our IPC::Channel that lives on the IO thread. |
342 std::unique_ptr<IPC::ChannelProxy> channel_; | 357 std::unique_ptr<IPC::ChannelProxy> channel_; |
343 | 358 |
344 // True if fast shutdown has been performed on this RPH. | 359 // True if fast shutdown has been performed on this RPH. |
345 bool fast_shutdown_started_; | 360 bool fast_shutdown_started_; |
346 | 361 |
347 // True if we've posted a DeleteTask and will be deleted soon. | 362 // True if we've posted a DeleteTask and will be deleted soon. |
348 bool deleting_soon_; | 363 bool deleting_soon_; |
349 | 364 |
350 #ifndef NDEBUG | 365 #ifndef NDEBUG |
351 // True if this object has deleted itself. | 366 // True if this object has deleted itself. |
352 bool is_self_deleted_; | 367 bool is_self_deleted_; |
353 #endif | 368 #endif |
354 | 369 |
355 // The count of currently swapped out but pending RenderViews. We have | 370 // 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 | 371 // started to swap these in, so the renderer process should not exit if |
357 // this count is non-zero. | 372 // this count is non-zero. |
358 int32_t pending_views_; | 373 int32_t pending_views_; |
359 | 374 |
360 private: | 375 private: |
361 friend class ChildProcessLauncherBrowserTest_ChildSpawnFail_Test; | 376 friend class ChildProcessLauncherBrowserTest_ChildSpawnFail_Test; |
362 friend class VisitRelayingRenderProcessHost; | 377 friend class VisitRelayingRenderProcessHost; |
363 class ConnectionFilterController; | 378 class ConnectionFilterController; |
364 class ConnectionFilterImpl; | 379 class ConnectionFilterImpl; |
365 | 380 |
| 381 // Use CreateRenderProcessHost() instead of calling this constructor |
| 382 // directly. |
| 383 RenderProcessHostImpl(BrowserContext* browser_context, |
| 384 StoragePartitionImpl* storage_partition_impl, |
| 385 bool is_for_guests_only); |
| 386 |
366 // Initializes a new IPC::ChannelProxy in |channel_|, which will be connected | 387 // Initializes a new IPC::ChannelProxy in |channel_|, which will be connected |
367 // to the next child process launched for this host, if any. | 388 // to the next child process launched for this host, if any. |
368 void InitializeChannelProxy(); | 389 void InitializeChannelProxy(); |
369 | 390 |
370 // Resets |channel_|, removing it from the attachment broker if necessary. | 391 // Resets |channel_|, removing it from the attachment broker if necessary. |
371 // Always call this in lieu of directly resetting |channel_|. | 392 // Always call this in lieu of directly resetting |channel_|. |
372 void ResetChannelProxy(); | 393 void ResetChannelProxy(); |
373 | 394 |
374 // Creates and adds the IO thread message filters. | 395 // Creates and adds the IO thread message filters. |
375 void CreateMessageFilters(); | 396 void CreateMessageFilters(); |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 FrameSinkProviderImpl frame_sink_provider_; | 734 FrameSinkProviderImpl frame_sink_provider_; |
714 | 735 |
715 base::WeakPtrFactory<RenderProcessHostImpl> weak_factory_; | 736 base::WeakPtrFactory<RenderProcessHostImpl> weak_factory_; |
716 | 737 |
717 DISALLOW_COPY_AND_ASSIGN(RenderProcessHostImpl); | 738 DISALLOW_COPY_AND_ASSIGN(RenderProcessHostImpl); |
718 }; | 739 }; |
719 | 740 |
720 } // namespace content | 741 } // namespace content |
721 | 742 |
722 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ | 743 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ |
OLD | NEW |