| 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 // showing. | 211 // showing. |
| 211 InterstitialPageImpl* interstitial_page() const { return interstitial_page_; } | 212 InterstitialPageImpl* interstitial_page() const { return interstitial_page_; } |
| 212 | 213 |
| 213 // RenderViewHostDelegate::RendererManagement implementation. | 214 // RenderViewHostDelegate::RendererManagement implementation. |
| 214 virtual void ShouldClosePage( | 215 virtual void ShouldClosePage( |
| 215 bool for_cross_site_transition, | 216 bool for_cross_site_transition, |
| 216 bool proceed, | 217 bool proceed, |
| 217 const base::TimeTicks& proceed_time) OVERRIDE; | 218 const base::TimeTicks& proceed_time) OVERRIDE; |
| 218 virtual void OnCrossSiteResponse( | 219 virtual void OnCrossSiteResponse( |
| 219 RenderViewHost* pending_render_view_host, | 220 RenderViewHost* pending_render_view_host, |
| 220 const GlobalRequestID& global_request_id) OVERRIDE; | 221 const GlobalRequestID& global_request_id, |
| 222 bool is_transfer, |
| 223 const GURL& transfer_url, |
| 224 const Referrer& referrer, |
| 225 int64 frame_id) OVERRIDE; |
| 221 | 226 |
| 222 // NotificationObserver implementation. | 227 // NotificationObserver implementation. |
| 223 virtual void Observe(int type, | 228 virtual void Observe(int type, |
| 224 const NotificationSource& source, | 229 const NotificationSource& source, |
| 225 const NotificationDetails& details) OVERRIDE; | 230 const NotificationDetails& details) OVERRIDE; |
| 226 | 231 |
| 227 // Called when a RenderViewHost is about to be deleted. | 232 // Called when a RenderViewHost is about to be deleted. |
| 228 void RenderViewDeleted(RenderViewHost* rvh); | 233 void RenderViewDeleted(RenderViewHost* rvh); |
| 229 | 234 |
| 230 // Returns whether the given RenderViewHost is on the list of swapped out | 235 // Returns whether the given RenderViewHost is on the list of swapped out |
| 231 // RenderViewHosts. | 236 // RenderViewHosts. |
| 232 bool IsOnSwappedOutList(RenderViewHost* rvh) const; | 237 bool IsOnSwappedOutList(RenderViewHost* rvh) const; |
| 233 | 238 |
| 234 // Returns the swapped out RenderViewHost for the given SiteInstance, if any. | 239 // Returns the swapped out RenderViewHost for the given SiteInstance, if any. |
| 235 RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance); | 240 RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance); |
| 236 | 241 |
| 237 // Runs the unload handler in the current page, when we know that a pending | 242 // Runs the unload handler in the current page, when we know that a pending |
| 238 // cross-process navigation is going to commit. | 243 // cross-process navigation is going to commit. We may initiate a transfer |
| 244 // to a new process after this completes or times out. |
| 239 void SwapOutOldPage(); | 245 void SwapOutOldPage(); |
| 240 | 246 |
| 241 private: | 247 private: |
| 242 friend class RenderViewHostManagerTest; | 248 friend class RenderViewHostManagerTest; |
| 243 friend class TestWebContents; | 249 friend class TestWebContents; |
| 244 | 250 |
| 245 // Tracks information about a navigation while a cross-process transition is | 251 // Tracks information about a navigation while a cross-process transition is |
| 246 // in progress. | 252 // in progress, in case we need to transfer it to a new RenderViewHost. |
| 247 // TODO(creis): Add transfer navigation params for http://crbug.com/238331. | |
| 248 struct PendingNavigationParams { | 253 struct PendingNavigationParams { |
| 249 PendingNavigationParams(); | 254 PendingNavigationParams(); |
| 250 explicit PendingNavigationParams(const GlobalRequestID& global_request_id); | 255 PendingNavigationParams(const GlobalRequestID& global_request_id, |
| 256 bool is_transfer, |
| 257 const GURL& transfer_url, |
| 258 Referrer referrer, |
| 259 int64 frame_id); |
| 251 | 260 |
| 261 // The child ID and request ID for the pending navigation. Present whether |
| 262 // |is_transfer| is true or false. |
| 252 GlobalRequestID global_request_id; | 263 GlobalRequestID global_request_id; |
| 264 |
| 265 // Whether this pending navigation needs to be transferred to another |
| 266 // process than the one it was going to commit in. If so, the |
| 267 // |transfer_url|, |referrer|, and |frame_id| parameters will be set. |
| 268 bool is_transfer; |
| 269 |
| 270 // If |is_transfer|, this is the destination URL to request in the new |
| 271 // process. |
| 272 GURL transfer_url; |
| 273 |
| 274 // If |is_transfer|, this is the referrer to use for the request in the new |
| 275 // process. |
| 276 Referrer referrer; |
| 277 |
| 278 // If |is_transfer|, this is the frame ID to use in RequestTransferURL. |
| 279 int64 frame_id; |
| 253 }; | 280 }; |
| 254 | 281 |
| 255 // Returns whether this tab should transition to a new renderer for | 282 // Returns whether this tab should transition to a new renderer for |
| 256 // cross-site URLs. Enabled unless we see the --process-per-tab command line | 283 // cross-site URLs. Enabled unless we see the --process-per-tab command line |
| 257 // switch. Can be overridden in unit tests. | 284 // switch. Can be overridden in unit tests. |
| 258 bool ShouldTransitionCrossSite(); | 285 bool ShouldTransitionCrossSite(); |
| 259 | 286 |
| 260 // Returns true if the two navigation entries are incompatible in some way | 287 // Returns true if the two navigation entries are incompatible in some way |
| 261 // other than site instances. Cases where this can happen include Web UI | 288 // other than site instances. Cases where this can happen include Web UI |
| 262 // to regular web pages. It will cause us to swap RenderViewHosts (and hence | 289 // to regular web pages. It will cause us to swap RenderViewHosts (and hence |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 InterstitialPageImpl* interstitial_page_; | 379 InterstitialPageImpl* interstitial_page_; |
| 353 | 380 |
| 354 NotificationRegistrar registrar_; | 381 NotificationRegistrar registrar_; |
| 355 | 382 |
| 356 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager); | 383 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager); |
| 357 }; | 384 }; |
| 358 | 385 |
| 359 } // namespace content | 386 } // namespace content |
| 360 | 387 |
| 361 #endif // CONTENT_BROWSER_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ | 388 #endif // CONTENT_BROWSER_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ |
| OLD | NEW |