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 FrameHostMsg_BeginNavigation_Params; | |
23 struct FrameMsg_Navigate_Params; | 24 struct FrameMsg_Navigate_Params; |
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; |
29 class FrameTreeNode; | 30 class FrameTreeNode; |
30 class InterstitialPageImpl; | 31 class InterstitialPageImpl; |
31 class NavigationControllerImpl; | 32 class NavigationControllerImpl; |
32 class NavigationEntry; | 33 class NavigationEntry; |
33 class NavigationEntryImpl; | 34 class NavigationEntryImpl; |
35 class NavigatorTestWithBrowserSideNavigation; | |
34 class RenderFrameHost; | 36 class RenderFrameHost; |
35 class RenderFrameHostDelegate; | 37 class RenderFrameHostDelegate; |
36 class RenderFrameHostImpl; | 38 class RenderFrameHostImpl; |
37 class RenderFrameHostManagerTest; | 39 class RenderFrameHostManagerTest; |
38 class RenderFrameProxyHost; | 40 class RenderFrameProxyHost; |
39 class RenderViewHost; | 41 class RenderViewHost; |
40 class RenderViewHostImpl; | 42 class RenderViewHostImpl; |
41 class RenderWidgetHostDelegate; | 43 class RenderWidgetHostDelegate; |
42 class RenderWidgetHostView; | 44 class RenderWidgetHostView; |
43 class TestWebContents; | 45 class TestWebContents; |
44 class WebUIImpl; | 46 class WebUIImpl; |
47 struct CommonNavigationParams; | |
45 | 48 |
46 // Manages RenderFrameHosts for a FrameTreeNode. It maintains a | 49 // Manages RenderFrameHosts for a FrameTreeNode. It maintains a |
47 // 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 |
48 // 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 |
49 // SiteInstance), it will replace its current RenderFrameHost with a new | 52 // SiteInstance), it will replace its current RenderFrameHost with a new |
50 // RenderFrameHost dedicated to the new SiteInstance, possibly in a new process. | 53 // RenderFrameHost dedicated to the new SiteInstance, possibly in a new process. |
51 // | 54 // |
52 // Cross-process navigation works like this: | 55 // Cross-process navigation works like this: |
53 // | 56 // |
54 // - 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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
360 | 363 |
361 // Deletes any proxy hosts associated with this node. Used during destruction | 364 // Deletes any proxy hosts associated with this node. Used during destruction |
362 // of WebContentsImpl. | 365 // of WebContentsImpl. |
363 void ResetProxyHosts(); | 366 void ResetProxyHosts(); |
364 | 367 |
365 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy | 368 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy |
366 // that has the given SiteInstance and is associated with this | 369 // that has the given SiteInstance and is associated with this |
367 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. | 370 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. |
368 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); | 371 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); |
369 | 372 |
370 // PlzNavigate: Called when a navigation is ready to commit, to select the | 373 // PlzNavigate |
371 // renderer that will commit it. | 374 // Notifies the RFHM that a navigation has begun so that it can speculatively |
375 // create a new renderer process if needed. | |
376 void BeginNavigation(const FrameHostMsg_BeginNavigation_Params& params, | |
377 const CommonNavigationParams& common_params); | |
378 | |
379 // PlzNavigate | |
380 // Called when a navigation is ready to commit to select the RenderFrameHost | |
381 // that will commit it. | |
nasko
2014/12/18 00:22:40
nit: "the RenderFrameHost in which the navigation
carlosk
2014/12/19 04:27:15
Done.
| |
372 RenderFrameHostImpl* GetFrameHostForNavigation(const GURL& url, | 382 RenderFrameHostImpl* GetFrameHostForNavigation(const GURL& url, |
373 ui::PageTransition transition); | 383 ui::PageTransition transition); |
374 | 384 |
385 // PlzNavigate | |
386 // Cancels any state for any ongoing navigation. | |
387 void CleanUpNavigation(); | |
388 | |
389 // PlzNavigate | |
390 // Clears the speculative members, returning the RenderFrameHost to the caller | |
391 // for disposal. | |
392 scoped_ptr<RenderFrameHostImpl> UnsetSpeculativeRenderFrameHost(); | |
393 | |
375 private: | 394 private: |
395 friend class NavigatorTestWithBrowserSideNavigation; | |
376 friend class RenderFrameHostManagerTest; | 396 friend class RenderFrameHostManagerTest; |
377 friend class TestWebContents; | 397 friend class TestWebContents; |
378 | 398 |
379 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, | 399 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, |
380 CreateCrossProcessSubframeProxies); | 400 CreateCrossProcessSubframeProxies); |
381 | 401 |
382 // Used with FrameTree::ForEach to erase RenderFrameProxyHosts from a | 402 // Used with FrameTree::ForEach to erase RenderFrameProxyHosts from a |
383 // FrameTreeNode's RenderFrameHostManager. | 403 // FrameTreeNode's RenderFrameHostManager. |
384 static bool ClearProxiesInSiteInstance(int32 site_instance_id, | 404 static bool ClearProxiesInSiteInstance(int32 site_instance_id, |
385 FrameTreeNode* node); | 405 FrameTreeNode* node); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 // route ID to be used for the new RenderView to be created. | 480 // route ID to be used for the new RenderView to be created. |
461 int CreateOpenerRenderViewsIfNeeded(SiteInstance* old_instance, | 481 int CreateOpenerRenderViewsIfNeeded(SiteInstance* old_instance, |
462 SiteInstance* new_instance); | 482 SiteInstance* new_instance); |
463 | 483 |
464 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. | 484 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. |
465 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, | 485 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, |
466 int view_routing_id, | 486 int view_routing_id, |
467 int frame_routing_id, | 487 int frame_routing_id, |
468 int flags); | 488 int flags); |
469 | 489 |
490 // PlzNavigate | |
491 // Creates and initializes a speculative RenderFrameHost and/or WebUI for an | |
492 // ongoing navigation. They might be destroyed and re-created later if the | |
493 // navigation is redirected to a different site. | |
494 bool CreateSpeculativeRenderFrameHost(const GURL& url, | |
495 SiteInstance* old_instance, | |
496 SiteInstance* new_instance, | |
497 int bindings); | |
498 | |
470 // Sets up the necessary state for a new RenderViewHost with the given opener, | 499 // Sets up the necessary state for a new RenderViewHost with the given opener, |
471 // if necessary. It creates a RenderFrameProxy in the target renderer process | 500 // if necessary. It creates a RenderFrameProxy in the target renderer process |
472 // with the given |proxy_routing_id|, which is used to route IPC messages when | 501 // with the given |proxy_routing_id|, which is used to route IPC messages when |
473 // in swapped out state. Returns early if the RenderViewHost has already been | 502 // in swapped out state. Returns early if the RenderViewHost has already been |
474 // initialized for another RenderFrameHost. | 503 // initialized for another RenderFrameHost. |
475 // TODO(creis): opener_route_id is currently for the RenderViewHost but should | 504 // TODO(creis): opener_route_id is currently for the RenderViewHost but should |
476 // be for the RenderFrame, since frames can have openers. | 505 // be for the RenderFrame, since frames can have openers. |
477 bool InitRenderView(RenderViewHostImpl* render_view_host, | 506 bool InitRenderView(RenderViewHostImpl* render_view_host, |
478 int opener_route_id, | 507 int opener_route_id, |
479 int proxy_routing_id, | 508 int proxy_routing_id, |
480 bool for_main_frame_navigation); | 509 bool for_main_frame_navigation); |
481 | 510 |
482 // Initialization for RenderFrameHost uses the same sequence as InitRenderView | 511 // Initialization for RenderFrameHost uses the same sequence as InitRenderView |
483 // above. | 512 // above. |
484 bool InitRenderFrame(RenderFrameHostImpl* render_frame_host); | 513 bool InitRenderFrame(RenderFrameHostImpl* render_frame_host); |
485 | 514 |
486 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this | 515 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this |
487 // doesn't require the pending render_frame_host_ pointer to be non-NULL, | 516 // doesn't require the pending render_frame_host_ pointer to be non-NULL, |
488 // since there could be Web UI switching as well. Call this for every commit. | 517 // since there could be Web UI switching as well. Call this for every commit. |
518 // If PlzNavigate is enabled the method will set the speculative (not pending) | |
519 // RenderFrameHost to be the active one. | |
489 void CommitPending(); | 520 void CommitPending(); |
490 | 521 |
491 // Runs the unload handler in the old RenderFrameHost, after the new | 522 // Runs the unload handler in the old RenderFrameHost, after the new |
492 // RenderFrameHost has committed. |old_render_frame_host| will either be | 523 // RenderFrameHost has committed. |old_render_frame_host| will either be |
493 // deleted or put on the pending delete list during this call. | 524 // deleted or put on the pending delete list during this call. |
494 void SwapOutOldFrame(scoped_ptr<RenderFrameHostImpl> old_render_frame_host); | 525 void SwapOutOldFrame(scoped_ptr<RenderFrameHostImpl> old_render_frame_host); |
495 | 526 |
496 // Discards a RenderFrameHost that was never made active (for active ones | 527 // Discards a RenderFrameHost that was never made active (for active ones |
497 // SwapOutOldFrame is used instead). | 528 // SwapOutOldFrame is used instead). |
498 void DiscardUnusedFrame(scoped_ptr<RenderFrameHostImpl> render_frame_host); | 529 void DiscardUnusedFrame(scoped_ptr<RenderFrameHostImpl> render_frame_host); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
564 // A RenderFrameHost used to load a cross-site page. This remains hidden | 595 // A RenderFrameHost used to load a cross-site page. This remains hidden |
565 // while a cross-site request is pending until it calls DidNavigate. It may | 596 // while a cross-site request is pending until it calls DidNavigate. It may |
566 // have an associated Web UI, in which case the Web UI pointer will be non- | 597 // have an associated Web UI, in which case the Web UI pointer will be non- |
567 // NULL. | 598 // NULL. |
568 // | 599 // |
569 // The |pending_web_ui_| may be non-NULL even when the | 600 // The |pending_web_ui_| may be non-NULL even when the |
570 // |pending_render_frame_host_| is NULL. This will happen when we're | 601 // |pending_render_frame_host_| is NULL. This will happen when we're |
571 // transitioning between two Web UI pages: the RFH won't be swapped, so the | 602 // transitioning between two Web UI pages: the RFH won't be swapped, so the |
572 // pending pointer will be unused, but there will be a pending Web UI | 603 // pending pointer will be unused, but there will be a pending Web UI |
573 // associated with the navigation. | 604 // associated with the navigation. |
605 // Note: This is not used in PlzNavigate. | |
574 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host_; | 606 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host_; |
575 | 607 |
576 // If a pending request needs to be transferred to another process, this | 608 // If a pending request needs to be transferred to another process, this |
577 // owns the request until it's transferred to the new process, so it will be | 609 // owns the request until it's transferred to the new process, so it will be |
578 // cleaned up if the navigation is cancelled. Otherwise, this is NULL. | 610 // cleaned up if the navigation is cancelled. Otherwise, this is NULL. |
579 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request_; | 611 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request_; |
580 | 612 |
581 // Tracks information about any navigation paused after receiving response | 613 // Tracks information about any navigation paused after receiving response |
582 // headers. | 614 // headers. |
583 scoped_ptr<GlobalRequestID> response_started_id_; | 615 scoped_ptr<GlobalRequestID> response_started_id_; |
(...skipping 14 matching lines...) Expand all Loading... | |
598 // because sets don't appear to support linked_ptrs. | 630 // because sets don't appear to support linked_ptrs. |
599 typedef std::list<linked_ptr<RenderFrameHostImpl> > RFHPendingDeleteList; | 631 typedef std::list<linked_ptr<RenderFrameHostImpl> > RFHPendingDeleteList; |
600 RFHPendingDeleteList pending_delete_hosts_; | 632 RFHPendingDeleteList pending_delete_hosts_; |
601 | 633 |
602 // The intersitial page currently shown if any, not own by this class | 634 // The intersitial page currently shown if any, not own by this class |
603 // (the InterstitialPage is self-owned, it deletes itself when hidden). | 635 // (the InterstitialPage is self-owned, it deletes itself when hidden). |
604 InterstitialPageImpl* interstitial_page_; | 636 InterstitialPageImpl* interstitial_page_; |
605 | 637 |
606 NotificationRegistrar registrar_; | 638 NotificationRegistrar registrar_; |
607 | 639 |
640 // PlzNavigate | |
641 // These members store a speculative RenderFrameHost and WebUI. They are | |
642 // created early in during a navigation so the renderer process can be started | |
643 // in parallel with it. This is purely an optimization and is not required for | |
644 // correct behavior. The created instance might be discarded later on if the | |
645 // final URL's SiteInstance isn't compatible with what was used to create it. | |
646 // Note: PlzNavigate only uses speculative RenderFrameHosts and not pending | |
647 // ones. | |
648 scoped_ptr<RenderFrameHostImpl> speculative_render_frame_host_; | |
649 scoped_ptr<WebUIImpl> speculative_web_ui_; | |
650 | |
651 // PlzNavigate | |
652 // If true at navigation commit time the current WebUI will be kept instead of | |
653 // creating a new one. | |
654 bool should_reuse_web_ui_; | |
655 | |
608 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; | 656 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; |
609 | 657 |
610 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); | 658 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); |
611 }; | 659 }; |
612 | 660 |
613 } // namespace content | 661 } // namespace content |
614 | 662 |
615 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 663 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
OLD | NEW |