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 "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/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
16 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
17 #include "content/public/common/referrer.h" | 18 #include "content/public/common/referrer.h" |
18 | 19 |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 class BrowserContext; | 22 class BrowserContext; |
22 class CrossProcessFrameConnector; | 23 class CrossProcessFrameConnector; |
23 class CrossSiteTransferringRequest; | 24 class CrossSiteTransferringRequest; |
24 class InterstitialPageImpl; | 25 class InterstitialPageImpl; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 virtual void CreateViewAndSetSizeForRVH(RenderViewHost* rvh) = 0; | 107 virtual void CreateViewAndSetSizeForRVH(RenderViewHost* rvh) = 0; |
107 | 108 |
108 // Returns true if views created for this delegate should be created in a | 109 // Returns true if views created for this delegate should be created in a |
109 // hidden state. | 110 // hidden state. |
110 virtual bool IsHidden() = 0; | 111 virtual bool IsHidden() = 0; |
111 | 112 |
112 protected: | 113 protected: |
113 virtual ~Delegate() {} | 114 virtual ~Delegate() {} |
114 }; | 115 }; |
115 | 116 |
| 117 // Used with FrameTree::ForEach to delete RenderFrameHosts pending shutdown |
| 118 // from a FrameTreeNode's RenderFrameHostManager. Used during destruction of |
| 119 // WebContentsImpl. |
| 120 static bool ClearRFHsPendingShutdown(FrameTreeNode* node); |
| 121 |
116 // All three delegate pointers must be non-NULL and are not owned by this | 122 // All three delegate pointers must be non-NULL and are not owned by this |
117 // class. They must outlive this class. The RenderViewHostDelegate and | 123 // class. They must outlive this class. The RenderViewHostDelegate and |
118 // RenderWidgetHostDelegate are what will be installed into all | 124 // RenderWidgetHostDelegate are what will be installed into all |
119 // RenderViewHosts that are created. | 125 // RenderViewHosts that are created. |
120 // | 126 // |
121 // You must call Init() before using this class. | 127 // You must call Init() before using this class. |
122 RenderFrameHostManager( | 128 RenderFrameHostManager( |
123 FrameTreeNode* frame_tree_node, | 129 FrameTreeNode* frame_tree_node, |
124 RenderFrameHostDelegate* render_frame_delegate, | 130 RenderFrameHostDelegate* render_frame_delegate, |
125 RenderViewHostDelegate* render_view_delegate, | 131 RenderViewHostDelegate* render_view_delegate, |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 // SiteInstance, if any. | 269 // SiteInstance, if any. |
264 RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance) const; | 270 RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance) const; |
265 RenderFrameHostImpl* GetSwappedOutRenderFrameHost( | 271 RenderFrameHostImpl* GetSwappedOutRenderFrameHost( |
266 SiteInstance* instance) const; | 272 SiteInstance* instance) const; |
267 | 273 |
268 // Runs the unload handler in the current page, when we know that a pending | 274 // Runs the unload handler in the current page, when we know that a pending |
269 // cross-process navigation is going to commit. We may initiate a transfer | 275 // cross-process navigation is going to commit. We may initiate a transfer |
270 // to a new process after this completes or times out. | 276 // to a new process after this completes or times out. |
271 void SwapOutOldPage(); | 277 void SwapOutOldPage(); |
272 | 278 |
| 279 // Deletes a RenderFrameHost that was pending shutdown. |
| 280 void ClearPendingShutdownRFHForSiteInstance(int32 site_instance_id, |
| 281 RenderFrameHostImpl* rfh); |
| 282 |
273 private: | 283 private: |
274 friend class RenderFrameHostManagerTest; | 284 friend class RenderFrameHostManagerTest; |
275 friend class TestWebContents; | 285 friend class TestWebContents; |
276 | 286 |
277 // Tracks information about a navigation while a cross-process transition is | 287 // Tracks information about a navigation while a cross-process transition is |
278 // in progress, in case we need to transfer it to a new RenderFrameHost. | 288 // in progress, in case we need to transfer it to a new RenderFrameHost. |
279 // When a request is being transferred, deleting the PendingNavigationParams, | 289 // When a request is being transferred, deleting the PendingNavigationParams, |
280 // and thus |cross_site_transferring_request|, will cancel the request being | 290 // and thus |cross_site_transferring_request|, will cancel the request being |
281 // transferred, unless its ReleaseRequest method has been called. | 291 // transferred, unless its ReleaseRequest method has been called. |
282 struct PendingNavigationParams { | 292 struct PendingNavigationParams { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 // used for when they reference the same object. If either is non-NULL, the | 443 // used for when they reference the same object. If either is non-NULL, the |
434 // other should be NULL. | 444 // other should be NULL. |
435 scoped_ptr<WebUIImpl> pending_web_ui_; | 445 scoped_ptr<WebUIImpl> pending_web_ui_; |
436 base::WeakPtr<WebUIImpl> pending_and_current_web_ui_; | 446 base::WeakPtr<WebUIImpl> pending_and_current_web_ui_; |
437 | 447 |
438 // A map of site instance ID to swapped out RenderFrameHosts. This may | 448 // A map of site instance ID to swapped out RenderFrameHosts. This may |
439 // include pending_render_frame_host_ for navigations to existing entries. | 449 // include pending_render_frame_host_ for navigations to existing entries. |
440 typedef base::hash_map<int32, RenderFrameHostImpl*> RenderFrameHostMap; | 450 typedef base::hash_map<int32, RenderFrameHostImpl*> RenderFrameHostMap; |
441 RenderFrameHostMap swapped_out_hosts_; | 451 RenderFrameHostMap swapped_out_hosts_; |
442 | 452 |
| 453 // A map of RenderFrameHosts pending shutdown. |
| 454 typedef base::hash_map<int32, linked_ptr<RenderFrameHostImpl> > |
| 455 RFHPendingDeleteMap; |
| 456 RFHPendingDeleteMap pending_delete_hosts_; |
| 457 |
443 // The intersitial page currently shown if any, not own by this class | 458 // The intersitial page currently shown if any, not own by this class |
444 // (the InterstitialPage is self-owned, it deletes itself when hidden). | 459 // (the InterstitialPage is self-owned, it deletes itself when hidden). |
445 InterstitialPageImpl* interstitial_page_; | 460 InterstitialPageImpl* interstitial_page_; |
446 | 461 |
447 NotificationRegistrar registrar_; | 462 NotificationRegistrar registrar_; |
448 | 463 |
449 // When |render_frame_host_| is in a different process from its parent in | 464 // When |render_frame_host_| is in a different process from its parent in |
450 // the frame tree, this class connects its associated RenderWidgetHostView | 465 // the frame tree, this class connects its associated RenderWidgetHostView |
451 // to the proxy RenderFrameHost for the parent's renderer process. NULL | 466 // to the proxy RenderFrameHost for the parent's renderer process. NULL |
452 // when |render_frame_host_| is the frame tree root or is in the same | 467 // when |render_frame_host_| is the frame tree root or is in the same |
453 // process as its parent. | 468 // process as its parent. |
454 CrossProcessFrameConnector* cross_process_frame_connector_; | 469 CrossProcessFrameConnector* cross_process_frame_connector_; |
455 | 470 |
| 471 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; |
| 472 |
456 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); | 473 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); |
457 }; | 474 }; |
458 | 475 |
459 } // namespace content | 476 } // namespace content |
460 | 477 |
461 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ | 478 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ |
OLD | NEW |