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

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

Issue 1736393002: Remove incorrect sanity checks in RenderFrameHostManager::OnCrossSiteResponse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/render_frame_host_manager.h" 5 #include "content/browser/frame_host/render_frame_host_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 if (IsBrowserSideNavigationEnabled() && speculative_render_frame_host_) 412 if (IsBrowserSideNavigationEnabled() && speculative_render_frame_host_)
413 CleanUpNavigation(); 413 CleanUpNavigation();
414 414
415 // This is not a cross-process navigation; the tab is being closed. 415 // This is not a cross-process navigation; the tab is being closed.
416 render_frame_host_->render_view_host()->ClosePage(); 416 render_frame_host_->render_view_host()->ClosePage();
417 } 417 }
418 } 418 }
419 } 419 }
420 420
421 void RenderFrameHostManager::OnCrossSiteResponse( 421 void RenderFrameHostManager::OnCrossSiteResponse(
422 RenderFrameHostImpl* pending_render_frame_host, 422 RenderFrameHostImpl* transferring_render_frame_host,
423 const GlobalRequestID& global_request_id, 423 const GlobalRequestID& global_request_id,
424 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request, 424 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request,
425 const std::vector<GURL>& transfer_url_chain, 425 const std::vector<GURL>& transfer_url_chain,
426 const Referrer& referrer, 426 const Referrer& referrer,
427 ui::PageTransition page_transition, 427 ui::PageTransition page_transition,
428 bool should_replace_current_entry) { 428 bool should_replace_current_entry) {
429 // We should only get here for transfer navigations. Most cross-process 429 // We should only get here for transfer navigations. Most cross-process
430 // navigations can just continue and wait to run the unload handler (by 430 // navigations can just continue and wait to run the unload handler (by
431 // swapping out) when the new navigation commits. 431 // swapping out) when the new navigation commits.
432 CHECK(cross_site_transferring_request); 432 CHECK(cross_site_transferring_request);
433 433
434 // A transfer should only have come from our pending or current RFH. 434 // A transfer should only have come from our pending or current RFH. If it
435 // started as a cross-process navigation via OpenURL, this is the pending
436 // one. If it wasn't cross-process until the transfer, this is the current
437 // one.
438 //
439 // Note that having a pending RFH does not imply that it was the one that
440 // made the request. Suppose that during a pending cross-site navigation,
441 // the frame performs a different same-site navigation which redirects
442 // cross-site. In this case, there will be a pending RFH, but this request
443 // is made by the current RFH. Later, this will create a new pending RFH and
444 // clean up the old one.
445 //
435 // TODO(creis): We need to handle the case that the pending RFH has changed 446 // TODO(creis): We need to handle the case that the pending RFH has changed
436 // in the mean time, while this was being posted from the IO thread. We 447 // in the mean time, while this was being posted from the IO thread. We
437 // should probably cancel the request in that case. 448 // should probably cancel the request in that case.
438 DCHECK(pending_render_frame_host == pending_render_frame_host_.get() || 449 DCHECK(transferring_render_frame_host == pending_render_frame_host_.get() ||
439 pending_render_frame_host == render_frame_host_.get()); 450 transferring_render_frame_host == render_frame_host_.get());
440 451
441 // Check if the FrameTreeNode is loading. This will be used later to notify 452 // Check if the FrameTreeNode is loading. This will be used later to notify
442 // the FrameTreeNode that the load stop if the transfer fails. 453 // the FrameTreeNode that the load stop if the transfer fails.
443 bool frame_tree_node_was_loading = frame_tree_node_->IsLoading(); 454 bool frame_tree_node_was_loading = frame_tree_node_->IsLoading();
444 455
445 // Store the transferring request so that we can release it if the transfer 456 // Store the transferring request so that we can release it if the transfer
446 // navigation matches. 457 // navigation matches.
447 cross_site_transferring_request_ = std::move(cross_site_transferring_request); 458 cross_site_transferring_request_ = std::move(cross_site_transferring_request);
448 459
449 // Store the NavigationHandle to give it to the appropriate RenderFrameHost 460 // Store the NavigationHandle to give it to the appropriate RenderFrameHost
450 // after it started navigating. 461 // after it started navigating.
451 transfer_navigation_handle_ = 462 transfer_navigation_handle_ =
452 pending_render_frame_host->PassNavigationHandleOwnership(); 463 transferring_render_frame_host->PassNavigationHandleOwnership();
453 DCHECK(transfer_navigation_handle_); 464 DCHECK(transfer_navigation_handle_);
454 465
455 // Set the transferring RenderFrameHost as not loading, so that it does not 466 // Set the transferring RenderFrameHost as not loading, so that it does not
456 // emit a DidStopLoading notification if it is destroyed when creating the 467 // emit a DidStopLoading notification if it is destroyed when creating the
457 // new navigating RenderFrameHost. 468 // new navigating RenderFrameHost.
458 pending_render_frame_host->set_is_loading(false); 469 transferring_render_frame_host->set_is_loading(false);
459
460 // Sanity check that the params are for the correct frame and process.
461 // These should match the RenderFrameHost that made the request.
462 // If it started as a cross-process navigation via OpenURL, this is the
463 // pending one. If it wasn't cross-process until the transfer, this is
464 // the current one.
465 int render_frame_id = pending_render_frame_host_
466 ? pending_render_frame_host_->GetRoutingID()
467 : render_frame_host_->GetRoutingID();
468 DCHECK_EQ(render_frame_id, pending_render_frame_host->GetRoutingID());
469 int process_id = pending_render_frame_host_ ?
470 pending_render_frame_host_->GetProcess()->GetID() :
471 render_frame_host_->GetProcess()->GetID();
472 DCHECK_EQ(process_id, global_request_id.child_id);
473 470
474 // Treat the last URL in the chain as the destination and the remainder as 471 // Treat the last URL in the chain as the destination and the remainder as
475 // the redirect chain. 472 // the redirect chain.
476 CHECK(transfer_url_chain.size()); 473 CHECK(transfer_url_chain.size());
477 GURL transfer_url = transfer_url_chain.back(); 474 GURL transfer_url = transfer_url_chain.back();
478 std::vector<GURL> rest_of_chain = transfer_url_chain; 475 std::vector<GURL> rest_of_chain = transfer_url_chain;
479 rest_of_chain.pop_back(); 476 rest_of_chain.pop_back();
480 477
481 pending_render_frame_host->frame_tree_node()->navigator()->RequestTransferURL( 478 transferring_render_frame_host->frame_tree_node()
482 pending_render_frame_host, transfer_url, nullptr, rest_of_chain, referrer, 479 ->navigator()
483 page_transition, global_request_id, should_replace_current_entry); 480 ->RequestTransferURL(transferring_render_frame_host, transfer_url,
481 nullptr, rest_of_chain, referrer, page_transition,
482 global_request_id, should_replace_current_entry);
484 483
485 // The transferring request was only needed during the RequestTransferURL 484 // The transferring request was only needed during the RequestTransferURL
486 // call, so it is safe to clear at this point. 485 // call, so it is safe to clear at this point.
487 cross_site_transferring_request_.reset(); 486 cross_site_transferring_request_.reset();
488 487
489 // If the navigation continued, the NavigationHandle should have been 488 // If the navigation continued, the NavigationHandle should have been
490 // transfered to a RenderFrameHost. In the other cases, it should be cleared. 489 // transfered to a RenderFrameHost. In the other cases, it should be cleared.
491 transfer_navigation_handle_.reset(); 490 transfer_navigation_handle_.reset();
492 491
493 // If the navigation in the new renderer did not start, inform the 492 // If the navigation in the new renderer did not start, inform the
(...skipping 2006 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { 2499 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) {
2501 if (!frame_tree_node_->opener()) 2500 if (!frame_tree_node_->opener())
2502 return MSG_ROUTING_NONE; 2501 return MSG_ROUTING_NONE;
2503 2502
2504 return frame_tree_node_->opener() 2503 return frame_tree_node_->opener()
2505 ->render_manager() 2504 ->render_manager()
2506 ->GetRoutingIdForSiteInstance(instance); 2505 ->GetRoutingIdForSiteInstance(instance);
2507 } 2506 }
2508 2507
2509 } // namespace content 2508 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698