| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 #endif | 73 #endif |
| 74 class PermissionServiceContext; | 74 class PermissionServiceContext; |
| 75 class PeerConnectionTrackerHost; | 75 class PeerConnectionTrackerHost; |
| 76 class PushMessagingManager; | 76 class PushMessagingManager; |
| 77 class RenderFrameMessageFilter; | 77 class RenderFrameMessageFilter; |
| 78 class RenderProcessHostFactory; | 78 class RenderProcessHostFactory; |
| 79 class RenderWidgetHelper; | 79 class RenderWidgetHelper; |
| 80 class RenderWidgetHost; | 80 class RenderWidgetHost; |
| 81 class RenderWidgetHostImpl; | 81 class RenderWidgetHostImpl; |
| 82 class ResourceMessageFilter; | 82 class ResourceMessageFilter; |
| 83 class SiteInstance; |
| 83 class SiteInstanceImpl; | 84 class SiteInstanceImpl; |
| 84 class StoragePartition; | 85 class StoragePartition; |
| 85 class StoragePartitionImpl; | 86 class StoragePartitionImpl; |
| 86 | 87 |
| 87 typedef base::Thread* (*RendererMainThreadFactoryFunction)( | 88 typedef base::Thread* (*RendererMainThreadFactoryFunction)( |
| 88 const InProcessChildThreadParams& params); | 89 const InProcessChildThreadParams& params); |
| 89 | 90 |
| 90 // Implements a concrete RenderProcessHost for the browser process for talking | 91 // Implements a concrete RenderProcessHost for the browser process for talking |
| 91 // to actual renderer processes (as opposed to mocks). | 92 // to actual renderer processes (as opposed to mocks). |
| 92 // | 93 // |
| (...skipping 14 matching lines...) Expand all Loading... |
| 107 // because all the IPCs from the RenderViews (renderer) will only ever be able | 108 // because all the IPCs from the RenderViews (renderer) will only ever be able |
| 108 // to access the partition they are assigned to. | 109 // to access the partition they are assigned to. |
| 109 class CONTENT_EXPORT RenderProcessHostImpl | 110 class CONTENT_EXPORT RenderProcessHostImpl |
| 110 : public RenderProcessHost, | 111 : public RenderProcessHost, |
| 111 public ChildProcessLauncher::Client, | 112 public ChildProcessLauncher::Client, |
| 112 public ui::GpuSwitchingObserver, | 113 public ui::GpuSwitchingObserver, |
| 113 public NON_EXPORTED_BASE(mojom::RouteProvider), | 114 public NON_EXPORTED_BASE(mojom::RouteProvider), |
| 114 public NON_EXPORTED_BASE(mojom::AssociatedInterfaceProvider), | 115 public NON_EXPORTED_BASE(mojom::AssociatedInterfaceProvider), |
| 115 public NON_EXPORTED_BASE(mojom::RendererHost) { | 116 public NON_EXPORTED_BASE(mojom::RendererHost) { |
| 116 public: | 117 public: |
| 117 RenderProcessHostImpl(BrowserContext* browser_context, | 118 // Use the spare RenderProcessHost if it exists, or create a new one. This |
| 118 StoragePartitionImpl* storage_partition_impl, | 119 // should be the usual way to get a new RenderProcessHost. |
| 119 bool is_for_guests_only); | 120 // If |storage_partition_impl| is null, the default partition from the |
| 121 // browser_context is used, using |site_instance| (for which a null value is |
| 122 // legal). |
| 123 static RenderProcessHost* CreateOrUseSpareRenderProcessHost( |
| 124 BrowserContext* browser_context, |
| 125 StoragePartitionImpl* storage_partition_impl, |
| 126 SiteInstance* site_instance, |
| 127 bool is_for_guests_only); |
| 128 |
| 129 // Create a new RenderProcessHost. In most cases |
| 130 // CreateOrUseSpareRenderProcessHost, above, should be used instead. |
| 131 // If |storage_partition_impl| is null, the default partition from the |
| 132 // browser_context is used, using |site_instance| (for which a null value is |
| 133 // legal). |site_instance| is not used if |storage_partition_impl| is not |
| 134 // null. |
| 135 static RenderProcessHost* CreateRenderProcessHost( |
| 136 BrowserContext* browser_context, |
| 137 StoragePartitionImpl* storage_partition_impl, |
| 138 SiteInstance* site_instance, |
| 139 bool is_for_guests_only); |
| 140 |
| 120 ~RenderProcessHostImpl() override; | 141 ~RenderProcessHostImpl() override; |
| 121 | 142 |
| 122 // RenderProcessHost implementation (public portion). | 143 // RenderProcessHost implementation (public portion). |
| 123 bool Init() override; | 144 bool Init() override; |
| 124 void EnableSendQueue() override; | 145 void EnableSendQueue() override; |
| 125 int GetNextRoutingID() override; | 146 int GetNextRoutingID() override; |
| 126 void AddRoute(int32_t routing_id, IPC::Listener* listener) override; | 147 void AddRoute(int32_t routing_id, IPC::Listener* listener) override; |
| 127 void RemoveRoute(int32_t routing_id) override; | 148 void RemoveRoute(int32_t routing_id) override; |
| 128 void AddObserver(RenderProcessHostObserver* observer) override; | 149 void AddObserver(RenderProcessHostObserver* observer) override; |
| 129 void RemoveObserver(RenderProcessHostObserver* observer) override; | 150 void RemoveObserver(RenderProcessHostObserver* observer) override; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 void Resume() override; | 210 void Resume() override; |
| 190 mojom::Renderer* GetRendererInterface() override; | 211 mojom::Renderer* GetRendererInterface() override; |
| 191 resource_coordinator::ResourceCoordinatorInterface* | 212 resource_coordinator::ResourceCoordinatorInterface* |
| 192 GetProcessResourceCoordinator() override; | 213 GetProcessResourceCoordinator() override; |
| 193 | 214 |
| 194 void SetIsNeverSuitableForReuse() override; | 215 void SetIsNeverSuitableForReuse() override; |
| 195 bool MayReuseHost() override; | 216 bool MayReuseHost() override; |
| 196 bool IsUnused() override; | 217 bool IsUnused() override; |
| 197 void SetIsUsed() override; | 218 void SetIsUsed() override; |
| 198 | 219 |
| 220 bool HostHasNotBeenUsed() override; |
| 221 |
| 199 mojom::RouteProvider* GetRemoteRouteProvider(); | 222 mojom::RouteProvider* GetRemoteRouteProvider(); |
| 200 | 223 |
| 201 // IPC::Sender via RenderProcessHost. | 224 // IPC::Sender via RenderProcessHost. |
| 202 bool Send(IPC::Message* msg) override; | 225 bool Send(IPC::Message* msg) override; |
| 203 | 226 |
| 204 // IPC::Listener via RenderProcessHost. | 227 // IPC::Listener via RenderProcessHost. |
| 205 bool OnMessageReceived(const IPC::Message& msg) override; | 228 bool OnMessageReceived(const IPC::Message& msg) override; |
| 206 void OnAssociatedInterfaceRequest( | 229 void OnAssociatedInterfaceRequest( |
| 207 const std::string& interface_name, | 230 const std::string& interface_name, |
| 208 mojo::ScopedInterfaceEndpointHandle handle) override; | 231 mojo::ScopedInterfaceEndpointHandle handle) override; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 RenderProcessHost* process, | 285 RenderProcessHost* process, |
| 263 const GURL& url); | 286 const GURL& url); |
| 264 | 287 |
| 265 // Returns a suitable RenderProcessHost to use for |site_instance|. Depending | 288 // Returns a suitable RenderProcessHost to use for |site_instance|. Depending |
| 266 // on the SiteInstance's ProcessReusePolicy and its url, this may be an | 289 // on the SiteInstance's ProcessReusePolicy and its url, this may be an |
| 267 // existing RenderProcessHost or a new one. | 290 // existing RenderProcessHost or a new one. |
| 268 static RenderProcessHost* GetProcessHostForSiteInstance( | 291 static RenderProcessHost* GetProcessHostForSiteInstance( |
| 269 BrowserContext* browser_context, | 292 BrowserContext* browser_context, |
| 270 SiteInstanceImpl* site_instance); | 293 SiteInstanceImpl* site_instance); |
| 271 | 294 |
| 295 // Cleanup and remove any spare renderer. This should be used when a |
| 296 // navigation has occurred or will be occurring that will not use the spare |
| 297 // renderer and resources should be cleaned up. |
| 298 static void CleanupSpareRenderProcessHost(); |
| 299 |
| 272 static base::MessageLoop* GetInProcessRendererThreadForTesting(); | 300 static base::MessageLoop* GetInProcessRendererThreadForTesting(); |
| 273 | 301 |
| 274 // This forces a renderer that is running "in process" to shut down. | 302 // This forces a renderer that is running "in process" to shut down. |
| 275 static void ShutDownInProcessRenderer(); | 303 static void ShutDownInProcessRenderer(); |
| 276 | 304 |
| 277 static void RegisterRendererMainThreadFactory( | 305 static void RegisterRendererMainThreadFactory( |
| 278 RendererMainThreadFactoryFunction create); | 306 RendererMainThreadFactoryFunction create); |
| 279 | 307 |
| 280 RenderFrameMessageFilter* render_frame_message_filter_for_testing() const { | 308 RenderFrameMessageFilter* render_frame_message_filter_for_testing() const { |
| 281 return render_frame_message_filter_.get(); | 309 return render_frame_message_filter_.get(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 // RenderProcessHosts. | 358 // RenderProcessHosts. |
| 331 static void AddExpectedNavigationToSite( | 359 static void AddExpectedNavigationToSite( |
| 332 BrowserContext* browser_context, | 360 BrowserContext* browser_context, |
| 333 RenderProcessHost* render_process_host, | 361 RenderProcessHost* render_process_host, |
| 334 const GURL& site_url); | 362 const GURL& site_url); |
| 335 static void RemoveExpectedNavigationToSite( | 363 static void RemoveExpectedNavigationToSite( |
| 336 BrowserContext* browser_context, | 364 BrowserContext* browser_context, |
| 337 RenderProcessHost* render_process_host, | 365 RenderProcessHost* render_process_host, |
| 338 const GURL& site_url); | 366 const GURL& site_url); |
| 339 | 367 |
| 368 // Return the spare RenderProcessHost, if it exists. There is at most one |
| 369 // globally-used spare RenderProcessHost at any time. |
| 370 static RenderProcessHost* GetSpareRenderProcessHostForTesting(); |
| 371 |
| 340 protected: | 372 protected: |
| 341 // A proxy for our IPC::Channel that lives on the IO thread. | 373 // A proxy for our IPC::Channel that lives on the IO thread. |
| 342 std::unique_ptr<IPC::ChannelProxy> channel_; | 374 std::unique_ptr<IPC::ChannelProxy> channel_; |
| 343 | 375 |
| 344 // True if fast shutdown has been performed on this RPH. | 376 // True if fast shutdown has been performed on this RPH. |
| 345 bool fast_shutdown_started_; | 377 bool fast_shutdown_started_; |
| 346 | 378 |
| 347 // True if we've posted a DeleteTask and will be deleted soon. | 379 // True if we've posted a DeleteTask and will be deleted soon. |
| 348 bool deleting_soon_; | 380 bool deleting_soon_; |
| 349 | 381 |
| 350 #ifndef NDEBUG | 382 #ifndef NDEBUG |
| 351 // True if this object has deleted itself. | 383 // True if this object has deleted itself. |
| 352 bool is_self_deleted_; | 384 bool is_self_deleted_; |
| 353 #endif | 385 #endif |
| 354 | 386 |
| 355 // The count of currently swapped out but pending RenderViews. We have | 387 // 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 | 388 // started to swap these in, so the renderer process should not exit if |
| 357 // this count is non-zero. | 389 // this count is non-zero. |
| 358 int32_t pending_views_; | 390 int32_t pending_views_; |
| 359 | 391 |
| 360 private: | 392 private: |
| 361 friend class ChildProcessLauncherBrowserTest_ChildSpawnFail_Test; | 393 friend class ChildProcessLauncherBrowserTest_ChildSpawnFail_Test; |
| 362 friend class VisitRelayingRenderProcessHost; | 394 friend class VisitRelayingRenderProcessHost; |
| 363 class ConnectionFilterController; | 395 class ConnectionFilterController; |
| 364 class ConnectionFilterImpl; | 396 class ConnectionFilterImpl; |
| 365 | 397 |
| 398 // Use CreateRenderProcessHost() instead of calling this constructor |
| 399 // directly. |
| 400 RenderProcessHostImpl(BrowserContext* browser_context, |
| 401 StoragePartitionImpl* storage_partition_impl, |
| 402 bool is_for_guests_only); |
| 403 |
| 366 // Initializes a new IPC::ChannelProxy in |channel_|, which will be connected | 404 // Initializes a new IPC::ChannelProxy in |channel_|, which will be connected |
| 367 // to the next child process launched for this host, if any. | 405 // to the next child process launched for this host, if any. |
| 368 void InitializeChannelProxy(); | 406 void InitializeChannelProxy(); |
| 369 | 407 |
| 370 // Resets |channel_|, removing it from the attachment broker if necessary. | 408 // Resets |channel_|, removing it from the attachment broker if necessary. |
| 371 // Always call this in lieu of directly resetting |channel_|. | 409 // Always call this in lieu of directly resetting |channel_|. |
| 372 void ResetChannelProxy(); | 410 void ResetChannelProxy(); |
| 373 | 411 |
| 374 // Creates and adds the IO thread message filters. | 412 // Creates and adds the IO thread message filters. |
| 375 void CreateMessageFilters(); | 413 void CreateMessageFilters(); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 FrameSinkProviderImpl frame_sink_provider_; | 752 FrameSinkProviderImpl frame_sink_provider_; |
| 715 | 753 |
| 716 base::WeakPtrFactory<RenderProcessHostImpl> weak_factory_; | 754 base::WeakPtrFactory<RenderProcessHostImpl> weak_factory_; |
| 717 | 755 |
| 718 DISALLOW_COPY_AND_ASSIGN(RenderProcessHostImpl); | 756 DISALLOW_COPY_AND_ASSIGN(RenderProcessHostImpl); |
| 719 }; | 757 }; |
| 720 | 758 |
| 721 } // namespace content | 759 } // namespace content |
| 722 | 760 |
| 723 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ | 761 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_PROCESS_HOST_IMPL_H_ |
| OLD | NEW |