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

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

Issue 2846983002: Add more navigation tracing to RenderFrameHost and NavigationRequest. (Closed)
Patch Set: Created 3 years, 7 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/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 1201
1202 void RenderFrameHostImpl::OnDidStartProvisionalLoad( 1202 void RenderFrameHostImpl::OnDidStartProvisionalLoad(
1203 const GURL& url, 1203 const GURL& url,
1204 const std::vector<GURL>& redirect_chain, 1204 const std::vector<GURL>& redirect_chain,
1205 const base::TimeTicks& navigation_start) { 1205 const base::TimeTicks& navigation_start) {
1206 // TODO(clamy): Check if other navigation methods (OpenURL, 1206 // TODO(clamy): Check if other navigation methods (OpenURL,
1207 // DidFailProvisionalLoad, ...) should also be ignored if the RFH is no longer 1207 // DidFailProvisionalLoad, ...) should also be ignored if the RFH is no longer
1208 // active. 1208 // active.
1209 if (!is_active()) 1209 if (!is_active())
1210 return; 1210 return;
1211
1212 TRACE_EVENT2("navigation", "RenderFrameHostImpl::OnDidStartProvisionalLoad",
1213 "frame_tree_node", frame_tree_node_->frame_tree_node_id(), "url",
1214 url.possibly_invalid_spec());
1215
1211 frame_tree_node_->navigator()->DidStartProvisionalLoad( 1216 frame_tree_node_->navigator()->DidStartProvisionalLoad(
1212 this, url, redirect_chain, navigation_start); 1217 this, url, redirect_chain, navigation_start);
1213 } 1218 }
1214 1219
1215 void RenderFrameHostImpl::OnDidFailProvisionalLoadWithError( 1220 void RenderFrameHostImpl::OnDidFailProvisionalLoadWithError(
1216 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) { 1221 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) {
1222 TRACE_EVENT2("navigation",
1223 "RenderFrameHostImpl::OnDidFailProvisionalLoadWithError",
1224 "frame_tree_node", frame_tree_node_->frame_tree_node_id(),
1225 "error", params.error_code);
1217 // TODO(clamy): Kill the renderer with RFH_FAIL_PROVISIONAL_LOAD_NO_HANDLE and 1226 // TODO(clamy): Kill the renderer with RFH_FAIL_PROVISIONAL_LOAD_NO_HANDLE and
1218 // return early if navigation_handle_ is null, once we prevent that case from 1227 // return early if navigation_handle_ is null, once we prevent that case from
1219 // happening in practice. 1228 // happening in practice.
1220 1229
1221 // Update the error code in the NavigationHandle of the navigation. 1230 // Update the error code in the NavigationHandle of the navigation.
1222 if (navigation_handle_) { 1231 if (navigation_handle_) {
1223 navigation_handle_->set_net_error_code( 1232 navigation_handle_->set_net_error_code(
1224 static_cast<net::Error>(params.error_code)); 1233 static_cast<net::Error>(params.error_code));
1225 } 1234 }
1226 1235
1227 frame_tree_node_->navigator()->DidFailProvisionalLoadWithError(this, params); 1236 frame_tree_node_->navigator()->DidFailProvisionalLoadWithError(this, params);
1228 } 1237 }
1229 1238
1230 void RenderFrameHostImpl::OnDidFailLoadWithError( 1239 void RenderFrameHostImpl::OnDidFailLoadWithError(
1231 const GURL& url, 1240 const GURL& url,
1232 int error_code, 1241 int error_code,
1233 const base::string16& error_description, 1242 const base::string16& error_description,
1234 bool was_ignored_by_handler) { 1243 bool was_ignored_by_handler) {
1244 TRACE_EVENT2("navigation",
1245 "RenderFrameHostImpl::OnDidFailProvisionalLoadWithError",
1246 "frame_tree_node", frame_tree_node_->frame_tree_node_id(),
1247 "error", error_code);
1248
1235 GURL validated_url(url); 1249 GURL validated_url(url);
1236 GetProcess()->FilterURL(false, &validated_url); 1250 GetProcess()->FilterURL(false, &validated_url);
1237 1251
1238 frame_tree_node_->navigator()->DidFailLoadWithError( 1252 frame_tree_node_->navigator()->DidFailLoadWithError(
1239 this, validated_url, error_code, error_description, 1253 this, validated_url, error_code, error_description,
1240 was_ignored_by_handler); 1254 was_ignored_by_handler);
1241 } 1255 }
1242 1256
1243 // Called when the renderer navigates. For every frame loaded, we'll get this 1257 // Called when the renderer navigates. For every frame loaded, we'll get this
1244 // notification containing parameters identifying the navigation. 1258 // notification containing parameters identifying the navigation.
1245 void RenderFrameHostImpl::OnDidCommitProvisionalLoad(const IPC::Message& msg) { 1259 void RenderFrameHostImpl::OnDidCommitProvisionalLoad(const IPC::Message& msg) {
1246 ScopedCommitStateResetter commit_state_resetter(this); 1260 ScopedCommitStateResetter commit_state_resetter(this);
1247 RenderProcessHost* process = GetProcess(); 1261 RenderProcessHost* process = GetProcess();
1248 1262
1249 // Read the parameters out of the IPC message directly to avoid making another 1263 // Read the parameters out of the IPC message directly to avoid making another
1250 // copy when we filter the URLs. 1264 // copy when we filter the URLs.
1251 base::PickleIterator iter(msg); 1265 base::PickleIterator iter(msg);
1252 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; 1266 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params;
1253 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: 1267 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>::
1254 Read(&msg, &iter, &validated_params)) { 1268 Read(&msg, &iter, &validated_params)) {
1255 bad_message::ReceivedBadMessage( 1269 bad_message::ReceivedBadMessage(
1256 process, bad_message::RFH_COMMIT_DESERIALIZATION_FAILED); 1270 process, bad_message::RFH_COMMIT_DESERIALIZATION_FAILED);
1257 return; 1271 return;
1258 } 1272 }
1259 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnDidCommitProvisionalLoad", 1273 TRACE_EVENT2("navigation", "RenderFrameHostImpl::OnDidCommitProvisionalLoad",
1260 "url", validated_params.url.possibly_invalid_spec()); 1274 "frame_tree_node", frame_tree_node_->frame_tree_node_id(), "url",
1275 validated_params.url.possibly_invalid_spec());
1261 1276
1262 // Sanity-check the page transition for frame type. 1277 // Sanity-check the page transition for frame type.
1263 DCHECK_EQ(ui::PageTransitionIsMainFrame(validated_params.transition), 1278 DCHECK_EQ(ui::PageTransitionIsMainFrame(validated_params.transition),
1264 !GetParent()); 1279 !GetParent());
1265 1280
1266 // If we're waiting for a cross-site beforeunload ack from this renderer and 1281 // If we're waiting for a cross-site beforeunload ack from this renderer and
1267 // we receive a Navigate message from the main frame, then the renderer was 1282 // we receive a Navigate message from the main frame, then the renderer was
1268 // navigating already and sent it before hearing the FrameMsg_Stop message. 1283 // navigating already and sent it before hearing the FrameMsg_Stop message.
1269 // Treat this as an implicit beforeunload ack to allow the pending navigation 1284 // Treat this as an implicit beforeunload ack to allow the pending navigation
1270 // to continue. 1285 // to continue.
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 return std::move(navigation_handle_); 1459 return std::move(navigation_handle_);
1445 } 1460 }
1446 1461
1447 void RenderFrameHostImpl::SwapOut( 1462 void RenderFrameHostImpl::SwapOut(
1448 RenderFrameProxyHost* proxy, 1463 RenderFrameProxyHost* proxy,
1449 bool is_loading) { 1464 bool is_loading) {
1450 // The end of this event is in OnSwapOutACK when the RenderFrame has completed 1465 // The end of this event is in OnSwapOutACK when the RenderFrame has completed
1451 // the operation and sends back an IPC message. 1466 // the operation and sends back an IPC message.
1452 // The trace event may not end properly if the ACK times out. We expect this 1467 // The trace event may not end properly if the ACK times out. We expect this
1453 // to be fixed when RenderViewHostImpl::OnSwapOut moves to RenderFrameHost. 1468 // to be fixed when RenderViewHostImpl::OnSwapOut moves to RenderFrameHost.
1454 TRACE_EVENT_ASYNC_BEGIN0("navigation", "RenderFrameHostImpl::SwapOut", this); 1469 TRACE_EVENT_ASYNC_BEGIN1("navigation", "RenderFrameHostImpl::SwapOut", this,
1470 "frame_tree_node",
1471 frame_tree_node_->frame_tree_node_id());
1455 1472
1456 // If this RenderFrameHost is already pending deletion, it must have already 1473 // If this RenderFrameHost is already pending deletion, it must have already
1457 // gone through this, therefore just return. 1474 // gone through this, therefore just return.
1458 if (!is_active()) { 1475 if (!is_active()) {
1459 NOTREACHED() << "RFH should be in default state when calling SwapOut."; 1476 NOTREACHED() << "RFH should be in default state when calling SwapOut.";
1460 return; 1477 return;
1461 } 1478 }
1462 1479
1463 if (swapout_event_monitor_timeout_) { 1480 if (swapout_event_monitor_timeout_) {
1464 swapout_event_monitor_timeout_->Start(base::TimeDelta::FromMilliseconds( 1481 swapout_event_monitor_timeout_->Start(base::TimeDelta::FromMilliseconds(
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 // process input events. 1794 // process input events.
1778 GetProcess()->SetIgnoreInputEvents(true); 1795 GetProcess()->SetIgnoreInputEvents(true);
1779 delegate_->RunJavaScriptDialog(this, message, default_prompt, frame_url, 1796 delegate_->RunJavaScriptDialog(this, message, default_prompt, frame_url,
1780 dialog_type, reply_msg); 1797 dialog_type, reply_msg);
1781 } 1798 }
1782 1799
1783 void RenderFrameHostImpl::OnRunBeforeUnloadConfirm( 1800 void RenderFrameHostImpl::OnRunBeforeUnloadConfirm(
1784 const GURL& frame_url, 1801 const GURL& frame_url,
1785 bool is_reload, 1802 bool is_reload,
1786 IPC::Message* reply_msg) { 1803 IPC::Message* reply_msg) {
1804 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnRunBeforeUnloadConfirm",
1805 "frame_tree_node", frame_tree_node_->frame_tree_node_id());
1806
1807 // TODO(nasko): It is strange to accept the frame URL as a parameter from
1808 // the renderer. Investigate and remove parameter, but for now let's
1809 // double check.
1810 DCHECK_EQ(frame_url, last_committed_url_);
1811
1787 // While a JS beforeunload dialog is showing, tabs in the same process 1812 // While a JS beforeunload dialog is showing, tabs in the same process
1788 // shouldn't process input events. 1813 // shouldn't process input events.
1789 GetProcess()->SetIgnoreInputEvents(true); 1814 GetProcess()->SetIgnoreInputEvents(true);
1790 1815
1791 // The beforeunload dialog for this frame may have been triggered by a 1816 // The beforeunload dialog for this frame may have been triggered by a
1792 // browser-side request to this frame or a frame up in the frame hierarchy. 1817 // browser-side request to this frame or a frame up in the frame hierarchy.
1793 // Stop any timers that are waiting. 1818 // Stop any timers that are waiting.
1794 for (RenderFrameHostImpl* frame = this; frame; frame = frame->GetParent()) { 1819 for (RenderFrameHostImpl* frame = this; frame; frame = frame->GetParent()) {
1795 if (frame->beforeunload_timeout_) 1820 if (frame->beforeunload_timeout_)
1796 frame->beforeunload_timeout_->Stop(); 1821 frame->beforeunload_timeout_->Stop();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 // Reset the callback for enabling early exit from future request. 1862 // Reset the callback for enabling early exit from future request.
1838 text_surrounding_selection_callback_.Reset(); 1863 text_surrounding_selection_callback_.Reset();
1839 } 1864 }
1840 1865
1841 void RenderFrameHostImpl::AllowBindings(int bindings_flags) { 1866 void RenderFrameHostImpl::AllowBindings(int bindings_flags) {
1842 // Never grant any bindings to browser plugin guests. 1867 // Never grant any bindings to browser plugin guests.
1843 if (GetProcess()->IsForGuestsOnly()) { 1868 if (GetProcess()->IsForGuestsOnly()) {
1844 NOTREACHED() << "Never grant bindings to a guest process."; 1869 NOTREACHED() << "Never grant bindings to a guest process.";
1845 return; 1870 return;
1846 } 1871 }
1872 TRACE_EVENT2("navigation", "RenderFrameHostImpl::AllowBindings",
1873 "frame_tree_node", frame_tree_node_->frame_tree_node_id(),
1874 "bindings flags", bindings_flags);
1847 1875
1848 // Ensure we aren't granting WebUI bindings to a process that has already 1876 // Ensure we aren't granting WebUI bindings to a process that has already
1849 // been used for non-privileged views. 1877 // been used for non-privileged views.
1850 if (bindings_flags & BINDINGS_POLICY_WEB_UI && 1878 if (bindings_flags & BINDINGS_POLICY_WEB_UI &&
1851 GetProcess()->HasConnection() && 1879 GetProcess()->HasConnection() &&
1852 !ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( 1880 !ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings(
1853 GetProcess()->GetID())) { 1881 GetProcess()->GetID())) {
1854 // This process has no bindings yet. Make sure it does not have more 1882 // This process has no bindings yet. Make sure it does not have more
1855 // than this single active view. 1883 // than this single active view.
1856 // --single-process only has one renderer. 1884 // --single-process only has one renderer.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1921 frame_tree_node_->render_manager()->DidChangeOpener(opener_routing_id, 1949 frame_tree_node_->render_manager()->DidChangeOpener(opener_routing_id,
1922 GetSiteInstance()); 1950 GetSiteInstance());
1923 } 1951 }
1924 1952
1925 void RenderFrameHostImpl::OnDidChangeName(const std::string& name, 1953 void RenderFrameHostImpl::OnDidChangeName(const std::string& name,
1926 const std::string& unique_name) { 1954 const std::string& unique_name) {
1927 if (GetParent() != nullptr) { 1955 if (GetParent() != nullptr) {
1928 // TODO(lukasza): Call ReceivedBadMessage when |unique_name| is empty. 1956 // TODO(lukasza): Call ReceivedBadMessage when |unique_name| is empty.
1929 DCHECK(!unique_name.empty()); 1957 DCHECK(!unique_name.empty());
1930 } 1958 }
1959 TRACE_EVENT2("navigation", "RenderFrameHostImpl::OnDidChangeName",
1960 "frame_tree_node", frame_tree_node_->frame_tree_node_id(),
1961 "name length", name.length());
1931 1962
1932 std::string old_name = frame_tree_node()->frame_name(); 1963 std::string old_name = frame_tree_node()->frame_name();
1933 frame_tree_node()->SetFrameName(name, unique_name); 1964 frame_tree_node()->SetFrameName(name, unique_name);
1934 if (old_name.empty() && !name.empty()) 1965 if (old_name.empty() && !name.empty())
1935 frame_tree_node_->render_manager()->CreateProxiesForNewNamedFrame(); 1966 frame_tree_node_->render_manager()->CreateProxiesForNewNamedFrame();
1936 delegate_->DidChangeName(this, name); 1967 delegate_->DidChangeName(this, name);
1937 } 1968 }
1938 1969
1939 void RenderFrameHostImpl::OnDidSetFeaturePolicyHeader( 1970 void RenderFrameHostImpl::OnDidSetFeaturePolicyHeader(
1940 const ParsedFeaturePolicyHeader& parsed_header) { 1971 const ParsedFeaturePolicyHeader& parsed_header) {
1941 frame_tree_node()->SetFeaturePolicyHeader(parsed_header); 1972 frame_tree_node()->SetFeaturePolicyHeader(parsed_header);
1942 ResetFeaturePolicy(); 1973 ResetFeaturePolicy();
1943 feature_policy_->SetHeaderPolicy(parsed_header); 1974 feature_policy_->SetHeaderPolicy(parsed_header);
1944 } 1975 }
1945 1976
1946 void RenderFrameHostImpl::OnDidAddContentSecurityPolicies( 1977 void RenderFrameHostImpl::OnDidAddContentSecurityPolicies(
1947 const std::vector<ContentSecurityPolicy>& policies) { 1978 const std::vector<ContentSecurityPolicy>& policies) {
1979 TRACE_EVENT1("navigation",
1980 "RenderFrameHostImpl::OnDidAddContentSecurityPolicies",
1981 "frame_tree_node", frame_tree_node_->frame_tree_node_id());
1982
1948 std::vector<ContentSecurityPolicyHeader> headers; 1983 std::vector<ContentSecurityPolicyHeader> headers;
1949 for (const ContentSecurityPolicy& policy : policies) { 1984 for (const ContentSecurityPolicy& policy : policies) {
1950 AddContentSecurityPolicy(policy); 1985 AddContentSecurityPolicy(policy);
1951 headers.push_back(policy.header); 1986 headers.push_back(policy.header);
1952 } 1987 }
1953 frame_tree_node()->AddContentSecurityPolicies(headers); 1988 frame_tree_node()->AddContentSecurityPolicies(headers);
1954 } 1989 }
1955 1990
1956 void RenderFrameHostImpl::OnEnforceInsecureRequestPolicy( 1991 void RenderFrameHostImpl::OnEnforceInsecureRequestPolicy(
1957 blink::WebInsecureRequestPolicy policy) { 1992 blink::WebInsecureRequestPolicy policy) {
1958 frame_tree_node()->SetInsecureRequestPolicy(policy); 1993 frame_tree_node()->SetInsecureRequestPolicy(policy);
1959 } 1994 }
1960 1995
1961 void RenderFrameHostImpl::OnUpdateToUniqueOrigin( 1996 void RenderFrameHostImpl::OnUpdateToUniqueOrigin(
1962 bool is_potentially_trustworthy_unique_origin) { 1997 bool is_potentially_trustworthy_unique_origin) {
1998 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnUpdateToUniqueOrigin",
1999 "frame_tree_node", frame_tree_node_->frame_tree_node_id());
2000
1963 url::Origin origin; 2001 url::Origin origin;
1964 DCHECK(origin.unique()); 2002 DCHECK(origin.unique());
1965 frame_tree_node()->SetCurrentOrigin(origin, 2003 frame_tree_node()->SetCurrentOrigin(origin,
1966 is_potentially_trustworthy_unique_origin); 2004 is_potentially_trustworthy_unique_origin);
1967 } 2005 }
1968 2006
1969 FrameTreeNode* RenderFrameHostImpl::FindAndVerifyChild( 2007 FrameTreeNode* RenderFrameHostImpl::FindAndVerifyChild(
1970 int32_t child_frame_routing_id, 2008 int32_t child_frame_routing_id,
1971 bad_message::BadMessageReason reason) { 2009 bad_message::BadMessageReason reason) {
1972 FrameTreeNode* child = frame_tree_node()->frame_tree()->FindByRoutingID( 2010 FrameTreeNode* child = frame_tree_node()->frame_tree()->FindByRoutingID(
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 // mirroring works correctly, add a check here to enforce it. 2080 // mirroring works correctly, add a check here to enforce it.
2043 delegate_->UpdateEncoding(this, encoding_name); 2081 delegate_->UpdateEncoding(this, encoding_name);
2044 } 2082 }
2045 2083
2046 void RenderFrameHostImpl::OnBeginNavigation( 2084 void RenderFrameHostImpl::OnBeginNavigation(
2047 const CommonNavigationParams& common_params, 2085 const CommonNavigationParams& common_params,
2048 const BeginNavigationParams& begin_params) { 2086 const BeginNavigationParams& begin_params) {
2049 CHECK(IsBrowserSideNavigationEnabled()); 2087 CHECK(IsBrowserSideNavigationEnabled());
2050 if (!is_active()) 2088 if (!is_active())
2051 return; 2089 return;
2090
2091 TRACE_EVENT2("navigation", "RenderFrameHostImpl::OnBeforeNavigation",
2092 "frame_tree_node", frame_tree_node_->frame_tree_node_id(), "url",
2093 common_params.url.possibly_invalid_spec());
2094
2052 CommonNavigationParams validated_params = common_params; 2095 CommonNavigationParams validated_params = common_params;
2053 GetProcess()->FilterURL(false, &validated_params.url); 2096 GetProcess()->FilterURL(false, &validated_params.url);
2054 2097
2055 BeginNavigationParams validated_begin_params = begin_params; 2098 BeginNavigationParams validated_begin_params = begin_params;
2056 GetProcess()->FilterURL(true, &validated_begin_params.searchable_form_url); 2099 GetProcess()->FilterURL(true, &validated_begin_params.searchable_form_url);
2057 2100
2058 if (waiting_for_init_) { 2101 if (waiting_for_init_) {
2059 pendinging_navigate_ = base::MakeUnique<PendingNavigation>( 2102 pendinging_navigate_ = base::MakeUnique<PendingNavigation>(
2060 validated_params, validated_begin_params); 2103 validated_params, validated_begin_params);
2061 return; 2104 return;
2062 } 2105 }
2063 2106
2064 frame_tree_node()->navigator()->OnBeginNavigation( 2107 frame_tree_node()->navigator()->OnBeginNavigation(
2065 frame_tree_node(), validated_params, validated_begin_params); 2108 frame_tree_node(), validated_params, validated_begin_params);
2066 } 2109 }
2067 2110
2068 void RenderFrameHostImpl::OnAbortNavigation() { 2111 void RenderFrameHostImpl::OnAbortNavigation() {
2112 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnAbortNavigation",
2113 "frame_tree_node", frame_tree_node_->frame_tree_node_id());
2069 if (!IsBrowserSideNavigationEnabled()) { 2114 if (!IsBrowserSideNavigationEnabled()) {
2070 NOTREACHED(); 2115 NOTREACHED();
2071 return; 2116 return;
2072 } 2117 }
2073 if (!is_active()) 2118 if (!is_active())
2074 return; 2119 return;
2075 frame_tree_node()->navigator()->OnAbortNavigation(frame_tree_node()); 2120 frame_tree_node()->navigator()->OnAbortNavigation(frame_tree_node());
2076 } 2121 }
2077 2122
2078 void RenderFrameHostImpl::OnDispatchLoad() { 2123 void RenderFrameHostImpl::OnDispatchLoad() {
2124 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnDispatchLoad",
2125 "frame_tree_node", frame_tree_node_->frame_tree_node_id());
2079 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); 2126 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible());
2080 2127
2081 // Don't forward the load event if this RFH is pending deletion. This can 2128 // Don't forward the load event if this RFH is pending deletion. This can
2082 // happen in a race where this RenderFrameHost finishes loading just after 2129 // happen in a race where this RenderFrameHost finishes loading just after
2083 // the frame navigates away. See https://crbug.com/626802. 2130 // the frame navigates away. See https://crbug.com/626802.
2084 if (!is_active()) 2131 if (!is_active())
2085 return; 2132 return;
2086 2133
2087 // Only frames with an out-of-process parent frame should be sending this 2134 // Only frames with an out-of-process parent frame should be sending this
2088 // message. 2135 // message.
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
2312 // Typically, this will be sent as part of the call on the |delegate_| above 2359 // Typically, this will be sent as part of the call on the |delegate_| above
2313 // when resizing the native windows, but sometimes fullscreen can be entered 2360 // when resizing the native windows, but sometimes fullscreen can be entered
2314 // without causing a resize, so we need to ensure that the resize message is 2361 // without causing a resize, so we need to ensure that the resize message is
2315 // sent in that case. We always send this to the main frame's widget, and if 2362 // sent in that case. We always send this to the main frame's widget, and if
2316 // there are any OOPIF widgets, this will also trigger them to resize via 2363 // there are any OOPIF widgets, this will also trigger them to resize via
2317 // frameRectsChanged. 2364 // frameRectsChanged.
2318 render_view_host_->GetWidget()->WasResized(); 2365 render_view_host_->GetWidget()->WasResized();
2319 } 2366 }
2320 2367
2321 void RenderFrameHostImpl::OnDidStartLoading(bool to_different_document) { 2368 void RenderFrameHostImpl::OnDidStartLoading(bool to_different_document) {
2369 TRACE_EVENT2("navigation", "RenderFrameHostImpl::OnDidStartLoading",
2370 "frame_tree_node", frame_tree_node_->frame_tree_node_id(),
2371 "to different document", to_different_document);
2372
2322 if (IsBrowserSideNavigationEnabled() && to_different_document) { 2373 if (IsBrowserSideNavigationEnabled() && to_different_document) {
2323 bad_message::ReceivedBadMessage(GetProcess(), 2374 bad_message::ReceivedBadMessage(GetProcess(),
2324 bad_message::RFH_UNEXPECTED_LOAD_START); 2375 bad_message::RFH_UNEXPECTED_LOAD_START);
2325 return; 2376 return;
2326 } 2377 }
2327 bool was_previously_loading = frame_tree_node_->frame_tree()->IsLoading(); 2378 bool was_previously_loading = frame_tree_node_->frame_tree()->IsLoading();
2328 is_loading_ = true; 2379 is_loading_ = true;
2329 2380
2330 // Only inform the FrameTreeNode of a change in load state if the load state 2381 // Only inform the FrameTreeNode of a change in load state if the load state
2331 // of this RenderFrameHost is being tracked. 2382 // of this RenderFrameHost is being tracked.
2332 if (is_active()) { 2383 if (is_active()) {
2333 frame_tree_node_->DidStartLoading(to_different_document, 2384 frame_tree_node_->DidStartLoading(to_different_document,
2334 was_previously_loading); 2385 was_previously_loading);
2335 } 2386 }
2336 } 2387 }
2337 2388
2338 void RenderFrameHostImpl::OnDidStopLoading() { 2389 void RenderFrameHostImpl::OnDidStopLoading() {
2390 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnDidStopLoading",
2391 "frame_tree_node", frame_tree_node_->frame_tree_node_id());
2392
2339 // This method should never be called when the frame is not loading. 2393 // This method should never be called when the frame is not loading.
2340 // Unfortunately, it can happen if a history navigation happens during a 2394 // Unfortunately, it can happen if a history navigation happens during a
2341 // BeforeUnload or Unload event. 2395 // BeforeUnload or Unload event.
2342 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been 2396 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been
2343 // refactored in Blink. See crbug.com/466089 2397 // refactored in Blink. See crbug.com/466089
2344 if (!is_loading_) { 2398 if (!is_loading_) {
2345 LOG(WARNING) << "OnDidStopLoading was called twice."; 2399 LOG(WARNING) << "OnDidStopLoading was called twice.";
2346 return; 2400 return;
2347 } 2401 }
2348 2402
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2435 const gfx::Rect& initial_rect, 2489 const gfx::Rect& initial_rect,
2436 bool user_gesture) { 2490 bool user_gesture) {
2437 delegate_->ShowCreatedWindow(GetProcess()->GetID(), pending_widget_routing_id, 2491 delegate_->ShowCreatedWindow(GetProcess()->GetID(), pending_widget_routing_id,
2438 disposition, initial_rect, user_gesture); 2492 disposition, initial_rect, user_gesture);
2439 } 2493 }
2440 2494
2441 void RenderFrameHostImpl::CreateNewWindow( 2495 void RenderFrameHostImpl::CreateNewWindow(
2442 mojom::CreateNewWindowParamsPtr params, 2496 mojom::CreateNewWindowParamsPtr params,
2443 CreateNewWindowCallback callback) { 2497 CreateNewWindowCallback callback) {
2444 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2498 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2499 TRACE_EVENT2("navigation", "RenderFrameHostImpl::CreateNewWindow",
2500 "frame_tree_node", frame_tree_node_->frame_tree_node_id(), "url",
2501 params->target_url.possibly_invalid_spec());
2445 2502
2446 bool no_javascript_access = false; 2503 bool no_javascript_access = false;
2447 2504
2448 // Filter out URLs that this process cannot request. 2505 // Filter out URLs that this process cannot request.
2449 GetProcess()->FilterURL(false, &params->target_url); 2506 GetProcess()->FilterURL(false, &params->target_url);
2450 2507
2451 // Ignore creation when sent from a frame that's not current or created. 2508 // Ignore creation when sent from a frame that's not current or created.
2452 bool can_create_window = 2509 bool can_create_window =
2453 frame_tree_node_->current_frame_host() == this && render_frame_created_ && 2510 frame_tree_node_->current_frame_host() == this && render_frame_created_ &&
2454 GetContentClient()->browser()->CanCreateWindow( 2511 GetContentClient()->browser()->CanCreateWindow(
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
2710 // Verify that the origin is allowed to commit in this process. 2767 // Verify that the origin is allowed to commit in this process.
2711 // Note: This also handles non-standard cases for |url|, such as 2768 // Note: This also handles non-standard cases for |url|, such as
2712 // about:blank, data, and blob URLs. 2769 // about:blank, data, and blob URLs.
2713 return CanCommitURL(origin_url); 2770 return CanCommitURL(origin_url);
2714 } 2771 }
2715 2772
2716 void RenderFrameHostImpl::Navigate( 2773 void RenderFrameHostImpl::Navigate(
2717 const CommonNavigationParams& common_params, 2774 const CommonNavigationParams& common_params,
2718 const StartNavigationParams& start_params, 2775 const StartNavigationParams& start_params,
2719 const RequestNavigationParams& request_params) { 2776 const RequestNavigationParams& request_params) {
2720 TRACE_EVENT0("navigation", "RenderFrameHostImpl::Navigate"); 2777 TRACE_EVENT1("navigation", "RenderFrameHostImpl::Navigate", "frame_tree_node",
2778 frame_tree_node_->frame_tree_node_id());
2721 DCHECK(!IsBrowserSideNavigationEnabled()); 2779 DCHECK(!IsBrowserSideNavigationEnabled());
2722 2780
2723 UpdatePermissionsForNavigation(common_params, request_params); 2781 UpdatePermissionsForNavigation(common_params, request_params);
2724 2782
2725 // Only send the message if we aren't suspended at the start of a cross-site 2783 // Only send the message if we aren't suspended at the start of a cross-site
2726 // request. 2784 // request.
2727 if (navigations_suspended_) { 2785 if (navigations_suspended_) {
2728 // This may replace an existing set of params, if this is a pending RFH that 2786 // This may replace an existing set of params, if this is a pending RFH that
2729 // is navigated twice consecutively. 2787 // is navigated twice consecutively.
2730 suspended_nav_params_.reset( 2788 suspended_nav_params_.reset(
(...skipping 16 matching lines...) Expand all
2747 // 2805 //
2748 // Blink doesn't send throb notifications for JavaScript URLs, so it is not 2806 // Blink doesn't send throb notifications for JavaScript URLs, so it is not
2749 // done here either. 2807 // done here either.
2750 if (!common_params.url.SchemeIs(url::kJavaScriptScheme) && 2808 if (!common_params.url.SchemeIs(url::kJavaScriptScheme) &&
2751 (!navigation_handle_ || !navigation_handle_->is_transferring())) { 2809 (!navigation_handle_ || !navigation_handle_->is_transferring())) {
2752 OnDidStartLoading(true); 2810 OnDidStartLoading(true);
2753 } 2811 }
2754 } 2812 }
2755 2813
2756 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { 2814 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) {
2815 TRACE_EVENT1("navigation", "RenderFrameHostImpl::NavigateToInterstitialURL",
2816 "frame_tree_node", frame_tree_node_->frame_tree_node_id());
2757 DCHECK(data_url.SchemeIs(url::kDataScheme)); 2817 DCHECK(data_url.SchemeIs(url::kDataScheme));
2758 CommonNavigationParams common_params( 2818 CommonNavigationParams common_params(
2759 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, 2819 data_url, Referrer(), ui::PAGE_TRANSITION_LINK,
2760 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, false, false, 2820 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, false, false,
2761 base::TimeTicks::Now(), FrameMsg_UILoadMetricsReportType::NO_REPORT, 2821 base::TimeTicks::Now(), FrameMsg_UILoadMetricsReportType::NO_REPORT,
2762 GURL(), GURL(), PREVIEWS_OFF, base::TimeTicks::Now(), "GET", nullptr, 2822 GURL(), GURL(), PREVIEWS_OFF, base::TimeTicks::Now(), "GET", nullptr,
2763 base::Optional<SourceLocation>(), 2823 base::Optional<SourceLocation>(),
2764 CSPDisposition::CHECK /* should_check_main_world_csp */); 2824 CSPDisposition::CHECK /* should_check_main_world_csp */);
2765 if (IsBrowserSideNavigationEnabled()) { 2825 if (IsBrowserSideNavigationEnabled()) {
2766 CommitNavigation(nullptr, nullptr, mojo::ScopedDataPipeConsumerHandle(), 2826 CommitNavigation(nullptr, nullptr, mojo::ScopedDataPipeConsumerHandle(),
2767 common_params, RequestNavigationParams(), false); 2827 common_params, RequestNavigationParams(), false);
2768 } else { 2828 } else {
2769 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); 2829 Navigate(common_params, StartNavigationParams(), RequestNavigationParams());
2770 } 2830 }
2771 } 2831 }
2772 2832
2773 void RenderFrameHostImpl::Stop() { 2833 void RenderFrameHostImpl::Stop() {
2834 TRACE_EVENT1("navigation", "RenderFrameHostImpl::Stop", "frame_tree_node",
2835 frame_tree_node_->frame_tree_node_id());
2774 Send(new FrameMsg_Stop(routing_id_)); 2836 Send(new FrameMsg_Stop(routing_id_));
2775 } 2837 }
2776 2838
2777 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_navigation, 2839 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_navigation,
2778 bool is_reload) { 2840 bool is_reload) {
2779 DCHECK(for_navigation || !is_reload); 2841 DCHECK(for_navigation || !is_reload);
2780 2842
2781 if (IsBrowserSideNavigationEnabled() && !for_navigation) { 2843 if (IsBrowserSideNavigationEnabled() && !for_navigation) {
2782 // Cancel any pending navigations, to avoid their navigation commit/fail 2844 // Cancel any pending navigations, to avoid their navigation commit/fail
2783 // event from wiping out the is_waiting_for_beforeunload_ack_ state. 2845 // event from wiping out the is_waiting_for_beforeunload_ack_ state.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2832 DCHECK(is_waiting_for_beforeunload_ack_); 2894 DCHECK(is_waiting_for_beforeunload_ack_);
2833 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_; 2895 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_;
2834 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now()); 2896 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now());
2835 } 2897 }
2836 2898
2837 bool RenderFrameHostImpl::ShouldDispatchBeforeUnload() { 2899 bool RenderFrameHostImpl::ShouldDispatchBeforeUnload() {
2838 return IsRenderFrameLive(); 2900 return IsRenderFrameLive();
2839 } 2901 }
2840 2902
2841 void RenderFrameHostImpl::UpdateOpener() { 2903 void RenderFrameHostImpl::UpdateOpener() {
2904 TRACE_EVENT1("navigation", "RenderFrameHostImpl::UpdateOpener",
2905 "frame_tree_node", frame_tree_node_->frame_tree_node_id());
2906
2842 // This frame (the frame whose opener is being updated) might not have had 2907 // This frame (the frame whose opener is being updated) might not have had
2843 // proxies for the new opener chain in its SiteInstance. Make sure they 2908 // proxies for the new opener chain in its SiteInstance. Make sure they
2844 // exist. 2909 // exist.
2845 if (frame_tree_node_->opener()) { 2910 if (frame_tree_node_->opener()) {
2846 frame_tree_node_->opener()->render_manager()->CreateOpenerProxies( 2911 frame_tree_node_->opener()->render_manager()->CreateOpenerProxies(
2847 GetSiteInstance(), frame_tree_node_); 2912 GetSiteInstance(), frame_tree_node_);
2848 } 2913 }
2849 2914
2850 int opener_routing_id = 2915 int opener_routing_id =
2851 frame_tree_node_->render_manager()->GetOpenerRoutingID(GetSiteInstance()); 2916 frame_tree_node_->render_manager()->GetOpenerRoutingID(GetSiteInstance());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2920 } 2985 }
2921 2986
2922 // PlzNavigate 2987 // PlzNavigate
2923 void RenderFrameHostImpl::CommitNavigation( 2988 void RenderFrameHostImpl::CommitNavigation(
2924 ResourceResponse* response, 2989 ResourceResponse* response,
2925 std::unique_ptr<StreamHandle> body, 2990 std::unique_ptr<StreamHandle> body,
2926 mojo::ScopedDataPipeConsumerHandle handle, 2991 mojo::ScopedDataPipeConsumerHandle handle,
2927 const CommonNavigationParams& common_params, 2992 const CommonNavigationParams& common_params,
2928 const RequestNavigationParams& request_params, 2993 const RequestNavigationParams& request_params,
2929 bool is_view_source) { 2994 bool is_view_source) {
2995 TRACE_EVENT2("navigation", "RenderFrameHostImpl::CommitNavigation",
2996 "frame_tree_node", frame_tree_node_->frame_tree_node_id(), "url",
2997 common_params.url.possibly_invalid_spec());
2930 DCHECK( 2998 DCHECK(
2931 (response && (body.get() || handle.is_valid())) || 2999 (response && (body.get() || handle.is_valid())) ||
2932 common_params.url.SchemeIs(url::kDataScheme) || 3000 common_params.url.SchemeIs(url::kDataScheme) ||
2933 !ShouldMakeNetworkRequestForURL(common_params.url) || 3001 !ShouldMakeNetworkRequestForURL(common_params.url) ||
2934 FrameMsg_Navigate_Type::IsSameDocument(common_params.navigation_type) || 3002 FrameMsg_Navigate_Type::IsSameDocument(common_params.navigation_type) ||
2935 IsRendererDebugURL(common_params.url)); 3003 IsRendererDebugURL(common_params.url));
2936 UpdatePermissionsForNavigation(common_params, request_params); 3004 UpdatePermissionsForNavigation(common_params, request_params);
2937 3005
2938 // Get back to a clean state, in case we start a new navigation without 3006 // Get back to a clean state, in case we start a new navigation without
2939 // completing an unload handler. 3007 // completing an unload handler.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2973 is_loading_ = true; 3041 is_loading_ = true;
2974 } 3042 }
2975 } 3043 }
2976 3044
2977 void RenderFrameHostImpl::FailedNavigation( 3045 void RenderFrameHostImpl::FailedNavigation(
2978 const CommonNavigationParams& common_params, 3046 const CommonNavigationParams& common_params,
2979 const BeginNavigationParams& begin_params, 3047 const BeginNavigationParams& begin_params,
2980 const RequestNavigationParams& request_params, 3048 const RequestNavigationParams& request_params,
2981 bool has_stale_copy_in_cache, 3049 bool has_stale_copy_in_cache,
2982 int error_code) { 3050 int error_code) {
3051 TRACE_EVENT2("navigation", "RenderFrameHostImpl::FailedNavigation",
3052 "frame_tree_node", frame_tree_node_->frame_tree_node_id(),
3053 "error", error_code);
3054
2983 // Update renderer permissions even for failed commits, so that for example 3055 // Update renderer permissions even for failed commits, so that for example
2984 // the URL bar correctly displays privileged URLs instead of filtering them. 3056 // the URL bar correctly displays privileged URLs instead of filtering them.
2985 UpdatePermissionsForNavigation(common_params, request_params); 3057 UpdatePermissionsForNavigation(common_params, request_params);
2986 3058
2987 // Get back to a clean state, in case a new navigation started without 3059 // Get back to a clean state, in case a new navigation started without
2988 // completing an unload handler. 3060 // completing an unload handler.
2989 ResetWaitingState(); 3061 ResetWaitingState();
2990 3062
2991 Send(new FrameMsg_FailedNavigation(routing_id_, common_params, request_params, 3063 Send(new FrameMsg_FailedNavigation(routing_id_, common_params, request_params,
2992 has_stale_copy_in_cache, error_code)); 3064 has_stale_copy_in_cache, error_code));
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
3792 } 3864 }
3793 3865
3794 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame( 3866 void RenderFrameHostImpl::ForwardGetInterfaceToRenderFrame(
3795 const std::string& interface_name, 3867 const std::string& interface_name,
3796 mojo::ScopedMessagePipeHandle pipe) { 3868 mojo::ScopedMessagePipeHandle pipe) {
3797 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe)); 3869 GetRemoteInterfaces()->GetInterface(interface_name, std::move(pipe));
3798 } 3870 }
3799 #endif 3871 #endif
3800 3872
3801 } // namespace content 3873 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698