Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 SiteInstance* site_instance = render_frame_host->GetSiteInstance(); | 282 SiteInstance* site_instance = render_frame_host->GetSiteInstance(); |
| 306 RenderViewHostMap::iterator iter = | 283 RenderViewHostMap::iterator iter = |
| 307 render_view_host_map_.find(site_instance->GetId()); | 284 render_view_host_map_.find(site_instance->GetId()); |
| 308 CHECK(iter != render_view_host_map_.end()); | 285 CHECK(iter != render_view_host_map_.end()); |
| 309 | 286 |
| 310 iter->second->increment_ref_count(); | 287 iter->second->increment_ref_count(); |
| 311 } | 288 } |
| 312 | 289 |
| 313 void FrameTree::UnregisterRenderFrameHost( | 290 void FrameTree::UnregisterRenderFrameHost( |
| 314 RenderFrameHostImpl* render_frame_host) { | 291 RenderFrameHostImpl* render_frame_host) { |
| 315 SiteInstance* site_instance = render_frame_host->GetSiteInstance(); | 292 SiteInstance* site_instance = |
| 293 render_frame_host->render_view_host()->GetSiteInstance(); | |
|
Charlie Reis
2015/02/06 00:04:47
Looks like a failed merge here.
nasko
2015/02/06 01:10:48
Oh, that was auto merged :(. Thanks for catching i
| |
| 316 int32 site_instance_id = site_instance->GetId(); | 294 int32 site_instance_id = site_instance->GetId(); |
| 317 RenderViewHostMap::iterator iter = | 295 RenderViewHostMap::iterator iter = |
| 318 render_view_host_map_.find(site_instance_id); | 296 render_view_host_map_.find(site_instance_id); |
| 319 if (iter != render_view_host_map_.end() && | 297 if (iter != render_view_host_map_.end() && |
| 320 iter->second == render_frame_host->render_view_host()) { | 298 iter->second == render_frame_host->render_view_host()) { |
| 321 // Decrement the refcount and shutdown the RenderViewHost if no one else is | 299 // Decrement the refcount and shutdown the RenderViewHost if no one else is |
| 322 // using it. | 300 // using it. |
| 323 CHECK_GT(iter->second->ref_count(), 0); | 301 CHECK_GT(iter->second->ref_count(), 0); |
| 324 iter->second->decrement_ref_count(); | 302 iter->second->decrement_ref_count(); |
| 325 if (iter->second->ref_count() == 0) { | 303 if (iter->second->ref_count() == 0) { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 348 rvh->Shutdown(); | 326 rvh->Shutdown(); |
| 349 render_view_host_pending_shutdown_map_.erase(multi_iter); | 327 render_view_host_pending_shutdown_map_.erase(multi_iter); |
| 350 } | 328 } |
| 351 break; | 329 break; |
| 352 } | 330 } |
| 353 CHECK(render_view_host_found); | 331 CHECK(render_view_host_found); |
| 354 } | 332 } |
| 355 } | 333 } |
| 356 | 334 |
| 357 } // namespace content | 335 } // namespace content |
| OLD | NEW |