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 <list> | 8 #include <list> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "content/browser/renderer_host/render_view_host_delegate.h" | 14 #include "content/browser/renderer_host/render_view_host_delegate.h" |
15 #include "content/browser/site_instance_impl.h" | 15 #include "content/browser/site_instance_impl.h" |
16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
17 #include "content/public/browser/global_request_id.h" | 17 #include "content/public/browser/global_request_id.h" |
18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
20 #include "content/public/common/referrer.h" | 20 #include "content/public/common/referrer.h" |
21 #include "ui/base/page_transition_types.h" | 21 #include "ui/base/page_transition_types.h" |
22 | 22 |
23 struct FrameMsg_Navigate_Params; | 23 struct FrameMsg_Navigate_Params; |
24 struct FrameHostMsg_BeginNavigation_Params; | |
Charlie Reis
2014/11/05 17:50:01
nit: Alphabetize
carlosk
2014/11/05 20:28:59
Done.
| |
24 | 25 |
25 namespace content { | 26 namespace content { |
26 class BrowserContext; | 27 class BrowserContext; |
27 class CrossProcessFrameConnector; | 28 class CrossProcessFrameConnector; |
28 class CrossSiteTransferringRequest; | 29 class CrossSiteTransferringRequest; |
30 class FrameTreeNode; | |
29 class InterstitialPageImpl; | 31 class InterstitialPageImpl; |
30 class FrameTreeNode; | |
31 class NavigationControllerImpl; | 32 class NavigationControllerImpl; |
32 class NavigationEntry; | 33 class NavigationEntry; |
33 class NavigationEntryImpl; | 34 class NavigationEntryImpl; |
34 class RenderFrameHost; | 35 class RenderFrameHost; |
36 class RenderFrameHost; | |
Charlie Reis
2014/11/05 17:50:01
This is a duplicate. (Wonder how it snuck in twic
carlosk
2014/11/05 20:28:59
Done. I wonder why the compiler didn't complain...
| |
35 class RenderFrameHostDelegate; | 37 class RenderFrameHostDelegate; |
36 class RenderFrameHost; | |
37 class RenderFrameHostImpl; | 38 class RenderFrameHostImpl; |
38 class RenderFrameHostManagerTest; | 39 class RenderFrameHostManagerTest; |
39 class RenderFrameProxyHost; | 40 class RenderFrameProxyHost; |
40 class RenderViewHost; | 41 class RenderViewHost; |
41 class RenderViewHostImpl; | 42 class RenderViewHostImpl; |
42 class RenderWidgetHostDelegate; | 43 class RenderWidgetHostDelegate; |
43 class RenderWidgetHostView; | 44 class RenderWidgetHostView; |
44 class TestWebContents; | 45 class TestWebContents; |
45 class WebUIImpl; | 46 class WebUIImpl; |
47 struct CommonNavigationParams; | |
46 | 48 |
47 // Manages RenderFrameHosts for a FrameTreeNode. It maintains a | 49 // Manages RenderFrameHosts for a FrameTreeNode. It maintains a |
48 // current_frame_host() which is the content currently visible to the user. When | 50 // current_frame_host() which is the content currently visible to the user. When |
49 // a frame is told to navigate to a different web site (as determined by | 51 // a frame is told to navigate to a different web site (as determined by |
50 // SiteInstance), it will replace its current RenderFrameHost with a new | 52 // SiteInstance), it will replace its current RenderFrameHost with a new |
51 // RenderFrameHost dedicated to the new SiteInstance, possibly in a new process. | 53 // RenderFrameHost dedicated to the new SiteInstance, possibly in a new process. |
52 // | 54 // |
53 // Cross-process navigation works like this: | 55 // Cross-process navigation works like this: |
54 // | 56 // |
55 // - RFHM::Navigate determines whether the destination is cross-site, and if so, | 57 // - RFHM::Navigate determines whether the destination is cross-site, and if so, |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 | 289 |
288 // Resume navigation paused after receiving response headers. | 290 // Resume navigation paused after receiving response headers. |
289 void ResumeResponseDeferredAtStart(); | 291 void ResumeResponseDeferredAtStart(); |
290 | 292 |
291 // Clear navigation transition data. | 293 // Clear navigation transition data. |
292 void ClearNavigationTransitionData(); | 294 void ClearNavigationTransitionData(); |
293 | 295 |
294 // Called when a renderer's frame navigates. | 296 // Called when a renderer's frame navigates. |
295 void DidNavigateFrame(RenderFrameHostImpl* render_frame_host); | 297 void DidNavigateFrame(RenderFrameHostImpl* render_frame_host); |
296 | 298 |
299 // PlzNavigate | |
300 // Cleans up ongoing navigation data. | |
301 void CleanUpCurrentNavigation(); | |
302 | |
297 // Called when a renderer sets its opener to null. | 303 // Called when a renderer sets its opener to null. |
298 void DidDisownOpener(RenderFrameHost* render_frame_host); | 304 void DidDisownOpener(RenderFrameHost* render_frame_host); |
299 | 305 |
300 // Helper method to create and initialize a RenderFrameHost. If |swapped_out| | 306 // Helper method to create and initialize a RenderFrameHost. If |swapped_out| |
301 // is true, it will be initially placed on the swapped out hosts list. | 307 // is true, it will be initially placed on the swapped out hosts list. |
302 // Returns the routing id of the *view* associated with the frame. | 308 // Returns the routing id of the *view* associated with the frame. |
303 int CreateRenderFrame(SiteInstance* instance, | 309 int CreateRenderFrame(SiteInstance* instance, |
304 int opener_route_id, | 310 int opener_route_id, |
305 bool swapped_out, | 311 bool swapped_out, |
306 bool for_main_frame_navigation, | 312 bool for_main_frame_navigation, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 | 361 |
356 // Deletes any proxy hosts associated with this node. Used during destruction | 362 // Deletes any proxy hosts associated with this node. Used during destruction |
357 // of WebContentsImpl. | 363 // of WebContentsImpl. |
358 void ResetProxyHosts(); | 364 void ResetProxyHosts(); |
359 | 365 |
360 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy | 366 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy |
361 // that has the given SiteInstance and is associated with this | 367 // that has the given SiteInstance and is associated with this |
362 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. | 368 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. |
363 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); | 369 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); |
364 | 370 |
371 // PlzNavigate: Notifies the RFHM that a navigation is about to begin so that | |
372 // it can do stuff in advance like trying to speculatively spawn a new | |
Charlie Reis
2014/11/05 17:50:01
Drop "do stuff in advance like trying to"
carlosk
2014/11/05 20:28:59
Done. That one fell through the gaps of my "let's
| |
373 // renderer process. | |
374 void WillBeginNavigating(const FrameHostMsg_BeginNavigation_Params& params, | |
375 const CommonNavigationParams& common_params); | |
376 | |
365 // PlzNavigate: Called when a navigation is ready to commit, to select the | 377 // PlzNavigate: Called when a navigation is ready to commit, to select the |
366 // renderer that will commit it. | 378 // renderer that will commit it. |
367 RenderFrameHostImpl* GetFrameHostForNavigation(const GURL& url, | 379 RenderFrameHostImpl* GetFrameHostForNavigation(const GURL& url, |
368 ui::PageTransition transition); | 380 ui::PageTransition transition); |
369 | 381 |
370 private: | 382 private: |
371 friend class RenderFrameHostManagerTest; | 383 friend class RenderFrameHostManagerTest; |
372 friend class TestWebContents; | 384 friend class TestWebContents; |
373 | 385 |
374 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, | 386 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 bool ShouldReuseWebUI( | 421 bool ShouldReuseWebUI( |
410 const NavigationEntry* current_entry, | 422 const NavigationEntry* current_entry, |
411 const GURL& new_url) const; | 423 const GURL& new_url) const; |
412 | 424 |
413 // Returns the SiteInstance to use for the navigation. | 425 // Returns the SiteInstance to use for the navigation. |
414 SiteInstance* GetSiteInstanceForNavigation( | 426 SiteInstance* GetSiteInstanceForNavigation( |
415 const GURL& dest_url, | 427 const GURL& dest_url, |
416 SiteInstance* dest_instance, | 428 SiteInstance* dest_instance, |
417 ui::PageTransition dest_transition, | 429 ui::PageTransition dest_transition, |
418 bool dest_is_restore, | 430 bool dest_is_restore, |
419 bool dest_is_view_source_mode); | 431 bool dest_is_view_source_mode, |
432 bool create_unbounded_site_instance); | |
Charlie Reis
2014/11/05 17:50:01
unbounded isn't the right word, but I also think w
carlosk
2014/11/05 20:28:58
Woudl "unset" be better? Or "without URL"?
| |
420 | 433 |
421 // Returns an appropriate SiteInstance object for the given |dest_url|, | 434 // Returns an appropriate SiteInstance object for the given |dest_url|, |
422 // possibly reusing the current SiteInstance. If --process-per-tab is used, | 435 // possibly reusing the current SiteInstance. If --process-per-tab is used, |
423 // this is only called when ShouldSwapBrowsingInstancesForNavigation returns | 436 // this is only called when ShouldSwapBrowsingInstancesForNavigation returns |
424 // true. |dest_instance| will be used if it is not null. | 437 // true. |dest_instance| will be used if it is not null. |
425 // This is a helper function for GetSiteInstanceForNavigation. | 438 // This is a helper function for GetSiteInstanceForNavigation. |
426 SiteInstance* GetSiteInstanceForURL( | 439 SiteInstance* GetSiteInstanceForURL(const GURL& dest_url, |
427 const GURL& dest_url, | 440 SiteInstance* dest_instance, |
428 SiteInstance* dest_instance, | 441 ui::PageTransition dest_transition, |
429 ui::PageTransition dest_transition, | 442 bool dest_is_restore, |
430 bool dest_is_restore, | 443 bool dest_is_view_source_mode, |
431 bool dest_is_view_source_mode, | 444 SiteInstance* current_instance, |
432 SiteInstance* current_instance, | 445 bool force_browsing_instance_swap, |
433 bool force_browsing_instance_swap); | 446 bool create_unbounded_site_instance); |
447 | |
448 SiteInstance* CreateSiteInstanceForURL(BrowserContext* browser_context, | |
Charlie Reis
2014/11/05 17:50:01
I'm hoping we can avoid these methods (see SiteIns
carlosk
2014/11/05 20:28:59
Acknowledged.
| |
449 const GURL& creation_url, | |
450 bool create_unbounded_site_instance, | |
451 SiteInstanceImpl* current_instance); | |
452 | |
453 SiteInstance* GetRelatedSiteInstanceForURL( | |
454 SiteInstanceImpl* current_instance, | |
455 const GURL& creation_url, | |
456 bool create_unbounded_site_instance); | |
434 | 457 |
435 // Determines the appropriate url to use as the current url for SiteInstance | 458 // Determines the appropriate url to use as the current url for SiteInstance |
436 // selection. | 459 // selection. |
437 const GURL& GetCurrentURLForSiteInstance( | 460 const GURL& GetCurrentURLForSiteInstance( |
438 SiteInstance* current_instance, | 461 SiteInstance* current_instance, |
439 NavigationEntry* current_entry); | 462 NavigationEntry* current_entry); |
440 | 463 |
441 // Creates a new RenderFrameHostImpl for the |new_instance| while respecting | 464 // Creates a new RenderFrameHostImpl for the |new_instance| while respecting |
442 // the opener route if needed and stores it in pending_render_frame_host_. | 465 // the opener route if needed and stores it in pending_render_frame_host_. |
443 void CreateRenderFrameHostForNewSiteInstance( | 466 void CreateRenderFrameHostForNewSiteInstance( |
444 SiteInstance* old_instance, | 467 SiteInstance* old_instance, |
445 SiteInstance* new_instance, | 468 SiteInstance* new_instance, |
446 bool is_main_frame); | 469 bool is_main_frame); |
447 | 470 |
448 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. | 471 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. |
449 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, | 472 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, |
450 int view_routing_id, | 473 int view_routing_id, |
451 int frame_routing_id, | 474 int frame_routing_id, |
452 bool swapped_out, | 475 bool swapped_out, |
453 bool hidden); | 476 bool hidden); |
454 | 477 |
478 // PlzNavigate | |
479 // Creates a new RenderFrameHost and does all required supporting work for the | |
480 // speculative creation of a new renderer for an ongoing navigation request. | |
481 // This new instance might be later destroyed if the final navigation | |
Charlie Reis
2014/11/05 17:50:01
new instance -> RenderFrameHost
carlosk
2014/11/05 20:28:59
Done.
| |
482 // destination doesn't match the initial one. | |
483 bool CreateSpeculativeRenderFrameHost(const GURL& url, | |
484 SiteInstance* old_instance, | |
485 SiteInstance* new_instance); | |
486 | |
455 // Sets up the necessary state for a new RenderViewHost with the given opener, | 487 // Sets up the necessary state for a new RenderViewHost with the given opener, |
456 // if necessary. It creates a RenderFrameProxy in the target renderer process | 488 // if necessary. It creates a RenderFrameProxy in the target renderer process |
457 // with the given |proxy_routing_id|, which is used to route IPC messages when | 489 // with the given |proxy_routing_id|, which is used to route IPC messages when |
458 // in swapped out state. Returns early if the RenderViewHost has already been | 490 // in swapped out state. Returns early if the RenderViewHost has already been |
459 // initialized for another RenderFrameHost. | 491 // initialized for another RenderFrameHost. |
460 // TODO(creis): opener_route_id is currently for the RenderViewHost but should | 492 // TODO(creis): opener_route_id is currently for the RenderViewHost but should |
461 // be for the RenderFrame, since frames can have openers. | 493 // be for the RenderFrame, since frames can have openers. |
462 bool InitRenderView(RenderViewHostImpl* render_view_host, | 494 bool InitRenderView(RenderViewHostImpl* render_view_host, |
463 int opener_route_id, | 495 int opener_route_id, |
464 int proxy_routing_id, | 496 int proxy_routing_id, |
465 bool for_main_frame_navigation); | 497 bool for_main_frame_navigation); |
466 | 498 |
467 // Initialization for RenderFrameHost uses the same sequence as InitRenderView | 499 // Initialization for RenderFrameHost uses the same sequence as InitRenderView |
468 // above. | 500 // above. |
469 bool InitRenderFrame(RenderFrameHostImpl* render_frame_host); | 501 bool InitRenderFrame(RenderFrameHostImpl* render_frame_host); |
470 | 502 |
471 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this | 503 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this |
472 // doesn't require the pending render_frame_host_ pointer to be non-NULL, | 504 // doesn't require the pending render_frame_host_ pointer to be non-NULL, |
473 // since there could be Web UI switching as well. Call this for every commit. | 505 // since there could be Web UI switching as well. Call this for every commit. |
474 void CommitPending(); | 506 void CommitPending(bool use_speculative_rfh); |
Charlie Reis
2014/11/05 17:50:01
Let's give a second paragraph in the comment about
carlosk
2014/11/05 20:28:58
Done.
| |
475 | 507 |
476 // Runs the unload handler in the old RenderFrameHost, after the new | 508 // Runs the unload handler in the old RenderFrameHost, after the new |
477 // RenderFrameHost has committed. |old_render_frame_host| will either be | 509 // RenderFrameHost has committed. |old_render_frame_host| will either be |
478 // deleted or put on the pending delete list during this call. | 510 // deleted or put on the pending delete list during this call. |
479 void SwapOutOldFrame(scoped_ptr<RenderFrameHostImpl> old_render_frame_host); | 511 void SwapOutOldFrame(scoped_ptr<RenderFrameHostImpl> old_render_frame_host); |
480 | 512 |
513 // Decides if the provided RenderFrameHostImpl instance should be destructed | |
514 // or swapped out and executes it. | |
515 void RecycleRenderFrameHost( | |
Charlie Reis
2014/11/05 17:50:01
If we need this, we should use a more common name
carlosk
2014/11/05 20:28:59
As in fact the RFH might not be destroyed (when it
| |
516 scoped_ptr<RenderFrameHostImpl> render_frame_host); | |
517 | |
481 // Holds |render_frame_host| until it can be deleted when its swap out ACK | 518 // Holds |render_frame_host| until it can be deleted when its swap out ACK |
482 // arrives. | 519 // arrives. |
483 void MoveToPendingDeleteHosts( | 520 void MoveToPendingDeleteHosts( |
484 scoped_ptr<RenderFrameHostImpl> render_frame_host); | 521 scoped_ptr<RenderFrameHostImpl> render_frame_host); |
485 | 522 |
486 // Shutdown all RenderFrameProxyHosts in a SiteInstance. This is called to | 523 // Shutdown all RenderFrameProxyHosts in a SiteInstance. This is called to |
487 // shutdown frames when all the frames in a SiteInstance are confirmed to be | 524 // shutdown frames when all the frames in a SiteInstance are confirmed to be |
488 // swapped out. | 525 // swapped out. |
489 void ShutdownRenderFrameProxyHostsInSiteInstance(int32 site_instance_id); | 526 void ShutdownRenderFrameProxyHostsInSiteInstance(int32 site_instance_id); |
490 | 527 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 RFHPendingDeleteList pending_delete_hosts_; | 614 RFHPendingDeleteList pending_delete_hosts_; |
578 | 615 |
579 // The intersitial page currently shown if any, not own by this class | 616 // The intersitial page currently shown if any, not own by this class |
580 // (the InterstitialPage is self-owned, it deletes itself when hidden). | 617 // (the InterstitialPage is self-owned, it deletes itself when hidden). |
581 InterstitialPageImpl* interstitial_page_; | 618 InterstitialPageImpl* interstitial_page_; |
582 | 619 |
583 NotificationRegistrar registrar_; | 620 NotificationRegistrar registrar_; |
584 | 621 |
585 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; | 622 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; |
586 | 623 |
624 // Members to store the speculative RFH created upon starting a navigation | |
Charlie Reis
2014/11/05 17:50:01
Important: Preface this with "PlzNavigate" and mak
carlosk
2014/11/05 20:28:59
Done. Just made it clear that for now PlzNavigate
| |
625 // allowing the creation of the renderer process as early as possible. | |
626 // Might be discarded later on if the final URL's SiteInstnace mismatches | |
Charlie Reis
2014/11/05 17:50:01
nit: SiteInstance
nit: doesn't match
carlosk
2014/11/05 20:28:59
Done.
| |
627 // what was assumed in the beginning. | |
628 scoped_ptr<RenderFrameHostImpl> speculative_render_frame_host_; | |
629 scoped_ptr<WebUIImpl> speculative_web_ui_; | |
630 | |
587 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); | 631 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); |
588 }; | 632 }; |
589 | 633 |
590 } // namespace content | 634 } // namespace content |
591 | 635 |
592 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 636 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
OLD | NEW |