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

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

Issue 565103002: Revert of Do not create proxy hosts in the subtree of navigating frame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/frame_tree.h" 5 #include "content/browser/frame_host/frame_tree.h"
6 6
7 #include <queue> 7 #include <queue>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 // Iterate over the FrameTree to reset any node affected by the loss of the 46 // Iterate over the FrameTree to reset any node affected by the loss of the
47 // given RenderViewHost's process. 47 // given RenderViewHost's process.
48 bool ResetNodesForNewProcess(RenderViewHost* render_view_host, 48 bool ResetNodesForNewProcess(RenderViewHost* render_view_host,
49 FrameTreeNode* node) { 49 FrameTreeNode* node) {
50 if (render_view_host == node->current_frame_host()->render_view_host()) 50 if (render_view_host == node->current_frame_host()->render_view_host())
51 node->ResetForNewProcess(); 51 node->ResetForNewProcess();
52 return true; 52 return true;
53 } 53 }
54 54
55 bool CreateProxyForSiteInstance(const scoped_refptr<SiteInstance>& instance, 55 bool CreateProxyForSiteInstance(FrameTreeNode* source_node,
56 const scoped_refptr<SiteInstance>& instance,
56 FrameTreeNode* node) { 57 FrameTreeNode* node) {
58 // Skip the node that initiated the creation.
59 if (source_node == node)
60 return true;
61
57 node->render_manager()->CreateRenderFrameProxy(instance.get()); 62 node->render_manager()->CreateRenderFrameProxy(instance.get());
58 return true; 63 return true;
59 } 64 }
60 65
61 } // namespace 66 } // namespace
62 67
63 FrameTree::FrameTree(Navigator* navigator, 68 FrameTree::FrameTree(Navigator* navigator,
64 RenderFrameHostDelegate* render_frame_delegate, 69 RenderFrameHostDelegate* render_frame_delegate,
65 RenderViewHostDelegate* render_view_delegate, 70 RenderViewHostDelegate* render_view_delegate,
66 RenderWidgetHostDelegate* render_widget_delegate, 71 RenderWidgetHostDelegate* render_widget_delegate,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 FrameTreeNode* result = render_frame_proxy_host->frame_tree_node(); 121 FrameTreeNode* result = render_frame_proxy_host->frame_tree_node();
117 if (this == result->frame_tree()) 122 if (this == result->frame_tree())
118 return result; 123 return result;
119 } 124 }
120 125
121 return NULL; 126 return NULL;
122 } 127 }
123 128
124 void FrameTree::ForEach( 129 void FrameTree::ForEach(
125 const base::Callback<bool(FrameTreeNode*)>& on_node) const { 130 const base::Callback<bool(FrameTreeNode*)>& on_node) const {
126 ForEach(on_node, NULL);
127 }
128
129 void FrameTree::ForEach(
130 const base::Callback<bool(FrameTreeNode*)>& on_node,
131 FrameTreeNode* skip_this_subtree) const {
132 std::queue<FrameTreeNode*> queue; 131 std::queue<FrameTreeNode*> queue;
133 queue.push(root_.get()); 132 queue.push(root_.get());
134 133
135 while (!queue.empty()) { 134 while (!queue.empty()) {
136 FrameTreeNode* node = queue.front(); 135 FrameTreeNode* node = queue.front();
137 queue.pop(); 136 queue.pop();
138 if (skip_this_subtree == node)
139 continue;
140
141 if (!on_node.Run(node)) 137 if (!on_node.Run(node))
142 break; 138 break;
143 139
144 for (size_t i = 0; i < node->child_count(); ++i) 140 for (size_t i = 0; i < node->child_count(); ++i)
145 queue.push(node->child_at(i)); 141 queue.push(node->child_at(i));
146 } 142 }
147 } 143 }
148 144
149 RenderFrameHostImpl* FrameTree::AddFrame(FrameTreeNode* parent, 145 RenderFrameHostImpl* FrameTree::AddFrame(FrameTreeNode* parent,
150 int new_routing_id, 146 int new_routing_id,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 if (!render_view_host) { 186 if (!render_view_host) {
191 root()->render_manager()->CreateRenderFrame(site_instance, 187 root()->render_manager()->CreateRenderFrame(site_instance,
192 MSG_ROUTING_NONE, 188 MSG_ROUTING_NONE,
193 true, 189 true,
194 false, 190 false,
195 true); 191 true);
196 } 192 }
197 } 193 }
198 194
199 scoped_refptr<SiteInstance> instance(site_instance); 195 scoped_refptr<SiteInstance> instance(site_instance);
200 196 ForEach(base::Bind(&CreateProxyForSiteInstance, source, instance));
201 // Proxies are created in the FrameTree in response to a node navigating to a
202 // new SiteInstance. Since |source|'s navigation will replace the currently
203 // loaded document, the entire subtree under |source| will be removed.
204 ForEach(base::Bind(&CreateProxyForSiteInstance, instance), source);
205 } 197 }
206 198
207 void FrameTree::ResetForMainFrameSwap() { 199 void FrameTree::ResetForMainFrameSwap() {
208 root_->ResetForNewProcess(); 200 root_->ResetForNewProcess();
209 focused_frame_tree_node_id_ = -1; 201 focused_frame_tree_node_id_ = -1;
210 } 202 }
211 203
212 void FrameTree::RenderProcessGone(RenderViewHost* render_view_host) { 204 void FrameTree::RenderProcessGone(RenderViewHost* render_view_host) {
213 // Walk the full tree looking for nodes that may be affected. Once a frame 205 // Walk the full tree looking for nodes that may be affected. Once a frame
214 // crashes, all of its child FrameTreeNodes go away. 206 // crashes, all of its child FrameTreeNodes go away.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 rvh->Shutdown(); 322 rvh->Shutdown();
331 render_view_host_pending_shutdown_map_.erase(multi_iter); 323 render_view_host_pending_shutdown_map_.erase(multi_iter);
332 } 324 }
333 break; 325 break;
334 } 326 }
335 CHECK(render_view_host_found); 327 CHECK(render_view_host_found);
336 } 328 }
337 } 329 }
338 330
339 } // namespace content 331 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/frame_tree.h ('k') | content/browser/frame_host/frame_tree_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698