Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: content/browser/frame_host/render_frame_host_manager.h

Issue 379143002: PlzNavigate: implement RequestNavigation in the no live renderer case (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "content/browser/renderer_host/render_view_host_delegate.h" 12 #include "content/browser/renderer_host/render_view_host_delegate.h"
13 #include "content/browser/site_instance_impl.h" 13 #include "content/browser/site_instance_impl.h"
14 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
15 #include "content/public/browser/global_request_id.h" 15 #include "content/public/browser/global_request_id.h"
16 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
18 #include "content/public/common/referrer.h" 18 #include "content/public/common/referrer.h"
19 19
20 struct FrameHostMsg_BeginNavigation_Params; 20 struct FrameHostMsg_BeginNavigation_Params;
21 struct FrameMsg_Navigate_Params;
21 22
22 namespace content { 23 namespace content {
23 class BrowserContext; 24 class BrowserContext;
24 class CrossProcessFrameConnector; 25 class CrossProcessFrameConnector;
25 class CrossSiteTransferringRequest; 26 class CrossSiteTransferringRequest;
26 class InterstitialPageImpl; 27 class InterstitialPageImpl;
27 class FrameTreeNode; 28 class FrameTreeNode;
28 class NavigationControllerImpl; 29 class NavigationControllerImpl;
29 class NavigationEntry; 30 class NavigationEntry;
30 class NavigationEntryImpl; 31 class NavigationEntryImpl;
31 class NavigationRequest; 32 class NavigationRequest;
32 class RenderFrameHost; 33 class RenderFrameHost;
33 class RenderFrameHostDelegate; 34 class RenderFrameHostDelegate;
34 class RenderFrameHost; 35 class RenderFrameHost;
35 class RenderFrameHostImpl; 36 class RenderFrameHostImpl;
36 class RenderFrameHostManagerTest; 37 class RenderFrameHostManagerTest;
37 class RenderFrameProxyHost; 38 class RenderFrameProxyHost;
38 class RenderViewHost; 39 class RenderViewHost;
39 class RenderViewHostImpl; 40 class RenderViewHostImpl;
40 class RenderWidgetHostDelegate; 41 class RenderWidgetHostDelegate;
41 class RenderWidgetHostView; 42 class RenderWidgetHostView;
42 class TestWebContents; 43 class TestWebContents;
43 class WebUIImpl; 44 class WebUIImpl;
45 struct NavigationBeforeCommitInfo;
44 46
45 // Manages RenderFrameHosts for a FrameTreeNode. This class acts as a state 47 // Manages RenderFrameHosts for a FrameTreeNode. This class acts as a state
46 // machine to make cross-process navigations in a frame possible. 48 // machine to make cross-process navigations in a frame possible.
47 class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { 49 class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver {
48 public: 50 public:
49 // Functions implemented by our owner that we need. 51 // Functions implemented by our owner that we need.
50 // 52 //
51 // TODO(brettw) Clean this up! These are all the functions in WebContentsImpl 53 // TODO(brettw) Clean this up! These are all the functions in WebContentsImpl
52 // that are required to run this class. The design should probably be better 54 // that are required to run this class. The design should probably be better
53 // such that these are more clear. 55 // such that these are more clear.
54 // 56 //
55 // There is additional complexity that some of the functions we need in 57 // There is additional complexity that some of the functions we need in
56 // WebContentsImpl are inherited and non-virtual. These are named with 58 // WebContentsImpl are inherited and non-virtual. These are named with
57 // "RenderManager" so that the duplicate implementation of them will be clear. 59 // "RenderManager" so that the duplicate implementation of them will be clear.
60 //
61 // Functions and parameters whose description are prefixed by PlzNavigate are
62 // part of a navigation refactoring project, currently behind the
63 // enable-browser-side-navigation flag. The idea is to move the logic behind
64 // driving navigations from the renderer to the browser.
58 class CONTENT_EXPORT Delegate { 65 class CONTENT_EXPORT Delegate {
59 public: 66 public:
60 // Initializes the given renderer if necessary and creates the view ID 67 // Initializes the given renderer if necessary and creates the view ID
61 // corresponding to this view host. If this method is not called and the 68 // corresponding to this view host. If this method is not called and the
62 // process is not shared, then the WebContentsImpl will act as though the 69 // process is not shared, then the WebContentsImpl will act as though the
63 // renderer is not running (i.e., it will render "sad tab"). This method is 70 // renderer is not running (i.e., it will render "sad tab"). This method is
64 // automatically called from LoadURL. |for_main_frame_navigation| indicates 71 // automatically called from LoadURL. |for_main_frame_navigation| indicates
65 // whether this RenderViewHost is used to render a top-level frame, so the 72 // whether this RenderViewHost is used to render a top-level frame, so the
66 // appropriate RenderWidgetHostView type is used. 73 // appropriate RenderWidgetHostView type is used.
67 virtual bool CreateRenderViewForRenderManager( 74 virtual bool CreateRenderViewForRenderManager(
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 void SwappedOut(RenderFrameHostImpl* render_frame_host); 250 void SwappedOut(RenderFrameHostImpl* render_frame_host);
244 251
245 // Called when a renderer's frame navigates. 252 // Called when a renderer's frame navigates.
246 void DidNavigateFrame(RenderFrameHostImpl* render_frame_host); 253 void DidNavigateFrame(RenderFrameHostImpl* render_frame_host);
247 254
248 // Called when a renderer sets its opener to null. 255 // Called when a renderer sets its opener to null.
249 void DidDisownOpener(RenderViewHost* render_view_host); 256 void DidDisownOpener(RenderViewHost* render_view_host);
250 257
251 // Helper method to create and initialize a RenderFrameHost. If |swapped_out| 258 // 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. 259 // 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.
254 // Returns the routing id of the *view* associated with the frame. 260 // Returns the routing id of the *view* associated with the frame.
255 int CreateRenderFrame(SiteInstance* instance, 261 int CreateRenderFrame(SiteInstance* instance,
256 int opener_route_id, 262 int opener_route_id,
257 bool swapped_out, 263 bool swapped_out,
258 bool for_main_frame_navigation, 264 bool for_main_frame_navigation,
259 bool hidden); 265 bool hidden);
260 266
261 // Helper method to create and initialize a RenderFrameProxyHost and return 267 // Helper method to create and initialize a RenderFrameProxyHost and return
262 // its routing id. 268 // its routing id.
263 int CreateRenderFrameProxy(SiteInstance* instance); 269 int CreateRenderFrameProxy(SiteInstance* instance);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 void SwapOutOldPage(); 310 void SwapOutOldPage();
305 311
306 // Deletes a RenderFrameHost that was pending shutdown. 312 // Deletes a RenderFrameHost that was pending shutdown.
307 void ClearPendingShutdownRFHForSiteInstance(int32 site_instance_id, 313 void ClearPendingShutdownRFHForSiteInstance(int32 site_instance_id,
308 RenderFrameHostImpl* rfh); 314 RenderFrameHostImpl* rfh);
309 315
310 // Deletes any proxy hosts associated with this node. Used during destruction 316 // Deletes any proxy hosts associated with this node. Used during destruction
311 // of WebContentsImpl. 317 // of WebContentsImpl.
312 void ResetProxyHosts(); 318 void ResetProxyHosts();
313 319
314 // Used to start a navigation, part of browser-side navigation project.
315 void OnBeginNavigation(const FrameHostMsg_BeginNavigation_Params& params);
316
317 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy 320 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy
318 // that has the given SiteInstance and is associated with this 321 // that has the given SiteInstance and is associated with this
319 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. 322 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found.
320 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); 323 int GetRoutingIdForSiteInstance(SiteInstance* site_instance);
321 324
325 // PlzNavigate: sends a RequestNavigation IPC to the renderer to ask it to
326 // navigate. If no live renderer is present, then the navigation request will
327 // be sent directly to the ResourceDispatcherHost.
328 bool RequestNavigation(const NavigationEntryImpl& entry,
329 const FrameMsg_Navigate_Params& navigate_params);
330
331 // PlzNavigate: Used to start a navigation. OnBeginNavigation is called
332 // directly by RequestNavigation when there is no live renderer. Otherwise, it
333 // is called following a BeginNavigation IPC from the renderer (which in
334 // browser-initiated navigation also happens after RequestNavigation has been
335 // called).
336 void OnBeginNavigation(const FrameHostMsg_BeginNavigation_Params& params);
337
338 // PlzNavigate: Called when a navigation request has received a response, to
339 // select a renderer to use for the navigation.
340 void CommitNavigation(const NavigationBeforeCommitInfo& info);
341
322 private: 342 private:
323 friend class RenderFrameHostManagerTest; 343 friend class RenderFrameHostManagerTest;
324 friend class TestWebContents; 344 friend class TestWebContents;
325 345
326 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, 346 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest,
327 CreateCrossProcessSubframeProxies); 347 CreateCrossProcessSubframeProxies);
328 348
329 // Tracks information about a navigation while a cross-process transition is 349 // 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. 350 // in progress, in case we need to transfer it to a new RenderFrameHost.
331 // When a request is being transferred, deleting the PendingNavigationParams, 351 // When a request is being transferred, deleting the PendingNavigationParams,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 SiteInstance* new_site_instance, 425 SiteInstance* new_site_instance,
406 const GURL& new_effective_url, 426 const GURL& new_effective_url,
407 bool new_is_view_source_mode) const; 427 bool new_is_view_source_mode) const;
408 428
409 // Returns true if it is safe to reuse the current WebUI when navigating from 429 // Returns true if it is safe to reuse the current WebUI when navigating from
410 // |current_entry| to |new_entry|. 430 // |current_entry| to |new_entry|.
411 bool ShouldReuseWebUI( 431 bool ShouldReuseWebUI(
412 const NavigationEntry* current_entry, 432 const NavigationEntry* current_entry,
413 const NavigationEntryImpl* new_entry) const; 433 const NavigationEntryImpl* new_entry) const;
414 434
435 // Returns the SiteInstance to use for the navigation.
436 SiteInstance* GetSiteInstanceForNavigation(
437 const GURL& dest_url,
438 SiteInstance* dest_instance,
439 PageTransition dest_transition,
440 bool dest_is_restore,
441 bool dest_is_view_source_mode);
442
415 // Returns an appropriate SiteInstance object for the given |dest_url|, 443 // Returns an appropriate SiteInstance object for the given |dest_url|,
416 // possibly reusing the current SiteInstance. If --process-per-tab is used, 444 // possibly reusing the current SiteInstance. If --process-per-tab is used,
417 // this is only called when ShouldSwapBrowsingInstancesForNavigation returns 445 // this is only called when ShouldSwapBrowsingInstancesForNavigation returns
418 // true. |dest_instance| will be used if it is not null. 446 // true. |dest_instance| will be used if it is not null.
447 // This is a helper function for GetSiteInstanceForNavigation.
419 SiteInstance* GetSiteInstanceForURL( 448 SiteInstance* GetSiteInstanceForURL(
420 const GURL& dest_url, 449 const GURL& dest_url,
421 SiteInstance* dest_instance, 450 SiteInstance* dest_instance,
422 PageTransition dest_transition, 451 PageTransition dest_transition,
423 bool dest_is_restore, 452 bool dest_is_restore,
424 bool dest_is_view_source_mode, 453 bool dest_is_view_source_mode,
425 SiteInstance* current_instance, 454 SiteInstance* current_instance,
426 bool force_browsing_instance_swap); 455 bool force_browsing_instance_swap);
427 456
457 // Creates a new RenderFrameHostImpl for the |new_instance| while respecting
458 // the opener route if needed and stores it in pending_render_frame_host_.
459 void CreateRenderFrameHostForNewSiteInstance(
460 SiteInstance* old_instance,
461 SiteInstance* new_instance,
462 bool is_main_frame);
463
428 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. 464 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary.
429 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, 465 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance,
430 int view_routing_id, 466 int view_routing_id,
431 int frame_routing_id, 467 int frame_routing_id,
432 bool swapped_out, 468 bool swapped_out,
433 bool hidden); 469 bool hidden);
434 470
435 // Sets up the necessary state for a new RenderViewHost with the given opener, 471 // Sets up the necessary state for a new RenderViewHost with the given opener,
436 // if necessary. It creates a RenderFrameProxy in the target renderer process 472 // if necessary. It creates a RenderFrameProxy in the target renderer process
437 // with the given |proxy_routing_id|, which is used to route IPC messages when 473 // with the given |proxy_routing_id|, which is used to route IPC messages when
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 typedef base::hash_map<int32, linked_ptr<RenderFrameHostImpl> > 572 typedef base::hash_map<int32, linked_ptr<RenderFrameHostImpl> >
537 RFHPendingDeleteMap; 573 RFHPendingDeleteMap;
538 RFHPendingDeleteMap pending_delete_hosts_; 574 RFHPendingDeleteMap pending_delete_hosts_;
539 575
540 // The intersitial page currently shown if any, not own by this class 576 // The intersitial page currently shown if any, not own by this class
541 // (the InterstitialPage is self-owned, it deletes itself when hidden). 577 // (the InterstitialPage is self-owned, it deletes itself when hidden).
542 InterstitialPageImpl* interstitial_page_; 578 InterstitialPageImpl* interstitial_page_;
543 579
544 NotificationRegistrar registrar_; 580 NotificationRegistrar registrar_;
545 581
546 // Owns a navigation request that originated in that frame until it commits. 582 // PlzNavigate: Owns a navigation request that originated in that frame until
583 // it commits.
547 scoped_ptr<NavigationRequest> navigation_request_; 584 scoped_ptr<NavigationRequest> navigation_request_;
548 585
549 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; 586 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_;
550 587
551 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); 588 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager);
552 }; 589 };
553 590
554 } // namespace content 591 } // namespace content
555 592
556 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ 593 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.cc ('k') | content/browser/frame_host/render_frame_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698