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

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

Issue 753173002: Preparation steps for adding speculative renderer creation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: TODO comments removed and new lines added. Created 6 years 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 <list> 8 #include <list>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "content/browser/renderer_host/render_view_host_delegate.h" 14 #include "content/browser/renderer_host/render_view_host_delegate.h"
15 #include "content/browser/site_instance_impl.h" 15 #include "content/browser/site_instance_impl.h"
16 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
17 #include "content/public/browser/global_request_id.h" 17 #include "content/public/browser/global_request_id.h"
18 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
20 #include "content/public/common/referrer.h" 20 #include "content/public/common/referrer.h"
21 #include "ui/base/page_transition_types.h" 21 #include "ui/base/page_transition_types.h"
22 22
23 struct FrameMsg_Navigate_Params; 23 struct FrameMsg_Navigate_Params;
24 24
25 namespace content { 25 namespace content {
26 class BrowserContext; 26 class BrowserContext;
27 class CrossProcessFrameConnector; 27 class CrossProcessFrameConnector;
28 class CrossSiteTransferringRequest; 28 class CrossSiteTransferringRequest;
29 class FrameTreeNode;
29 class InterstitialPageImpl; 30 class InterstitialPageImpl;
30 class FrameTreeNode;
31 class NavigationControllerImpl; 31 class NavigationControllerImpl;
32 class NavigationEntry; 32 class NavigationEntry;
33 class NavigationEntryImpl; 33 class NavigationEntryImpl;
34 class RenderFrameHost; 34 class RenderFrameHost;
35 class RenderFrameHostDelegate; 35 class RenderFrameHostDelegate;
36 class RenderFrameHost;
37 class RenderFrameHostImpl; 36 class RenderFrameHostImpl;
38 class RenderFrameHostManagerTest; 37 class RenderFrameHostManagerTest;
39 class RenderFrameProxyHost; 38 class RenderFrameProxyHost;
40 class RenderViewHost; 39 class RenderViewHost;
41 class RenderViewHostImpl; 40 class RenderViewHostImpl;
42 class RenderWidgetHostDelegate; 41 class RenderWidgetHostDelegate;
43 class RenderWidgetHostView; 42 class RenderWidgetHostView;
44 class TestWebContents; 43 class TestWebContents;
45 class WebUIImpl; 44 class WebUIImpl;
46 45
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 223
225 // Returns the current committed Web UI or NULL if none applies. 224 // Returns the current committed Web UI or NULL if none applies.
226 WebUIImpl* web_ui() const { return web_ui_.get(); } 225 WebUIImpl* web_ui() const { return web_ui_.get(); }
227 226
228 // Returns the Web UI for the pending navigation, or NULL of none applies. 227 // Returns the Web UI for the pending navigation, or NULL of none applies.
229 WebUIImpl* pending_web_ui() const { 228 WebUIImpl* pending_web_ui() const {
230 return pending_web_ui_.get() ? pending_web_ui_.get() : 229 return pending_web_ui_.get() ? pending_web_ui_.get() :
231 pending_and_current_web_ui_.get(); 230 pending_and_current_web_ui_.get();
232 } 231 }
233 232
234 // Sets the pending Web UI for the pending navigation, ensuring that the
235 // bindings are appropriate compared to |bindings|.
236 void SetPendingWebUI(const GURL& url, int bindings);
237
238 // Called when we want to instruct the renderer to navigate to the given 233 // Called when we want to instruct the renderer to navigate to the given
239 // navigation entry. It may create a new RenderFrameHost or re-use an existing 234 // navigation entry. It may create a new RenderFrameHost or re-use an existing
240 // one. The RenderFrameHost to navigate will be returned. Returns NULL if one 235 // one. The RenderFrameHost to navigate will be returned. Returns NULL if one
241 // could not be created. 236 // could not be created.
242 RenderFrameHostImpl* Navigate(const NavigationEntryImpl& entry); 237 RenderFrameHostImpl* Navigate(const NavigationEntryImpl& entry);
243 238
244 // Instructs the various live views to stop. Called when the user directed the 239 // Instructs the various live views to stop. Called when the user directed the
245 // page to stop loading. 240 // page to stop loading.
246 void Stop(); 241 void Stop();
247 242
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 285
291 // Clear navigation transition data. 286 // Clear navigation transition data.
292 void ClearNavigationTransitionData(); 287 void ClearNavigationTransitionData();
293 288
294 // Called when a renderer's frame navigates. 289 // Called when a renderer's frame navigates.
295 void DidNavigateFrame(RenderFrameHostImpl* render_frame_host); 290 void DidNavigateFrame(RenderFrameHostImpl* render_frame_host);
296 291
297 // Called when a renderer sets its opener to null. 292 // Called when a renderer sets its opener to null.
298 void DidDisownOpener(RenderFrameHost* render_frame_host); 293 void DidDisownOpener(RenderFrameHost* render_frame_host);
299 294
300 // Helper method to create and initialize a RenderFrameHost. If |flags| 295 // Sets the pending Web UI for the pending navigation, ensuring that the
301 // has the CREATE_RF_SWAPPED_OUT bit set from the CreateRenderFrameFlags 296 // bindings are appropriate compared to |bindings|.
302 // enum, it will initially be placed on the swapped out hosts list. 297 void SetPendingWebUI(const GURL& url, int bindings);
303 // Returns the routing id of the *view* associated with the frame. 298
304 int CreateRenderFrame(SiteInstance* instance, int opener_route_id, int flags); 299 // Creates and initializes a RenderFrameHost. If |flags| has the
300 // CREATE_RF_SWAPPED_OUT bit set from the CreateRenderFrameFlags enum, it will
301 // initially be placed on the swapped out hosts list. If |routing_id_ptr| is
302 // not nullptr it will be set to the routing id of the *view* associated with
303 // the frame.
304 scoped_ptr<RenderFrameHostImpl> CreateRenderFrame(SiteInstance* instance,
305 int opener_route_id,
306 int flags,
307 const WebUIImpl* web_ui,
Charlie Reis 2014/11/26 00:42:54 DRAFT: This seems like a strange type.
Charlie Reis 2014/11/26 01:06:40 At the moment, it's hard to tell what this paramet
carlosk 2014/11/27 11:02:44 Done. I agree it was confusing and I was in doubt
308 int* routing_id_ptr);
Charlie Reis 2014/11/26 00:42:54 We should put "view" in the name of this parameter
carlosk 2014/11/27 11:02:44 Done.
305 309
306 // Helper method to create and initialize a RenderFrameProxyHost and return 310 // Helper method to create and initialize a RenderFrameProxyHost and return
307 // its routing id. 311 // its routing id.
308 int CreateRenderFrameProxy(SiteInstance* instance); 312 int CreateRenderFrameProxy(SiteInstance* instance);
309 313
310 // Sets the passed passed interstitial as the currently showing interstitial. 314 // Sets the passed passed interstitial as the currently showing interstitial.
311 // |interstitial_page| should be non NULL (use the remove_interstitial_page 315 // |interstitial_page| should be non NULL (use the remove_interstitial_page
312 // method to unset the interstitial) and no interstitial page should be set 316 // method to unset the interstitial) and no interstitial page should be set
313 // when there is already a non NULL interstitial page set. 317 // when there is already a non NULL interstitial page set.
314 void set_interstitial_page(InterstitialPageImpl* interstitial_page) { 318 void set_interstitial_page(InterstitialPageImpl* interstitial_page) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 // SiteInstance's site and when we later call IsSameWebSite. If there is no 398 // SiteInstance's site and when we later call IsSameWebSite. If there is no
395 // current NavigationEntry, check the current SiteInstance's site, which might 399 // current NavigationEntry, check the current SiteInstance's site, which might
396 // already be committed to a Web UI URL (such as the NTP). 400 // already be committed to a Web UI URL (such as the NTP).
397 bool ShouldSwapBrowsingInstancesForNavigation( 401 bool ShouldSwapBrowsingInstancesForNavigation(
398 const GURL& current_effective_url, 402 const GURL& current_effective_url,
399 bool current_is_view_source_mode, 403 bool current_is_view_source_mode,
400 SiteInstance* new_site_instance, 404 SiteInstance* new_site_instance,
401 const GURL& new_effective_url, 405 const GURL& new_effective_url,
402 bool new_is_view_source_mode) const; 406 bool new_is_view_source_mode) const;
403 407
408 // Creates a new Web UI, ensuring that the bindings are appropriate compared
409 // to |bindings|. The caller is responsible for the instance ownership.
Charlie Reis 2014/11/26 01:06:40 Yes, should return a scoped_ptr then.
carlosk 2014/11/27 11:02:44 Done. I also removed that extra comment as the sco
410 WebUIImpl* CreateWebUI(const GURL& url, int bindings);
411
404 // Returns true if it is safe to reuse the current WebUI when navigating from 412 // Returns true if it is safe to reuse the current WebUI when navigating from
405 // |current_entry| to |new_url|. 413 // |current_entry| to |new_url|.
406 bool ShouldReuseWebUI( 414 bool ShouldReuseWebUI(
407 const NavigationEntry* current_entry, 415 const NavigationEntry* current_entry,
408 const GURL& new_url) const; 416 const GURL& new_url) const;
409 417
410 // Returns the SiteInstance to use for the navigation. 418 // Returns the SiteInstance to use for the navigation.
411 SiteInstance* GetSiteInstanceForNavigation( 419 SiteInstance* GetSiteInstanceForNavigation(
412 const GURL& dest_url, 420 const GURL& dest_url,
413 SiteInstance* dest_instance, 421 SiteInstance* dest_instance,
(...skipping 21 matching lines...) Expand all
435 SiteInstance* current_instance, 443 SiteInstance* current_instance,
436 NavigationEntry* current_entry); 444 NavigationEntry* current_entry);
437 445
438 // Creates a new RenderFrameHostImpl for the |new_instance| while respecting 446 // Creates a new RenderFrameHostImpl for the |new_instance| while respecting
439 // the opener route if needed and stores it in pending_render_frame_host_. 447 // the opener route if needed and stores it in pending_render_frame_host_.
440 void CreateRenderFrameHostForNewSiteInstance( 448 void CreateRenderFrameHostForNewSiteInstance(
441 SiteInstance* old_instance, 449 SiteInstance* old_instance,
442 SiteInstance* new_instance, 450 SiteInstance* new_instance,
443 bool is_main_frame); 451 bool is_main_frame);
444 452
453 // Ensure that we have created RFHs for the new RFH's opener chain if
454 // we are staying in the same BrowsingInstance. This allows the new RFH
455 // to send cross-process script calls to its opener(s). Returns the opener
456 // route ID to be used for the new RenderView to be created.
457 int CreateOpenerRenderViewsIfNeeded(SiteInstance* old_instance,
458 SiteInstance* new_instance);
459
445 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary. 460 // Creates a RenderFrameHost and corresponding RenderViewHost if necessary.
446 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance, 461 scoped_ptr<RenderFrameHostImpl> CreateRenderFrameHost(SiteInstance* instance,
447 int view_routing_id, 462 int view_routing_id,
448 int frame_routing_id, 463 int frame_routing_id,
449 int flags); 464 int flags);
450 465
451 // Sets up the necessary state for a new RenderViewHost with the given opener, 466 // Sets up the necessary state for a new RenderViewHost with the given opener,
452 // if necessary. It creates a RenderFrameProxy in the target renderer process 467 // if necessary. It creates a RenderFrameProxy in the target renderer process
453 // with the given |proxy_routing_id|, which is used to route IPC messages when 468 // with the given |proxy_routing_id|, which is used to route IPC messages when
454 // in swapped out state. Returns early if the RenderViewHost has already been 469 // in swapped out state. Returns early if the RenderViewHost has already been
(...skipping 12 matching lines...) Expand all
467 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this 482 // Sets the pending RenderFrameHost/WebUI to be the active one. Note that this
468 // doesn't require the pending render_frame_host_ pointer to be non-NULL, 483 // doesn't require the pending render_frame_host_ pointer to be non-NULL,
469 // since there could be Web UI switching as well. Call this for every commit. 484 // since there could be Web UI switching as well. Call this for every commit.
470 void CommitPending(); 485 void CommitPending();
471 486
472 // Runs the unload handler in the old RenderFrameHost, after the new 487 // Runs the unload handler in the old RenderFrameHost, after the new
473 // RenderFrameHost has committed. |old_render_frame_host| will either be 488 // RenderFrameHost has committed. |old_render_frame_host| will either be
474 // deleted or put on the pending delete list during this call. 489 // deleted or put on the pending delete list during this call.
475 void SwapOutOldFrame(scoped_ptr<RenderFrameHostImpl> old_render_frame_host); 490 void SwapOutOldFrame(scoped_ptr<RenderFrameHostImpl> old_render_frame_host);
476 491
492 // Discards a RenderFrameHost that was never made active (for active ones
493 // SwapOutOldFrame is used instead).
494 void DiscardRenderFrameHost(
Charlie Reis 2014/11/26 00:42:54 DiscardUnusedRenderFrameHost (or DiscardUnusedFram
carlosk 2014/11/27 11:02:44 Done.
495 scoped_ptr<RenderFrameHostImpl> render_frame_host);
496
477 // Holds |render_frame_host| until it can be deleted when its swap out ACK 497 // Holds |render_frame_host| until it can be deleted when its swap out ACK
478 // arrives. 498 // arrives.
479 void MoveToPendingDeleteHosts( 499 void MoveToPendingDeleteHosts(
480 scoped_ptr<RenderFrameHostImpl> render_frame_host); 500 scoped_ptr<RenderFrameHostImpl> render_frame_host);
481 501
482 // Shutdown all RenderFrameProxyHosts in a SiteInstance. This is called to 502 // Shutdown all RenderFrameProxyHosts in a SiteInstance. This is called to
483 // shutdown frames when all the frames in a SiteInstance are confirmed to be 503 // shutdown frames when all the frames in a SiteInstance are confirmed to be
484 // swapped out. 504 // swapped out.
485 void ShutdownRenderFrameProxyHostsInSiteInstance(int32 site_instance_id); 505 void ShutdownRenderFrameProxyHostsInSiteInstance(int32 site_instance_id);
486 506
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 NotificationRegistrar registrar_; 599 NotificationRegistrar registrar_;
580 600
581 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_; 601 base::WeakPtrFactory<RenderFrameHostManager> weak_factory_;
582 602
583 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager); 603 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostManager);
584 }; 604 };
585 605
586 } // namespace content 606 } // namespace content
587 607
588 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_ 608 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698