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

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

Issue 444503002: Start using RenderFrameProxyHost objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Create view IFF frame is main frame Created 6 years, 4 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
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_FRAME_HOST_MANAGER_H_ 5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ 6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_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 13 matching lines...) Expand all
24 class CrossProcessFrameConnector; 24 class CrossProcessFrameConnector;
25 class CrossSiteTransferringRequest; 25 class CrossSiteTransferringRequest;
26 class InterstitialPageImpl; 26 class InterstitialPageImpl;
27 class FrameTreeNode; 27 class FrameTreeNode;
28 class NavigationControllerImpl; 28 class NavigationControllerImpl;
29 class NavigationEntry; 29 class NavigationEntry;
30 class NavigationEntryImpl; 30 class NavigationEntryImpl;
31 class NavigationRequest; 31 class NavigationRequest;
32 class RenderFrameHost; 32 class RenderFrameHost;
33 class RenderFrameHostDelegate; 33 class RenderFrameHostDelegate;
34 class RenderFrameHost;
34 class RenderFrameHostImpl; 35 class RenderFrameHostImpl;
35 class RenderFrameHostManagerTest; 36 class RenderFrameHostManagerTest;
36 class RenderFrameProxyHost; 37 class RenderFrameProxyHost;
37 class RenderViewHost; 38 class RenderViewHost;
38 class RenderViewHostImpl; 39 class RenderViewHostImpl;
39 class RenderWidgetHostDelegate; 40 class RenderWidgetHostDelegate;
40 class RenderWidgetHostView; 41 class RenderWidgetHostView;
41 class TestWebContents; 42 class TestWebContents;
42 class WebUIImpl; 43 class WebUIImpl;
43 44
44 // Manages RenderFrameHosts for a FrameTreeNode. This class acts as a state 45 // Manages RenderFrameHosts for a FrameTreeNode. This class acts as a state
45 // machine to make cross-process navigations in a frame possible. 46 // machine to make cross-process navigations in a frame possible.
46 class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver { 47 class CONTENT_EXPORT RenderFrameHostManager : public NotificationObserver {
47 public: 48 public:
48 // Functions implemented by our owner that we need. 49 // Functions implemented by our owner that we need.
49 // 50 //
50 // TODO(brettw) Clean this up! These are all the functions in WebContentsImpl 51 // TODO(brettw) Clean this up! These are all the functions in WebContentsImpl
51 // that are required to run this class. The design should probably be better 52 // that are required to run this class. The design should probably be better
52 // such that these are more clear. 53 // such that these are more clear.
53 // 54 //
54 // There is additional complexity that some of the functions we need in 55 // There is additional complexity that some of the functions we need in
55 // WebContentsImpl are inherited and non-virtual. These are named with 56 // WebContentsImpl are inherited and non-virtual. These are named with
56 // "RenderManager" so that the duplicate implementation of them will be clear. 57 // "RenderManager" so that the duplicate implementation of them will be clear.
57 class CONTENT_EXPORT Delegate { 58 class CONTENT_EXPORT Delegate {
58 public: 59 public:
59 // Initializes the given renderer if necessary and creates the view ID 60 // Initializes the given renderer if necessary and creates the view ID
60 // corresponding to this view host. If this method is not called and the 61 // corresponding to this view host. If this method is not called and the
61 // process is not shared, then the WebContentsImpl will act as though the 62 // process is not shared, then the WebContentsImpl will act as though the
62 // renderer is not running (i.e., it will render "sad tab"). This method is 63 // renderer is not running (i.e., it will render "sad tab"). This method is
63 // automatically called from LoadURL. |for_main_frame| indicates whether 64 // automatically called from LoadURL. |for_main_frame_navigation| indicates
64 // this RenderViewHost is used to render a top-level frame, so the 65 // whether this RenderViewHost is used to render a top-level frame, so the
65 // appropriate RenderWidgetHostView type is used. 66 // appropriate RenderWidgetHostView type is used.
66 virtual bool CreateRenderViewForRenderManager( 67 virtual bool CreateRenderViewForRenderManager(
67 RenderViewHost* render_view_host, 68 RenderViewHost* render_view_host,
68 int opener_route_id, 69 int opener_route_id,
69 int proxy_routing_id, 70 int proxy_routing_id,
70 bool for_main_frame) = 0; 71 bool for_main_frame_navigation) = 0;
72 virtual bool CreateRenderFrameForRenderManager(
73 RenderFrameHost* render_frame_host,
74 int parent_routing_id) = 0;
71 virtual void BeforeUnloadFiredFromRenderManager( 75 virtual void BeforeUnloadFiredFromRenderManager(
72 bool proceed, const base::TimeTicks& proceed_time, 76 bool proceed, const base::TimeTicks& proceed_time,
73 bool* proceed_to_fire_unload) = 0; 77 bool* proceed_to_fire_unload) = 0;
74 virtual void RenderProcessGoneFromRenderManager( 78 virtual void RenderProcessGoneFromRenderManager(
75 RenderViewHost* render_view_host) = 0; 79 RenderViewHost* render_view_host) = 0;
76 virtual void UpdateRenderViewSizeForRenderManager() = 0; 80 virtual void UpdateRenderViewSizeForRenderManager() = 0;
77 virtual void CancelModalDialogsForRenderManager() = 0; 81 virtual void CancelModalDialogsForRenderManager() = 0;
78 virtual void NotifySwappedFromRenderManager(RenderFrameHost* old_host, 82 virtual void NotifySwappedFromRenderManager(RenderFrameHost* old_host,
79 RenderFrameHost* new_host, 83 RenderFrameHost* new_host,
80 bool is_main_frame) = 0; 84 bool is_main_frame) = 0;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // Called when a renderer sets its opener to null. 248 // Called when a renderer sets its opener to null.
245 void DidDisownOpener(RenderViewHost* render_view_host); 249 void DidDisownOpener(RenderViewHost* render_view_host);
246 250
247 // Helper method to create and initialize a RenderFrameHost. If |swapped_out| 251 // Helper method to create and initialize a RenderFrameHost. If |swapped_out|
248 // is true, it will be initially placed on the swapped out hosts list. 252 // is true, it will be initially placed on the swapped out hosts list.
249 // Otherwise, it will be used for a pending cross-site navigation. 253 // Otherwise, it will be used for a pending cross-site navigation.
250 // Returns the routing id of the *view* associated with the frame. 254 // Returns the routing id of the *view* associated with the frame.
251 int CreateRenderFrame(SiteInstance* instance, 255 int CreateRenderFrame(SiteInstance* instance,
252 int opener_route_id, 256 int opener_route_id,
253 bool swapped_out, 257 bool swapped_out,
258 bool for_main_frame_navigation,
254 bool hidden); 259 bool hidden);
255 260
261 // Helper method to create and initialize a RenderFrameProxyHost and return
262 // its routing id.
263 int CreateRenderFrameProxy(SiteInstance* instance);
264
256 // Sets the passed passed interstitial as the currently showing interstitial. 265 // Sets the passed passed interstitial as the currently showing interstitial.
257 // |interstitial_page| should be non NULL (use the remove_interstitial_page 266 // |interstitial_page| should be non NULL (use the remove_interstitial_page
258 // method to unset the interstitial) and no interstitial page should be set 267 // method to unset the interstitial) and no interstitial page should be set
259 // when there is already a non NULL interstitial page set. 268 // when there is already a non NULL interstitial page set.
260 void set_interstitial_page(InterstitialPageImpl* interstitial_page) { 269 void set_interstitial_page(InterstitialPageImpl* interstitial_page) {
261 DCHECK(!interstitial_page_ && interstitial_page); 270 DCHECK(!interstitial_page_ && interstitial_page);
262 interstitial_page_ = interstitial_page; 271 interstitial_page_ = interstitial_page;
263 } 272 }
264 273
265 // Unsets the currently showing interstitial. 274 // Unsets the currently showing interstitial.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 void ClearPendingShutdownRFHForSiteInstance(int32 site_instance_id, 307 void ClearPendingShutdownRFHForSiteInstance(int32 site_instance_id,
299 RenderFrameHostImpl* rfh); 308 RenderFrameHostImpl* rfh);
300 309
301 // Deletes any proxy hosts associated with this node. Used during destruction 310 // Deletes any proxy hosts associated with this node. Used during destruction
302 // of WebContentsImpl. 311 // of WebContentsImpl.
303 void ResetProxyHosts(); 312 void ResetProxyHosts();
304 313
305 // Used to start a navigation, part of browser-side navigation project. 314 // Used to start a navigation, part of browser-side navigation project.
306 void OnBeginNavigation(const FrameHostMsg_BeginNavigation_Params& params); 315 void OnBeginNavigation(const FrameHostMsg_BeginNavigation_Params& params);
307 316
317 // Returns the routing id for a RenderFrameHost or RenderFrameHostProxy
318 // that has the given SiteInstance and is associated with this
319 // RenderFrameHostManager. Returns MSG_ROUTING_NONE if none is found.
320 int GetRoutingIdForSiteInstance(SiteInstance* site_instance);
321
308 private: 322 private:
309 friend class RenderFrameHostManagerTest; 323 friend class RenderFrameHostManagerTest;
310 friend class TestWebContents; 324 friend class TestWebContents;
311 325
326 FRIEND_TEST_ALL_PREFIXES(CrossProcessFrameTreeBrowserTest,
327 CreateCrossProcessSubframeProxies);
328
312 // Tracks information about a navigation while a cross-process transition is 329 // Tracks information about a navigation while a cross-process transition is
313 // in progress, in case we need to transfer it to a new RenderFrameHost. 330 // in progress, in case we need to transfer it to a new RenderFrameHost.
314 // When a request is being transferred, deleting the PendingNavigationParams, 331 // When a request is being transferred, deleting the PendingNavigationParams,
315 // and thus |cross_site_transferring_request|, will cancel the request being 332 // and thus |cross_site_transferring_request|, will cancel the request being
316 // transferred, unless its ReleaseRequest method has been called. 333 // transferred, unless its ReleaseRequest method has been called.
317 struct PendingNavigationParams { 334 struct PendingNavigationParams {
318 PendingNavigationParams( 335 PendingNavigationParams(
319 const GlobalRequestID& global_request_id, 336 const GlobalRequestID& global_request_id,
320 scoped_ptr<CrossSiteTransferringRequest> 337 scoped_ptr<CrossSiteTransferringRequest>
321 cross_site_transferring_request, 338 cross_site_transferring_request,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 // Sets up the necessary state for a new RenderViewHost with the given opener, 421 // Sets up the necessary state for a new RenderViewHost with the given opener,
405 // if necessary. It creates a RenderFrameProxy in the target renderer process 422 // if necessary. It creates a RenderFrameProxy in the target renderer process
406 // with the given |proxy_routing_id|, which is used to route IPC messages when 423 // with the given |proxy_routing_id|, which is used to route IPC messages when
407 // in swapped out state. Returns early if the RenderViewHost has already been 424 // in swapped out state. Returns early if the RenderViewHost has already been
408 // initialized for another RenderFrameHost. 425 // initialized for another RenderFrameHost.
409 // TODO(creis): opener_route_id is currently for the RenderViewHost but should 426 // TODO(creis): opener_route_id is currently for the RenderViewHost but should
410 // be for the RenderFrame, since frames can have openers. 427 // be for the RenderFrame, since frames can have openers.
411 bool InitRenderView(RenderViewHost* render_view_host, 428 bool InitRenderView(RenderViewHost* render_view_host,
412 int opener_route_id, 429 int opener_route_id,
413 int proxy_routing_id, 430 int proxy_routing_id,
414 bool for_main_frame); 431 bool for_main_frame_navigation);
432
433 // Initialization for RenderFrameHost uses the same sequence as InitRenderView
434 // above.
435 bool InitRenderFrame(RenderFrameHost* render_frame_host);
415 436
416 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this 437 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this
417 // doesn't require the pending render_frame_host_ pointer to be non-NULL, 438 // doesn't require the pending render_frame_host_ pointer to be non-NULL,
418 // since there could be Web UI switching as well. Call this for every commit. 439 // since there could be Web UI switching as well. Call this for every commit.
419 void CommitPending(); 440 void CommitPending();
420 441
421 // Shutdown all RenderFrameHosts in a SiteInstance. This is called to shutdown 442 // Shutdown all RenderFrameProxyHosts in a SiteInstance. This is called to
422 // frames when all the frames in a SiteInstance are confirmed to be swapped 443 // shutdown frames when all the frames in a SiteInstance are confirmed to be
423 // out. 444 // swapped out.
424 void ShutdownRenderFrameHostsInSiteInstance(int32 site_instance_id); 445 void ShutdownRenderFrameProxyHostsInSiteInstance(int32 site_instance_id);
425 446
426 // Helper method to terminate the pending RenderViewHost. 447 // Helper method to terminate the pending RenderViewHost.
427 void CancelPending(); 448 void CancelPending();
428 449
429 // Helper method to set the active RenderFrameHost. Returns the old 450 // Helper method to set the active RenderFrameHost. Returns the old
430 // RenderFrameHost and updates counts. 451 // RenderFrameHost and updates counts.
431 scoped_ptr<RenderFrameHostImpl> SetRenderFrameHost( 452 scoped_ptr<RenderFrameHostImpl> SetRenderFrameHost(
432 scoped_ptr<RenderFrameHostImpl> render_frame_host); 453 scoped_ptr<RenderFrameHostImpl> render_frame_host);
433 454
434 RenderFrameHostImpl* UpdateStateForNavigate( 455 RenderFrameHostImpl* UpdateStateForNavigate(
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 scoped_ptr<NavigationRequest> navigation_request_; 529 scoped_ptr<NavigationRequest> navigation_request_;
509 530
510 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; 531 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_;
511 532
512 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); 533 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager);
513 }; 534 };
514 535
515 } // namespace content 536 } // namespace content
516 537
517 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ 538 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.cc ('k') | content/browser/frame_host/render_frame_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698