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

Side by Side Diff: content/browser/web_contents/render_view_host_manager.h

Issue 15682009: Eliminate SwapOut message parameters, keeping state in RVHM instead. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move pending_nav_params_ to RVHM Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
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"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // Notifies the regular and pending RenderViewHosts that a load is or is not 159 // Notifies the regular and pending RenderViewHosts that a load is or is not
160 // happening. Even though the message is only for one of them, we don't know 160 // happening. Even though the message is only for one of them, we don't know
161 // which one so we tell both. 161 // which one so we tell both.
162 void SetIsLoading(bool is_loading); 162 void SetIsLoading(bool is_loading);
163 163
164 // Whether to close the tab or not when there is a hang during an unload 164 // Whether to close the tab or not when there is a hang during an unload
165 // handler. If we are mid-crosssite navigation, then we should proceed 165 // handler. If we are mid-crosssite navigation, then we should proceed
166 // with the navigation instead of closing the tab. 166 // with the navigation instead of closing the tab.
167 bool ShouldCloseTabOnUnresponsiveRenderer(); 167 bool ShouldCloseTabOnUnresponsiveRenderer();
168 168
169 // The RenderViewHost has been swapped out, so we should resume the pending
170 // network response and allow the pending RenderViewHost to commit.
171 void SwappedOut(RenderViewHost* render_view_host);
172
169 // Called when a renderer's main frame navigates. 173 // Called when a renderer's main frame navigates.
170 void DidNavigateMainFrame(RenderViewHost* render_view_host); 174 void DidNavigateMainFrame(RenderViewHost* render_view_host);
171 175
172 // Called when a renderer sets its opener to null. 176 // Called when a renderer sets its opener to null.
173 void DidDisownOpener(RenderViewHost* render_view_host); 177 void DidDisownOpener(RenderViewHost* render_view_host);
174 178
175 // Helper method to create a RenderViewHost. If |swapped_out| is true, it 179 // Helper method to create a RenderViewHost. If |swapped_out| is true, it
176 // will be initially placed on the swapped out hosts list. Otherwise, it 180 // will be initially placed on the swapped out hosts list. Otherwise, it
177 // will be used for a pending cross-site navigation. 181 // will be used for a pending cross-site navigation.
178 int CreateRenderView(SiteInstance* instance, 182 int CreateRenderView(SiteInstance* instance,
(...skipping 20 matching lines...) Expand all
199 203
200 // Returns the currently showing interstitial, NULL if no interstitial is 204 // Returns the currently showing interstitial, NULL if no interstitial is
201 // showing. 205 // showing.
202 InterstitialPageImpl* interstitial_page() const { return interstitial_page_; } 206 InterstitialPageImpl* interstitial_page() const { return interstitial_page_; }
203 207
204 // RenderViewHostDelegate::RendererManagement implementation. 208 // RenderViewHostDelegate::RendererManagement implementation.
205 virtual void ShouldClosePage( 209 virtual void ShouldClosePage(
206 bool for_cross_site_transition, 210 bool for_cross_site_transition,
207 bool proceed, 211 bool proceed,
208 const base::TimeTicks& proceed_time) OVERRIDE; 212 const base::TimeTicks& proceed_time) OVERRIDE;
209 virtual void OnCrossSiteResponse(int new_render_process_host_id, 213 virtual void OnCrossSiteResponse(
nasko 2013/06/06 15:41:50 nit: Missing empty line between the two methods.
Charlie Reis 2013/06/06 16:33:09 This is consistent with other places that we imple
210 int new_request_id) OVERRIDE; 214 RenderViewHost* pending_render_view_host,
215 const GlobalRequestID& global_request_id) OVERRIDE;
211 216
212 // NotificationObserver implementation. 217 // NotificationObserver implementation.
213 virtual void Observe(int type, 218 virtual void Observe(int type,
214 const NotificationSource& source, 219 const NotificationSource& source,
215 const NotificationDetails& details) OVERRIDE; 220 const NotificationDetails& details) OVERRIDE;
216 221
217 // Called when a RenderViewHost is about to be deleted. 222 // Called when a RenderViewHost is about to be deleted.
218 void RenderViewDeleted(RenderViewHost* rvh); 223 void RenderViewDeleted(RenderViewHost* rvh);
219 224
220 // Returns whether the given RenderViewHost is on the list of swapped out 225 // Returns whether the given RenderViewHost is on the list of swapped out
221 // RenderViewHosts. 226 // RenderViewHosts.
222 bool IsOnSwappedOutList(RenderViewHost* rvh) const; 227 bool IsOnSwappedOutList(RenderViewHost* rvh) const;
223 228
224 // Returns the swapped out RenderViewHost for the given SiteInstance, if any. 229 // Returns the swapped out RenderViewHost for the given SiteInstance, if any.
225 RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance); 230 RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance);
226 231
232 // Runs the unload handler in the current page, when we know that a pending
233 // cross-process navigation is going to commit.
234 void SwapOutOldPage();
235
227 private: 236 private:
228 friend class RenderViewHostManagerTest; 237 friend class RenderViewHostManagerTest;
229 friend class TestWebContents; 238 friend class TestWebContents;
230 239
240 // Tracks information about a navigation while a cross-process transition is
241 // in progress.
242 // TODO(creis): Add transfer navigation params for http://crbug.com/238331.
243 struct PendingNavigationParams {
244 PendingNavigationParams();
245 explicit PendingNavigationParams(const GlobalRequestID& global_request_id);
246
247 GlobalRequestID global_request_id;
248 };
249
231 // Returns whether this tab should transition to a new renderer for 250 // Returns whether this tab should transition to a new renderer for
232 // cross-site URLs. Enabled unless we see the --process-per-tab command line 251 // cross-site URLs. Enabled unless we see the --process-per-tab command line
233 // switch. Can be overridden in unit tests. 252 // switch. Can be overridden in unit tests.
234 bool ShouldTransitionCrossSite(); 253 bool ShouldTransitionCrossSite();
235 254
236 // Returns true if the two navigation entries are incompatible in some way 255 // Returns true if the two navigation entries are incompatible in some way
237 // other than site instances. Cases where this can happen include Web UI 256 // other than site instances. Cases where this can happen include Web UI
238 // to regular web pages. It will cause us to swap RenderViewHosts (and hence 257 // to regular web pages. It will cause us to swap RenderViewHosts (and hence
239 // RenderProcessHosts) even if the site instance would otherwise be the same. 258 // RenderProcessHosts) even if the site instance would otherwise be the same.
240 // As part of this, we'll also force new SiteInstances and BrowsingInstances. 259 // As part of this, we'll also force new SiteInstances and BrowsingInstances.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // have an associated Web UI, in which case the Web UI pointer will be non- 315 // have an associated Web UI, in which case the Web UI pointer will be non-
297 // NULL. 316 // NULL.
298 // 317 //
299 // The |pending_web_ui_| may be non-NULL even when the 318 // The |pending_web_ui_| may be non-NULL even when the
300 // |pending_render_view_host_| is NULL. This will happen when we're 319 // |pending_render_view_host_| is NULL. This will happen when we're
301 // transitioning between two Web UI pages: the RVH won't be swapped, so the 320 // transitioning between two Web UI pages: the RVH won't be swapped, so the
302 // pending pointer will be unused, but there will be a pending Web UI 321 // pending pointer will be unused, but there will be a pending Web UI
303 // associated with the navigation. 322 // associated with the navigation.
304 RenderViewHostImpl* pending_render_view_host_; 323 RenderViewHostImpl* pending_render_view_host_;
305 324
325 // Tracks information about any current pending cross-process navigation.
326 scoped_ptr<PendingNavigationParams> pending_nav_params_;
327
306 // If either of these is non-NULL, the pending navigation is to a chrome: 328 // If either of these is non-NULL, the pending navigation is to a chrome:
307 // page. The scoped_ptr is used if pending_web_ui_ != web_ui_, the WeakPtr is 329 // page. The scoped_ptr is used if pending_web_ui_ != web_ui_, the WeakPtr is
308 // used for when they reference the same object. If either is non-NULL, the 330 // used for when they reference the same object. If either is non-NULL, the
309 // other should be NULL. 331 // other should be NULL.
310 scoped_ptr<WebUIImpl> pending_web_ui_; 332 scoped_ptr<WebUIImpl> pending_web_ui_;
311 base::WeakPtr<WebUIImpl> pending_and_current_web_ui_; 333 base::WeakPtr<WebUIImpl> pending_and_current_web_ui_;
312 334
313 // A map of site instance ID to swapped out RenderViewHosts. This may include 335 // A map of site instance ID to swapped out RenderViewHosts. This may include
314 // pending_render_view_host_ for navigations to existing entries. 336 // pending_render_view_host_ for navigations to existing entries.
315 typedef base::hash_map<int32, RenderViewHostImpl*> RenderViewHostMap; 337 typedef base::hash_map<int32, RenderViewHostImpl*> RenderViewHostMap;
316 RenderViewHostMap swapped_out_hosts_; 338 RenderViewHostMap swapped_out_hosts_;
317 339
318 // The intersitial page currently shown if any, not own by this class 340 // The intersitial page currently shown if any, not own by this class
319 // (the InterstitialPage is self-owned, it deletes itself when hidden). 341 // (the InterstitialPage is self-owned, it deletes itself when hidden).
320 InterstitialPageImpl* interstitial_page_; 342 InterstitialPageImpl* interstitial_page_;
321 343
322 NotificationRegistrar registrar_; 344 NotificationRegistrar registrar_;
323 345
324 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager); 346 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager);
325 }; 347 };
326 348
327 } // namespace content 349 } // namespace content
328 350
329 #endif // CONTENT_BROWSER_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_ 351 #endif // CONTENT_BROWSER_WEB_CONTENTS_RENDER_VIEW_HOST_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698