OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ |
6 #define CONTENT_BROWSER_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_RENDER_VIEW_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/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
16 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 17 #include "content/public/common/referrer.h" |
17 | 18 |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 class BrowserContext; | 21 class BrowserContext; |
21 class InterstitialPageImpl; | 22 class InterstitialPageImpl; |
22 class NavigationControllerImpl; | 23 class NavigationControllerImpl; |
23 class NavigationEntry; | 24 class NavigationEntry; |
24 class NavigationEntryImpl; | 25 class NavigationEntryImpl; |
25 class RenderViewHost; | 26 class RenderViewHost; |
26 class RenderViewHostImpl; | 27 class RenderViewHostImpl; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 // showing. | 206 // showing. |
206 InterstitialPageImpl* interstitial_page() const { return interstitial_page_; } | 207 InterstitialPageImpl* interstitial_page() const { return interstitial_page_; } |
207 | 208 |
208 // RenderViewHostDelegate::RendererManagement implementation. | 209 // RenderViewHostDelegate::RendererManagement implementation. |
209 virtual void ShouldClosePage( | 210 virtual void ShouldClosePage( |
210 bool for_cross_site_transition, | 211 bool for_cross_site_transition, |
211 bool proceed, | 212 bool proceed, |
212 const base::TimeTicks& proceed_time) OVERRIDE; | 213 const base::TimeTicks& proceed_time) OVERRIDE; |
213 virtual void OnCrossSiteResponse( | 214 virtual void OnCrossSiteResponse( |
214 RenderViewHost* pending_render_view_host, | 215 RenderViewHost* pending_render_view_host, |
215 const GlobalRequestID& global_request_id) OVERRIDE; | 216 const GlobalRequestID& global_request_id, |
| 217 bool is_transfer, |
| 218 const GURL& transfer_url, |
| 219 const Referrer& referrer, |
| 220 int64 frame_id) OVERRIDE; |
216 | 221 |
217 // NotificationObserver implementation. | 222 // NotificationObserver implementation. |
218 virtual void Observe(int type, | 223 virtual void Observe(int type, |
219 const NotificationSource& source, | 224 const NotificationSource& source, |
220 const NotificationDetails& details) OVERRIDE; | 225 const NotificationDetails& details) OVERRIDE; |
221 | 226 |
222 // Called when a RenderViewHost is about to be deleted. | 227 // Called when a RenderViewHost is about to be deleted. |
223 void RenderViewDeleted(RenderViewHost* rvh); | 228 void RenderViewDeleted(RenderViewHost* rvh); |
224 | 229 |
225 // Returns whether the given RenderViewHost is on the list of swapped out | 230 // Returns whether the given RenderViewHost is on the list of swapped out |
226 // RenderViewHosts. | 231 // RenderViewHosts. |
227 bool IsOnSwappedOutList(RenderViewHost* rvh) const; | 232 bool IsOnSwappedOutList(RenderViewHost* rvh) const; |
228 | 233 |
229 // Returns the swapped out RenderViewHost for the given SiteInstance, if any. | 234 // Returns the swapped out RenderViewHost for the given SiteInstance, if any. |
230 RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance); | 235 RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance); |
231 | 236 |
232 // Runs the unload handler in the current page, when we know that a pending | 237 // Runs the unload handler in the current page, when we know that a pending |
233 // cross-process navigation is going to commit. | 238 // cross-process navigation is going to commit. We may initiate a transfer |
| 239 // to a new process after this completes or times out. |
234 void SwapOutOldPage(); | 240 void SwapOutOldPage(); |
235 | 241 |
236 private: | 242 private: |
237 friend class RenderViewHostManagerTest; | 243 friend class RenderViewHostManagerTest; |
238 friend class TestWebContents; | 244 friend class TestWebContents; |
239 | 245 |
240 // Tracks information about a navigation while a cross-process transition is | 246 // Tracks information about a navigation while a cross-process transition is |
241 // in progress. | 247 // in progress, in case we need to transfer it to a new RenderViewHost. |
242 // TODO(creis): Add transfer navigation params for http://crbug.com/238331. | |
243 struct PendingNavigationParams { | 248 struct PendingNavigationParams { |
244 PendingNavigationParams(); | 249 PendingNavigationParams(); |
245 explicit PendingNavigationParams(const GlobalRequestID& global_request_id); | 250 PendingNavigationParams(const GlobalRequestID& global_request_id, |
| 251 bool is_transfer, |
| 252 const GURL& transfer_url, |
| 253 Referrer referrer, |
| 254 int64 frame_id); |
246 | 255 |
| 256 // The child ID and request ID for the pending navigation. Present whether |
| 257 // |is_transfer| is true or false. |
247 GlobalRequestID global_request_id; | 258 GlobalRequestID global_request_id; |
| 259 |
| 260 // Whether this pending navigation needs to be transferred to another |
| 261 // process than the one it was going to commit in. If so, the |
| 262 // |transfer_url|, |referrer|, and |frame_id| parameters will be set. |
| 263 bool is_transfer; |
| 264 |
| 265 // If |is_transfer|, this is the destination URL to request in the new |
| 266 // process. |
| 267 GURL transfer_url; |
| 268 |
| 269 // If |is_transfer|, this is the referrer to use for the request in the new |
| 270 // process. |
| 271 Referrer referrer; |
| 272 |
| 273 // If |is_transfer|, this is the frame ID to use in RequestTransferURL. |
| 274 int64 frame_id; |
248 }; | 275 }; |
249 | 276 |
250 // Returns whether this tab should transition to a new renderer for | 277 // Returns whether this tab should transition to a new renderer for |
251 // cross-site URLs. Enabled unless we see the --process-per-tab command line | 278 // cross-site URLs. Enabled unless we see the --process-per-tab command line |
252 // switch. Can be overridden in unit tests. | 279 // switch. Can be overridden in unit tests. |
253 bool ShouldTransitionCrossSite(); | 280 bool ShouldTransitionCrossSite(); |
254 | 281 |
255 // Returns true if the two navigation entries are incompatible in some way | 282 // Returns true if the two navigation entries are incompatible in some way |
256 // other than site instances. Cases where this can happen include Web UI | 283 // other than site instances. Cases where this can happen include Web UI |
257 // to regular web pages. It will cause us to swap RenderViewHosts (and hence | 284 // to regular web pages. It will cause us to swap RenderViewHosts (and hence |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 InterstitialPageImpl* interstitial_page_; | 369 InterstitialPageImpl* interstitial_page_; |
343 | 370 |
344 NotificationRegistrar registrar_; | 371 NotificationRegistrar registrar_; |
345 | 372 |
346 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager); | 373 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager); |
347 }; | 374 }; |
348 | 375 |
349 } // namespace content | 376 } // namespace content |
350 | 377 |
351 #endif // CONTENT_BROWSER_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ | 378 #endif // CONTENT_BROWSER_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ |
OLD | NEW |