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

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

Issue 26316005: Move out DidStartProvisionalLoad from WebContentsImpl into Navigator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add NavigatorDelegate Created 7 years, 1 month 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 | Annotate | Revision Log
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"
11 #include "content/browser/frame_host/frame_tree_node.h" 11 #include "content/browser/frame_host/frame_tree_node.h"
12 #include "content/browser/frame_host/navigator.h"
13 #include "content/browser/frame_host/navigator_delegate.h"
12 #include "content/browser/frame_host/render_frame_host_impl.h" 14 #include "content/browser/frame_host/render_frame_host_impl.h"
13 15
14 namespace content { 16 namespace content {
15 17
16 namespace { 18 namespace {
17 // Used with FrameTree::ForEach() to search for the FrameTreeNode 19 // Used with FrameTree::ForEach() to search for the FrameTreeNode
18 // corresponding to |frame_id|. 20 // corresponding to |frame_id|.
19 bool FrameTreeNodeForId(int64 frame_id, FrameTreeNode** out_node, 21 bool FrameTreeNodeForId(int64 frame_id, FrameTreeNode** out_node,
20 FrameTreeNode* node) { 22 FrameTreeNode* node) {
21 if (node->frame_id() == frame_id) { 23 if (node->frame_id() == frame_id) {
22 *out_node = node; 24 *out_node = node;
23 // Terminate iteration once the node has been found. 25 // Terminate iteration once the node has been found.
24 return false; 26 return false;
25 } 27 }
26 return true; 28 return true;
27 } 29 }
28 30
29 } // namespace 31 } // namespace
30 32
31 FrameTree::FrameTree() 33 FrameTree::FrameTree() {
32 : root_(new FrameTreeNode(FrameTreeNode::kInvalidFrameId, std::string(), 34 }
33 scoped_ptr<RenderFrameHostImpl>())) { 35
36 void FrameTree::Init(
37 NavigationControllerImpl* navigation_controller,
Charlie Reis 2013/11/07 01:22:43 nit: Goes on previous line.
38 NavigatorDelegate* navigator_delegate) {
39 root_.reset(new FrameTreeNode(navigation_controller,
40 navigator_delegate,
41 FrameTreeNode::kInvalidFrameId, std::string(),
42 scoped_ptr<RenderFrameHostImpl>()));
34 } 43 }
35 44
36 FrameTree::~FrameTree() { 45 FrameTree::~FrameTree() {
37 } 46 }
38 47
39 FrameTreeNode* FrameTree::FindByID(int64 frame_id) { 48 FrameTreeNode* FrameTree::FindByID(int64 frame_id) {
40 FrameTreeNode* node = NULL; 49 FrameTreeNode* node = NULL;
41 ForEach(base::Bind(&FrameTreeNodeForId, frame_id, &node)); 50 ForEach(base::Bind(&FrameTreeNodeForId, frame_id, &node));
42 return node; 51 return node;
43 } 52 }
(...skipping 23 matching lines...) Expand all
67 } 76 }
68 77
69 void FrameTree::AddFrame(int render_frame_host_id, int64 parent_frame_id, 78 void FrameTree::AddFrame(int render_frame_host_id, int64 parent_frame_id,
70 int64 frame_id, const std::string& frame_name) { 79 int64 frame_id, const std::string& frame_name) {
71 FrameTreeNode* parent = FindByID(parent_frame_id); 80 FrameTreeNode* parent = FindByID(parent_frame_id);
72 // TODO(ajwong): Should the renderer be killed here? Would there be a race on 81 // TODO(ajwong): Should the renderer be killed here? Would there be a race on
73 // shutdown that might make this case possible? 82 // shutdown that might make this case possible?
74 if (!parent) 83 if (!parent)
75 return; 84 return;
76 85
77 parent->AddChild(CreateNode(frame_id, frame_name, render_frame_host_id, 86 parent->AddChild(CreateNode(parent->navigator(),
87 frame_id, frame_name, render_frame_host_id,
78 parent->render_frame_host()->GetProcess())); 88 parent->render_frame_host()->GetProcess()));
79 } 89 }
80 90
81 void FrameTree::RemoveFrame(int64 parent_frame_id, int64 frame_id) { 91 void FrameTree::RemoveFrame(int64 parent_frame_id, int64 frame_id) {
82 // If switches::kSitePerProcess is not specified, then the FrameTree only 92 // If switches::kSitePerProcess is not specified, then the FrameTree only
83 // contains a node for the root element. However, even in this case 93 // contains a node for the root element. However, even in this case
84 // frame detachments need to be broadcast outwards. 94 // frame detachments need to be broadcast outwards.
85 // 95 //
86 // TODO(ajwong): Move this below the |parent| check after the FrameTree is 96 // TODO(ajwong): Move this below the |parent| check after the FrameTree is
87 // guaranteed to be correctly populated even without the 97 // guaranteed to be correctly populated even without the
(...skipping 30 matching lines...) Expand all
118 RenderFrameHostImpl* FrameTree::GetMainFrame() const { 128 RenderFrameHostImpl* FrameTree::GetMainFrame() const {
119 return root_->render_frame_host(); 129 return root_->render_frame_host();
120 } 130 }
121 131
122 void FrameTree::SetFrameRemoveListener( 132 void FrameTree::SetFrameRemoveListener(
123 const base::Callback<void(RenderViewHostImpl*, int64)>& on_frame_removed) { 133 const base::Callback<void(RenderViewHostImpl*, int64)>& on_frame_removed) {
124 on_frame_removed_ = on_frame_removed; 134 on_frame_removed_ = on_frame_removed;
125 } 135 }
126 136
127 scoped_ptr<FrameTreeNode> FrameTree::CreateNode( 137 scoped_ptr<FrameTreeNode> FrameTree::CreateNode(
128 int64 frame_id, const std::string& frame_name, int render_frame_host_id, 138 Navigator* parent_navigator,
139 int64 frame_id,
140 const std::string& frame_name,
141 int render_frame_host_id,
129 RenderProcessHost* render_process_host) { 142 RenderProcessHost* render_process_host) {
130 scoped_ptr<RenderFrameHostImpl> render_frame_host( 143 scoped_ptr<RenderFrameHostImpl> render_frame_host(
131 new RenderFrameHostImpl(root_->render_frame_host()->render_view_host(), 144 new RenderFrameHostImpl(root_->render_frame_host()->render_view_host(),
132 this, render_frame_host_id, false)); 145 this, parent_navigator, render_frame_host_id,
146 false));
133 147
134 return make_scoped_ptr(new FrameTreeNode(frame_id, frame_name, 148 return make_scoped_ptr(new FrameTreeNode(parent_navigator->controller(),
149 parent_navigator->delegate(),
150 frame_id, frame_name,
135 render_frame_host.Pass())); 151 render_frame_host.Pass()));
136 } 152 }
137 153
138 } // namespace content 154 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698