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

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

Issue 464593003: Don't swap out the old RenderFrameHost until the new one commits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase past PlzNavigate CL 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 | Annotate | Revision Log
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"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // Received a response from CrossSiteResourceHandler. If the navigation 238 // Received a response from CrossSiteResourceHandler. If the navigation
239 // specifies a transition, this is called and the navigation will not resume 239 // specifies a transition, this is called and the navigation will not resume
240 // until ResumeResponseDeferredAtStart. 240 // until ResumeResponseDeferredAtStart.
241 void OnDeferredAfterResponseStarted( 241 void OnDeferredAfterResponseStarted(
242 const GlobalRequestID& global_request_id, 242 const GlobalRequestID& global_request_id,
243 RenderFrameHostImpl* pending_render_frame_host); 243 RenderFrameHostImpl* pending_render_frame_host);
244 244
245 // Resume navigation paused after receiving response headers. 245 // Resume navigation paused after receiving response headers.
246 void ResumeResponseDeferredAtStart(); 246 void ResumeResponseDeferredAtStart();
247 247
248 // The RenderFrameHost has been swapped out, so we should resume the pending
249 // network response and allow the pending RenderFrameHost to commit.
250 void SwappedOut(RenderFrameHostImpl* render_frame_host);
251
252 // Called when a renderer's frame navigates. 248 // Called when a renderer's frame navigates.
253 void DidNavigateFrame(RenderFrameHostImpl* render_frame_host); 249 void DidNavigateFrame(RenderFrameHostImpl* render_frame_host);
254 250
255 // Called when a renderer sets its opener to null. 251 // Called when a renderer sets its opener to null.
256 void DidDisownOpener(RenderViewHost* render_view_host); 252 void DidDisownOpener(RenderViewHost* render_view_host);
257 253
258 // Helper method to create and initialize a RenderFrameHost. If |swapped_out| 254 // Helper method to create and initialize a RenderFrameHost. If |swapped_out|
259 // is true, it will be initially placed on the swapped out hosts list. 255 // is true, it will be initially placed on the swapped out hosts list.
260 // Returns the routing id of the *view* associated with the frame. 256 // Returns the routing id of the *view* associated with the frame.
261 int CreateRenderFrame(SiteInstance* instance, 257 int CreateRenderFrame(SiteInstance* instance,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 bool IsRVHOnSwappedOutList(RenderViewHostImpl* rvh) const; 293 bool IsRVHOnSwappedOutList(RenderViewHostImpl* rvh) const;
298 bool IsOnSwappedOutList(RenderFrameHostImpl* rfh) const; 294 bool IsOnSwappedOutList(RenderFrameHostImpl* rfh) const;
299 295
300 // Returns the swapped out RenderViewHost or RenderFrameHost for the given 296 // Returns the swapped out RenderViewHost or RenderFrameHost for the given
301 // SiteInstance, if any. This method is *deprecated* and 297 // SiteInstance, if any. This method is *deprecated* and
302 // GetRenderFrameProxyHost should be used. 298 // GetRenderFrameProxyHost should be used.
303 RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance) const; 299 RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance) const;
304 RenderFrameProxyHost* GetRenderFrameProxyHost( 300 RenderFrameProxyHost* GetRenderFrameProxyHost(
305 SiteInstance* instance) const; 301 SiteInstance* instance) const;
306 302
307 // Runs the unload handler in the current page, when we know that a pending
308 // cross-process navigation is going to commit. We may initiate a transfer
309 // to a new process after this completes or times out.
310 void SwapOutOldPage();
311
312 // Deletes a RenderFrameHost that was pending shutdown. 303 // Deletes a RenderFrameHost that was pending shutdown.
313 void ClearPendingShutdownRFHForSiteInstance(int32 site_instance_id, 304 void ClearPendingShutdownRFHForSiteInstance(int32 site_instance_id,
314 RenderFrameHostImpl* rfh); 305 RenderFrameHostImpl* rfh);
315 306
316 // Deletes any proxy hosts associated with this node. Used during destruction 307 // Deletes any proxy hosts associated with this node. Used during destruction
317 // of WebContentsImpl. 308 // of WebContentsImpl.
318 void ResetProxyHosts(); 309 void ResetProxyHosts();
319 310
320 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy 311 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy
321 // that has the given SiteInstance and is associated with this 312 // that has the given SiteInstance and is associated with this
(...skipping 17 matching lines...) Expand all
339 // select a renderer to use for the navigation. 330 // select a renderer to use for the navigation.
340 void CommitNavigation(const NavigationBeforeCommitInfo& info); 331 void CommitNavigation(const NavigationBeforeCommitInfo& info);
341 332
342 private: 333 private:
343 friend class RenderFrameHostManagerTest; 334 friend class RenderFrameHostManagerTest;
344 friend class TestWebContents; 335 friend class TestWebContents;
345 336
346 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest, 337 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest,
347 CreateCrossProcessSubframeProxies); 338 CreateCrossProcessSubframeProxies);
348 339
349 // Tracks information about a navigation while a cross-process transition is
350 // in progress, in case we need to transfer it to a new RenderFrameHost.
351 // When a request is being transferred, deleting the PendingNavigationParams,
352 // and thus |cross_site_transferring_request|, will cancel the request being
353 // transferred, unless its ReleaseRequest method has been called.
354 struct PendingNavigationParams {
355 PendingNavigationParams(
356 const GlobalRequestID& global_request_id,
357 scoped_ptr<CrossSiteTransferringRequest>
358 cross_site_transferring_request,
359 const std::vector<GURL>& transfer_url,
360 Referrer referrer,
361 PageTransition page_transition,
362 int render_frame_id,
363 bool should_replace_current_entry);
364 ~PendingNavigationParams();
365
366 // The child ID and request ID for the pending navigation. Present whether
367 // |request_transfer| is NULL or not.
368 GlobalRequestID global_request_id;
369
370 // If a pending request needs to be transferred to another process, this
371 // owns the request until it's transferred to the new process, so it will be
372 // cleaned up if the navigation is cancelled. Otherwise, this is NULL.
373 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request;
374
375 // If |request_transfer| is non-NULL, the values below are all set.
376
377 // The first entry is the original request URL, and the last entry is the
378 // destination URL to request in the new process.
379 std::vector<GURL> transfer_url_chain;
380
381 // This is the referrer to use for the request in the new process.
382 Referrer referrer;
383
384 // This is the transition type for the original navigation.
385 PageTransition page_transition;
386
387 // This is the frame routing ID to use in RequestTransferURL.
388 int render_frame_id;
389
390 // This is whether the navigation should replace the current history entry.
391 bool should_replace_current_entry;
392 };
393
394 // Returns the current navigation request (used in the PlzNavigate navigation 340 // Returns the current navigation request (used in the PlzNavigate navigation
395 // logic refactoring project). 341 // logic refactoring project).
396 NavigationRequest* navigation_request_for_testing() const { 342 NavigationRequest* navigation_request_for_testing() const {
397 return navigation_request_.get(); } 343 return navigation_request_.get(); }
398 344
399 // Used with FrameTree::ForEach to erase RenderFrameProxyHosts from a 345 // Used with FrameTree::ForEach to erase RenderFrameProxyHosts from a
400 // FrameTreeNode's RenderFrameHostManager. 346 // FrameTreeNode's RenderFrameHostManager.
401 static bool ClearProxiesInSiteInstance(int32 site_instance_id, 347 static bool ClearProxiesInSiteInstance(int32 site_instance_id,
402 FrameTreeNode* node); 348 FrameTreeNode* node);
403 349
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 428
483 // Initialization for RenderFrameHost uses the same sequence as InitRenderView 429 // Initialization for RenderFrameHost uses the same sequence as InitRenderView
484 // above. 430 // above.
485 bool InitRenderFrame(RenderFrameHost* render_frame_host); 431 bool InitRenderFrame(RenderFrameHost* render_frame_host);
486 432
487 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this 433 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this
488 // doesn't require the pending render_frame_host_ pointer to be non-NULL, 434 // doesn't require the pending render_frame_host_ pointer to be non-NULL,
489 // since there could be Web UI switching as well. Call this for every commit. 435 // since there could be Web UI switching as well. Call this for every commit.
490 void CommitPending(); 436 void CommitPending();
491 437
438 // Runs the unload handler in the current page, after the new page has
439 // committed.
440 void SwapOutOldPage(RenderFrameHostImpl* old_render_frame_host);
441
492 // Shutdown all RenderFrameProxyHosts in a SiteInstance. This is called to 442 // Shutdown all RenderFrameProxyHosts in a SiteInstance. This is called to
493 // shutdown frames when all the frames in a SiteInstance are confirmed to be 443 // shutdown frames when all the frames in a SiteInstance are confirmed to be
494 // swapped out. 444 // swapped out.
495 void ShutdownRenderFrameProxyHostsInSiteInstance(int32 site_instance_id); 445 void ShutdownRenderFrameProxyHostsInSiteInstance(int32 site_instance_id);
496 446
497 // Helper method to terminate the pending RenderViewHost. 447 // Helper method to terminate the pending RenderViewHost.
498 void CancelPending(); 448 void CancelPending();
499 449
500 // Helper method to set the active RenderFrameHost. Returns the old 450 // Helper method to set the active RenderFrameHost. Returns the old
501 // RenderFrameHost and updates counts. 451 // RenderFrameHost and updates counts.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 // have an associated Web UI, in which case the Web UI pointer will be non- 493 // have an associated Web UI, in which case the Web UI pointer will be non-
544 // NULL. 494 // NULL.
545 // 495 //
546 // The |pending_web_ui_| may be non-NULL even when the 496 // The |pending_web_ui_| may be non-NULL even when the
547 // |pending_render_frame_host_| is NULL. This will happen when we're 497 // |pending_render_frame_host_| is NULL. This will happen when we're
548 // transitioning between two Web UI pages: the RFH won't be swapped, so the 498 // transitioning between two Web UI pages: the RFH won't be swapped, so the
549 // pending pointer will be unused, but there will be a pending Web UI 499 // pending pointer will be unused, but there will be a pending Web UI
550 // associated with the navigation. 500 // associated with the navigation.
551 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host_; 501 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host_;
552 502
553 // Tracks information about any current pending cross-process navigation. 503 // If a pending request needs to be transferred to another process, this
554 scoped_ptr<PendingNavigationParams> pending_nav_params_; 504 // owns the request until it's transferred to the new process, so it will be
505 // cleaned up if the navigation is cancelled. Otherwise, this is NULL.
506 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request_;
555 507
556 // Tracks information about any navigation paused after receiving response 508 // Tracks information about any navigation paused after receiving response
557 // headers. 509 // headers.
558 scoped_ptr<GlobalRequestID> response_started_id_; 510 scoped_ptr<GlobalRequestID> response_started_id_;
559 511
560 // If either of these is non-NULL, the pending navigation is to a chrome: 512 // If either of these is non-NULL, the pending navigation is to a chrome:
561 // page. The scoped_ptr is used if pending_web_ui_ != web_ui_, the WeakPtr is 513 // page. The scoped_ptr is used if pending_web_ui_ != web_ui_, the WeakPtr is
562 // used for when they reference the same object. If either is non-NULL, the 514 // used for when they reference the same object. If either is non-NULL, the
563 // other should be NULL. 515 // other should be NULL.
564 scoped_ptr<WebUIImpl> pending_web_ui_; 516 scoped_ptr<WebUIImpl> pending_web_ui_;
(...skipping 19 matching lines...) Expand all
584 scoped_ptr<NavigationRequest> navigation_request_; 536 scoped_ptr<NavigationRequest> navigation_request_;
585 537
586 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; 538 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_;
587 539
588 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); 540 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager);
589 }; 541 };
590 542
591 } // namespace content 543 } // namespace content
592 544
593 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ 545 #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