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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 FrameMsg_Navigate_Params* params) { | 84 FrameMsg_Navigate_Params* params) { |
85 FrameMsg_UILoadMetricsReportType::Value report_type = | 85 FrameMsg_UILoadMetricsReportType::Value report_type = |
86 FrameMsg_UILoadMetricsReportType::NO_REPORT; | 86 FrameMsg_UILoadMetricsReportType::NO_REPORT; |
87 base::TimeTicks ui_timestamp = base::TimeTicks(); | 87 base::TimeTicks ui_timestamp = base::TimeTicks(); |
88 #if defined(OS_ANDROID) | 88 #if defined(OS_ANDROID) |
89 if (!entry.intent_received_timestamp().is_null()) | 89 if (!entry.intent_received_timestamp().is_null()) |
90 report_type = FrameMsg_UILoadMetricsReportType::REPORT_INTENT; | 90 report_type = FrameMsg_UILoadMetricsReportType::REPORT_INTENT; |
91 ui_timestamp = entry.intent_received_timestamp(); | 91 ui_timestamp = entry.intent_received_timestamp(); |
92 #endif | 92 #endif |
93 | 93 |
| 94 const GURL history_url_for_data_url = |
| 95 entry.GetBaseURLForDataURL().is_empty()? GURL() : entry.GetVirtualURL(); |
94 params->common_params = CommonNavigationParams( | 96 params->common_params = CommonNavigationParams( |
95 entry.GetURL(), entry.GetReferrer(), entry.GetTransitionType(), | 97 entry.GetURL(), entry.GetReferrer(), entry.GetTransitionType(), |
96 GetNavigationType(controller->GetBrowserContext(), entry, reload_type), | 98 GetNavigationType(controller->GetBrowserContext(), entry, reload_type), |
97 !entry.IsViewSourceMode(), ui_timestamp, report_type); | 99 !entry.IsViewSourceMode(), ui_timestamp, report_type, |
| 100 entry.GetBaseURLForDataURL(), history_url_for_data_url); |
98 params->commit_params = CommitNavigationParams( | 101 params->commit_params = CommitNavigationParams( |
99 entry.GetPageState(), entry.GetIsOverridingUserAgent(), navigation_start); | 102 entry.GetPageState(), entry.GetIsOverridingUserAgent(), navigation_start); |
100 params->is_post = entry.GetHasPostData(); | 103 params->is_post = entry.GetHasPostData(); |
101 params->extra_headers = entry.extra_headers(); | 104 params->extra_headers = entry.extra_headers(); |
102 if (entry.GetBrowserInitiatedPostData()) { | 105 if (entry.GetBrowserInitiatedPostData()) { |
103 params->browser_initiated_post_data.assign( | 106 params->browser_initiated_post_data.assign( |
104 entry.GetBrowserInitiatedPostData()->front(), | 107 entry.GetBrowserInitiatedPostData()->front(), |
105 entry.GetBrowserInitiatedPostData()->front() + | 108 entry.GetBrowserInitiatedPostData()->front() + |
106 entry.GetBrowserInitiatedPostData()->size()); | 109 entry.GetBrowserInitiatedPostData()->size()); |
107 } | 110 } |
108 | 111 |
109 if (!entry.GetBaseURLForDataURL().is_empty()) { | |
110 params->base_url_for_data_url = entry.GetBaseURLForDataURL(); | |
111 params->history_url_for_data_url = entry.GetVirtualURL(); | |
112 } | |
113 params->should_replace_current_entry = entry.should_replace_entry(); | 112 params->should_replace_current_entry = entry.should_replace_entry(); |
114 // This is used by the old performance infrastructure to set up DocumentState | 113 // This is used by the old performance infrastructure to set up DocumentState |
115 // associated with the RenderView. | 114 // associated with the RenderView. |
116 // TODO(ppi): make it go away. | 115 // TODO(ppi): make it go away. |
117 params->request_time = base::Time::Now(); | 116 params->request_time = base::Time::Now(); |
118 params->transferred_request_child_id = | 117 params->transferred_request_child_id = |
119 entry.transferred_global_request_id().child_id; | 118 entry.transferred_global_request_id().child_id; |
120 params->transferred_request_request_id = | 119 params->transferred_request_request_id = |
121 entry.transferred_global_request_id().request_id; | 120 entry.transferred_global_request_id().request_id; |
122 | 121 |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 BeginNavigation(frame_tree_node); | 722 BeginNavigation(frame_tree_node); |
724 } | 723 } |
725 | 724 |
726 // PlzNavigate | 725 // PlzNavigate |
727 void NavigatorImpl::CommitNavigation(FrameTreeNode* frame_tree_node, | 726 void NavigatorImpl::CommitNavigation(FrameTreeNode* frame_tree_node, |
728 ResourceResponse* response, | 727 ResourceResponse* response, |
729 scoped_ptr<StreamHandle> body) { | 728 scoped_ptr<StreamHandle> body) { |
730 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 729 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
731 switches::kEnableBrowserSideNavigation)); | 730 switches::kEnableBrowserSideNavigation)); |
732 | 731 |
| 732 NavigationRequest* navigation_request = |
| 733 navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); |
| 734 DCHECK(navigation_request); |
| 735 DCHECK(response || |
| 736 !ShouldMakeNetworkRequestForNavigation( |
| 737 navigation_request->common_params().url)); |
| 738 |
733 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not | 739 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not |
734 // commit; they leave the frame showing the previous page. | 740 // commit; they leave the frame showing the previous page. |
735 if (response->head.headers.get() && | 741 if (response && response->head.headers.get() && |
736 (response->head.headers->response_code() == 204 || | 742 (response->head.headers->response_code() == 204 || |
737 response->head.headers->response_code() == 205)) { | 743 response->head.headers->response_code() == 205)) { |
738 CancelNavigation(frame_tree_node); | 744 CancelNavigation(frame_tree_node); |
739 return; | 745 return; |
740 } | 746 } |
741 | 747 |
742 NavigationRequest* navigation_request = | |
743 navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); | |
744 DCHECK(navigation_request); | |
745 | |
746 // Select an appropriate renderer to commit the navigation. | 748 // Select an appropriate renderer to commit the navigation. |
747 RenderFrameHostImpl* render_frame_host = | 749 RenderFrameHostImpl* render_frame_host = |
748 frame_tree_node->render_manager()->GetFrameHostForNavigation( | 750 frame_tree_node->render_manager()->GetFrameHostForNavigation( |
749 *navigation_request); | 751 *navigation_request); |
750 CheckWebUIRendererDoesNotDisplayNormalURL( | 752 CheckWebUIRendererDoesNotDisplayNormalURL( |
751 render_frame_host, navigation_request->common_params().url); | 753 render_frame_host, navigation_request->common_params().url); |
752 | 754 |
753 render_frame_host->CommitNavigation(response, body.Pass(), | 755 render_frame_host->CommitNavigation(response, body.Pass(), |
754 navigation_request->common_params(), | 756 navigation_request->common_params(), |
755 navigation_request->commit_params()); | 757 navigation_request->commit_params()); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 | 856 |
855 void NavigatorImpl::BeginNavigation(FrameTreeNode* frame_tree_node) { | 857 void NavigatorImpl::BeginNavigation(FrameTreeNode* frame_tree_node) { |
856 NavigationRequest* navigation_request = | 858 NavigationRequest* navigation_request = |
857 navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); | 859 navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); |
858 | 860 |
859 // A browser-initiated navigation could have been cancelled while it was | 861 // A browser-initiated navigation could have been cancelled while it was |
860 // waiting for the BeforeUnload event to execute. | 862 // waiting for the BeforeUnload event to execute. |
861 if (!navigation_request) | 863 if (!navigation_request) |
862 return; | 864 return; |
863 | 865 |
864 // First start the request on the IO thread. | 866 // Start the request. |
865 navigation_request->BeginNavigation(); | 867 if (navigation_request->BeginNavigation()) { |
866 | 868 // If the request was sent to the IO thread, notify the |
867 // Then notify the RenderFrameHostManager so it can speculatively create a | 869 // RenderFrameHostManager so it can speculatively create a RenderFrameHost |
868 // RenderFrameHost (and potentially a new renderer process) in parallel. | 870 // (and potentially a new renderer process) in parallel. |
869 frame_tree_node->render_manager()->BeginNavigation(*navigation_request); | 871 frame_tree_node->render_manager()->BeginNavigation(*navigation_request); |
| 872 } |
870 } | 873 } |
871 | 874 |
872 void NavigatorImpl::RecordNavigationMetrics( | 875 void NavigatorImpl::RecordNavigationMetrics( |
873 const LoadCommittedDetails& details, | 876 const LoadCommittedDetails& details, |
874 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, | 877 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
875 SiteInstance* site_instance) { | 878 SiteInstance* site_instance) { |
876 DCHECK(site_instance->HasProcess()); | 879 DCHECK(site_instance->HasProcess()); |
877 | 880 |
878 if (!details.is_in_page) | 881 if (!details.is_in_page) |
879 RecordAction(base::UserMetricsAction("FrameLoad")); | 882 RecordAction(base::UserMetricsAction("FrameLoad")); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", | 920 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", |
918 time_to_commit); | 921 time_to_commit); |
919 UMA_HISTOGRAM_TIMES( | 922 UMA_HISTOGRAM_TIMES( |
920 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", | 923 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", |
921 time_to_network); | 924 time_to_network); |
922 } | 925 } |
923 navigation_data_.reset(); | 926 navigation_data_.reset(); |
924 } | 927 } |
925 | 928 |
926 } // namespace content | 929 } // namespace content |
OLD | NEW |