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/navigator_impl.h" | 5 #include "content/browser/frame_host/navigator_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "content/browser/frame_host/frame_tree.h" | 10 #include "content/browser/frame_host/frame_tree.h" |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 } | 526 } |
527 | 527 |
528 // Run tasks that must execute just before the commit. | 528 // Run tasks that must execute just before the commit. |
529 bool is_navigation_within_page = controller_->IsURLInPageNavigation( | 529 bool is_navigation_within_page = controller_->IsURLInPageNavigation( |
530 params.url, params.was_within_same_page, render_frame_host); | 530 params.url, params.was_within_same_page, render_frame_host); |
531 delegate_->DidNavigateMainFramePreCommit(is_navigation_within_page); | 531 delegate_->DidNavigateMainFramePreCommit(is_navigation_within_page); |
532 } | 532 } |
533 | 533 |
534 if (!use_site_per_process) | 534 if (!use_site_per_process) |
535 frame_tree->root()->render_manager()->DidNavigateFrame( | 535 frame_tree->root()->render_manager()->DidNavigateFrame( |
536 render_frame_host, params.gesture == NavigationGestureUser); | 536 render_frame_host, params.gesture == NavigationGestureUser, |
| 537 params.was_within_same_page); |
537 } | 538 } |
538 | 539 |
539 // Save the origin of the new page. Do this before calling | 540 // Save the origin of the new page. Do this before calling |
540 // DidNavigateFrame(), because the origin needs to be included in the SwapOut | 541 // DidNavigateFrame(), because the origin needs to be included in the SwapOut |
541 // message, which is sent inside DidNavigateFrame(). SwapOut needs the | 542 // message, which is sent inside DidNavigateFrame(). SwapOut needs the |
542 // origin because it creates a RenderFrameProxy that needs this to initialize | 543 // origin because it creates a RenderFrameProxy that needs this to initialize |
543 // its security context. This origin will also be sent to RenderFrameProxies | 544 // its security context. This origin will also be sent to RenderFrameProxies |
544 // created via ViewMsg_New and FrameMsg_NewFrameProxy. | 545 // created via ViewMsg_New and FrameMsg_NewFrameProxy. |
545 render_frame_host->frame_tree_node()->set_current_origin(params.origin); | 546 render_frame_host->frame_tree_node()->set_current_origin(params.origin); |
546 | 547 |
547 // When using --site-per-process, we notify the RFHM for all navigations, | 548 // When using --site-per-process, we notify the RFHM for all navigations, |
548 // not just main frame navigations. | 549 // not just main frame navigations. |
549 if (use_site_per_process) { | 550 if (use_site_per_process) { |
550 FrameTreeNode* frame = render_frame_host->frame_tree_node(); | 551 FrameTreeNode* frame = render_frame_host->frame_tree_node(); |
551 frame->render_manager()->DidNavigateFrame( | 552 frame->render_manager()->DidNavigateFrame( |
552 render_frame_host, params.gesture == NavigationGestureUser); | 553 render_frame_host, params.gesture == NavigationGestureUser, |
| 554 params.was_within_same_page); |
553 } | 555 } |
554 | 556 |
555 // Update the site of the SiteInstance if it doesn't have one yet, unless | 557 // Update the site of the SiteInstance if it doesn't have one yet, unless |
556 // assigning a site is not necessary for this URL. In that case, the | 558 // assigning a site is not necessary for this URL. In that case, the |
557 // SiteInstance can still be considered unused until a navigation to a real | 559 // SiteInstance can still be considered unused until a navigation to a real |
558 // page. | 560 // page. |
559 SiteInstanceImpl* site_instance = | 561 SiteInstanceImpl* site_instance = |
560 static_cast<SiteInstanceImpl*>(render_frame_host->GetSiteInstance()); | 562 static_cast<SiteInstanceImpl*>(render_frame_host->GetSiteInstance()); |
561 if (!site_instance->HasSite() && | 563 if (!site_instance->HasSite() && |
562 ShouldAssignSiteForURL(params.url)) { | 564 ShouldAssignSiteForURL(params.url)) { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 scoped_ptr<NavigationRequestInfo> info(new NavigationRequestInfo(params)); | 771 scoped_ptr<NavigationRequestInfo> info(new NavigationRequestInfo(params)); |
770 | 772 |
771 info->first_party_for_cookies = | 773 info->first_party_for_cookies = |
772 frame_tree_node->IsMainFrame() | 774 frame_tree_node->IsMainFrame() |
773 ? navigation_request->common_params().url | 775 ? navigation_request->common_params().url |
774 : frame_tree_node->frame_tree()->root()->current_url(); | 776 : frame_tree_node->frame_tree()->root()->current_url(); |
775 info->is_main_frame = frame_tree_node->IsMainFrame(); | 777 info->is_main_frame = frame_tree_node->IsMainFrame(); |
776 info->parent_is_main_frame = !frame_tree_node->parent() ? | 778 info->parent_is_main_frame = !frame_tree_node->parent() ? |
777 false : frame_tree_node->parent()->IsMainFrame(); | 779 false : frame_tree_node->parent()->IsMainFrame(); |
778 | 780 |
779 // TODO(clamy): Inform the RenderFrameHostManager that a navigation is about | 781 // First start the request on the IO thread. |
780 // to begin, so that it can speculatively spawn a new renderer if needed. | 782 navigation_request->BeginNavigation(info.Pass(), params.request_body); |
781 | 783 |
782 navigation_request->BeginNavigation(info.Pass(), params.request_body); | 784 // Then notify the RenderFrameHostManager so it can speculatively create a |
| 785 // renderer in parallel. |
| 786 frame_tree_node->render_manager()->BeginNavigation(params, common_params); |
783 } | 787 } |
784 | 788 |
785 // PlzNavigate | 789 // PlzNavigate |
786 void NavigatorImpl::CommitNavigation(FrameTreeNode* frame_tree_node, | 790 void NavigatorImpl::CommitNavigation(FrameTreeNode* frame_tree_node, |
787 ResourceResponse* response, | 791 ResourceResponse* response, |
788 scoped_ptr<StreamHandle> body) { | 792 scoped_ptr<StreamHandle> body) { |
789 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 793 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
790 switches::kEnableBrowserSideNavigation)); | 794 switches::kEnableBrowserSideNavigation)); |
791 | 795 |
792 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not | 796 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not |
(...skipping 20 matching lines...) Expand all Loading... |
813 render_frame_host->CommitNavigation(response, body.Pass(), | 817 render_frame_host->CommitNavigation(response, body.Pass(), |
814 navigation_request->common_params(), | 818 navigation_request->common_params(), |
815 navigation_request->commit_params()); | 819 navigation_request->commit_params()); |
816 } | 820 } |
817 | 821 |
818 // PlzNavigate | 822 // PlzNavigate |
819 void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node) { | 823 void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node) { |
820 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 824 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
821 switches::kEnableBrowserSideNavigation)); | 825 switches::kEnableBrowserSideNavigation)); |
822 navigation_request_map_.erase(frame_tree_node->frame_tree_node_id()); | 826 navigation_request_map_.erase(frame_tree_node->frame_tree_node_id()); |
| 827 frame_tree_node->render_manager()->CleanUpNavigation(); |
823 } | 828 } |
824 | 829 |
825 // PlzNavigate | 830 // PlzNavigate |
826 NavigationRequest* NavigatorImpl::GetNavigationRequestForNodeForTesting( | 831 NavigationRequest* NavigatorImpl::GetNavigationRequestForNodeForTesting( |
827 FrameTreeNode* frame_tree_node) { | 832 FrameTreeNode* frame_tree_node) { |
828 return navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); | 833 return navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); |
829 } | 834 } |
830 | 835 |
831 void NavigatorImpl::LogResourceRequestTime( | 836 void NavigatorImpl::LogResourceRequestTime( |
832 base::TimeTicks timestamp, const GURL& url) { | 837 base::TimeTicks timestamp, const GURL& url) { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", | 967 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", |
963 time_to_commit); | 968 time_to_commit); |
964 UMA_HISTOGRAM_TIMES( | 969 UMA_HISTOGRAM_TIMES( |
965 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", | 970 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", |
966 time_to_network); | 971 time_to_network); |
967 } | 972 } |
968 navigation_data_.reset(); | 973 navigation_data_.reset(); |
969 } | 974 } |
970 | 975 |
971 } // namespace content | 976 } // namespace content |
OLD | NEW |