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

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

Powered by Google App Engine
This is Rietveld 408576698