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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 2974553002: Fix NavigationHandle being thrown out and recreated (without all the state) after rapid navigations. (Closed)
Patch Set: fix Created 3 years, 5 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
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after
1746 std::unique_ptr<NavigationParams> navigation_params) { 1746 std::unique_ptr<NavigationParams> navigation_params) {
1747 pending_navigation_params_ = std::move(navigation_params); 1747 pending_navigation_params_ = std::move(navigation_params);
1748 } 1748 }
1749 1749
1750 void RenderFrameImpl::OnBeforeUnload(bool is_reload) { 1750 void RenderFrameImpl::OnBeforeUnload(bool is_reload) {
1751 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::OnBeforeUnload", 1751 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::OnBeforeUnload",
1752 "id", routing_id_); 1752 "id", routing_id_);
1753 // Save the routing_id, as the RenderFrameImpl can be deleted in 1753 // Save the routing_id, as the RenderFrameImpl can be deleted in
1754 // dispatchBeforeUnloadEvent. See https://crbug.com/666714 for details. 1754 // dispatchBeforeUnloadEvent. See https://crbug.com/666714 for details.
1755 int routing_id = routing_id_; 1755 int routing_id = routing_id_;
1756 base::WeakPtr<RenderFrameImpl> weak_this = weak_factory_.GetWeakPtr();
1756 1757
1757 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); 1758 base::TimeTicks before_unload_start_time = base::TimeTicks::Now();
1758 1759
1759 // TODO(clamy): Ensure BeforeUnload is dispatched to all subframes, even when 1760 // TODO(clamy): Ensure BeforeUnload is dispatched to all subframes, even when
1760 // --site-per-process is enabled. |dispatchBeforeUnloadEvent| will only 1761 // --site-per-process is enabled. |dispatchBeforeUnloadEvent| will only
1761 // execute the BeforeUnload event in this frame and local child frames. It 1762 // execute the BeforeUnload event in this frame and local child frames. It
1762 // should also be dispatched to out-of-process child frames. 1763 // should also be dispatched to out-of-process child frames.
1763 bool proceed = frame_->DispatchBeforeUnloadEvent(is_reload); 1764 bool proceed = frame_->DispatchBeforeUnloadEvent(is_reload);
1765 if (IsBrowserSideNavigationEnabled() && proceed && weak_this) {
1766 ran_before_unload_ = true;
1767 // If there's already a pending navigation its didcommitprovisionalload or
1768 // didstoploading IPCs (exact one which fires is racy) would interfere with
1769 // the new navigation. By forcing the old navigation to be cancelled first,
1770 // then we are assured that the IPC pipe is flushed of IPCs related to a
1771 // previous navigation.
1772 frame_->StopLoading();
jam 2017/07/08 01:32:49 this prevents stray FrameHostMsg_DidCommitProvisio
clamy 2017/07/10 13:02:05 That seems wrong to me. If we're trying to load a
1773 }
1764 1774
1765 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); 1775 base::TimeTicks before_unload_end_time = base::TimeTicks::Now();
1766 RenderThread::Get()->Send(new FrameHostMsg_BeforeUnload_ACK( 1776 RenderThread::Get()->Send(new FrameHostMsg_BeforeUnload_ACK(
1767 routing_id, proceed, before_unload_start_time, before_unload_end_time)); 1777 routing_id, proceed, before_unload_start_time, before_unload_end_time));
1768 } 1778 }
1769 1779
1770 void RenderFrameImpl::OnSwapOut( 1780 void RenderFrameImpl::OnSwapOut(
1771 int proxy_routing_id, 1781 int proxy_routing_id,
1772 bool is_loading, 1782 bool is_loading,
1773 const FrameReplicationState& replicated_frame_state) { 1783 const FrameReplicationState& replicated_frame_state) {
(...skipping 3292 matching lines...) Expand 10 before | Expand all | Expand 10 after
5066 history_subframe_unique_names_.clear(); 5076 history_subframe_unique_names_.clear();
5067 5077
5068 blink::WebIconURL::Type icon_types_mask = 5078 blink::WebIconURL::Type icon_types_mask =
5069 static_cast<blink::WebIconURL::Type>( 5079 static_cast<blink::WebIconURL::Type>(
5070 blink::WebIconURL::kTypeFavicon | 5080 blink::WebIconURL::kTypeFavicon |
5071 blink::WebIconURL::kTypeTouchPrecomposed | 5081 blink::WebIconURL::kTypeTouchPrecomposed |
5072 blink::WebIconURL::kTypeTouch); 5082 blink::WebIconURL::kTypeTouch);
5073 SendUpdateFaviconURL(icon_types_mask); 5083 SendUpdateFaviconURL(icon_types_mask);
5074 5084
5075 render_view_->FrameDidStopLoading(frame_); 5085 render_view_->FrameDidStopLoading(frame_);
5086
5087 if (IsBrowserSideNavigationEnabled() && ran_before_unload_) {
5088 // Avoid a previous navigation's didstop IPC from resetting the
5089 // NavigationHandle of the next navigation.
5090 return;
jam 2017/07/08 01:32:49 this prevents the other case of stray FrameHostMsg
5091 }
5092
5076 Send(new FrameHostMsg_DidStopLoading(routing_id_)); 5093 Send(new FrameHostMsg_DidStopLoading(routing_id_));
5077 } 5094 }
5078 5095
5079 void RenderFrameImpl::DidChangeLoadProgress(double load_progress) { 5096 void RenderFrameImpl::DidChangeLoadProgress(double load_progress) {
5080 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress)); 5097 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress));
5081 } 5098 }
5082 5099
5083 void RenderFrameImpl::HandleWebAccessibilityEvent( 5100 void RenderFrameImpl::HandleWebAccessibilityEvent(
5084 const blink::WebAXObject& obj, blink::WebAXEvent event) { 5101 const blink::WebAXObject& obj, blink::WebAXEvent event) {
5085 if (render_accessibility_) 5102 if (render_accessibility_)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
5156 mojo::ScopedMessagePipeHandle(commit_data.url_loader_factory), 0u)); 5173 mojo::ScopedMessagePipeHandle(commit_data.url_loader_factory), 0u));
5157 } 5174 }
5158 5175
5159 // If the request was initiated in the context of a user gesture then make 5176 // If the request was initiated in the context of a user gesture then make
5160 // sure that the navigation also executes in the context of a user gesture. 5177 // sure that the navigation also executes in the context of a user gesture.
5161 std::unique_ptr<blink::WebScopedUserGesture> gesture( 5178 std::unique_ptr<blink::WebScopedUserGesture> gesture(
5162 request_params.has_user_gesture ? new blink::WebScopedUserGesture(frame_) 5179 request_params.has_user_gesture ? new blink::WebScopedUserGesture(frame_)
5163 : nullptr); 5180 : nullptr);
5164 5181
5165 browser_side_navigation_pending_ = false; 5182 browser_side_navigation_pending_ = false;
5183 ran_before_unload_ = false;
5166 5184
5167 NavigateInternal(common_params, StartNavigationParams(), request_params, 5185 NavigateInternal(common_params, StartNavigationParams(), request_params,
5168 std::move(stream_override)); 5186 std::move(stream_override));
5169 5187
5170 // Don't add code after this since NavigateInternal may have destroyed this 5188 // Don't add code after this since NavigateInternal may have destroyed this
5171 // RenderFrameImpl. 5189 // RenderFrameImpl.
5172 } 5190 }
5173 5191
5174 // PlzNavigate 5192 // PlzNavigate
5175 void RenderFrameImpl::OnFailedNavigation( 5193 void RenderFrameImpl::OnFailedNavigation(
(...skipping 11 matching lines...) Expand all
5187 5205
5188 // If this frame is navigating cross-process, it may naively assume that this 5206 // If this frame is navigating cross-process, it may naively assume that this
5189 // is the first navigation in the frame, but this may not actually be the 5207 // is the first navigation in the frame, but this may not actually be the
5190 // case. Inform the frame's state machine if this frame has already committed 5208 // case. Inform the frame's state machine if this frame has already committed
5191 // other loads. 5209 // other loads.
5192 if (request_params.has_committed_real_load) 5210 if (request_params.has_committed_real_load)
5193 frame_->SetCommittedFirstRealLoad(); 5211 frame_->SetCommittedFirstRealLoad();
5194 5212
5195 pending_navigation_params_.reset(new NavigationParams( 5213 pending_navigation_params_.reset(new NavigationParams(
5196 common_params, StartNavigationParams(), request_params)); 5214 common_params, StartNavigationParams(), request_params));
5215 ran_before_unload_ = false;
5197 5216
5198 // Send the provisional load failure. 5217 // Send the provisional load failure.
5199 blink::WebURLError error = 5218 blink::WebURLError error =
5200 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); 5219 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code);
5201 WebURLRequest failed_request = 5220 WebURLRequest failed_request =
5202 CreateURLRequestForNavigation(common_params, request_params, 5221 CreateURLRequestForNavigation(common_params, request_params,
5203 std::unique_ptr<StreamOverrideParameters>(), 5222 std::unique_ptr<StreamOverrideParameters>(),
5204 frame_->IsViewSourceModeEnabled(), 5223 frame_->IsViewSourceModeEnabled(),
5205 false); // is_same_document_navigation 5224 false); // is_same_document_navigation
5206 5225
(...skipping 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after
6903 replaces_current_history_item(info.replaces_current_history_item), 6922 replaces_current_history_item(info.replaces_current_history_item),
6904 history_navigation_in_new_child_frame( 6923 history_navigation_in_new_child_frame(
6905 info.is_history_navigation_in_new_child_frame), 6924 info.is_history_navigation_in_new_child_frame),
6906 client_redirect(info.is_client_redirect), 6925 client_redirect(info.is_client_redirect),
6907 triggering_event_info(info.triggering_event_info), 6926 triggering_event_info(info.triggering_event_info),
6908 cache_disabled(info.is_cache_disabled), 6927 cache_disabled(info.is_cache_disabled),
6909 form(info.form), 6928 form(info.form),
6910 source_location(info.source_location) {} 6929 source_location(info.source_location) {}
6911 6930
6912 } // namespace content 6931 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698