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

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

Issue 2224213005: Ensure FrameNavigationEntry is fully updated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clear children FNEs of main frame on redirects. Created 4 years, 4 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 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 FrameTreeNode* frame_tree_node, 764 FrameTreeNode* frame_tree_node,
765 int64_t item_sequence_number, 765 int64_t item_sequence_number,
766 int64_t document_sequence_number, 766 int64_t document_sequence_number,
767 SiteInstanceImpl* site_instance, 767 SiteInstanceImpl* site_instance,
768 scoped_refptr<SiteInstanceImpl> source_site_instance, 768 scoped_refptr<SiteInstanceImpl> source_site_instance,
769 const GURL& url, 769 const GURL& url,
770 const Referrer& referrer, 770 const Referrer& referrer,
771 const PageState& page_state, 771 const PageState& page_state,
772 const std::string& method, 772 const std::string& method,
773 int64_t post_id) { 773 int64_t post_id) {
774 // We should only have an empty PageState if the navigation is new, and thus
775 // page ID is -1.
776 if (!page_state.IsValid() && GetPageID() != -1) {
777 // Temporarily generate a minidump to diagnose https://crbug.com/568703.
778 base::debug::DumpWithoutCrashing();
779 NOTREACHED() << "Shouldn't set an empty PageState.";
780 }
781
782 // If this is called for the main frame, the FrameNavigationEntry is
783 // guaranteed to exist, so just update it directly and return.
784 if (frame_tree_node->IsMainFrame()) {
785 // If the document of the FrameNavigationEntry is changing, we must clear
786 // any child FrameNavigationEntries.
787 if (root_node()->frame_entry->document_sequence_number() !=
788 document_sequence_number)
789 root_node()->children.clear();
790
791 root_node()->frame_entry->UpdateEntry(
792 frame_tree_node->unique_name(), item_sequence_number,
793 document_sequence_number, site_instance,
794 std::move(source_site_instance), url,
795 referrer, page_state, method, post_id);
796 return;
797 }
798
774 // We should already have a TreeNode for the parent node by the time this node 799 // We should already have a TreeNode for the parent node by the time this node
775 // commits. Find it first. 800 // commits. Find it first.
776 DCHECK(frame_tree_node->parent());
777 NavigationEntryImpl::TreeNode* parent_node = 801 NavigationEntryImpl::TreeNode* parent_node =
778 FindFrameEntry(frame_tree_node->parent()); 802 FindFrameEntry(frame_tree_node->parent());
779 if (!parent_node) { 803 if (!parent_node) {
780 // The renderer should not send a commit for a subframe before its parent. 804 // The renderer should not send a commit for a subframe before its parent.
781 // TODO(creis): Kill the renderer if we get here. 805 // TODO(creis): Kill the renderer if we get here.
782 return; 806 return;
783 } 807 }
784 808
785 // We should only have an empty PageState if the navigation is new, and thus
786 // page ID is -1.
787 if (!page_state.IsValid() && GetPageID() != -1) {
788 // Temporarily generate a minidump to diagnose https://crbug.com/568703.
789 base::debug::DumpWithoutCrashing();
790 NOTREACHED() << "Shouldn't set an empty PageState.";
791 }
792
793 // Now check whether we have a TreeNode for the node itself. 809 // Now check whether we have a TreeNode for the node itself.
794 const std::string& unique_name = frame_tree_node->unique_name(); 810 const std::string& unique_name = frame_tree_node->unique_name();
795 for (TreeNode* child : parent_node->children) { 811 for (TreeNode* child : parent_node->children) {
796 if (child->frame_entry->frame_unique_name() == unique_name) { 812 if (child->frame_entry->frame_unique_name() == unique_name) {
797 // If the document of the FrameNavigationEntry is changing, we must clear 813 // If the document of the FrameNavigationEntry is changing, we must clear
798 // any child FrameNavigationEntries. 814 // any child FrameNavigationEntries.
799 if (child->frame_entry->document_sequence_number() != 815 if (child->frame_entry->document_sequence_number() !=
800 document_sequence_number) 816 document_sequence_number)
801 child->children.clear(); 817 child->children.clear();
802 818
(...skipping 17 matching lines...) Expand all
820 parent_node->children.push_back( 836 parent_node->children.push_back(
821 new NavigationEntryImpl::TreeNode(parent_node, frame_entry)); 837 new NavigationEntryImpl::TreeNode(parent_node, frame_entry));
822 } 838 }
823 839
824 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry( 840 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry(
825 FrameTreeNode* frame_tree_node) const { 841 FrameTreeNode* frame_tree_node) const {
826 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node); 842 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node);
827 return tree_node ? tree_node->frame_entry.get() : nullptr; 843 return tree_node ? tree_node->frame_entry.get() : nullptr;
828 } 844 }
829 845
830 void NavigationEntryImpl::ClearChildren(FrameTreeNode* frame_tree_node) {
831 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node);
832 if (tree_node)
833 tree_node->children.clear();
834 }
835
836 void NavigationEntryImpl::ClearStaleFrameEntriesForNewFrame( 846 void NavigationEntryImpl::ClearStaleFrameEntriesForNewFrame(
837 FrameTreeNode* frame_tree_node) { 847 FrameTreeNode* frame_tree_node) {
838 DCHECK(!frame_tree_node->IsMainFrame()); 848 DCHECK(!frame_tree_node->IsMainFrame());
839 849
840 NavigationEntryImpl::TreeNode* node = nullptr; 850 NavigationEntryImpl::TreeNode* node = nullptr;
841 std::queue<NavigationEntryImpl::TreeNode*> work_queue; 851 std::queue<NavigationEntryImpl::TreeNode*> work_queue;
842 int count = 0; 852 int count = 0;
843 853
844 work_queue.push(root_node()); 854 work_queue.push(root_node());
845 while (!work_queue.empty()) { 855 while (!work_queue.empty()) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 return node; 903 return node;
894 904
895 // Enqueue any children and keep looking. 905 // Enqueue any children and keep looking.
896 for (auto* child : node->children) 906 for (auto* child : node->children)
897 work_queue.push(child); 907 work_queue.push(child);
898 } 908 }
899 return nullptr; 909 return nullptr;
900 } 910 }
901 911
902 } // namespace content 912 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698