| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 // Received a response from CrossSiteResourceHandler. If the navigation | 231 // Received a response from CrossSiteResourceHandler. If the navigation |
| 232 // specifies a transition, this is called and the navigation will not resume | 232 // specifies a transition, this is called and the navigation will not resume |
| 233 // until ResumeResponseDeferredAtStart. | 233 // until ResumeResponseDeferredAtStart. |
| 234 void OnDeferredAfterResponseStarted( | 234 void OnDeferredAfterResponseStarted( |
| 235 const GlobalRequestID& global_request_id, | 235 const GlobalRequestID& global_request_id, |
| 236 RenderFrameHostImpl* pending_render_frame_host); | 236 RenderFrameHostImpl* pending_render_frame_host); |
| 237 | 237 |
| 238 // Resume navigation paused after receiving response headers. | 238 // Resume navigation paused after receiving response headers. |
| 239 void ResumeResponseDeferredAtStart(); | 239 void ResumeResponseDeferredAtStart(); |
| 240 | 240 |
| 241 // The RenderFrameHost has been swapped out, so we should resume the pending | |
| 242 // network response and allow the pending RenderFrameHost to commit. | |
| 243 void SwappedOut(RenderFrameHostImpl* render_frame_host); | |
| 244 | |
| 245 // Called when a renderer's frame navigates. | 241 // Called when a renderer's frame navigates. |
| 246 void DidNavigateFrame(RenderFrameHostImpl* render_frame_host); | 242 void DidNavigateFrame(RenderFrameHostImpl* render_frame_host); |
| 247 | 243 |
| 248 // Called when a renderer sets its opener to null. | 244 // Called when a renderer sets its opener to null. |
| 249 void DidDisownOpener(RenderViewHost* render_view_host); | 245 void DidDisownOpener(RenderViewHost* render_view_host); |
| 250 | 246 |
| 251 // Helper method to create and initialize a RenderFrameHost. If |swapped_out| | 247 // Helper method to create and initialize a RenderFrameHost. If |swapped_out| |
| 252 // is true, it will be initially placed on the swapped out hosts list. | 248 // is true, it will be initially placed on the swapped out hosts list. |
| 253 // Otherwise, it will be used for a pending cross-site navigation. | 249 // Otherwise, it will be used for a pending cross-site navigation. |
| 254 // Returns the routing id of the *view* associated with the frame. | 250 // Returns the routing id of the *view* associated with the frame. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 bool IsRVHOnSwappedOutList(RenderViewHostImpl* rvh) const; | 287 bool IsRVHOnSwappedOutList(RenderViewHostImpl* rvh) const; |
| 292 bool IsOnSwappedOutList(RenderFrameHostImpl* rfh) const; | 288 bool IsOnSwappedOutList(RenderFrameHostImpl* rfh) const; |
| 293 | 289 |
| 294 // Returns the swapped out RenderViewHost or RenderFrameHost for the given | 290 // Returns the swapped out RenderViewHost or RenderFrameHost for the given |
| 295 // SiteInstance, if any. This method is *deprecated* and | 291 // SiteInstance, if any. This method is *deprecated* and |
| 296 // GetRenderFrameProxyHost should be used. | 292 // GetRenderFrameProxyHost should be used. |
| 297 RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance) const; | 293 RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance) const; |
| 298 RenderFrameProxyHost* GetRenderFrameProxyHost( | 294 RenderFrameProxyHost* GetRenderFrameProxyHost( |
| 299 SiteInstance* instance) const; | 295 SiteInstance* instance) const; |
| 300 | 296 |
| 301 // Runs the unload handler in the current page, when we know that a pending | |
| 302 // cross-process navigation is going to commit. We may initiate a transfer | |
| 303 // to a new process after this completes or times out. | |
| 304 void SwapOutOldPage(); | |
| 305 | |
| 306 // Deletes a RenderFrameHost that was pending shutdown. | 297 // Deletes a RenderFrameHost that was pending shutdown. |
| 307 void ClearPendingShutdownRFHForSiteInstance(int32 site_instance_id, | 298 void ClearPendingShutdownRFHForSiteInstance(int32 site_instance_id, |
| 308 RenderFrameHostImpl* rfh); | 299 RenderFrameHostImpl* rfh); |
| 309 | 300 |
| 310 // Deletes any proxy hosts associated with this node. Used during destruction | 301 // Deletes any proxy hosts associated with this node. Used during destruction |
| 311 // of WebContentsImpl. | 302 // of WebContentsImpl. |
| 312 void ResetProxyHosts(); | 303 void ResetProxyHosts(); |
| 313 | 304 |
| 314 // Used to start a navigation, part of browser-side navigation project. | 305 // Used to start a navigation, part of browser-side navigation project. |
| 315 void OnBeginNavigation(const FrameHostMsg_BeginNavigation_Params& params); | 306 void OnBeginNavigation(const FrameHostMsg_BeginNavigation_Params& params); |
| 316 | 307 |
| 317 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy | 308 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy |
| 318 // that has the given SiteInstance and is associated with this | 309 // that has the given SiteInstance and is associated with this |
| 319 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. | 310 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. |
| 320 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); | 311 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); |
| 321 | 312 |
| 322 private: | 313 private: |
| 323 friend class RenderFrameHostManagerTest; | 314 friend class RenderFrameHostManagerTest; |
| 324 friend class TestWebContents; | 315 friend class TestWebContents; |
| 325 | 316 |
| 326 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, | 317 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, |
| 327 CreateCrossProcessSubframeProxies); | 318 CreateCrossProcessSubframeProxies); |
| 328 | 319 |
| 329 // Tracks information about a navigation while a cross-process transition is | |
| 330 // in progress, in case we need to transfer it to a new RenderFrameHost. | |
| 331 // When a request is being transferred, deleting the PendingNavigationParams, | |
| 332 // and thus |cross_site_transferring_request|, will cancel the request being | |
| 333 // transferred, unless its ReleaseRequest method has been called. | |
| 334 struct PendingNavigationParams { | |
| 335 PendingNavigationParams( | |
| 336 const GlobalRequestID& global_request_id, | |
| 337 scoped_ptr<CrossSiteTransferringRequest> | |
| 338 cross_site_transferring_request, | |
| 339 const std::vector<GURL>& transfer_url, | |
| 340 Referrer referrer, | |
| 341 PageTransition page_transition, | |
| 342 int render_frame_id, | |
| 343 bool should_replace_current_entry); | |
| 344 ~PendingNavigationParams(); | |
| 345 | |
| 346 // The child ID and request ID for the pending navigation. Present whether | |
| 347 // |request_transfer| is NULL or not. | |
| 348 GlobalRequestID global_request_id; | |
| 349 | |
| 350 // If a pending request needs to be transferred to another process, this | |
| 351 // owns the request until it's transferred to the new process, so it will be | |
| 352 // cleaned up if the navigation is cancelled. Otherwise, this is NULL. | |
| 353 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request; | |
| 354 | |
| 355 // If |request_transfer| is non-NULL, the values below are all set. | |
| 356 | |
| 357 // The first entry is the original request URL, and the last entry is the | |
| 358 // destination URL to request in the new process. | |
| 359 std::vector<GURL> transfer_url_chain; | |
| 360 | |
| 361 // This is the referrer to use for the request in the new process. | |
| 362 Referrer referrer; | |
| 363 | |
| 364 // This is the transition type for the original navigation. | |
| 365 PageTransition page_transition; | |
| 366 | |
| 367 // This is the frame routing ID to use in RequestTransferURL. | |
| 368 int render_frame_id; | |
| 369 | |
| 370 // This is whether the navigation should replace the current history entry. | |
| 371 bool should_replace_current_entry; | |
| 372 }; | |
| 373 | |
| 374 // Returns the current navigation request (used in the PlzNavigate navigation | 320 // Returns the current navigation request (used in the PlzNavigate navigation |
| 375 // logic refactoring project). | 321 // logic refactoring project). |
| 376 NavigationRequest* navigation_request_for_testing() const { | 322 NavigationRequest* navigation_request_for_testing() const { |
| 377 return navigation_request_.get(); } | 323 return navigation_request_.get(); } |
| 378 | 324 |
| 379 // Used with FrameTree::ForEach to erase RenderFrameProxyHosts from a | 325 // Used with FrameTree::ForEach to erase RenderFrameProxyHosts from a |
| 380 // FrameTreeNode's RenderFrameHostManager. | 326 // FrameTreeNode's RenderFrameHostManager. |
| 381 static bool ClearProxiesInSiteInstance(int32 site_instance_id, | 327 static bool ClearProxiesInSiteInstance(int32 site_instance_id, |
| 382 FrameTreeNode* node); | 328 FrameTreeNode* node); |
| 383 | 329 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 | 392 |
| 447 // Initialization for RenderFrameHost uses the same sequence as InitRenderView | 393 // Initialization for RenderFrameHost uses the same sequence as InitRenderView |
| 448 // above. | 394 // above. |
| 449 bool InitRenderFrame(RenderFrameHost* render_frame_host); | 395 bool InitRenderFrame(RenderFrameHost* render_frame_host); |
| 450 | 396 |
| 451 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this | 397 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this |
| 452 // doesn't require the pending render_frame_host_ pointer to be non-NULL, | 398 // doesn't require the pending render_frame_host_ pointer to be non-NULL, |
| 453 // since there could be Web UI switching as well. Call this for every commit. | 399 // since there could be Web UI switching as well. Call this for every commit. |
| 454 void CommitPending(); | 400 void CommitPending(); |
| 455 | 401 |
| 402 // Runs the unload handler in the current page, after the new page has |
| 403 // committed. |
| 404 void SwapOutOldPage(RenderFrameHostImpl* old_render_frame_host); |
| 405 |
| 456 // Shutdown all RenderFrameProxyHosts in a SiteInstance. This is called to | 406 // Shutdown all RenderFrameProxyHosts in a SiteInstance. This is called to |
| 457 // shutdown frames when all the frames in a SiteInstance are confirmed to be | 407 // shutdown frames when all the frames in a SiteInstance are confirmed to be |
| 458 // swapped out. | 408 // swapped out. |
| 459 void ShutdownRenderFrameProxyHostsInSiteInstance(int32 site_instance_id); | 409 void ShutdownRenderFrameProxyHostsInSiteInstance(int32 site_instance_id); |
| 460 | 410 |
| 461 // Helper method to terminate the pending RenderViewHost. | 411 // Helper method to terminate the pending RenderViewHost. |
| 462 void CancelPending(); | 412 void CancelPending(); |
| 463 | 413 |
| 464 // Helper method to set the active RenderFrameHost. Returns the old | 414 // Helper method to set the active RenderFrameHost. Returns the old |
| 465 // RenderFrameHost and updates counts. | 415 // RenderFrameHost and updates counts. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 // have an associated Web UI, in which case the Web UI pointer will be non- | 457 // have an associated Web UI, in which case the Web UI pointer will be non- |
| 508 // NULL. | 458 // NULL. |
| 509 // | 459 // |
| 510 // The |pending_web_ui_| may be non-NULL even when the | 460 // The |pending_web_ui_| may be non-NULL even when the |
| 511 // |pending_render_frame_host_| is NULL. This will happen when we're | 461 // |pending_render_frame_host_| is NULL. This will happen when we're |
| 512 // transitioning between two Web UI pages: the RFH won't be swapped, so the | 462 // transitioning between two Web UI pages: the RFH won't be swapped, so the |
| 513 // pending pointer will be unused, but there will be a pending Web UI | 463 // pending pointer will be unused, but there will be a pending Web UI |
| 514 // associated with the navigation. | 464 // associated with the navigation. |
| 515 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host_; | 465 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host_; |
| 516 | 466 |
| 517 // Tracks information about any current pending cross-process navigation. | 467 // If a pending request needs to be transferred to another process, this |
| 518 scoped_ptr<PendingNavigationParams> pending_nav_params_; | 468 // owns the request until it's transferred to the new process, so it will be |
| 469 // cleaned up if the navigation is cancelled. Otherwise, this is NULL. |
| 470 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request_; |
| 519 | 471 |
| 520 // Tracks information about any navigation paused after receiving response | 472 // Tracks information about any navigation paused after receiving response |
| 521 // headers. | 473 // headers. |
| 522 scoped_ptr<GlobalRequestID> response_started_id_; | 474 scoped_ptr<GlobalRequestID> response_started_id_; |
| 523 | 475 |
| 524 // If either of these is non-NULL, the pending navigation is to a chrome: | 476 // If either of these is non-NULL, the pending navigation is to a chrome: |
| 525 // page. The scoped_ptr is used if pending_web_ui_ != web_ui_, the WeakPtr is | 477 // page. The scoped_ptr is used if pending_web_ui_ != web_ui_, the WeakPtr is |
| 526 // used for when they reference the same object. If either is non-NULL, the | 478 // used for when they reference the same object. If either is non-NULL, the |
| 527 // other should be NULL. | 479 // other should be NULL. |
| 528 scoped_ptr<WebUIImpl> pending_web_ui_; | 480 scoped_ptr<WebUIImpl> pending_web_ui_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 547 scoped_ptr<NavigationRequest> navigation_request_; | 499 scoped_ptr<NavigationRequest> navigation_request_; |
| 548 | 500 |
| 549 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; | 501 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; |
| 550 | 502 |
| 551 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); | 503 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); |
| 552 }; | 504 }; |
| 553 | 505 |
| 554 } // namespace content | 506 } // namespace content |
| 555 | 507 |
| 556 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 508 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
| OLD | NEW |