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

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

Issue 2368183004: Move redirect_chain from NavigationEntry to FrameNavigationEntry. (Closed)
Patch Set: Addressed comments. Created 4 years, 2 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 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/navigation_entry_impl.h" 5 #include "content/browser/frame_host/navigation_entry_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <queue> 9 #include <queue>
10 #include <utility> 10 #include <utility>
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 void NavigationEntryImpl::SetHttpStatusCode(int http_status_code) { 541 void NavigationEntryImpl::SetHttpStatusCode(int http_status_code) {
542 http_status_code_ = http_status_code; 542 http_status_code_ = http_status_code;
543 } 543 }
544 544
545 int NavigationEntryImpl::GetHttpStatusCode() const { 545 int NavigationEntryImpl::GetHttpStatusCode() const {
546 return http_status_code_; 546 return http_status_code_;
547 } 547 }
548 548
549 void NavigationEntryImpl::SetRedirectChain( 549 void NavigationEntryImpl::SetRedirectChain(
550 const std::vector<GURL>& redirect_chain) { 550 const std::vector<GURL>& redirect_chain) {
551 redirect_chain_ = redirect_chain; 551 root_node()->frame_entry->set_redirect_chain(redirect_chain);
552 } 552 }
553 553
554 const std::vector<GURL>& NavigationEntryImpl::GetRedirectChain() const { 554 const std::vector<GURL>& NavigationEntryImpl::GetRedirectChain() const {
555 return redirect_chain_; 555 return root_node()->frame_entry->redirect_chain();
556 } 556 }
557 557
558 bool NavigationEntryImpl::IsRestored() const { 558 bool NavigationEntryImpl::IsRestored() const {
559 return restore_type_ != RestoreType::NONE; 559 return restore_type_ != RestoreType::NONE;
560 } 560 }
561 561
562 void NavigationEntryImpl::SetCanLoadLocalResources(bool allow) { 562 void NavigationEntryImpl::SetCanLoadLocalResources(bool allow) {
563 can_load_local_resources_ = allow; 563 can_load_local_resources_ = allow;
564 } 564 }
565 565
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 copy->screenshot_ = screenshot_; 625 copy->screenshot_ = screenshot_;
626 copy->extra_headers_ = extra_headers_; 626 copy->extra_headers_ = extra_headers_;
627 copy->base_url_for_data_url_ = base_url_for_data_url_; 627 copy->base_url_for_data_url_ = base_url_for_data_url_;
628 #if defined(OS_ANDROID) 628 #if defined(OS_ANDROID)
629 copy->data_url_as_string_ = data_url_as_string_; 629 copy->data_url_as_string_ = data_url_as_string_;
630 #endif 630 #endif
631 // ResetForCommit: is_renderer_initiated_ 631 // ResetForCommit: is_renderer_initiated_
632 copy->cached_display_title_ = cached_display_title_; 632 copy->cached_display_title_ = cached_display_title_;
633 // ResetForCommit: transferred_global_request_id_ 633 // ResetForCommit: transferred_global_request_id_
634 // ResetForCommit: should_replace_entry_ 634 // ResetForCommit: should_replace_entry_
635 copy->redirect_chain_ = redirect_chain_;
636 // ResetForCommit: should_clear_history_list_ 635 // ResetForCommit: should_clear_history_list_
637 // ResetForCommit: frame_tree_node_id_ 636 // ResetForCommit: frame_tree_node_id_
638 // ResetForCommit: intent_received_timestamp_ 637 // ResetForCommit: intent_received_timestamp_
639 #if defined(OS_ANDROID) 638 #if defined(OS_ANDROID)
640 copy->has_user_gesture_ = has_user_gesture_; 639 copy->has_user_gesture_ = has_user_gesture_;
641 #endif 640 #endif
642 copy->extra_data_ = extra_data_; 641 copy->extra_data_ = extra_data_;
643 642
644 return copy; 643 return copy;
645 } 644 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 bool has_subtree_history_items, 693 bool has_subtree_history_items,
695 bool has_committed_real_load, 694 bool has_committed_real_load,
696 bool intended_as_new_entry, 695 bool intended_as_new_entry,
697 int pending_history_list_offset, 696 int pending_history_list_offset,
698 int current_history_list_offset, 697 int current_history_list_offset,
699 int current_history_list_length) const { 698 int current_history_list_length) const {
700 // Set the redirect chain to the navigation's redirects, unless returning to a 699 // Set the redirect chain to the navigation's redirects, unless returning to a
701 // completed navigation (whose previous redirects don't apply). 700 // completed navigation (whose previous redirects don't apply).
702 std::vector<GURL> redirects; 701 std::vector<GURL> redirects;
703 if (ui::PageTransitionIsNewNavigation(GetTransitionType())) { 702 if (ui::PageTransitionIsNewNavigation(GetTransitionType())) {
704 redirects = GetRedirectChain(); 703 redirects = frame_entry.redirect_chain();
705 } 704 }
706 705
707 int pending_offset_to_send = pending_history_list_offset; 706 int pending_offset_to_send = pending_history_list_offset;
708 int current_offset_to_send = current_history_list_offset; 707 int current_offset_to_send = current_history_list_offset;
709 int current_length_to_send = current_history_list_length; 708 int current_length_to_send = current_history_list_length;
710 if (should_clear_history_list()) { 709 if (should_clear_history_list()) {
711 // Set the history list related parameters to the same values a 710 // Set the history list related parameters to the same values a
712 // NavigationController would return before its first navigation. This will 711 // NavigationController would return before its first navigation. This will
713 // fully clear the RenderView's view of the session history. 712 // fully clear the RenderView's view of the session history.
714 pending_offset_to_send = -1; 713 pending_offset_to_send = -1;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 } 764 }
766 765
767 void NavigationEntryImpl::AddOrUpdateFrameEntry( 766 void NavigationEntryImpl::AddOrUpdateFrameEntry(
768 FrameTreeNode* frame_tree_node, 767 FrameTreeNode* frame_tree_node,
769 int64_t item_sequence_number, 768 int64_t item_sequence_number,
770 int64_t document_sequence_number, 769 int64_t document_sequence_number,
771 SiteInstanceImpl* site_instance, 770 SiteInstanceImpl* site_instance,
772 scoped_refptr<SiteInstanceImpl> source_site_instance, 771 scoped_refptr<SiteInstanceImpl> source_site_instance,
773 const GURL& url, 772 const GURL& url,
774 const Referrer& referrer, 773 const Referrer& referrer,
774 const std::vector<GURL>& redirect_chain,
775 const PageState& page_state, 775 const PageState& page_state,
776 const std::string& method, 776 const std::string& method,
777 int64_t post_id) { 777 int64_t post_id) {
778 // We should only have an empty PageState if the navigation is new, and thus 778 // We should only have an empty PageState if the navigation is new, and thus
779 // page ID is -1. 779 // page ID is -1.
780 if (!page_state.IsValid() && GetPageID() != -1) { 780 if (!page_state.IsValid() && GetPageID() != -1) {
781 // Temporarily generate a minidump to diagnose https://crbug.com/568703. 781 // Temporarily generate a minidump to diagnose https://crbug.com/568703.
782 base::debug::DumpWithoutCrashing(); 782 base::debug::DumpWithoutCrashing();
783 NOTREACHED() << "Shouldn't set an empty PageState."; 783 NOTREACHED() << "Shouldn't set an empty PageState.";
784 } 784 }
785 785
786 // If this is called for the main frame, the FrameNavigationEntry is 786 // If this is called for the main frame, the FrameNavigationEntry is
787 // guaranteed to exist, so just update it directly and return. 787 // guaranteed to exist, so just update it directly and return.
788 if (frame_tree_node->IsMainFrame()) { 788 if (frame_tree_node->IsMainFrame()) {
789 // If the document of the FrameNavigationEntry is changing, we must clear 789 // If the document of the FrameNavigationEntry is changing, we must clear
790 // any child FrameNavigationEntries. 790 // any child FrameNavigationEntries.
791 if (root_node()->frame_entry->document_sequence_number() != 791 if (root_node()->frame_entry->document_sequence_number() !=
792 document_sequence_number) 792 document_sequence_number)
793 root_node()->children.clear(); 793 root_node()->children.clear();
794 794
795 root_node()->frame_entry->UpdateEntry( 795 root_node()->frame_entry->UpdateEntry(
796 frame_tree_node->unique_name(), item_sequence_number, 796 frame_tree_node->unique_name(), item_sequence_number,
797 document_sequence_number, site_instance, 797 document_sequence_number, site_instance,
798 std::move(source_site_instance), url, referrer, page_state, method, 798 std::move(source_site_instance), url, referrer, redirect_chain,
799 post_id); 799 page_state, method, post_id);
800 return; 800 return;
801 } 801 }
802 802
803 // We should already have a TreeNode for the parent node by the time this node 803 // We should already have a TreeNode for the parent node by the time this node
804 // commits. Find it first. 804 // commits. Find it first.
805 NavigationEntryImpl::TreeNode* parent_node = 805 NavigationEntryImpl::TreeNode* parent_node =
806 FindFrameEntry(frame_tree_node->parent()); 806 FindFrameEntry(frame_tree_node->parent());
807 if (!parent_node) { 807 if (!parent_node) {
808 // The renderer should not send a commit for a subframe before its parent. 808 // The renderer should not send a commit for a subframe before its parent.
809 // TODO(creis): Kill the renderer if we get here. 809 // TODO(creis): Kill the renderer if we get here.
810 return; 810 return;
811 } 811 }
812 812
813 // Now check whether we have a TreeNode for the node itself. 813 // Now check whether we have a TreeNode for the node itself.
814 const std::string& unique_name = frame_tree_node->unique_name(); 814 const std::string& unique_name = frame_tree_node->unique_name();
815 for (TreeNode* child : parent_node->children) { 815 for (TreeNode* child : parent_node->children) {
816 if (child->frame_entry->frame_unique_name() == unique_name) { 816 if (child->frame_entry->frame_unique_name() == unique_name) {
817 // If the document of the FrameNavigationEntry is changing, we must clear 817 // If the document of the FrameNavigationEntry is changing, we must clear
818 // any child FrameNavigationEntries. 818 // any child FrameNavigationEntries.
819 if (child->frame_entry->document_sequence_number() != 819 if (child->frame_entry->document_sequence_number() !=
820 document_sequence_number) 820 document_sequence_number)
821 child->children.clear(); 821 child->children.clear();
822 822
823 // Update the existing FrameNavigationEntry (e.g., for replaceState). 823 // Update the existing FrameNavigationEntry (e.g., for replaceState).
824 child->frame_entry->UpdateEntry(unique_name, item_sequence_number, 824 child->frame_entry->UpdateEntry(
825 document_sequence_number, site_instance, 825 unique_name, item_sequence_number, document_sequence_number,
826 std::move(source_site_instance), url, 826 site_instance, std::move(source_site_instance), url, referrer,
827 referrer, page_state, method, post_id); 827 redirect_chain, page_state, method, post_id);
828 return; 828 return;
829 } 829 }
830 } 830 }
831 831
832 // No entry exists yet, so create a new one. 832 // No entry exists yet, so create a new one.
833 // Unordered list, since we expect to look up entries by frame sequence number 833 // Unordered list, since we expect to look up entries by frame sequence number
834 // or unique name. 834 // or unique name.
835 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( 835 FrameNavigationEntry* frame_entry = new FrameNavigationEntry(
836 unique_name, item_sequence_number, document_sequence_number, 836 unique_name, item_sequence_number, document_sequence_number,
837 site_instance, std::move(source_site_instance), url, referrer, method, 837 site_instance, std::move(source_site_instance), url, referrer, method,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 return node; 913 return node;
914 914
915 // Enqueue any children and keep looking. 915 // Enqueue any children and keep looking.
916 for (auto* child : node->children) 916 for (auto* child : node->children)
917 work_queue.push(child); 917 work_queue.push(child);
918 } 918 }
919 return nullptr; 919 return nullptr;
920 } 920 }
921 921
922 } // namespace content 922 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698