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

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

Issue 367653002: Add a FrameHostMsg_BeginNavigation IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a stub for CommitNavigation to clarify lifetime of rfh Created 6 years, 5 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 RenderFrameHostImpl; 35 class RenderFrameHostImpl;
35 class RenderFrameHostManagerTest; 36 class RenderFrameHostManagerTest;
36 class RenderFrameProxyHost; 37 class RenderFrameProxyHost;
37 class RenderViewHost; 38 class RenderViewHost;
38 class RenderViewHostImpl; 39 class RenderViewHostImpl;
39 class RenderWidgetHostDelegate; 40 class RenderWidgetHostDelegate;
40 class RenderWidgetHostView; 41 class RenderWidgetHostView;
41 class TestWebContents; 42 class TestWebContents;
42 class WebUIImpl; 43 class WebUIImpl;
44 struct NavigationCommitInfo;
43 45
44 // Manages RenderFrameHosts for a FrameTreeNode. This class acts as a state 46 // Manages RenderFrameHosts for a FrameTreeNode. This class acts as a state
45 // machine to make cross-process navigations in a frame possible. 47 // machine to make cross-process navigations in a frame possible.
46 class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { 48 class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver {
47 public: 49 public:
48 // Functions implemented by our owner that we need. 50 // Functions implemented by our owner that we need.
49 // 51 //
50 // TODO(brettw) Clean this up! These are all the functions in WebContentsImpl 52 // TODO(brettw) Clean this up! These are all the functions in WebContentsImpl
51 // that are required to run this class. The design should probably be better 53 // that are required to run this class. The design should probably be better
52 // such that these are more clear. 54 // such that these are more clear.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // Sets the pending Web UI for the pending navigation, ensuring that the 182 // Sets the pending Web UI for the pending navigation, ensuring that the
181 // bindings are appropriate for the given NavigationEntry. 183 // bindings are appropriate for the given NavigationEntry.
182 void SetPendingWebUI(const NavigationEntryImpl& entry); 184 void SetPendingWebUI(const NavigationEntryImpl& entry);
183 185
184 // Called when we want to instruct the renderer to navigate to the given 186 // Called when we want to instruct the renderer to navigate to the given
185 // navigation entry. It may create a new RenderFrameHost or re-use an existing 187 // navigation entry. It may create a new RenderFrameHost or re-use an existing
186 // one. The RenderFrameHost to navigate will be returned. Returns NULL if one 188 // one. The RenderFrameHost to navigate will be returned. Returns NULL if one
187 // could not be created. 189 // could not be created.
188 RenderFrameHostImpl* Navigate(const NavigationEntryImpl& entry); 190 RenderFrameHostImpl* Navigate(const NavigationEntryImpl& entry);
189 191
192 // As part of the PlzNavigate refactoring project, sends a RequestNavigation
193 // IPC to the renderer to ask it to navigate. If no live renderer is present,
194 // then the navigation request will be sent directly to the
195 // ResourceDispatcherHost.
196 bool RequestNavigation(const NavigationEntryImpl& entry,
197 const FrameMsg_Navigate_Params& navigate_params);
198
190 // Instructs the various live views to stop. Called when the user directed the 199 // Instructs the various live views to stop. Called when the user directed the
191 // page to stop loading. 200 // page to stop loading.
192 void Stop(); 201 void Stop();
193 202
194 // Notifies the regular and pending RenderViewHosts that a load is or is not 203 // Notifies the regular and pending RenderViewHosts that a load is or is not
195 // happening. Even though the message is only for one of them, we don't know 204 // happening. Even though the message is only for one of them, we don't know
196 // which one so we tell both. 205 // which one so we tell both.
197 void SetIsLoading(bool is_loading); 206 void SetIsLoading(bool is_loading);
198 207
199 // Whether to close the tab or not when there is a hang during an unload 208 // Whether to close the tab or not when there is a hang during an unload
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 void SwappedOut(RenderFrameHostImpl* render_frame_host); 248 void SwappedOut(RenderFrameHostImpl* render_frame_host);
240 249
241 // Called when a renderer's frame navigates. 250 // Called when a renderer's frame navigates.
242 void DidNavigateFrame(RenderFrameHostImpl* render_frame_host); 251 void DidNavigateFrame(RenderFrameHostImpl* render_frame_host);
243 252
244 // Called when a renderer sets its opener to null. 253 // Called when a renderer sets its opener to null.
245 void DidDisownOpener(RenderViewHost* render_view_host); 254 void DidDisownOpener(RenderViewHost* render_view_host);
246 255
247 // Helper method to create and initialize a RenderFrameHost. If |swapped_out| 256 // Helper method to create and initialize a RenderFrameHost. If |swapped_out|
248 // is true, it will be initially placed on the swapped out hosts list. 257 // is true, it will be initially placed on the swapped out hosts list.
258 // Else if |is_speculative| is true, then it will used as a speculatively
259 // spawned renderer in the PlzNavigate navigation refactoring project.
249 // Otherwise, it will be used for a pending cross-site navigation. 260 // Otherwise, it will be used for a pending cross-site navigation.
250 // Returns the routing id of the *view* associated with the frame. 261 // Returns the routing id of the *view* associated with the frame.
251 int CreateRenderFrame(SiteInstance* instance, 262 int CreateRenderFrame(SiteInstance* instance,
252 int opener_route_id, 263 int opener_route_id,
253 bool swapped_out, 264 bool swapped_out,
254 bool hidden); 265 bool hidden,
266 bool is_speculative);
255 267
256 // Sets the passed passed interstitial as the currently showing interstitial. 268 // Sets the passed passed interstitial as the currently showing interstitial.
257 // |interstitial_page| should be non NULL (use the remove_interstitial_page 269 // |interstitial_page| should be non NULL (use the remove_interstitial_page
258 // method to unset the interstitial) and no interstitial page should be set 270 // method to unset the interstitial) and no interstitial page should be set
259 // when there is already a non NULL interstitial page set. 271 // when there is already a non NULL interstitial page set.
260 void set_interstitial_page(InterstitialPageImpl* interstitial_page) { 272 void set_interstitial_page(InterstitialPageImpl* interstitial_page) {
261 DCHECK(!interstitial_page_ && interstitial_page); 273 DCHECK(!interstitial_page_ && interstitial_page);
262 interstitial_page_ = interstitial_page; 274 interstitial_page_ = interstitial_page;
263 } 275 }
264 276
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 void ClearPendingShutdownRFHForSiteInstance(int32 site_instance_id, 310 void ClearPendingShutdownRFHForSiteInstance(int32 site_instance_id,
299 RenderFrameHostImpl* rfh); 311 RenderFrameHostImpl* rfh);
300 312
301 // Deletes any proxy hosts associated with this node. Used during destruction 313 // Deletes any proxy hosts associated with this node. Used during destruction
302 // of WebContentsImpl. 314 // of WebContentsImpl.
303 void ResetProxyHosts(); 315 void ResetProxyHosts();
304 316
305 // Used to start a navigation, part of browser-side navigation project. 317 // Used to start a navigation, part of browser-side navigation project.
306 void OnBeginNavigation(const FrameHostMsg_BeginNavigation_Params& params); 318 void OnBeginNavigation(const FrameHostMsg_BeginNavigation_Params& params);
307 319
320 // Used to signal the commit of a navigation request, part of PlzNavigate
321 // navigation refactoring project.
322 void CommitNavigation(const NavigationCommitInfo& info);
323
308 private: 324 private:
309 friend class RenderFrameHostManagerTest; 325 friend class RenderFrameHostManagerTest;
310 friend class TestWebContents; 326 friend class TestWebContents;
311 327
312 // Tracks information about a navigation while a cross-process transition is 328 // Tracks information about a navigation while a cross-process transition is
313 // in progress, in case we need to transfer it to a new RenderFrameHost. 329 // in progress, in case we need to transfer it to a new RenderFrameHost.
314 // When a request is being transferred, deleting the PendingNavigationParams, 330 // When a request is being transferred, deleting the PendingNavigationParams,
315 // and thus |cross_site_transferring_request|, will cancel the request being 331 // and thus |cross_site_transferring_request|, will cancel the request being
316 // transferred, unless its ReleaseRequest method has been called. 332 // transferred, unless its ReleaseRequest method has been called.
317 struct PendingNavigationParams { 333 struct PendingNavigationParams {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 403
388 // Returns an appropriate SiteInstance object for the given NavigationEntry, 404 // Returns an appropriate SiteInstance object for the given NavigationEntry,
389 // possibly reusing the current SiteInstance. If --process-per-tab is used, 405 // possibly reusing the current SiteInstance. If --process-per-tab is used,
390 // this is only called when ShouldSwapBrowsingInstancesForNavigation returns 406 // this is only called when ShouldSwapBrowsingInstancesForNavigation returns
391 // true. 407 // true.
392 SiteInstance* GetSiteInstanceForEntry( 408 SiteInstance* GetSiteInstanceForEntry(
393 const NavigationEntryImpl& entry, 409 const NavigationEntryImpl& entry,
394 SiteInstance* current_instance, 410 SiteInstance* current_instance,
395 bool force_browsing_instance_swap); 411 bool force_browsing_instance_swap);
396 412
413 // Creates a new RenderFrameHostImpl for the |new_instance| while respecting
414 // the opener route if needed. If |is_speculative| is true, then the newly
415 // created RFH will be stored in speculative_render_frame_host_, otherwise it
416 // will be stored in pending_render_frame_host_. Also returns a pointer to the
417 // newly created RFH.
418 RenderFrameHostImpl* CreateRenderFrameHostForCrossSite(
419 SiteInstance* old_instance,
420 SiteInstance* new_instance,
421 bool is_speculative);
422
397 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. 423 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary.
398 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, 424 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance,
399 int view_routing_id, 425 int view_routing_id,
400 int frame_routing_id, 426 int frame_routing_id,
401 bool swapped_out, 427 bool swapped_out,
402 bool hidden); 428 bool hidden);
403 429
404 // Sets up the necessary state for a new RenderViewHost with the given opener, 430 // Sets up the necessary state for a new RenderViewHost with the given opener,
405 // if necessary. It creates a RenderFrameProxy in the target renderer process 431 // if necessary. It creates a RenderFrameProxy in the target renderer process
406 // with the given |proxy_routing_id|, which is used to route IPC messages when 432 // with the given |proxy_routing_id|, which is used to route IPC messages when
407 // in swapped out state. Returns early if the RenderViewHost has already been 433 // in swapped out state. Returns early if the RenderViewHost has already been
408 // initialized for another RenderFrameHost. 434 // initialized for another RenderFrameHost.
409 // TODO(creis): opener_route_id is currently for the RenderViewHost but should 435 // TODO(creis): opener_route_id is currently for the RenderViewHost but should
410 // be for the RenderFrame, since frames can have openers. 436 // be for the RenderFrame, since frames can have openers.
411 bool InitRenderView(RenderViewHost* render_view_host, 437 bool InitRenderView(RenderViewHost* render_view_host,
412 int opener_route_id, 438 int opener_route_id,
413 int proxy_routing_id, 439 int proxy_routing_id,
414 bool for_main_frame); 440 bool for_main_frame);
415 441
442 // Initializes |dest_render_frame_host| and |render_frame_host_| if necessary
443 // before navigating.
444 bool InitRenderFrameHostsBeforeNavigation(
445 RenderFrameHostImpl* dest_render_frame_host);
446
447 // Returns the SiteInstance to use for the navigation.
448 SiteInstance* GetSiteInstanceForNavigation(const NavigationEntryImpl& entry);
449
416 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this 450 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this
417 // doesn't require the pending render_frame_host_ pointer to be non-NULL, 451 // doesn't require the pending render_frame_host_ pointer to be non-NULL,
418 // since there could be Web UI switching as well. Call this for every commit. 452 // since there could be Web UI switching as well. Call this for every commit.
419 void CommitPending(); 453 void CommitPending();
420 454
421 // Shutdown all RenderFrameHosts in a SiteInstance. This is called to shutdown 455 // Shutdown all RenderFrameHosts in a SiteInstance. This is called to shutdown
422 // frames when all the frames in a SiteInstance are confirmed to be swapped 456 // frames when all the frames in a SiteInstance are confirmed to be swapped
423 // out. 457 // out.
424 void ShutdownRenderFrameHostsInSiteInstance(int32 site_instance_id); 458 void ShutdownRenderFrameHostsInSiteInstance(int32 site_instance_id);
425 459
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 // associated with the navigation. 509 // associated with the navigation.
476 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host_; 510 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host_;
477 511
478 // Tracks information about any current pending cross-process navigation. 512 // Tracks information about any current pending cross-process navigation.
479 scoped_ptr<PendingNavigationParams> pending_nav_params_; 513 scoped_ptr<PendingNavigationParams> pending_nav_params_;
480 514
481 // Tracks information about any navigation paused after receiving response 515 // Tracks information about any navigation paused after receiving response
482 // headers. 516 // headers.
483 scoped_ptr<GlobalRequestID> response_started_id_; 517 scoped_ptr<GlobalRequestID> response_started_id_;
484 518
519 // A RenderFrameHost speculatively created when receiving a navigation
520 // request. It should be used or deleted when the current navigation request
521 // commits.
522 scoped_ptr<RenderFrameHostImpl> speculative_render_frame_host_;
523
485 // If either of these is non-NULL, the pending navigation is to a chrome: 524 // If either of these is non-NULL, the pending navigation is to a chrome:
486 // page. The scoped_ptr is used if pending_web_ui_ != web_ui_, the WeakPtr is 525 // page. The scoped_ptr is used if pending_web_ui_ != web_ui_, the WeakPtr is
487 // used for when they reference the same object. If either is non-NULL, the 526 // used for when they reference the same object. If either is non-NULL, the
488 // other should be NULL. 527 // other should be NULL.
489 scoped_ptr<WebUIImpl> pending_web_ui_; 528 scoped_ptr<WebUIImpl> pending_web_ui_;
490 base::WeakPtr<WebUIImpl> pending_and_current_web_ui_; 529 base::WeakPtr<WebUIImpl> pending_and_current_web_ui_;
491 530
492 // A map of site instance ID to RenderFrameProxyHosts. 531 // A map of site instance ID to RenderFrameProxyHosts.
493 typedef base::hash_map<int32, RenderFrameProxyHost*> RenderFrameProxyHostMap; 532 typedef base::hash_map<int32, RenderFrameProxyHost*> RenderFrameProxyHostMap;
494 RenderFrameProxyHostMap proxy_hosts_; 533 RenderFrameProxyHostMap proxy_hosts_;
(...skipping 13 matching lines...) Expand all
508 scoped_ptr<NavigationRequest> navigation_request_; 547 scoped_ptr<NavigationRequest> navigation_request_;
509 548
510 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; 549 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_;
511 550
512 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); 551 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager);
513 }; 552 };
514 553
515 } // namespace content 554 } // namespace content
516 555
517 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ 556 #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