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

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

Issue 2657813004: PlzNavigate: set the error code in NavigationHandle on abort (Closed)
Patch Set: PlzNavigate: set the error code in NavigationHandle on abort Created 3 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/navigation_request.h" 5 #include "content/browser/frame_host/navigation_request.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "content/browser/appcache/appcache_navigation_handle.h" 10 #include "content/browser/appcache/appcache_navigation_handle.h"
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 DCHECK(result != NavigationThrottle::DEFER); 568 DCHECK(result != NavigationThrottle::DEFER);
569 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE); 569 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE);
570 570
571 if (on_start_checks_complete_closure_) 571 if (on_start_checks_complete_closure_)
572 on_start_checks_complete_closure_.Run(); 572 on_start_checks_complete_closure_.Run();
573 573
574 // Abort the request if needed. This will destroy the NavigationRequest. 574 // Abort the request if needed. This will destroy the NavigationRequest.
575 if (result == NavigationThrottle::CANCEL_AND_IGNORE || 575 if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
576 result == NavigationThrottle::CANCEL) { 576 result == NavigationThrottle::CANCEL) {
577 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. 577 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
578 frame_tree_node_->ResetNavigationRequest(false); 578 OnRequestFailed(false, net::ERR_ABORTED);
clamy 2017/01/26 15:33:45 OnRequestFailed will set the error code on the Nav
579 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has
580 // destroyed the NavigationRequest.
579 return; 581 return;
580 } 582 }
581 583
582 if (result == NavigationThrottle::BLOCK_REQUEST) { 584 if (result == NavigationThrottle::BLOCK_REQUEST) {
583 OnRequestFailed(false, net::ERR_BLOCKED_BY_CLIENT); 585 OnRequestFailed(false, net::ERR_BLOCKED_BY_CLIENT);
584 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has 586 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has
585 // destroyed the NavigationRequest. 587 // destroyed the NavigationRequest.
586 return; 588 return;
587 } 589 }
588 590
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 663
662 void NavigationRequest::OnRedirectChecksComplete( 664 void NavigationRequest::OnRedirectChecksComplete(
663 NavigationThrottle::ThrottleCheckResult result) { 665 NavigationThrottle::ThrottleCheckResult result) {
664 DCHECK(result != NavigationThrottle::DEFER); 666 DCHECK(result != NavigationThrottle::DEFER);
665 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE); 667 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE);
666 668
667 // Abort the request if needed. This will destroy the NavigationRequest. 669 // Abort the request if needed. This will destroy the NavigationRequest.
668 if (result == NavigationThrottle::CANCEL_AND_IGNORE || 670 if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
669 result == NavigationThrottle::CANCEL) { 671 result == NavigationThrottle::CANCEL) {
670 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. 672 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
671 frame_tree_node_->ResetNavigationRequest(false); 673 OnRequestFailed(false, net::ERR_ABORTED);
674 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has
675 // destroyed the NavigationRequest.
672 return; 676 return;
673 } 677 }
674 678
675 loader_->FollowRedirect(); 679 loader_->FollowRedirect();
676 } 680 }
677 681
678 void NavigationRequest::OnWillProcessResponseChecksComplete( 682 void NavigationRequest::OnWillProcessResponseChecksComplete(
679 NavigationThrottle::ThrottleCheckResult result) { 683 NavigationThrottle::ThrottleCheckResult result) {
680 DCHECK(result != NavigationThrottle::DEFER); 684 DCHECK(result != NavigationThrottle::DEFER);
681 685
682 // Abort the request if needed. This includes requests that were blocked by 686 // Abort the request if needed. This includes requests that were blocked by
683 // NavigationThrottles and requests that should not commit (e.g. downloads, 687 // NavigationThrottles and requests that should not commit (e.g. downloads,
684 // 204/205s). This will destroy the NavigationRequest. 688 // 204/205s). This will destroy the NavigationRequest.
685 if (result == NavigationThrottle::CANCEL_AND_IGNORE || 689 if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
686 result == NavigationThrottle::CANCEL || !response_should_be_rendered_) { 690 result == NavigationThrottle::CANCEL || !response_should_be_rendered_) {
687 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. 691 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
688 frame_tree_node_->navigator()->DiscardPendingEntryIfNeeded( 692 OnRequestFailed(false, net::ERR_ABORTED);
689 navigation_handle_.get()); 693 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has
690 frame_tree_node_->ResetNavigationRequest(false); 694 // destroyed the NavigationRequest.
691 return; 695 return;
692 } 696 }
693 697
694 if (result == NavigationThrottle::BLOCK_RESPONSE) { 698 if (result == NavigationThrottle::BLOCK_RESPONSE) {
695 OnRequestFailed(false, net::ERR_BLOCKED_BY_RESPONSE); 699 OnRequestFailed(false, net::ERR_BLOCKED_BY_RESPONSE);
696 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has 700 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has
697 // destroyed the NavigationRequest. 701 // destroyed the NavigationRequest.
698 return; 702 return;
699 } 703 }
700 704
(...skipping 23 matching lines...) Expand all
724 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); 728 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture);
725 729
726 render_frame_host->CommitNavigation(response_.get(), std::move(body_), 730 render_frame_host->CommitNavigation(response_.get(), std::move(body_),
727 common_params_, request_params_, 731 common_params_, request_params_,
728 is_view_source_); 732 is_view_source_);
729 733
730 frame_tree_node_->ResetNavigationRequest(true); 734 frame_tree_node_->ResetNavigationRequest(true);
731 } 735 }
732 736
733 } // namespace content 737 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698