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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/navigation_entry_impl.cc
diff --git a/content/browser/frame_host/navigation_entry_impl.cc b/content/browser/frame_host/navigation_entry_impl.cc
index 41033a819a689111868c496c1755a18fca585830..e2cdcb8bcebd8b39ac46b4c4da6811530cbc598c 100644
--- a/content/browser/frame_host/navigation_entry_impl.cc
+++ b/content/browser/frame_host/navigation_entry_impl.cc
@@ -774,9 +774,33 @@ void NavigationEntryImpl::AddOrUpdateFrameEntry(
const PageState& page_state,
const std::string& method,
int64_t post_id) {
+ // We should only have an empty PageState if the navigation is new, and thus
+ // page ID is -1.
+ if (!page_state.IsValid() && GetPageID() != -1) {
+ // Temporarily generate a minidump to diagnose https://crbug.com/568703.
+ base::debug::DumpWithoutCrashing();
+ NOTREACHED() << "Shouldn't set an empty PageState.";
+ }
+
+ // If this is called for the main frame, the FrameNavigationEntry is
+ // guaranteed to exist, so just update it directly and return.
+ if (frame_tree_node->IsMainFrame()) {
+ // If the document of the FrameNavigationEntry is changing, we must clear
+ // any child FrameNavigationEntries.
+ if (root_node()->frame_entry->document_sequence_number() !=
+ document_sequence_number)
+ root_node()->children.clear();
+
+ root_node()->frame_entry->UpdateEntry(
+ frame_tree_node->unique_name(), item_sequence_number,
+ document_sequence_number, site_instance,
+ std::move(source_site_instance), url, referrer, page_state, method,
+ post_id);
+ return;
+ }
+
// We should already have a TreeNode for the parent node by the time this node
// commits. Find it first.
- DCHECK(frame_tree_node->parent());
NavigationEntryImpl::TreeNode* parent_node =
FindFrameEntry(frame_tree_node->parent());
if (!parent_node) {
@@ -785,14 +809,6 @@ void NavigationEntryImpl::AddOrUpdateFrameEntry(
return;
}
- // We should only have an empty PageState if the navigation is new, and thus
- // page ID is -1.
- if (!page_state.IsValid() && GetPageID() != -1) {
- // Temporarily generate a minidump to diagnose https://crbug.com/568703.
- base::debug::DumpWithoutCrashing();
- NOTREACHED() << "Shouldn't set an empty PageState.";
- }
-
// Now check whether we have a TreeNode for the node itself.
const std::string& unique_name = frame_tree_node->unique_name();
for (TreeNode* child : parent_node->children) {
@@ -830,12 +846,6 @@ FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry(
return tree_node ? tree_node->frame_entry.get() : nullptr;
}
-void NavigationEntryImpl::ClearChildren(FrameTreeNode* frame_tree_node) {
- NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node);
- if (tree_node)
- tree_node->children.clear();
-}
-
void NavigationEntryImpl::ClearStaleFrameEntriesForNewFrame(
FrameTreeNode* frame_tree_node) {
DCHECK(!frame_tree_node->IsMainFrame());

Powered by Google App Engine
This is Rietveld 408576698