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

Unified Diff: content/browser/frame_host/navigation_handle_impl.cc

Issue 2510083003: PlzNavigate: properly update NavigationHandle for 204/205 and download responses (Closed)
Patch Set: . Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/navigation_handle_impl.cc
diff --git a/content/browser/frame_host/navigation_handle_impl.cc b/content/browser/frame_host/navigation_handle_impl.cc
index f2b2f133ddb19e898c42a356464ef428bd77a875..bbcdcfed714ce72c31ee6e791299a06d76325ca9 100644
--- a/content/browser/frame_host/navigation_handle_impl.cc
+++ b/content/browser/frame_host/navigation_handle_impl.cc
@@ -623,6 +623,23 @@ NavigationHandleImpl::CheckWillProcessResponse() {
DCHECK(state_ == WILL_PROCESS_RESPONSE || state_ == DEFERRING_RESPONSE);
DCHECK(state_ != WILL_PROCESS_RESPONSE || next_index_ == 0);
DCHECK(state_ != DEFERRING_RESPONSE || next_index_ != 0);
+
+ // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not
+ // commit; they leave the frame showing the previous page.
+ const bool is_204_205_response =
clamy 2016/11/25 10:46:00 I'm still not super happy about the code flow here
yzshen1 2016/11/28 22:03:59 Done.
clamy 2016/11/30 17:44:03 Yes this is something we could do as well. Let me
+ response_headers_ && (response_headers_->response_code() == 204 ||
+ response_headers_->response_code() == 205);
+
+ // No need to cancel in non-PlzNavigate case. In that case, we will get
+ // DidFailProvisionalLoadWithError notification from the renderer to abort the
+ // navigation.
+ if (IsBrowserSideNavigationEnabled() &&
+ (is_204_205_response || is_download_)) {
+ net_error_code_ = net::ERR_ABORTED;
+ state_ = CANCELING;
+ return NavigationThrottle::CANCEL_AND_IGNORE;
+ }
+
for (size_t i = next_index_; i < throttles_.size(); ++i) {
NavigationThrottle::ThrottleCheckResult result =
throttles_[i]->WillProcessResponse();
« no previous file with comments | « no previous file | content/browser/frame_host/navigation_request.h » ('j') | content/browser/frame_host/navigation_request.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698