OLD | NEW |
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" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 RenderFrameHostManager::~RenderFrameHostManager() { | 100 RenderFrameHostManager::~RenderFrameHostManager() { |
101 if (pending_render_frame_host_) | 101 if (pending_render_frame_host_) |
102 CancelPending(); | 102 CancelPending(); |
103 | 103 |
104 // We should always have a current RenderFrameHost except in some tests. | 104 // We should always have a current RenderFrameHost except in some tests. |
105 SetRenderFrameHost(scoped_ptr<RenderFrameHostImpl>()); | 105 SetRenderFrameHost(scoped_ptr<RenderFrameHostImpl>()); |
106 | 106 |
107 // Delete any swapped out RenderFrameHosts. | 107 // Delete any swapped out RenderFrameHosts. |
108 STLDeleteValues(&proxy_hosts_); | 108 STLDeleteValues(&proxy_hosts_); |
| 109 |
| 110 // PlzNavigate |
| 111 // There is an active navigation request for this RFHM so it needs to be |
| 112 // canceled. |
| 113 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 114 switches::kEnableBrowserSideNavigation)) { |
| 115 if (navigation_request_.get()) |
| 116 navigation_request_->CancelNavigation(); |
| 117 } |
| 118 |
109 } | 119 } |
110 | 120 |
111 void RenderFrameHostManager::Init(BrowserContext* browser_context, | 121 void RenderFrameHostManager::Init(BrowserContext* browser_context, |
112 SiteInstance* site_instance, | 122 SiteInstance* site_instance, |
113 int view_routing_id, | 123 int view_routing_id, |
114 int frame_routing_id) { | 124 int frame_routing_id) { |
115 // Create a RenderViewHost and RenderFrameHost, once we have an instance. It | 125 // Create a RenderViewHost and RenderFrameHost, once we have an instance. It |
116 // is important to immediately give this SiteInstance to a RenderViewHost so | 126 // is important to immediately give this SiteInstance to a RenderViewHost so |
117 // that the SiteInstance is ref counted. | 127 // that the SiteInstance is ref counted. |
118 if (!site_instance) | 128 if (!site_instance) |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 static_cast<RenderProcessHostImpl*>(render_frame_host_->GetProcess()); | 430 static_cast<RenderProcessHostImpl*>(render_frame_host_->GetProcess()); |
421 process->ResumeResponseDeferredAtStart(*response_started_id_); | 431 process->ResumeResponseDeferredAtStart(*response_started_id_); |
422 | 432 |
423 render_frame_host_->ClearPendingTransitionRequestData(); | 433 render_frame_host_->ClearPendingTransitionRequestData(); |
424 | 434 |
425 response_started_id_.reset(); | 435 response_started_id_.reset(); |
426 } | 436 } |
427 | 437 |
428 void RenderFrameHostManager::DidNavigateFrame( | 438 void RenderFrameHostManager::DidNavigateFrame( |
429 RenderFrameHostImpl* render_frame_host) { | 439 RenderFrameHostImpl* render_frame_host) { |
| 440 // PlzNavigate |
| 441 // The navigation request has been committed so the browser process doesn't |
| 442 // need to care about it anymore. |
| 443 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 444 switches::kEnableBrowserSideNavigation)) { |
| 445 navigation_request_.reset(); |
| 446 } |
| 447 |
430 if (!cross_navigation_pending_) { | 448 if (!cross_navigation_pending_) { |
431 DCHECK(!pending_render_frame_host_); | 449 DCHECK(!pending_render_frame_host_); |
432 | 450 |
433 // We should only hear this from our current renderer. | 451 // We should only hear this from our current renderer. |
434 DCHECK_EQ(render_frame_host_, render_frame_host); | 452 DCHECK_EQ(render_frame_host_, render_frame_host); |
435 | 453 |
436 // Even when there is no pending RVH, there may be a pending Web UI. | 454 // Even when there is no pending RVH, there may be a pending Web UI. |
437 if (pending_web_ui()) | 455 if (pending_web_ui()) |
438 CommitPending(); | 456 CommitPending(); |
439 return; | 457 return; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 params.url : frame_tree_node_->frame_tree()->root()->current_url(); | 591 params.url : frame_tree_node_->frame_tree()->root()->current_url(); |
574 info.is_main_frame = frame_tree_node_->IsMainFrame(); | 592 info.is_main_frame = frame_tree_node_->IsMainFrame(); |
575 info.parent_is_main_frame = !frame_tree_node_->parent() ? | 593 info.parent_is_main_frame = !frame_tree_node_->parent() ? |
576 false : frame_tree_node_->parent()->IsMainFrame(); | 594 false : frame_tree_node_->parent()->IsMainFrame(); |
577 info.is_showing = GetRenderWidgetHostView()->IsShowing(); | 595 info.is_showing = GetRenderWidgetHostView()->IsShowing(); |
578 | 596 |
579 // TODO(clamy): Check if the current RFH should be initialized (in case it has | 597 // TODO(clamy): Check if the current RFH should be initialized (in case it has |
580 // crashed) not to display a sad tab while navigating. | 598 // crashed) not to display a sad tab while navigating. |
581 // TODO(clamy): Spawn a speculative renderer process if we do not have one to | 599 // TODO(clamy): Spawn a speculative renderer process if we do not have one to |
582 // use for the navigation. | 600 // use for the navigation. |
| 601 |
| 602 // If there is an ongoing request it must be canceled. |
| 603 if (navigation_request_.get()) |
| 604 navigation_request_->CancelNavigation(); |
| 605 |
583 navigation_request_.reset(new NavigationRequest( | 606 navigation_request_.reset(new NavigationRequest( |
584 info, frame_tree_node_->frame_tree_node_id())); | 607 info, frame_tree_node_->frame_tree_node_id())); |
585 navigation_request_->BeginNavigation(params.request_body); | 608 navigation_request_->BeginNavigation(params.request_body); |
586 } | 609 } |
587 | 610 |
588 // PlzNavigate | 611 // PlzNavigate |
589 void RenderFrameHostManager::CommitNavigation( | 612 void RenderFrameHostManager::CommitNavigation( |
590 const NavigationBeforeCommitInfo& info) { | 613 const NavigationBeforeCommitInfo& info) { |
591 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( | 614 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( |
592 switches::kEnableBrowserSideNavigation)); | 615 switches::kEnableBrowserSideNavigation)); |
| 616 DCHECK(navigation_request_.get()); |
| 617 // Ignores navigation commits if the request ID doesn't match the current |
| 618 // active request. |
| 619 if (navigation_request_->navigation_request_id() != |
| 620 info.navigation_request_id) { |
| 621 return; |
| 622 } |
| 623 |
593 // Pick the right RenderFrameHost to commit the navigation. | 624 // Pick the right RenderFrameHost to commit the navigation. |
594 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 625 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); |
595 // TODO(clamy): Replace the default values by the right ones. This may require | 626 // TODO(clamy): Replace the default values by the right ones. This may require |
596 // some storing in RequestNavigation. | 627 // some storing in RequestNavigation. |
597 SiteInstance* new_instance = GetSiteInstanceForNavigation( | 628 SiteInstance* new_instance = GetSiteInstanceForNavigation( |
598 info.navigation_url, | 629 info.navigation_url, |
599 NULL, | 630 NULL, |
600 navigation_request_->info().navigation_params.transition_type, | 631 navigation_request_->info().navigation_params.transition_type, |
601 false, | 632 false, |
602 false); | 633 false); |
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 1689 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
1659 SiteInstance* instance) { | 1690 SiteInstance* instance) { |
1660 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 1691 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
1661 if (iter != proxy_hosts_.end()) { | 1692 if (iter != proxy_hosts_.end()) { |
1662 delete iter->second; | 1693 delete iter->second; |
1663 proxy_hosts_.erase(iter); | 1694 proxy_hosts_.erase(iter); |
1664 } | 1695 } |
1665 } | 1696 } |
1666 | 1697 |
1667 } // namespace content | 1698 } // namespace content |
OLD | NEW |