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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 } | 87 } |
88 | 88 |
89 bool FrameTree::IsFirstNavigationAfterSwap() const { | 89 bool FrameTree::IsFirstNavigationAfterSwap() const { |
90 return root_->frame_id() == FrameTreeNode::kInvalidFrameId; | 90 return root_->frame_id() == FrameTreeNode::kInvalidFrameId; |
91 } | 91 } |
92 | 92 |
93 void FrameTree::OnFirstNavigationAfterSwap(int main_frame_id) { | 93 void FrameTree::OnFirstNavigationAfterSwap(int main_frame_id) { |
94 root_->set_frame_id(main_frame_id); | 94 root_->set_frame_id(main_frame_id); |
95 } | 95 } |
96 | 96 |
97 void FrameTree::AddFrame(int render_frame_host_id, | 97 RenderFrameHostImpl* FrameTree::AddFrame(int render_frame_host_id, |
98 int64 parent_frame_id, | 98 int64 parent_frame_id, |
99 int64 frame_id, | 99 int64 frame_id, |
100 const std::string& frame_name) { | 100 const std::string& frame_name) { |
101 FrameTreeNode* parent = FindByFrameID(parent_frame_id); | 101 FrameTreeNode* parent = FindByFrameID(parent_frame_id); |
102 // TODO(ajwong): Should the renderer be killed here? Would there be a race on | 102 // TODO(ajwong): Should the renderer be killed here? Would there be a race on |
103 // shutdown that might make this case possible? | 103 // shutdown that might make this case possible? |
104 if (!parent) | 104 if (!parent) |
105 return; | 105 return NULL; |
106 | 106 |
107 parent->AddChild( | 107 scoped_ptr<FrameTreeNode> node(CreateNode( |
108 CreateNode(frame_id, frame_name, render_frame_host_id, parent)); | 108 frame_id, frame_name, render_frame_host_id, parent)); |
| 109 RenderFrameHostImpl* render_frame = node->render_frame_host(); |
| 110 parent->AddChild(node.Pass()); |
| 111 return render_frame; |
109 } | 112 } |
110 | 113 |
111 void FrameTree::RemoveFrame(RenderFrameHostImpl* render_frame_host, | 114 void FrameTree::RemoveFrame(RenderFrameHostImpl* render_frame_host, |
112 int64 parent_frame_id, | 115 int64 parent_frame_id, |
113 int64 frame_id) { | 116 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 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 this, | 182 this, |
180 frame_tree_node.get(), | 183 frame_tree_node.get(), |
181 render_frame_host_id, | 184 render_frame_host_id, |
182 false)); | 185 false)); |
183 | 186 |
184 frame_tree_node->set_render_frame_host(render_frame_host.release(), true); | 187 frame_tree_node->set_render_frame_host(render_frame_host.release(), true); |
185 return frame_tree_node.Pass(); | 188 return frame_tree_node.Pass(); |
186 } | 189 } |
187 | 190 |
188 } // namespace content | 191 } // namespace content |
OLD | NEW |