| OLD | NEW |
| 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 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 "navigation", "Navigation timeToNetworkStack", navigation_handle_.get(), | 678 "navigation", "Navigation timeToNetworkStack", navigation_handle_.get(), |
| 679 timestamp); | 679 timestamp); |
| 680 } | 680 } |
| 681 | 681 |
| 682 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, | 682 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, |
| 683 common_params_.url); | 683 common_params_.url); |
| 684 } | 684 } |
| 685 | 685 |
| 686 void NavigationRequest::OnStartChecksComplete( | 686 void NavigationRequest::OnStartChecksComplete( |
| 687 NavigationThrottle::ThrottleCheckResult result) { | 687 NavigationThrottle::ThrottleCheckResult result) { |
| 688 DCHECK(result != NavigationThrottle::DEFER); | 688 DCHECK(result.action() != NavigationThrottle::DEFER); |
| 689 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE); | 689 DCHECK(result.action() != NavigationThrottle::BLOCK_RESPONSE); |
| 690 | 690 |
| 691 if (on_start_checks_complete_closure_) | 691 if (on_start_checks_complete_closure_) |
| 692 on_start_checks_complete_closure_.Run(); | 692 on_start_checks_complete_closure_.Run(); |
| 693 | 693 |
| 694 // Abort the request if needed. This will destroy the NavigationRequest. | 694 // Abort the request if needed. This will destroy the NavigationRequest. |
| 695 if (result == NavigationThrottle::CANCEL_AND_IGNORE || | 695 if (result.action() == NavigationThrottle::CANCEL_AND_IGNORE || |
| 696 result == NavigationThrottle::CANCEL) { | 696 result.action() == NavigationThrottle::CANCEL) { |
| 697 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. | 697 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. |
| 698 DCHECK_EQ(net::ERR_ABORTED, result.net_error_code()); |
| 698 OnRequestFailed(false, net::ERR_ABORTED); | 699 OnRequestFailed(false, net::ERR_ABORTED); |
| 699 | 700 |
| 700 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has | 701 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has |
| 701 // destroyed the NavigationRequest. | 702 // destroyed the NavigationRequest. |
| 702 return; | 703 return; |
| 703 } | 704 } |
| 704 | 705 |
| 705 if (result == NavigationThrottle::BLOCK_REQUEST) { | 706 if (result.action() == NavigationThrottle::BLOCK_REQUEST) { |
| 706 OnRequestFailed(false, net::ERR_BLOCKED_BY_CLIENT); | 707 DCHECK_NE(net::OK, result.net_error_code()); |
| 708 OnRequestFailed(false, result.net_error_code()); |
| 707 | 709 |
| 708 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has | 710 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has |
| 709 // destroyed the NavigationRequest. | 711 // destroyed the NavigationRequest. |
| 710 return; | 712 return; |
| 711 } | 713 } |
| 712 | 714 |
| 713 // Use the SiteInstance of the navigating RenderFrameHost to get access to | 715 // Use the SiteInstance of the navigating RenderFrameHost to get access to |
| 714 // the StoragePartition. Using the url of the navigation will result in a | 716 // the StoragePartition. Using the url of the navigation will result in a |
| 715 // wrong StoragePartition being picked when a WebView is navigating. | 717 // wrong StoragePartition being picked when a WebView is navigating. |
| 716 DCHECK_NE(AssociatedSiteInstanceType::NONE, associated_site_instance_type_); | 718 DCHECK_NE(AssociatedSiteInstanceType::NONE, associated_site_instance_type_); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 IsSecureFrame(frame_tree_node_->parent()), | 784 IsSecureFrame(frame_tree_node_->parent()), |
| 783 frame_tree_node_->frame_tree_node_id(), is_for_guests_only, | 785 frame_tree_node_->frame_tree_node_id(), is_for_guests_only, |
| 784 report_raw_headers, navigating_frame_host->GetVisibilityState()), | 786 report_raw_headers, navigating_frame_host->GetVisibilityState()), |
| 785 std::move(navigation_ui_data), | 787 std::move(navigation_ui_data), |
| 786 navigation_handle_->service_worker_handle(), | 788 navigation_handle_->service_worker_handle(), |
| 787 navigation_handle_->appcache_handle(), this); | 789 navigation_handle_->appcache_handle(), this); |
| 788 } | 790 } |
| 789 | 791 |
| 790 void NavigationRequest::OnRedirectChecksComplete( | 792 void NavigationRequest::OnRedirectChecksComplete( |
| 791 NavigationThrottle::ThrottleCheckResult result) { | 793 NavigationThrottle::ThrottleCheckResult result) { |
| 792 DCHECK(result != NavigationThrottle::DEFER); | 794 DCHECK(result.action() != NavigationThrottle::DEFER); |
| 793 DCHECK(result != NavigationThrottle::BLOCK_RESPONSE); | 795 DCHECK(result.action() != NavigationThrottle::BLOCK_RESPONSE); |
| 794 | 796 |
| 795 // Abort the request if needed. This will destroy the NavigationRequest. | 797 // Abort the request if needed. This will destroy the NavigationRequest. |
| 796 if (result == NavigationThrottle::CANCEL_AND_IGNORE || | 798 if (result.action() == NavigationThrottle::CANCEL_AND_IGNORE || |
| 797 result == NavigationThrottle::CANCEL) { | 799 result.action() == NavigationThrottle::CANCEL) { |
| 800 DCHECK_EQ(net::ERR_ABORTED, result.net_error_code()); |
| 798 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. | 801 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. |
| 799 OnRequestFailed(false, net::ERR_ABORTED); | 802 OnRequestFailed(false, net::ERR_ABORTED); |
| 800 | 803 |
| 801 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has | 804 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has |
| 802 // destroyed the NavigationRequest. | 805 // destroyed the NavigationRequest. |
| 803 return; | 806 return; |
| 804 } | 807 } |
| 805 | 808 |
| 806 if (result == NavigationThrottle::BLOCK_REQUEST) { | 809 if (result.action() == NavigationThrottle::BLOCK_REQUEST) { |
| 807 OnRequestFailed(false, net::ERR_BLOCKED_BY_CLIENT); | 810 DCHECK_NE(net::OK, result.net_error_code()); |
| 811 OnRequestFailed(false, result.net_error_code()); |
| 808 | 812 |
| 809 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has | 813 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has |
| 810 // destroyed the NavigationRequest. | 814 // destroyed the NavigationRequest. |
| 811 return; | 815 return; |
| 812 } | 816 } |
| 813 | 817 |
| 814 loader_->FollowRedirect(); | 818 loader_->FollowRedirect(); |
| 815 } | 819 } |
| 816 | 820 |
| 817 void NavigationRequest::OnWillProcessResponseChecksComplete( | 821 void NavigationRequest::OnWillProcessResponseChecksComplete( |
| 818 NavigationThrottle::ThrottleCheckResult result) { | 822 NavigationThrottle::ThrottleCheckResult result) { |
| 819 DCHECK(result != NavigationThrottle::DEFER); | 823 DCHECK(result.action() != NavigationThrottle::DEFER); |
| 820 | 824 |
| 821 // If the NavigationThrottles allowed the navigation to continue, have the | 825 // If the NavigationThrottles allowed the navigation to continue, have the |
| 822 // processing of the response resume in the network stack. | 826 // processing of the response resume in the network stack. |
| 823 if (result == NavigationThrottle::PROCEED) | 827 |
| 828 if (result.action() == NavigationThrottle::PROCEED) |
| 824 loader_->ProceedWithResponse(); | 829 loader_->ProceedWithResponse(); |
| 825 | 830 |
| 826 // Abort the request if needed. This includes requests that were blocked by | 831 // Abort the request if needed. This includes requests that were blocked by |
| 827 // NavigationThrottles and requests that should not commit (e.g. downloads, | 832 // NavigationThrottles and requests that should not commit (e.g. downloads, |
| 828 // 204/205s). This will destroy the NavigationRequest. | 833 // 204/205s). This will destroy the NavigationRequest. |
| 829 if (result == NavigationThrottle::CANCEL_AND_IGNORE || | 834 if (result == NavigationThrottle::CANCEL_AND_IGNORE || |
| 830 result == NavigationThrottle::CANCEL || !response_should_be_rendered_) { | 835 result == NavigationThrottle::CANCEL || !response_should_be_rendered_) { |
| 831 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. | 836 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. |
| 837 if (response_should_be_rendered_) |
| 838 DCHECK_EQ(net::ERR_ABORTED, result.net_error_code()); |
| 832 OnRequestFailed(false, net::ERR_ABORTED); | 839 OnRequestFailed(false, net::ERR_ABORTED); |
| 833 | 840 |
| 834 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has | 841 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has |
| 835 // destroyed the NavigationRequest. | 842 // destroyed the NavigationRequest. |
| 836 return; | 843 return; |
| 837 } | 844 } |
| 838 | 845 |
| 839 if (result == NavigationThrottle::BLOCK_RESPONSE) { | 846 if (result.action() == NavigationThrottle::BLOCK_RESPONSE) { |
| 840 OnRequestFailed(false, net::ERR_BLOCKED_BY_RESPONSE); | 847 DCHECK_NE(net::OK, result.net_error_code()); |
| 848 OnRequestFailed(false, result.net_error_code()); |
| 841 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has | 849 // DO NOT ADD CODE after this. The previous call to OnRequestFailed has |
| 842 // destroyed the NavigationRequest. | 850 // destroyed the NavigationRequest. |
| 843 return; | 851 return; |
| 844 } | 852 } |
| 845 | 853 |
| 846 CommitNavigation(); | 854 CommitNavigation(); |
| 847 | 855 |
| 848 // DO NOT ADD CODE after this. The previous call to CommitNavigation caused | 856 // DO NOT ADD CODE after this. The previous call to CommitNavigation caused |
| 849 // the destruction of the NavigationRequest. | 857 // the destruction of the NavigationRequest. |
| 850 } | 858 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 867 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); | 875 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); |
| 868 | 876 |
| 869 render_frame_host->CommitNavigation(response_.get(), std::move(body_), | 877 render_frame_host->CommitNavigation(response_.get(), std::move(body_), |
| 870 std::move(handle_), common_params_, | 878 std::move(handle_), common_params_, |
| 871 request_params_, is_view_source_); | 879 request_params_, is_view_source_); |
| 872 | 880 |
| 873 frame_tree_node_->ResetNavigationRequest(true, true); | 881 frame_tree_node_->ResetNavigationRequest(true, true); |
| 874 } | 882 } |
| 875 | 883 |
| 876 } // namespace content | 884 } // namespace content |
| OLD | NEW |