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

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

Issue 917793006: Resetting FrameTreeNode must remove child FrameTreeNodes from global map. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: A better fix. Created 5 years, 10 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
« no previous file with comments | « no previous file | content/browser/frame_host/frame_tree_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/frame_tree_node.h" 5 #include "content/browser/frame_host/frame_tree_node.h"
6 6
7 #include <queue> 7 #include <queue>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 85 }
86 } 86 }
87 87
88 void FrameTreeNode::ResetForNewProcess() { 88 void FrameTreeNode::ResetForNewProcess() {
89 current_url_ = GURL(); 89 current_url_ = GURL();
90 90
91 // The children may not have been cleared if a cross-process navigation 91 // The children may not have been cleared if a cross-process navigation
92 // commits before the old process cleans everything up. Make sure the child 92 // commits before the old process cleans everything up. Make sure the child
93 // nodes get deleted before swapping to a new process. 93 // nodes get deleted before swapping to a new process.
94 ScopedVector<FrameTreeNode> old_children = children_.Pass(); 94 ScopedVector<FrameTreeNode> old_children = children_.Pass();
95
96 // Loop over all children removing them from the FrameTree. This will ensure
97 // that nodes are properly remove from the tree and notifications are sent.
Charlie Reis 2015/02/12 23:26:07 nit: removed
nasko 2015/02/12 23:30:51 Done.
98 // Note: since the |children_| vector is now empty, the calls into RemoveChild
99 // will be a noop and will not result in traversing twice through the list.
Charlie Reis 2015/02/12 23:26:07 nit: no-op nit: s/traversing twice through/repeate
nasko 2015/02/12 23:30:51 Done.
100 for (const auto& child : old_children) {
Charlie Reis 2015/02/12 23:26:07 nit: No braces needed.
nasko 2015/02/12 23:30:51 Done.
101 frame_tree_->RemoveFrame(child);
102 }
95 old_children.clear(); // May notify observers. 103 old_children.clear(); // May notify observers.
96 } 104 }
97 105
98 bool FrameTreeNode::IsDescendantOf(FrameTreeNode* other) const { 106 bool FrameTreeNode::IsDescendantOf(FrameTreeNode* other) const {
99 if (!other || !other->child_count()) 107 if (!other || !other->child_count())
100 return false; 108 return false;
101 109
102 for (FrameTreeNode* node = parent(); node; node = node->parent()) { 110 for (FrameTreeNode* node = parent(); node; node = node->parent()) {
103 if (node == other) 111 if (node == other)
104 return true; 112 return true;
105 } 113 }
106 114
107 return false; 115 return false;
108 } 116 }
109 117
110 } // namespace content 118 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/frame_tree_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698