Commit ffeb1b9c authored by Mohamed Abdelhalim's avatar Mohamed Abdelhalim Committed by Commit Bot

Navigation: Move states from NavigationHandleState to NavigationState 2.

This moves WILL_REDIRECT_REQUEST to NavigationRequest::NavigationState.

Bug: 916537
Change-Id: Ifef36753c384592465b72be16737373daa1501bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1865167
Commit-Queue: Mohamed Abdelhalim <zetamoo@chromium.org>
Reviewed-by: default avatarCamille Lamy <clamy@chromium.org>
Reviewed-by: default avatarArthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711280}
parent a9007a1e
......@@ -1871,7 +1871,8 @@ void NavigationRequest::OnRequestFailedInternal(
const base::Optional<std::string>& error_page_content,
bool collapse_frame) {
DCHECK(state_ == WILL_START_NAVIGATION || state_ == WILL_START_REQUEST ||
state_ == RESPONSE_STARTED || state_ == CANCELING);
state_ == WILL_REDIRECT_REQUEST || state_ == RESPONSE_STARTED ||
state_ == CANCELING);
DCHECK(!(status.error_code == net::ERR_ABORTED &&
error_page_content.has_value()));
......@@ -2934,7 +2935,7 @@ void NavigationRequest::OnWillStartRequestProcessed(
void NavigationRequest::OnWillRedirectRequestProcessed(
NavigationThrottle::ThrottleCheckResult result) {
DCHECK_EQ(WILL_REDIRECT_REQUEST, handle_state_);
DCHECK_EQ(WILL_REDIRECT_REQUEST, state_);
DCHECK_NE(NavigationThrottle::BLOCK_RESPONSE, result.action());
DCHECK(processing_navigation_throttle_);
processing_navigation_throttle_ = false;
......@@ -3033,8 +3034,7 @@ void NavigationRequest::CancelDeferredNavigationInternal(
result.action() == NavigationThrottle::CANCEL ||
result.action() == NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE);
DCHECK(result.action() != NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE ||
state_ == WILL_START_REQUEST ||
handle_state_ == WILL_REDIRECT_REQUEST);
state_ == WILL_START_REQUEST || state_ == WILL_REDIRECT_REQUEST);
TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationRequest", this,
"CancelDeferredNavigation");
......@@ -3246,7 +3246,7 @@ void NavigationRequest::UpdateStateFollowingRedirect(
was_redirected_ = true;
redirect_chain_.push_back(common_params_->url);
handle_state_ = WILL_REDIRECT_REQUEST;
state_ = WILL_REDIRECT_REQUEST;
processing_navigation_throttle_ = true;
#if defined(OS_ANDROID)
......@@ -3462,14 +3462,13 @@ void NavigationRequest::SetCommitTimeoutForTesting(
}
void NavigationRequest::RemoveRequestHeader(const std::string& header_name) {
DCHECK(handle_state_ == WILL_REDIRECT_REQUEST);
DCHECK(state_ == WILL_REDIRECT_REQUEST);
removed_request_headers_.push_back(header_name);
}
void NavigationRequest::SetRequestHeader(const std::string& header_name,
const std::string& header_value) {
DCHECK(state_ == WILL_START_REQUEST ||
handle_state_ == WILL_REDIRECT_REQUEST);
DCHECK(state_ == WILL_START_REQUEST || state_ == WILL_REDIRECT_REQUEST);
modified_request_headers_.SetHeader(header_name, header_value);
}
......
......@@ -100,6 +100,11 @@ class CONTENT_EXPORT NavigationRequest : public NavigationHandle,
// This is potentially asynchronous.
WILL_START_REQUEST,
// The request is being redirected. Wait for the NavigationThrottles to
// finish running the WillRedirectRequest event. This is potentially
// asynchronous.
WILL_REDIRECT_REQUEST,
// The response started on the IO thread and is ready to be committed. This
// is one of the two final states for the request.
RESPONSE_STARTED,
......@@ -120,7 +125,6 @@ class CONTENT_EXPORT NavigationRequest : public NavigationHandle,
// the duplicates.
enum NavigationHandleState {
NOT_CREATED = 0,
WILL_REDIRECT_REQUEST,
WILL_FAIL_REQUEST,
WILL_PROCESS_RESPONSE,
READY_TO_COMMIT,
......
......@@ -349,7 +349,7 @@ TEST_F(NavigationRequestTest, MAYBE_CancelDeferredWillRedirect) {
// Simulate WillRedirectRequest. The request should be deferred. The callback
// should not have been called.
SimulateWillRedirectRequest();
EXPECT_EQ(NavigationRequest::WILL_REDIRECT_REQUEST, state());
EXPECT_EQ(NavigationRequest::WILL_REDIRECT_REQUEST, request_state());
EXPECT_FALSE(was_callback_called());
EXPECT_TRUE(call_counts_match(test_throttle, 0, 1, 0, 0));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment