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

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

Issue 906283003: PlzNavigate: Support data urls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 5 years, 10 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/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
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();
Charlie Reis 2015/02/20 22:11:50 nit: Wrong indent. Also, maybe it makes sense to
clamy 2015/02/26 15:28:36 Done.
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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 BeginNavigation(frame_tree_node); 731 BeginNavigation(frame_tree_node);
733 } 732 }
734 733
735 // PlzNavigate 734 // PlzNavigate
736 void NavigatorImpl::CommitNavigation(FrameTreeNode* frame_tree_node, 735 void NavigatorImpl::CommitNavigation(FrameTreeNode* frame_tree_node,
737 ResourceResponse* response, 736 ResourceResponse* response,
738 scoped_ptr<StreamHandle> body) { 737 scoped_ptr<StreamHandle> body) {
739 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 738 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
740 switches::kEnableBrowserSideNavigation)); 739 switches::kEnableBrowserSideNavigation));
741 740
741 NavigationRequest* navigation_request =
742 navigation_request_map_.get(frame_tree_node->frame_tree_node_id());
743 DCHECK(navigation_request);
744 DCHECK(response ||
745 !NavigationRequest::ShouldMakeNetworkRequest(
746 navigation_request->common_params().url));
747
742 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not 748 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not
743 // commit; they leave the frame showing the previous page. 749 // commit; they leave the frame showing the previous page.
744 if (response->head.headers.get() && 750 if (response && response->head.headers.get() &&
745 (response->head.headers->response_code() == 204 || 751 (response->head.headers->response_code() == 204 ||
746 response->head.headers->response_code() == 205)) { 752 response->head.headers->response_code() == 205)) {
747 CancelNavigation(frame_tree_node); 753 CancelNavigation(frame_tree_node);
748 return; 754 return;
749 } 755 }
750 756
751 NavigationRequest* navigation_request =
752 navigation_request_map_.get(frame_tree_node->frame_tree_node_id());
753 DCHECK(navigation_request);
754
755 // Select an appropriate renderer to commit the navigation. 757 // Select an appropriate renderer to commit the navigation.
756 RenderFrameHostImpl* render_frame_host = 758 RenderFrameHostImpl* render_frame_host =
757 frame_tree_node->render_manager()->GetFrameHostForNavigation( 759 frame_tree_node->render_manager()->GetFrameHostForNavigation(
758 *navigation_request); 760 *navigation_request);
759 CheckWebUIRendererDoesNotDisplayNormalURL( 761 CheckWebUIRendererDoesNotDisplayNormalURL(
760 render_frame_host, navigation_request->common_params().url); 762 render_frame_host, navigation_request->common_params().url);
761 763
762 render_frame_host->CommitNavigation(response, body.Pass(), 764 render_frame_host->CommitNavigation(response, body.Pass(),
763 navigation_request->common_params(), 765 navigation_request->common_params(),
764 navigation_request->commit_params()); 766 navigation_request->commit_params());
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 865
864 void NavigatorImpl::BeginNavigation(FrameTreeNode* frame_tree_node) { 866 void NavigatorImpl::BeginNavigation(FrameTreeNode* frame_tree_node) {
865 NavigationRequest* navigation_request = 867 NavigationRequest* navigation_request =
866 navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); 868 navigation_request_map_.get(frame_tree_node->frame_tree_node_id());
867 869
868 // A browser-initiated navigation could have been cancelled while it was 870 // A browser-initiated navigation could have been cancelled while it was
869 // waiting for the BeforeUnload event to execute. 871 // waiting for the BeforeUnload event to execute.
870 if (!navigation_request) 872 if (!navigation_request)
871 return; 873 return;
872 874
873 // First start the request on the IO thread. 875 // Start the request.
874 navigation_request->BeginNavigation(); 876 if (navigation_request->BeginNavigation()) {
875 877 // If the request was sent to the IO thread, notify the
876 // Then notify the RenderFrameHostManager so it can speculatively create a 878 // RenderFrameHostManager so it can speculatively create a RenderFrameHost
877 // RenderFrameHost (and potentially a new renderer process) in parallel. 879 // (and potentially a new renderer process) in parallel.
878 frame_tree_node->render_manager()->BeginNavigation(*navigation_request); 880 frame_tree_node->render_manager()->BeginNavigation(*navigation_request);
881 }
879 } 882 }
880 883
881 void NavigatorImpl::RecordNavigationMetrics( 884 void NavigatorImpl::RecordNavigationMetrics(
882 const LoadCommittedDetails& details, 885 const LoadCommittedDetails& details,
883 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, 886 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
884 SiteInstance* site_instance) { 887 SiteInstance* site_instance) {
885 DCHECK(site_instance->HasProcess()); 888 DCHECK(site_instance->HasProcess());
886 889
887 if (!details.is_in_page) 890 if (!details.is_in_page)
888 RecordAction(base::UserMetricsAction("FrameLoad")); 891 RecordAction(base::UserMetricsAction("FrameLoad"));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", 929 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted",
927 time_to_commit); 930 time_to_commit);
928 UMA_HISTOGRAM_TIMES( 931 UMA_HISTOGRAM_TIMES(
929 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", 932 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted",
930 time_to_network); 933 time_to_network);
931 } 934 }
932 navigation_data_.reset(); 935 navigation_data_.reset();
933 } 936 }
934 937
935 } // namespace content 938 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698