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

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

Issue 2510083003: PlzNavigate: properly update NavigationHandle for 204/205 and download responses (Closed)
Patch Set: address comments of clamy@ Created 4 years 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 "content/browser/child_process_security_policy_impl.h" 9 #include "content/browser/child_process_security_policy_impl.h"
10 #include "content/browser/devtools/render_frame_devtools_agent_host.h" 10 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 const scoped_refptr<ResourceResponse>& response, 376 const scoped_refptr<ResourceResponse>& response,
377 std::unique_ptr<StreamHandle> body, 377 std::unique_ptr<StreamHandle> body,
378 const SSLStatus& ssl_status, 378 const SSLStatus& ssl_status,
379 std::unique_ptr<NavigationData> navigation_data, 379 std::unique_ptr<NavigationData> navigation_data,
380 const GlobalRequestID& request_id, 380 const GlobalRequestID& request_id,
381 bool is_download, 381 bool is_download,
382 bool is_stream) { 382 bool is_stream) {
383 DCHECK(state_ == STARTED); 383 DCHECK(state_ == STARTED);
384 state_ = RESPONSE_STARTED; 384 state_ = RESPONSE_STARTED;
385 385
386 // HTTP 204 (No Content) and HTTP 205 (Reset Content) responses should not
387 // commit; they leave the frame showing the previous page.
388 DCHECK(response); 386 DCHECK(response);
389 if (response->head.headers.get() &&
390 (response->head.headers->response_code() == 204 ||
391 response->head.headers->response_code() == 205)) {
392 frame_tree_node_->navigator()->DiscardPendingEntryIfNeeded(
393 navigation_handle_.get());
394 frame_tree_node_->ResetNavigationRequest(false);
395 return;
396 }
397 387
398 // Update the service worker params of the request params. 388 // Update the service worker params of the request params.
399 bool did_create_service_worker_host = 389 bool did_create_service_worker_host =
400 navigation_handle_->service_worker_handle() && 390 navigation_handle_->service_worker_handle() &&
401 navigation_handle_->service_worker_handle() 391 navigation_handle_->service_worker_handle()
402 ->service_worker_provider_host_id() != 392 ->service_worker_provider_host_id() !=
403 kInvalidServiceWorkerProviderId; 393 kInvalidServiceWorkerProviderId;
404 request_params_.service_worker_provider_id = 394 request_params_.service_worker_provider_id =
405 did_create_service_worker_host 395 did_create_service_worker_host
406 ? navigation_handle_->service_worker_handle() 396 ? navigation_handle_->service_worker_handle()
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 } 553 }
564 554
565 loader_->FollowRedirect(); 555 loader_->FollowRedirect();
566 } 556 }
567 557
568 void NavigationRequest::OnWillProcessResponseChecksComplete( 558 void NavigationRequest::OnWillProcessResponseChecksComplete(
569 NavigationThrottle::ThrottleCheckResult result) { 559 NavigationThrottle::ThrottleCheckResult result) {
570 CHECK(result != NavigationThrottle::DEFER); 560 CHECK(result != NavigationThrottle::DEFER);
571 561
572 // Abort the request if needed. This will destroy the NavigationRequest. 562 // Abort the request if needed. This will destroy the NavigationRequest.
573 if (result == NavigationThrottle::CANCEL_AND_IGNORE || 563 if (result == NavigationThrottle::CANCEL_AND_IGNORE) {
574 result == NavigationThrottle::CANCEL) { 564 frame_tree_node_->navigator()->DiscardPendingEntryIfNeeded(
575 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. 565 navigation_handle_.get());
576 frame_tree_node_->ResetNavigationRequest(false); 566 frame_tree_node_->ResetNavigationRequest(false);
577 return; 567 return;
578 } 568 }
569 if (result == NavigationThrottle::CANCEL) {
570 frame_tree_node_->ResetNavigationRequest(false);
571 return;
572 }
579 573
580 // Have the processing of the response resume in the network stack. 574 // Have the processing of the response resume in the network stack.
581 loader_->ProceedWithResponse(); 575 loader_->ProceedWithResponse();
582 576
583 CommitNavigation(); 577 CommitNavigation();
584 578
585 // DO NOT ADD CODE after this. The previous call to CommitNavigation caused 579 // DO NOT ADD CODE after this. The previous call to CommitNavigation caused
586 // the destruction of the NavigationRequest. 580 // the destruction of the NavigationRequest.
587 } 581 }
588 582
(...skipping 14 matching lines...) Expand all
603 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); 597 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture);
604 598
605 render_frame_host->CommitNavigation(response_.get(), std::move(body_), 599 render_frame_host->CommitNavigation(response_.get(), std::move(body_),
606 common_params_, request_params_, 600 common_params_, request_params_,
607 is_view_source_); 601 is_view_source_);
608 602
609 frame_tree_node_->ResetNavigationRequest(true); 603 frame_tree_node_->ResetNavigationRequest(true);
610 } 604 }
611 605
612 } // namespace content 606 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_handle_impl.cc ('k') | content/browser/loader/navigation_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698