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

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

Issue 894843003: Move the RenderProcessGone IPC from RenderViewHost to RenderFrameHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix conflict with dalecurtis' CL 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 | « content/browser/frame_host/frame_tree.h ('k') | content/browser/frame_host/frame_tree_node.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.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 25 matching lines...) Expand all
36 FrameTreeNode** out_node, 36 FrameTreeNode** out_node,
37 FrameTreeNode* node) { 37 FrameTreeNode* node) {
38 if (node->frame_tree_node_id() == frame_tree_node_id) { 38 if (node->frame_tree_node_id() == frame_tree_node_id) {
39 *out_node = node; 39 *out_node = node;
40 // Terminate iteration once the node has been found. 40 // Terminate iteration once the node has been found.
41 return false; 41 return false;
42 } 42 }
43 return true; 43 return true;
44 } 44 }
45 45
46 // Iterate over the FrameTree to reset any node affected by the loss of the
47 // given RenderViewHost's process.
48 bool ResetNodesForNewProcess(RenderViewHost* render_view_host,
49 FrameTreeNode* node) {
50 if (render_view_host == node->current_frame_host()->render_view_host()) {
51 // Ensure that if the frame host is reused for a new RenderFrame, it will
52 // set up the Mojo connection with that frame.
53 node->current_frame_host()->InvalidateMojoConnection();
54 node->ResetForNewProcess();
55 }
56 return true;
57 }
58
59 bool CreateProxyForSiteInstance(const scoped_refptr<SiteInstance>& instance, 46 bool CreateProxyForSiteInstance(const scoped_refptr<SiteInstance>& instance,
60 FrameTreeNode* node) { 47 FrameTreeNode* node) {
61 // If a new frame is created in the current SiteInstance, other frames in 48 // If a new frame is created in the current SiteInstance, other frames in
62 // that SiteInstance don't need a proxy for the new frame. 49 // that SiteInstance don't need a proxy for the new frame.
63 SiteInstance* current_instance = 50 SiteInstance* current_instance =
64 node->render_manager()->current_frame_host()->GetSiteInstance(); 51 node->render_manager()->current_frame_host()->GetSiteInstance();
65 if (current_instance != instance.get()) 52 if (current_instance != instance.get())
66 node->render_manager()->CreateRenderFrameProxy(instance.get()); 53 node->render_manager()->CreateRenderFrameProxy(instance.get());
67 return true; 54 return true;
68 } 55 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // new SiteInstance. Since |source|'s navigation will replace the currently 207 // new SiteInstance. Since |source|'s navigation will replace the currently
221 // loaded document, the entire subtree under |source| will be removed. 208 // loaded document, the entire subtree under |source| will be removed.
222 ForEach(base::Bind(&CreateProxyForSiteInstance, instance), source); 209 ForEach(base::Bind(&CreateProxyForSiteInstance, instance), source);
223 } 210 }
224 211
225 void FrameTree::ResetForMainFrameSwap() { 212 void FrameTree::ResetForMainFrameSwap() {
226 root_->ResetForNewProcess(); 213 root_->ResetForNewProcess();
227 focused_frame_tree_node_id_ = -1; 214 focused_frame_tree_node_id_ = -1;
228 } 215 }
229 216
230 void FrameTree::RenderProcessGone(RenderViewHost* render_view_host) {
231 // Walk the full tree looking for nodes that may be affected. Once a frame
232 // crashes, all of its child FrameTreeNodes go away.
233 // Note that the helper function may call ResetForNewProcess on a node, which
234 // clears its children before we iterate over them. That's ok, because
235 // ForEach does not add a node's children to the queue until after visiting
236 // the node itself.
237 ForEach(base::Bind(&ResetNodesForNewProcess, render_view_host));
238 }
239
240 RenderFrameHostImpl* FrameTree::GetMainFrame() const { 217 RenderFrameHostImpl* FrameTree::GetMainFrame() const {
241 return root_->current_frame_host(); 218 return root_->current_frame_host();
242 } 219 }
243 220
244 FrameTreeNode* FrameTree::GetFocusedFrame() { 221 FrameTreeNode* FrameTree::GetFocusedFrame() {
245 return FindByID(focused_frame_tree_node_id_); 222 return FindByID(focused_frame_tree_node_id_);
246 } 223 }
247 224
248 void FrameTree::SetFocusedFrame(FrameTreeNode* node) { 225 void FrameTree::SetFocusedFrame(FrameTreeNode* node) {
249 focused_frame_tree_node_id_ = node->frame_tree_node_id(); 226 focused_frame_tree_node_id_ = node->frame_tree_node_id();
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 rvh->Shutdown(); 325 rvh->Shutdown();
349 render_view_host_pending_shutdown_map_.erase(multi_iter); 326 render_view_host_pending_shutdown_map_.erase(multi_iter);
350 } 327 }
351 break; 328 break;
352 } 329 }
353 CHECK(render_view_host_found); 330 CHECK(render_view_host_found);
354 } 331 }
355 } 332 }
356 333
357 } // namespace content 334 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/frame_tree.h ('k') | content/browser/frame_host/frame_tree_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698