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

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

Issue 2191543003: Remove existing FrameNavigationEntry when new named frame is added. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node); 781 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node);
782 return tree_node ? tree_node->frame_entry.get() : nullptr; 782 return tree_node ? tree_node->frame_entry.get() : nullptr;
783 } 783 }
784 784
785 void NavigationEntryImpl::ClearChildren(FrameTreeNode* frame_tree_node) { 785 void NavigationEntryImpl::ClearChildren(FrameTreeNode* frame_tree_node) {
786 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node); 786 NavigationEntryImpl::TreeNode* tree_node = FindFrameEntry(frame_tree_node);
787 if (tree_node) 787 if (tree_node)
788 tree_node->children.clear(); 788 tree_node->children.clear();
789 } 789 }
790 790
791 void NavigationEntryImpl::ClearNamedFrameEntries(
792 const std::string& frame_unique_name) {
793 NavigationEntryImpl::TreeNode* node = nullptr;
794 NavigationEntryImpl::TreeNode* parent = nullptr;
795 std::queue<
796 std::pair<NavigationEntryImpl::TreeNode*, NavigationEntryImpl::TreeNode*>>
Charlie Reis 2016/07/27 22:48:28 I suppose that's what we get for not having a pare
nasko 2016/07/29 15:52:21 Acknowledged.
797 work_queue;
798 work_queue.push(std::make_pair(root_node(), nullptr));
799 int count = 0;
800
801 while (!work_queue.empty()) {
802 node = work_queue.front().first;
803 parent = work_queue.front().second;
804 work_queue.pop();
805
806 if (parent && node->frame_entry->frame_unique_name() == frame_unique_name) {
Charlie Reis 2016/07/27 22:48:28 I'm curious if it would be better to use MatchesFr
nasko 2016/07/29 15:52:22 Done.
807 auto it =
808 std::find(parent->children.begin(), parent->children.end(), node);
809 if (it != parent->children.end()) {
Charlie Reis 2016/07/27 22:48:27 This shouldn't ever fail, should it?
nasko 2016/07/29 15:52:21 No.
810 parent->children.erase(it);
811 ++count;
812 }
813 continue;
814 }
815
816 // Enqueue any children and keep looking.
817 for (auto* child : node->children)
818 work_queue.push(std::make_pair(child, node));
819 }
820
821 // There should be at most one frame matching the |frame_unique_name|.
822 DCHECK_GE(1, count);
823 }
824
791 void NavigationEntryImpl::SetScreenshotPNGData( 825 void NavigationEntryImpl::SetScreenshotPNGData(
792 scoped_refptr<base::RefCountedBytes> png_data) { 826 scoped_refptr<base::RefCountedBytes> png_data) {
793 screenshot_ = png_data; 827 screenshot_ = png_data;
794 if (screenshot_.get()) 828 if (screenshot_.get())
795 UMA_HISTOGRAM_MEMORY_KB("Overscroll.ScreenshotSize", screenshot_->size()); 829 UMA_HISTOGRAM_MEMORY_KB("Overscroll.ScreenshotSize", screenshot_->size());
796 } 830 }
797 831
798 GURL NavigationEntryImpl::GetHistoryURLForDataURL() const { 832 GURL NavigationEntryImpl::GetHistoryURLForDataURL() const {
799 return GetBaseURLForDataURL().is_empty() ? GURL() : GetVirtualURL(); 833 return GetBaseURLForDataURL().is_empty() ? GURL() : GetVirtualURL();
800 } 834 }
(...skipping 10 matching lines...) Expand all
811 return node; 845 return node;
812 846
813 // Enqueue any children and keep looking. 847 // Enqueue any children and keep looking.
814 for (auto* child : node->children) 848 for (auto* child : node->children)
815 work_queue.push(child); 849 work_queue.push(child);
816 } 850 }
817 return nullptr; 851 return nullptr;
818 } 852 }
819 853
820 } // namespace content 854 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698