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