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

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

Issue 2136873002: Clear child FrameNavigationEntries if a history navigation redirects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up and disable test in --site-per-process. Created 4 years, 5 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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 if (!parent_node) { 707 if (!parent_node) {
708 // The renderer should not send a commit for a subframe before its parent. 708 // The renderer should not send a commit for a subframe before its parent.
709 // TODO(creis): Kill the renderer if we get here. 709 // TODO(creis): Kill the renderer if we get here.
710 return; 710 return;
711 } 711 }
712 712
713 // Now check whether we have a TreeNode for the node itself. 713 // Now check whether we have a TreeNode for the node itself.
714 const std::string& unique_name = frame_tree_node->unique_name(); 714 const std::string& unique_name = frame_tree_node->unique_name();
715 for (TreeNode* child : parent_node->children) { 715 for (TreeNode* child : parent_node->children) {
716 if (child->frame_entry->frame_unique_name() == unique_name) { 716 if (child->frame_entry->frame_unique_name() == unique_name) {
717 // If the document of the FrameNavigationEntry is changing, we must clear
718 // any child FrameNavigationEntries.
719 if (child->frame_entry->document_sequence_number() !=
720 document_sequence_number)
721 child->children.clear();
722
717 // Update the existing FrameNavigationEntry (e.g., for replaceState). 723 // Update the existing FrameNavigationEntry (e.g., for replaceState).
718 child->frame_entry->UpdateEntry(unique_name, item_sequence_number, 724 child->frame_entry->UpdateEntry(unique_name, item_sequence_number,
719 document_sequence_number, site_instance, 725 document_sequence_number, site_instance,
720 std::move(source_site_instance), url, 726 std::move(source_site_instance), url,
721 referrer, page_state, method, post_id); 727 referrer, page_state, method, post_id);
722 return; 728 return;
723 } 729 }
724 } 730 }
725 731
726 // No entry exists yet, so create a new one. 732 // No entry exists yet, so create a new one.
727 // Unordered list, since we expect to look up entries by frame sequence number 733 // Unordered list, since we expect to look up entries by frame sequence number
728 // or unique name. 734 // or unique name.
729 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( 735 FrameNavigationEntry* frame_entry = new FrameNavigationEntry(
730 unique_name, item_sequence_number, document_sequence_number, 736 unique_name, item_sequence_number, document_sequence_number,
731 site_instance, std::move(source_site_instance), url, referrer, method, 737 site_instance, std::move(source_site_instance), url, referrer, method,
732 post_id); 738 post_id);
733 frame_entry->set_page_state(page_state); 739 frame_entry->set_page_state(page_state);
734 parent_node->children.push_back( 740 parent_node->children.push_back(
735 new NavigationEntryImpl::TreeNode(frame_entry)); 741 new NavigationEntryImpl::TreeNode(frame_entry));
736 } 742 }
737 743
738 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry( 744 FrameNavigationEntry* NavigationEntryImpl::GetFrameEntry(
739 FrameTreeNode* frame_tree_node) const { 745 FrameTreeNode* frame_tree_node) const {
740 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node); 746 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node);
741 return tree_node ? tree_node->frame_entry.get() : nullptr; 747 return tree_node ? tree_node->frame_entry.get() : nullptr;
742 } 748 }
743 749
750 void NavigationEntryImpl::ClearChildren(FrameTreeNode* frame_tree_node) {
751 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node);
752 if (tree_node)
753 tree_node->children.clear();
754 }
755
744 void NavigationEntryImpl::SetScreenshotPNGData( 756 void NavigationEntryImpl::SetScreenshotPNGData(
745 scoped_refptr<base::RefCountedBytes> png_data) { 757 scoped_refptr<base::RefCountedBytes> png_data) {
746 screenshot_ = png_data; 758 screenshot_ = png_data;
747 if (screenshot_.get()) 759 if (screenshot_.get())
748 UMA_HISTOGRAM_MEMORY_KB("Overscroll.ScreenshotSize", screenshot_->size()); 760 UMA_HISTOGRAM_MEMORY_KB("Overscroll.ScreenshotSize", screenshot_->size());
749 } 761 }
750 762
751 GURL NavigationEntryImpl::GetHistoryURLForDataURL() const { 763 GURL NavigationEntryImpl::GetHistoryURLForDataURL() const {
752 return GetBaseURLForDataURL().is_empty() ? GURL() : GetVirtualURL(); 764 return GetBaseURLForDataURL().is_empty() ? GURL() : GetVirtualURL();
753 } 765 }
(...skipping 10 matching lines...) Expand all
764 return node; 776 return node;
765 777
766 // Enqueue any children and keep looking. 778 // Enqueue any children and keep looking.
767 for (auto& child : node->children) 779 for (auto& child : node->children)
768 work_queue.push(child); 780 work_queue.push(child);
769 } 781 }
770 return nullptr; 782 return nullptr;
771 } 783 }
772 784
773 } // namespace content 785 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698