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

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

Issue 378743002: Navigation transitions: Place transition page in same process as destination page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 #include "content/browser/frame_host/render_frame_host_manager.h" 5 #include "content/browser/frame_host/render_frame_host_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "content/browser/child_process_security_policy_impl.h" 13 #include "content/browser/child_process_security_policy_impl.h"
14 #include "content/browser/devtools/render_view_devtools_agent_host.h" 14 #include "content/browser/devtools/render_view_devtools_agent_host.h"
15 #include "content/browser/frame_host/cross_site_transferring_request.h" 15 #include "content/browser/frame_host/cross_site_transferring_request.h"
16 #include "content/browser/frame_host/debug_urls.h" 16 #include "content/browser/frame_host/debug_urls.h"
17 #include "content/browser/frame_host/interstitial_page_impl.h" 17 #include "content/browser/frame_host/interstitial_page_impl.h"
18 #include "content/browser/frame_host/navigation_controller_impl.h" 18 #include "content/browser/frame_host/navigation_controller_impl.h"
19 #include "content/browser/frame_host/navigation_entry_impl.h" 19 #include "content/browser/frame_host/navigation_entry_impl.h"
20 #include "content/browser/frame_host/navigator.h" 20 #include "content/browser/frame_host/navigator.h"
21 #include "content/browser/frame_host/render_frame_host_factory.h" 21 #include "content/browser/frame_host/render_frame_host_factory.h"
22 #include "content/browser/frame_host/render_frame_host_impl.h" 22 #include "content/browser/frame_host/render_frame_host_impl.h"
23 #include "content/browser/frame_host/render_frame_proxy_host.h" 23 #include "content/browser/frame_host/render_frame_proxy_host.h"
24 #include "content/browser/renderer_host/render_process_host_impl.h" 24 #include "content/browser/renderer_host/render_process_host_impl.h"
25 #include "content/browser/renderer_host/render_view_host_factory.h" 25 #include "content/browser/renderer_host/render_view_host_factory.h"
26 #include "content/browser/renderer_host/render_view_host_impl.h" 26 #include "content/browser/renderer_host/render_view_host_impl.h"
27 #include "content/browser/site_instance_impl.h" 27 #include "content/browser/site_instance_impl.h"
28 #include "content/browser/transition_request_manager.h"
28 #include "content/browser/webui/web_ui_controller_factory_registry.h" 29 #include "content/browser/webui/web_ui_controller_factory_registry.h"
29 #include "content/browser/webui/web_ui_impl.h" 30 #include "content/browser/webui/web_ui_impl.h"
30 #include "content/common/view_messages.h" 31 #include "content/common/view_messages.h"
31 #include "content/public/browser/content_browser_client.h" 32 #include "content/public/browser/content_browser_client.h"
32 #include "content/public/browser/notification_service.h" 33 #include "content/public/browser/notification_service.h"
33 #include "content/public/browser/notification_types.h" 34 #include "content/public/browser/notification_types.h"
34 #include "content/public/browser/render_widget_host_iterator.h" 35 #include "content/public/browser/render_widget_host_iterator.h"
35 #include "content/public/browser/render_widget_host_view.h" 36 #include "content/public/browser/render_widget_host_view.h"
36 #include "content/public/browser/user_metrics.h" 37 #include "content/public/browser/user_metrics.h"
37 #include "content/public/browser/web_ui_controller.h" 38 #include "content/public/browser/web_ui_controller.h"
(...skipping 14 matching lines...) Expand all
52 cross_site_transferring_request(cross_site_transferring_request.Pass()), 53 cross_site_transferring_request(cross_site_transferring_request.Pass()),
53 transfer_url_chain(transfer_url_chain), 54 transfer_url_chain(transfer_url_chain),
54 referrer(referrer), 55 referrer(referrer),
55 page_transition(page_transition), 56 page_transition(page_transition),
56 render_frame_id(render_frame_id), 57 render_frame_id(render_frame_id),
57 should_replace_current_entry(should_replace_current_entry) { 58 should_replace_current_entry(should_replace_current_entry) {
58 } 59 }
59 60
60 RenderFrameHostManager::PendingNavigationParams::~PendingNavigationParams() {} 61 RenderFrameHostManager::PendingNavigationParams::~PendingNavigationParams() {}
61 62
63 RenderFrameHostManager::TransitionParams::TransitionParams(
64 const GlobalRequestID& global_request_id,
65 const GURL& transition_url)
66 : global_request_id(global_request_id),
67 transition_url(transition_url) {
68 }
69
70 RenderFrameHostManager::TransitionParams::~TransitionParams() {
71 }
72
62 bool RenderFrameHostManager::ClearRFHsPendingShutdown(FrameTreeNode* node) { 73 bool RenderFrameHostManager::ClearRFHsPendingShutdown(FrameTreeNode* node) {
63 node->render_manager()->pending_delete_hosts_.clear(); 74 node->render_manager()->pending_delete_hosts_.clear();
64 return true; 75 return true;
65 } 76 }
66 77
67 RenderFrameHostManager::RenderFrameHostManager( 78 RenderFrameHostManager::RenderFrameHostManager(
68 FrameTreeNode* frame_tree_node, 79 FrameTreeNode* frame_tree_node,
69 RenderFrameHostDelegate* render_frame_delegate, 80 RenderFrameHostDelegate* render_frame_delegate,
70 RenderViewHostDelegate* render_view_delegate, 81 RenderViewHostDelegate* render_view_delegate,
71 RenderWidgetHostDelegate* render_widget_delegate, 82 RenderWidgetHostDelegate* render_widget_delegate,
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 transfer_url_chain, referrer, page_transition, 362 transfer_url_chain, referrer, page_transition,
352 pending_render_frame_host->GetRoutingID(), 363 pending_render_frame_host->GetRoutingID(),
353 should_replace_current_entry)); 364 should_replace_current_entry));
354 365
355 // Run the unload handler of the current page. 366 // Run the unload handler of the current page.
356 SwapOutOldPage(); 367 SwapOutOldPage();
357 } 368 }
358 369
359 void RenderFrameHostManager::OnDeferredAfterResponseStarted( 370 void RenderFrameHostManager::OnDeferredAfterResponseStarted(
360 const GlobalRequestID& global_request_id, 371 const GlobalRequestID& global_request_id,
361 RenderFrameHostImpl* pending_render_frame_host) { 372 RenderFrameHostImpl* pending_render_frame_host,
362 DCHECK(!response_started_id_.get()); 373 const GURL& transition_url) {
374 DCHECK(!response_started_params_.get());
363 375
364 response_started_id_.reset(new GlobalRequestID(global_request_id)); 376 TransitionRequestManager::GetInstance()->AddPendingTransitionProcessID(
377 transition_url, pending_render_frame_host->GetProcess()->GetID());
378
379 response_started_params_.reset(
380 new TransitionParams(global_request_id, transition_url));
365 } 381 }
366 382
367 void RenderFrameHostManager::ResumeResponseDeferredAtStart() { 383 void RenderFrameHostManager::ResumeResponseDeferredAtStart() {
368 DCHECK(response_started_id_.get()); 384 DCHECK(response_started_params_.get());
369 385
370 RenderProcessHostImpl* process = 386 RenderProcessHostImpl* process =
371 static_cast<RenderProcessHostImpl*>(render_frame_host_->GetProcess()); 387 static_cast<RenderProcessHostImpl*>(render_frame_host_->GetProcess());
372 process->ResumeResponseDeferredAtStart(*response_started_id_); 388 process->ResumeResponseDeferredAtStart(
389 response_started_params_->global_request_id);
390
391 TransitionRequestManager::GetInstance()->ClearPendingTransitionProcessID(
392 response_started_params_->transition_url);
373 393
374 render_frame_host_->SetHasPendingTransitionRequest(false); 394 render_frame_host_->SetHasPendingTransitionRequest(false);
375 395
376 response_started_id_.reset(); 396 response_started_params_.reset();
377 } 397 }
378 398
379 void RenderFrameHostManager::SwappedOut( 399 void RenderFrameHostManager::SwappedOut(
380 RenderFrameHostImpl* render_frame_host) { 400 RenderFrameHostImpl* render_frame_host) {
381 // Make sure this is from our current RFH, and that we have a pending 401 // Make sure this is from our current RFH, and that we have a pending
382 // navigation from OnCrossSiteResponse. (There may be no pending navigation 402 // navigation from OnCrossSiteResponse. (There may be no pending navigation
383 // for data URLs that don't make network requests, for example.) If not, 403 // for data URLs that don't make network requests, for example.) If not,
384 // just return early and ignore. 404 // just return early and ignore.
385 if (render_frame_host != render_frame_host_ || !pending_nav_params_.get()) { 405 if (render_frame_host != render_frame_host_ || !pending_nav_params_.get()) {
386 pending_nav_params_.reset(); 406 pending_nav_params_.reset();
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 } 773 }
754 774
755 SiteInstanceImpl* current_site_instance = 775 SiteInstanceImpl* current_site_instance =
756 static_cast<SiteInstanceImpl*>(current_instance); 776 static_cast<SiteInstanceImpl*>(current_instance);
757 777
758 // If we haven't used our SiteInstance (and thus RVH) yet, then we can use it 778 // If we haven't used our SiteInstance (and thus RVH) yet, then we can use it
759 // for this entry. We won't commit the SiteInstance to this site until the 779 // for this entry. We won't commit the SiteInstance to this site until the
760 // navigation commits (in DidNavigate), unless the navigation entry was 780 // navigation commits (in DidNavigate), unless the navigation entry was
761 // restored or it's a Web UI as described below. 781 // restored or it's a Web UI as described below.
762 if (!current_site_instance->HasSite()) { 782 if (!current_site_instance->HasSite()) {
783 // If the virtual transition url is set, we should use it instead so that
784 // when GetProcess() is called, the virtual transition url is used to
785 // retrieve the correct renderer.
786 if (!entry.GetVirtualURLForTransition().is_empty()) {
787 return SiteInstance::CreateForURL(browser_context,
788 entry.GetVirtualURLForTransition());
789 }
790
763 // If we've already created a SiteInstance for our destination, we don't 791 // If we've already created a SiteInstance for our destination, we don't
764 // want to use this unused SiteInstance; use the existing one. (We don't 792 // want to use this unused SiteInstance; use the existing one. (We don't
765 // do this check if the current_instance has a site, because for now, we 793 // do this check if the current_instance has a site, because for now, we
766 // want to compare against the current URL and not the SiteInstance's site. 794 // want to compare against the current URL and not the SiteInstance's site.
767 // In this case, there is no current URL, so comparing against the site is 795 // In this case, there is no current URL, so comparing against the site is
768 // ok. See additional comments below.) 796 // ok. See additional comments below.)
769 // 797 //
770 // Also, if the URL should use process-per-site mode and there is an 798 // Also, if the URL should use process-per-site mode and there is an
771 // existing process for the site, we should use it. We can call 799 // existing process for the site, we should use it. We can call
772 // GetRelatedSiteInstance() for this, which will eagerly set the site and 800 // GetRelatedSiteInstance() for this, which will eagerly set the site and
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 SiteInstance* instance) const { 1512 SiteInstance* instance) const {
1485 RenderFrameProxyHostMap::const_iterator iter = 1513 RenderFrameProxyHostMap::const_iterator iter =
1486 proxy_hosts_.find(instance->GetId()); 1514 proxy_hosts_.find(instance->GetId());
1487 if (iter != proxy_hosts_.end()) 1515 if (iter != proxy_hosts_.end())
1488 return iter->second; 1516 return iter->second;
1489 1517
1490 return NULL; 1518 return NULL;
1491 } 1519 }
1492 1520
1493 } // namespace content 1521 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698