OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_TAB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ |
6 #define CONTENT_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ | 6 #define CONTENT_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_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/common/notification_observer.h" | 13 #include "content/common/notification_observer.h" |
14 #include "content/common/notification_registrar.h" | 14 #include "content/common/notification_registrar.h" |
| 15 #include "content/browser/site_instance.h" |
15 | 16 |
16 class WebUI; | 17 class WebUI; |
17 class InterstitialPage; | 18 class InterstitialPage; |
18 class NavigationController; | 19 class NavigationController; |
19 class NavigationEntry; | 20 class NavigationEntry; |
20 class Profile; | 21 class Profile; |
21 class RenderWidgetHostView; | 22 class RenderWidgetHostView; |
22 class RenderViewHost; | 23 class RenderViewHost; |
23 class SiteInstance; | |
24 | 24 |
25 // Manages RenderViewHosts for a TabContents. Normally there is only one and | 25 // Manages RenderViewHosts for a TabContents. Normally there is only one and |
26 // it is easy to do. But we can also have transitions of processes (and hence | 26 // it is easy to do. But we can also have transitions of processes (and hence |
27 // RenderViewHosts) that can get complex. | 27 // RenderViewHosts) that can get complex. |
28 class RenderViewHostManager | 28 class RenderViewHostManager |
29 : public RenderViewHostDelegate::RendererManagement, | 29 : public RenderViewHostDelegate::RendererManagement, |
30 public NotificationObserver { | 30 public NotificationObserver { |
31 public: | 31 public: |
32 // Functions implemented by our owner that we need. | 32 // Functions implemented by our owner that we need. |
33 // | 33 // |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 const NotificationDetails& details); | 179 const NotificationDetails& details); |
180 | 180 |
181 // Called when a RenderViewHost is about to be deleted. | 181 // Called when a RenderViewHost is about to be deleted. |
182 void RenderViewDeleted(RenderViewHost* rvh); | 182 void RenderViewDeleted(RenderViewHost* rvh); |
183 | 183 |
184 // Allows a caller to swap in a provided RenderViewHost to replace the | 184 // Allows a caller to swap in a provided RenderViewHost to replace the |
185 // current RenderViewHost. The current RVH will be shutdown and ultimately | 185 // current RenderViewHost. The current RVH will be shutdown and ultimately |
186 // deleted. | 186 // deleted. |
187 void SwapInRenderViewHost(RenderViewHost* rvh); | 187 void SwapInRenderViewHost(RenderViewHost* rvh); |
188 | 188 |
| 189 // Returns whether the given RenderViewHost is on the list of swapped out |
| 190 // RenderViewHosts. |
| 191 bool IsSwappedOut(RenderViewHost* rvh); |
| 192 |
189 private: | 193 private: |
190 friend class TestTabContents; | 194 friend class TestTabContents; |
191 friend class RenderViewHostManagerTest; | 195 friend class RenderViewHostManagerTest; |
192 | 196 |
193 // Returns whether this tab should transition to a new renderer for | 197 // Returns whether this tab should transition to a new renderer for |
194 // cross-site URLs. Enabled unless we see the --process-per-tab command line | 198 // cross-site URLs. Enabled unless we see the --process-per-tab command line |
195 // switch. Can be overridden in unit tests. | 199 // switch. Can be overridden in unit tests. |
196 bool ShouldTransitionCrossSite(); | 200 bool ShouldTransitionCrossSite(); |
197 | 201 |
198 // Returns true if the two navigation entries are incompatible in some way | 202 // Returns true if the two navigation entries are incompatible in some way |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 // have an associated Web UI, in which case the Web UI pointer will be non- | 262 // have an associated Web UI, in which case the Web UI pointer will be non- |
259 // NULL. | 263 // NULL. |
260 // | 264 // |
261 // The pending_web_ui may be non-NULL even when the pending_render_view_host_ | 265 // The pending_web_ui may be non-NULL even when the pending_render_view_host_ |
262 // is. This will happen when we're transitioning between two Web UI pages: | 266 // is. This will happen when we're transitioning between two Web UI pages: |
263 // the RVH won't be swapped, so the pending pointer will be unused, but there | 267 // the RVH won't be swapped, so the pending pointer will be unused, but there |
264 // will be a pending Web UI associated with the navigation. | 268 // will be a pending Web UI associated with the navigation. |
265 RenderViewHost* pending_render_view_host_; | 269 RenderViewHost* pending_render_view_host_; |
266 scoped_ptr<WebUI> pending_web_ui_; | 270 scoped_ptr<WebUI> pending_web_ui_; |
267 | 271 |
| 272 // A map of site instance ID to swapped out RenderViewHosts. |
| 273 typedef base::hash_map<int32, RenderViewHost*> RenderViewHostMap; |
| 274 RenderViewHostMap swapped_out_hosts_; |
| 275 |
268 // The intersitial page currently shown if any, not own by this class | 276 // The intersitial page currently shown if any, not own by this class |
269 // (the InterstitialPage is self-owned, it deletes itself when hidden). | 277 // (the InterstitialPage is self-owned, it deletes itself when hidden). |
270 InterstitialPage* interstitial_page_; | 278 InterstitialPage* interstitial_page_; |
271 | 279 |
272 NotificationRegistrar registrar_; | 280 NotificationRegistrar registrar_; |
273 | 281 |
274 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager); | 282 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager); |
275 }; | 283 }; |
276 | 284 |
277 // The "details" for a NOTIFY_RENDER_VIEW_HOST_CHANGED notification. The old | 285 // The "details" for a NOTIFY_RENDER_VIEW_HOST_CHANGED notification. The old |
278 // host can be NULL when the first RenderViewHost is set. | 286 // host can be NULL when the first RenderViewHost is set. |
279 struct RenderViewHostSwitchedDetails { | 287 struct RenderViewHostSwitchedDetails { |
280 RenderViewHost* old_host; | 288 RenderViewHost* old_host; |
281 RenderViewHost* new_host; | 289 RenderViewHost* new_host; |
282 }; | 290 }; |
283 | 291 |
284 #endif // CONTENT_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ | 292 #endif // CONTENT_BROWSER_TAB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ |
OLD | NEW |