| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 88 } |
| 89 | 89 |
| 90 bool FrameTree::IsFirstNavigationAfterSwap() const { | 90 bool FrameTree::IsFirstNavigationAfterSwap() const { |
| 91 return root_->frame_id() == FrameTreeNode::kInvalidFrameId; | 91 return root_->frame_id() == FrameTreeNode::kInvalidFrameId; |
| 92 } | 92 } |
| 93 | 93 |
| 94 void FrameTree::OnFirstNavigationAfterSwap(int main_frame_id) { | 94 void FrameTree::OnFirstNavigationAfterSwap(int main_frame_id) { |
| 95 root_->set_frame_id(main_frame_id); | 95 root_->set_frame_id(main_frame_id); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void FrameTree::AddFrame(int render_frame_host_id, | 98 RenderFrameHostImpl* FrameTree::AddFrame(int render_frame_host_id, |
| 99 int64 parent_frame_id, | 99 int64 parent_frame_id, |
| 100 int64 frame_id, | 100 int64 frame_id, |
| 101 const std::string& frame_name) { | 101 const std::string& frame_name) { |
| 102 FrameTreeNode* parent = FindByFrameID(parent_frame_id); | 102 FrameTreeNode* parent = FindByFrameID(parent_frame_id); |
| 103 // TODO(ajwong): Should the renderer be killed here? Would there be a race on | 103 // TODO(ajwong): Should the renderer be killed here? Would there be a race on |
| 104 // shutdown that might make this case possible? | 104 // shutdown that might make this case possible? |
| 105 if (!parent) | 105 if (!parent) |
| 106 return; | 106 return NULL; |
| 107 | 107 |
| 108 parent->AddChild(CreateNode(frame_id, frame_name, render_frame_host_id, | 108 scoped_ptr<FrameTreeNode> node(CreateNode( |
| 109 parent->navigator(), | 109 frame_id, frame_name, render_frame_host_id, parent->navigator(), |
| 110 parent->render_frame_host()->GetProcess())); | 110 parent->render_frame_host()->GetProcess())); |
| 111 RenderFrameHostImpl* render_frame = node->render_frame_host(); |
| 112 parent->AddChild(node.Pass()); |
| 113 return render_frame; |
| 111 } | 114 } |
| 112 | 115 |
| 113 void FrameTree::RemoveFrame(int64 parent_frame_id, int64 frame_id) { | 116 void FrameTree::RemoveFrame(int64 parent_frame_id, int64 frame_id) { |
| 114 // If switches::kSitePerProcess is not specified, then the FrameTree only | 117 // If switches::kSitePerProcess is not specified, then the FrameTree only |
| 115 // contains a node for the root element. However, even in this case | 118 // contains a node for the root element. However, even in this case |
| 116 // frame detachments need to be broadcast outwards. | 119 // frame detachments need to be broadcast outwards. |
| 117 // | 120 // |
| 118 // TODO(ajwong): Move this below the |parent| check after the FrameTree is | 121 // TODO(ajwong): Move this below the |parent| check after the FrameTree is |
| 119 // guaranteed to be correctly populated even without the | 122 // guaranteed to be correctly populated even without the |
| 120 // switches::kSitePerProcess flag. | 123 // switches::kSitePerProcess flag. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 this, | 179 this, |
| 177 render_frame_host_id, | 180 render_frame_host_id, |
| 178 false)); | 181 false)); |
| 179 | 182 |
| 180 return make_scoped_ptr(new FrameTreeNode(navigator, | 183 return make_scoped_ptr(new FrameTreeNode(navigator, |
| 181 render_frame_delegate_, render_view_delegate_, render_widget_delegate_, | 184 render_frame_delegate_, render_view_delegate_, render_widget_delegate_, |
| 182 manager_delegate_, frame_id, frame_name, render_frame_host.Pass())); | 185 manager_delegate_, frame_id, frame_name, render_frame_host.Pass())); |
| 183 } | 186 } |
| 184 | 187 |
| 185 } // namespace content | 188 } // namespace content |
| OLD | NEW |