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

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

Issue 525583002: Fix RenderFrameHost lifetime and clean up CommitPending. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 2 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 <list>
9
8 #include "base/basictypes.h" 10 #include "base/basictypes.h"
9 #include "base/logging.h" 11 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
12 #include "content/browser/renderer_host/render_view_host_delegate.h" 14 #include "content/browser/renderer_host/render_view_host_delegate.h"
13 #include "content/browser/site_instance_impl.h" 15 #include "content/browser/site_instance_impl.h"
14 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
15 #include "content/public/browser/global_request_id.h" 17 #include "content/public/browser/global_request_id.h"
16 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 bool IsRVHOnSwappedOutList(RenderViewHostImpl* rvh) const; 293 bool IsRVHOnSwappedOutList(RenderViewHostImpl* rvh) const;
292 bool IsOnSwappedOutList(RenderFrameHostImpl* rfh) const; 294 bool IsOnSwappedOutList(RenderFrameHostImpl* rfh) const;
293 295
294 // Returns the swapped out RenderViewHost or RenderFrameHost for the given 296 // Returns the swapped out RenderViewHost or RenderFrameHost for the given
295 // SiteInstance, if any. This method is *deprecated* and 297 // SiteInstance, if any. This method is *deprecated* and
296 // GetRenderFrameProxyHost should be used. 298 // GetRenderFrameProxyHost should be used.
297 RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance) const; 299 RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance) const;
298 RenderFrameProxyHost* GetRenderFrameProxyHost( 300 RenderFrameProxyHost* GetRenderFrameProxyHost(
299 SiteInstance* instance) const; 301 SiteInstance* instance) const;
300 302
301 // Deletes a RenderFrameHost that was pending shutdown. 303 // Returns whether |render_frame_host| is on the pending deletion list.
302 void ClearPendingShutdownRFHForSiteInstance(int32 site_instance_id, 304 bool IsPendingDeletion(RenderFrameHostImpl* render_frame_host);
303 RenderFrameHostImpl* rfh); 305
306 // If |render_frame_host| is on the pending deletion list, this deletes it.
307 // Returns whether it was deleted.
308 bool DeleteFromPendingList(RenderFrameHostImpl* render_frame_host);
304 309
305 // Deletes any proxy hosts associated with this node. Used during destruction 310 // Deletes any proxy hosts associated with this node. Used during destruction
306 // of WebContentsImpl. 311 // of WebContentsImpl.
307 void ResetProxyHosts(); 312 void ResetProxyHosts();
308 313
309 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy 314 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy
310 // that has the given SiteInstance and is associated with this 315 // that has the given SiteInstance and is associated with this
311 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found. 316 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found.
312 int GetRoutingIdForSiteInstance(SiteInstance* site_instance); 317 int GetRoutingIdForSiteInstance(SiteInstance* site_instance);
313 318
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 414
410 // Initialization for RenderFrameHost uses the same sequence as InitRenderView 415 // Initialization for RenderFrameHost uses the same sequence as InitRenderView
411 // above. 416 // above.
412 bool InitRenderFrame(RenderFrameHostImpl* render_frame_host); 417 bool InitRenderFrame(RenderFrameHostImpl* render_frame_host);
413 418
414 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this 419 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this
415 // doesn't require the pending render_frame_host_ pointer to be non-NULL, 420 // doesn't require the pending render_frame_host_ pointer to be non-NULL,
416 // since there could be Web UI switching as well. Call this for every commit. 421 // since there could be Web UI switching as well. Call this for every commit.
417 void CommitPending(); 422 void CommitPending();
418 423
419 // Runs the unload handler in the current page, after the new page has 424 // Runs the unload handler in the old RenderFrameHost, after the new
420 // committed. 425 // RenderFrameHost has committed. |old_render_frame_host| will either be
421 void SwapOutOldPage(RenderFrameHostImpl* old_render_frame_host); 426 // deleted or put on the pending delete list during this call.
427 void SwapOutOldFrame(scoped_ptr<RenderFrameHostImpl> old_render_frame_host);
428
429 // Holds |render_frame_host| until it can be deleted when its swap out ACK
430 // arrives.
431 void MoveToPendingDeleteHosts(
432 scoped_ptr<RenderFrameHostImpl> render_frame_host);
422 433
423 // Shutdown all RenderFrameProxyHosts in a SiteInstance. This is called to 434 // Shutdown all RenderFrameProxyHosts in a SiteInstance. This is called to
424 // shutdown frames when all the frames in a SiteInstance are confirmed to be 435 // shutdown frames when all the frames in a SiteInstance are confirmed to be
425 // swapped out. 436 // swapped out.
426 void ShutdownRenderFrameProxyHostsInSiteInstance(int32 site_instance_id); 437 void ShutdownRenderFrameProxyHostsInSiteInstance(int32 site_instance_id);
427 438
428 // Helper method to terminate the pending RenderViewHost. 439 // Helper method to terminate the pending RenderViewHost.
429 void CancelPending(); 440 void CancelPending();
430 441
431 // Helper method to set the active RenderFrameHost. Returns the old 442 // Helper method to set the active RenderFrameHost. Returns the old
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 // page. The scoped_ptr is used if pending_web_ui_ != web_ui_, the WeakPtr is 511 // page. The scoped_ptr is used if pending_web_ui_ != web_ui_, the WeakPtr is
501 // used for when they reference the same object. If either is non-NULL, the 512 // used for when they reference the same object. If either is non-NULL, the
502 // other should be NULL. 513 // other should be NULL.
503 scoped_ptr<WebUIImpl> pending_web_ui_; 514 scoped_ptr<WebUIImpl> pending_web_ui_;
504 base::WeakPtr<WebUIImpl> pending_and_current_web_ui_; 515 base::WeakPtr<WebUIImpl> pending_and_current_web_ui_;
505 516
506 // A map of site instance ID to RenderFrameProxyHosts. 517 // A map of site instance ID to RenderFrameProxyHosts.
507 typedef base::hash_map<int32, RenderFrameProxyHost*> RenderFrameProxyHostMap; 518 typedef base::hash_map<int32, RenderFrameProxyHost*> RenderFrameProxyHostMap;
508 RenderFrameProxyHostMap proxy_hosts_; 519 RenderFrameProxyHostMap proxy_hosts_;
509 520
510 // A map of RenderFrameHosts pending shutdown. 521 // A list of RenderFrameHosts waiting to shut down after swapping out. We use
511 typedef base::hash_map<int32, linked_ptr<RenderFrameHostImpl> > 522 // a linked list since we expect frequent deletes and no indexed access, and
512 RFHPendingDeleteMap; 523 // because sets don't appear to support linked_ptrs.
513 RFHPendingDeleteMap pending_delete_hosts_; 524 typedef std::list<linked_ptr<RenderFrameHostImpl> > RFHPendingDeleteList;
525 RFHPendingDeleteList pending_delete_hosts_;
514 526
515 // The intersitial page currently shown if any, not own by this class 527 // The intersitial page currently shown if any, not own by this class
516 // (the InterstitialPage is self-owned, it deletes itself when hidden). 528 // (the InterstitialPage is self-owned, it deletes itself when hidden).
517 InterstitialPageImpl* interstitial_page_; 529 InterstitialPageImpl* interstitial_page_;
518 530
519 NotificationRegistrar registrar_; 531 NotificationRegistrar registrar_;
520 532
521 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; 533 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_;
522 534
523 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); 535 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager);
524 }; 536 };
525 537
526 } // namespace content 538 } // namespace content
527 539
528 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ 540 #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