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

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

Issue 30323002: [DRAFT] Create RenderFrameHostManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 1 month 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 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_VIEW_HOST_MANAGER_H_ 5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_VIEW_HOST_MANAGER_H_
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_VIEW_HOST_MANAGER_H_ 6 #define CONTENT_BROWSER_FRAME_HOST_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 #include "content/public/common/referrer.h"
18 18
19 19
20 namespace content { 20 namespace content {
21 class BrowserContext; 21 class BrowserContext;
22 class InterstitialPageImpl; 22 class InterstitialPageImpl;
23 class NavigationControllerImpl; 23 class NavigationControllerImpl;
24 class NavigationEntry; 24 class NavigationEntry;
25 class NavigationEntryImpl; 25 class NavigationEntryImpl;
26 class RenderFrameHostImpl;
26 class RenderViewHost; 27 class RenderViewHost;
27 class RenderViewHostImpl; 28 class RenderViewHostImpl;
28 class RenderViewHostManagerTest; 29 class RenderViewHostManagerTest;
29 class RenderWidgetHostDelegate; 30 class RenderWidgetHostDelegate;
30 class RenderWidgetHostView; 31 class RenderWidgetHostView;
31 class TestWebContents; 32 class TestWebContents;
32 class WebUIImpl; 33 class WebUIImpl;
33 34
34 // Manages RenderViewHosts for a WebContentsImpl. Normally there is only one and 35 // Manages RenderViewHosts for a WebContentsImpl. Normally there is only one and
35 // it is easy to do. But we can also have transitions of processes (and hence 36 // it is easy to do. But we can also have transitions of processes (and hence
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 void Init(BrowserContext* browser_context, 124 void Init(BrowserContext* browser_context,
124 SiteInstance* site_instance, 125 SiteInstance* site_instance,
125 int routing_id, 126 int routing_id,
126 int main_frame_routing_id); 127 int main_frame_routing_id);
127 128
128 // Returns the currently active RenderViewHost. 129 // Returns the currently active RenderViewHost.
129 // 130 //
130 // This will be non-NULL between Init() and Shutdown(). You may want to NULL 131 // This will be non-NULL between Init() and Shutdown(). You may want to NULL
131 // check it in many cases, however. Windows can send us messages during the 132 // check it in many cases, however. Windows can send us messages during the
132 // destruction process after it has been shut down. 133 // destruction process after it has been shut down.
134 // TODO(creis): Change to RenderFrameHostImpl.
133 RenderViewHostImpl* current_host() const; 135 RenderViewHostImpl* current_host() const;
136 RenderFrameHostImpl* current_frame() const {
137 return render_frame_host_;
138 }
134 139
135 // Returns the view associated with the current RenderViewHost, or NULL if 140 // Returns the view associated with the current RenderViewHost, or NULL if
136 // there is no current one. 141 // there is no current one.
137 RenderWidgetHostView* GetRenderWidgetHostView() const; 142 RenderWidgetHostView* GetRenderWidgetHostView() const;
138 143
139 // Returns the pending render view host, or NULL if there is no pending one. 144 // Returns the pending render view host, or NULL if there is no pending one.
145 // TODO(creis): Change to RenderFrameHostImpl.
140 RenderViewHostImpl* pending_render_view_host() const; 146 RenderViewHostImpl* pending_render_view_host() const;
141 147
142 // Returns the current committed Web UI or NULL if none applies. 148 // Returns the current committed Web UI or NULL if none applies.
143 WebUIImpl* web_ui() const { return web_ui_.get(); } 149 WebUIImpl* web_ui() const { return web_ui_.get(); }
144 150
145 // Returns the Web UI for the pending navigation, or NULL of none applies. 151 // Returns the Web UI for the pending navigation, or NULL of none applies.
146 WebUIImpl* pending_web_ui() const { 152 WebUIImpl* pending_web_ui() const {
147 return pending_web_ui_.get() ? pending_web_ui_.get() : 153 return pending_web_ui_.get() ? pending_web_ui_.get() :
148 pending_and_current_web_ui_.get(); 154 pending_and_current_web_ui_.get();
149 } 155 }
(...skipping 28 matching lines...) Expand all
178 184
179 // Called when a renderer's main frame navigates. 185 // Called when a renderer's main frame navigates.
180 void DidNavigateMainFrame(RenderViewHost* render_view_host); 186 void DidNavigateMainFrame(RenderViewHost* render_view_host);
181 187
182 // Called when a renderer sets its opener to null. 188 // Called when a renderer sets its opener to null.
183 void DidDisownOpener(RenderViewHost* render_view_host); 189 void DidDisownOpener(RenderViewHost* render_view_host);
184 190
185 // Helper method to create a RenderViewHost. If |swapped_out| is true, it 191 // Helper method to create a RenderViewHost. If |swapped_out| is true, it
186 // will be initially placed on the swapped out hosts list. Otherwise, it 192 // will be initially placed on the swapped out hosts list. Otherwise, it
187 // will be used for a pending cross-site navigation. 193 // will be used for a pending cross-site navigation.
188 int CreateRenderView(SiteInstance* instance, 194 int CreateRenderFrame(SiteInstance* instance,
189 int opener_route_id, 195 int opener_route_id,
190 bool swapped_out, 196 bool swapped_out,
191 bool hidden); 197 bool hidden);
192 198
193 // Called when a provisional load on the given renderer is aborted. 199 // Called when a provisional load on the given renderer is aborted.
194 void RendererAbortedProvisionalLoad(RenderViewHost* render_view_host); 200 void RendererAbortedProvisionalLoad(RenderViewHost* render_view_host);
195 201
196 // Sets the passed passed interstitial as the currently showing interstitial. 202 // Sets the passed passed interstitial as the currently showing interstitial.
197 // |interstitial_page| should be non NULL (use the remove_interstitial_page 203 // |interstitial_page| should be non NULL (use the remove_interstitial_page
198 // method to unset the interstitial) and no interstitial page should be set 204 // method to unset the interstitial) and no interstitial page should be set
199 // when there is already a non NULL interstitial page set. 205 // when there is already a non NULL interstitial page set.
200 void set_interstitial_page(InterstitialPageImpl* interstitial_page) { 206 void set_interstitial_page(InterstitialPageImpl* interstitial_page) {
201 DCHECK(!interstitial_page_ && interstitial_page); 207 DCHECK(!interstitial_page_ && interstitial_page);
(...skipping 25 matching lines...) Expand all
227 int64 frame_id) OVERRIDE; 233 int64 frame_id) OVERRIDE;
228 234
229 // NotificationObserver implementation. 235 // NotificationObserver implementation.
230 virtual void Observe(int type, 236 virtual void Observe(int type,
231 const NotificationSource& source, 237 const NotificationSource& source,
232 const NotificationDetails& details) OVERRIDE; 238 const NotificationDetails& details) OVERRIDE;
233 239
234 // Called when a RenderViewHost is about to be deleted. 240 // Called when a RenderViewHost is about to be deleted.
235 void RenderViewDeleted(RenderViewHost* rvh); 241 void RenderViewDeleted(RenderViewHost* rvh);
236 242
237 // Returns whether the given RenderViewHost is on the list of swapped out 243 // Returns whether the given RenderFrameHost is on the list of swapped out
238 // RenderViewHosts. 244 // RenderFrameHosts.
239 bool IsOnSwappedOutList(RenderViewHost* rvh) const; 245 bool IsOnSwappedOutList(RenderFrameHostImpl* rfh) const;
240 246
241 // Returns the swapped out RenderViewHost for the given SiteInstance, if any. 247 // Returns the swapped out RenderViewHost for the given SiteInstance, if any.
242 RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance); 248 RenderViewHostImpl* GetSwappedOutRenderViewHost(SiteInstance* instance);
249 RenderFrameHostImpl* GetSwappedOutRenderFrameHost(SiteInstance* instance);
243 250
244 // Runs the unload handler in the current page, when we know that a pending 251 // Runs the unload handler in the current page, when we know that a pending
245 // cross-process navigation is going to commit. We may initiate a transfer 252 // cross-process navigation is going to commit. We may initiate a transfer
246 // to a new process after this completes or times out. 253 // to a new process after this completes or times out.
247 void SwapOutOldPage(); 254 void SwapOutOldPage();
248 255
249 private: 256 private:
250 friend class RenderViewHostManagerTest; 257 friend class RenderViewHostManagerTest;
251 friend class TestWebContents; 258 friend class TestWebContents;
252 259
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 const NavigationEntryImpl* new_entry) const; 315 const NavigationEntryImpl* new_entry) const;
309 316
310 // Returns an appropriate SiteInstance object for the given NavigationEntry, 317 // Returns an appropriate SiteInstance object for the given NavigationEntry,
311 // possibly reusing the current SiteInstance. 318 // possibly reusing the current SiteInstance.
312 // Never called if --process-per-tab is used. 319 // Never called if --process-per-tab is used.
313 SiteInstance* GetSiteInstanceForEntry( 320 SiteInstance* GetSiteInstanceForEntry(
314 const NavigationEntryImpl& entry, 321 const NavigationEntryImpl& entry,
315 SiteInstance* curr_instance); 322 SiteInstance* curr_instance);
316 323
317 // Sets up the necessary state for a new RenderViewHost with the given opener. 324 // Sets up the necessary state for a new RenderViewHost with the given opener.
318 bool InitRenderView(RenderViewHost* render_view_host, int opener_route_id); 325 // This also initializes the RenderView if necessary.
326 // TODO(creis): opener_route_id is currently for the RenderView but should be
327 // the RenderFrame, since frames can have openers.
328 bool InitRenderView(RenderViewHost* render_view_host,
329 int opener_route_id);
319 330
320 // Sets the pending RenderViewHost/WebUI to be the active one. Note that this 331 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this
321 // doesn't require the pending render_view_host_ pointer to be non-NULL, since 332 // doesn't require the pending render_frame_host_ pointer to be non-NULL,
322 // there could be Web UI switching as well. Call this for every commit. 333 // since there could be Web UI switching as well. Call this for every commit.
323 void CommitPending(); 334 void CommitPending();
324 335
325 // Shutdown all RenderViewHosts in a SiteInstance. This is called 336 // Shutdown all RenderFrameHosts in a SiteInstance. This is called to shutdown
326 // to shutdown views when all the views in a SiteInstance are 337 // frames when all the views in a SiteInstance are confirmed to be swapped
327 // confirmed to be swapped out. 338 // out.
328 void ShutdownRenderViewHostsInSiteInstance(int32 site_instance_id); 339 void ShutdownRenderFrameHostsInSiteInstance(int32 site_instance_id);
329 340
330 // Helper method to terminate the pending RenderViewHost. 341 // Helper method to terminate the pending RenderViewHost.
331 void CancelPending(); 342 void CancelPending();
332 343
333 RenderViewHostImpl* UpdateRendererStateForNavigate( 344 RenderFrameHostImpl* UpdateRendererStateForNavigate(
334 const NavigationEntryImpl& entry); 345 const NavigationEntryImpl& entry);
335 346
336 // Called when a renderer process is starting to close. We should not 347 // Called when a renderer process is starting to close. We should not
337 // schedule new navigations in its swapped out RenderViewHosts after this. 348 // schedule new navigations in its swapped out RenderFrameHosts after this.
338 void RendererProcessClosing(RenderProcessHost* render_process_host); 349 void RendererProcessClosing(RenderProcessHost* render_process_host);
339 350
340 // Our delegate, not owned by us. Guaranteed non-NULL. 351 // Our delegate, not owned by us. Guaranteed non-NULL.
341 Delegate* delegate_; 352 Delegate* delegate_;
342 353
343 // Whether a navigation requiring different RenderView's is pending. This is 354 // Whether a navigation requiring different RenderFrames is pending. This is
344 // either cross-site request is (in the new process model), or when required 355 // either for cross-site requests or when required for the view type (like
345 // for the view type (like view source versus not). 356 // WebUI).
346 bool cross_navigation_pending_; 357 bool cross_navigation_pending_;
347 358
348 // Implemented by the owner of this class, these delegates are installed into 359 // Implemented by the owner of this class. These delegates are installed into
349 // all the RenderViewHosts that we create. 360 // all the RenderViewHosts that we create.
350 RenderViewHostDelegate* render_view_delegate_; 361 RenderViewHostDelegate* render_view_delegate_;
351 RenderWidgetHostDelegate* render_widget_delegate_; 362 RenderWidgetHostDelegate* render_widget_delegate_;
352 363
353 // Our RenderView host and its associated Web UI (if any, will be NULL for 364 // Our RenderFrameHost and its associated Web UI (if any, will be NULL for
354 // non-DOM-UI pages). This object is responsible for all communication with 365 // non-Web-UI pages). This object is responsible for all communication with
355 // a child RenderView instance. 366 // a child RenderFrame instance.
356 RenderViewHostImpl* render_view_host_; 367 // For now, RenderFrameHost keeps a RenderViewHost in its SiteInstance alive.
368 // Eventually, RenderViewHost will be replaced with a page context.
369 RenderFrameHostImpl* render_frame_host_;
357 scoped_ptr<WebUIImpl> web_ui_; 370 scoped_ptr<WebUIImpl> web_ui_;
358 371
359 // A RenderViewHost used to load a cross-site page. This remains hidden 372 // A RenderFrameHost used to load a cross-site page. This remains hidden
360 // while a cross-site request is pending until it calls DidNavigate. It may 373 // while a cross-site request is pending until it calls DidNavigate. It may
361 // have an associated Web UI, in which case the Web UI pointer will be non- 374 // have an associated Web UI, in which case the Web UI pointer will be non-
362 // NULL. 375 // NULL.
363 // 376 //
364 // The |pending_web_ui_| may be non-NULL even when the 377 // The |pending_web_ui_| may be non-NULL even when the
365 // |pending_render_view_host_| is NULL. This will happen when we're 378 // |pending_render_view_host_| is NULL. This will happen when we're
366 // transitioning between two Web UI pages: the RVH won't be swapped, so the 379 // transitioning between two Web UI pages: the RFH won't be swapped, so the
367 // pending pointer will be unused, but there will be a pending Web UI 380 // pending pointer will be unused, but there will be a pending Web UI
368 // associated with the navigation. 381 // associated with the navigation.
369 RenderViewHostImpl* pending_render_view_host_; 382 RenderFrameHostImpl* pending_render_frame_host_;
370 383
371 // Tracks information about any current pending cross-process navigation. 384 // Tracks information about any current pending cross-process navigation.
372 scoped_ptr<PendingNavigationParams> pending_nav_params_; 385 scoped_ptr<PendingNavigationParams> pending_nav_params_;
373 386
374 // If either of these is non-NULL, the pending navigation is to a chrome: 387 // If either of these is non-NULL, the pending navigation is to a chrome:
375 // page. The scoped_ptr is used if pending_web_ui_ != web_ui_, the WeakPtr is 388 // page. The scoped_ptr is used if pending_web_ui_ != web_ui_, the WeakPtr is
376 // used for when they reference the same object. If either is non-NULL, the 389 // used for when they reference the same object. If either is non-NULL, the
377 // other should be NULL. 390 // other should be NULL.
378 scoped_ptr<WebUIImpl> pending_web_ui_; 391 scoped_ptr<WebUIImpl> pending_web_ui_;
379 base::WeakPtr<WebUIImpl> pending_and_current_web_ui_; 392 base::WeakPtr<WebUIImpl> pending_and_current_web_ui_;
380 393
381 // A map of site instance ID to swapped out RenderViewHosts. This may include 394 // A map of site instance ID to swapped out RenderFrameHosts. This may
382 // pending_render_view_host_ for navigations to existing entries. 395 // include pending_render_frame_host_ for navigations to existing entries.
383 typedef base::hash_map<int32, RenderViewHostImpl*> RenderViewHostMap; 396 typedef base::hash_map<int32, RenderFrameHostImpl*> RenderFrameHostMap;
384 RenderViewHostMap swapped_out_hosts_; 397 RenderFrameHostMap swapped_out_hosts_;
385 398
386 // The intersitial page currently shown if any, not own by this class 399 // The intersitial page currently shown if any, not own by this class
387 // (the InterstitialPage is self-owned, it deletes itself when hidden). 400 // (the InterstitialPage is self-owned, it deletes itself when hidden).
388 InterstitialPageImpl* interstitial_page_; 401 InterstitialPageImpl* interstitial_page_;
389 402
390 NotificationRegistrar registrar_; 403 NotificationRegistrar registrar_;
391 404
392 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager); 405 DISALLOW_COPY_AND_ASSIGN(RenderViewHostManager);
393 }; 406 };
394 407
395 } // namespace content 408 } // namespace content
396 409
397 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_VIEW_HOST_MANAGER_H_ 410 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_VIEW_HOST_MANAGER_H_
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.cc ('k') | content/browser/frame_host/render_view_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698