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

Side by Side Diff: content/browser/frame_host/frame_tree_node.h

Issue 30323002: [DRAFT] Create RenderFrameHostManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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 #ifndef CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_H_ 5 #ifndef CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_H_
6 #define CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_H_ 6 #define CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
14 #include "content/browser/frame_host/render_view_host_manager.h" 14 #include "content/browser/frame_host/render_view_host_manager.h"
15 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 class Navigator; 20 class Navigator;
21 class RenderFrameHostImpl; 21 class RenderFrameHostImpl;
22 22
23 // When a page contains iframes, its renderer process maintains a tree structure 23 // When a page contains iframes, its renderer process maintains a tree structure
24 // of those frames. We are mirroring this tree in the browser process. This 24 // of those frames. We are mirroring this tree in the browser process. This
25 // class represents a node in this tree and is a wrapper for all objects that 25 // class represents a node in this tree and is a wrapper for all objects that
26 // are frame-specific (as opposed to page-specific). 26 // are frame-specific (as opposed to page-specific).
27 class CONTENT_EXPORT FrameTreeNode { 27 class CONTENT_EXPORT FrameTreeNode {
28 public: 28 public:
29 static const int64 kInvalidFrameId;
30
31 FrameTreeNode(Navigator* navigator, 29 FrameTreeNode(Navigator* navigator,
32 RenderViewHostDelegate* render_view_delegate, 30 RenderViewHostDelegate* render_view_delegate,
33 RenderWidgetHostDelegate* render_widget_delegate, 31 RenderWidgetHostDelegate* render_widget_delegate,
34 RenderViewHostManager::Delegate* manager_delegate, 32 RenderViewHostManager::Delegate* manager_delegate,
35 int64 frame_id, 33 const std::string& name);
36 const std::string& name,
37 scoped_ptr<RenderFrameHostImpl> render_frame_host);
38 34
39 ~FrameTreeNode(); 35 ~FrameTreeNode();
40 36
41 void AddChild(scoped_ptr<FrameTreeNode> child); 37 void AddChild(scoped_ptr<FrameTreeNode> child,
38 int render_frame_host_id);
42 void RemoveChild(FrameTreeNode* child); 39 void RemoveChild(FrameTreeNode* child);
43 40
44 // Transitional API allowing the RenderFrameHost of a FrameTreeNode
45 // representing the main frame to be provided by someone else. After
46 // this is called, the FrameTreeNode no longer owns its RenderFrameHost.
47 //
48 // This should only be used for the main frame (aka root) in a frame tree.
49 //
50 // TODO(ajwong): Remove this method once the main frame RenderFrameHostImpl is
51 // no longer owned by the RenderViewHostImpl.
52 void ResetForMainFrame(RenderFrameHostImpl* new_render_frame_host);
53
54 Navigator* navigator() { 41 Navigator* navigator() {
55 return navigator_.get(); 42 return navigator_.get();
56 } 43 }
57 44
58 RenderViewHostManager* render_manager() { 45 RenderViewHostManager* render_manager() {
59 return &render_manager_; 46 return &render_manager_;
60 } 47 }
61 48
49 // This is the browser-wide unique ID for the FrameTreeNode. If you have a
50 // renderer-specific frame ID, you can look up the corresponding FrameTreeNode
51 // ID using RenderViewHostImpl::GetFrameTreeNodeID(frame_id).
62 int64 frame_tree_node_id() const { 52 int64 frame_tree_node_id() const {
63 return frame_tree_node_id_; 53 return frame_tree_node_id_;
64 } 54 }
65 55
66 // DO NOT USE. Only used by FrameTree until we replace renderer-specific
67 // frame IDs with RenderFrameHost routing IDs.
68 void set_frame_id(int64 frame_id) {
69 DCHECK_EQ(frame_id_, kInvalidFrameId);
70 frame_id_ = frame_id;
71 }
72 int64 frame_id() const {
73 return frame_id_;
74 }
75
76 const std::string& frame_name() const { 56 const std::string& frame_name() const {
77 return frame_name_; 57 return frame_name_;
78 } 58 }
79 59
80 size_t child_count() const { 60 size_t child_count() const {
81 return children_.size(); 61 return children_.size();
82 } 62 }
83 63
84 FrameTreeNode* child_at(size_t index) const { 64 FrameTreeNode* child_at(size_t index) const {
85 return children_[index]; 65 return children_[index];
86 } 66 }
87 67
88 const GURL& current_url() const { 68 const GURL& current_url() const {
89 return current_url_; 69 return current_url_;
90 } 70 }
91 71
92 void set_current_url(const GURL& url) { 72 void set_current_url(const GURL& url) {
93 current_url_ = url; 73 current_url_ = url;
94 } 74 }
95 75
96 RenderFrameHostImpl* render_frame_host() const { 76 RenderFrameHostImpl* render_frame_host() const {
97 return render_frame_host_; 77 return render_manager_.current_frame();
98 } 78 }
99 79
100 private: 80 private:
101 // The next available browser-global FrameTreeNode ID. 81 // The next available browser-global FrameTreeNode ID.
102 static int64 next_frame_tree_node_id_; 82 static int64 next_frame_tree_node_id_;
103 83
104 // The Navigator object responsible for managing navigations at this node 84 // The Navigator object responsible for managing navigations at this node
105 // of the frame tree. 85 // of the frame tree.
106 scoped_refptr<Navigator> navigator_; 86 scoped_refptr<Navigator> navigator_;
107 87
108 // Manages creation and swapping of RenderViewHosts for this frame. This must 88 // Manages creation and swapping of RenderFrameHosts for this frame. This
109 // be declared before |children_| so that it gets deleted after them. That's 89 // must be declared before |children_| so that it gets deleted after them.
110 // currently necessary so that RenderFrameHostImpl's destructor can call 90 // That's currently necessary so that RenderFrameHostImpl's destructor can
111 // GetProcess. 91 // call GetProcess.
112 // TODO(creis): This will become a RenderFrameHostManager, which eliminates 92 // TODO(creis): This will become a RenderFrameHostManager, which eliminates
113 // the need for |render_frame_host_| below. 93 // the need for |render_frame_host_| below.
114 RenderViewHostManager render_manager_; 94 RenderViewHostManager render_manager_;
115 95
116 // A browser-global identifier for the frame in the page, which stays stable 96 // A browser-global identifier for the frame in the page, which stays stable
117 // even if the frame does a cross-process navigation. 97 // even if the frame does a cross-process navigation.
118 const int64 frame_tree_node_id_; 98 int64 frame_tree_node_id_;
119
120 // The renderer-specific identifier for the frame in the page.
121 // TODO(creis): Remove this in favor of the RenderFrameHost's routing ID once
122 // we create FrameTreeNodes for all frames (even without a flag), since this
123 // value can change after cross-process navigations.
124 int64 frame_id_;
125 99
126 // The assigned name of the frame. This name can be empty, unlike the unique 100 // The assigned name of the frame. This name can be empty, unlike the unique
127 // name generated internally in the DOM tree. 101 // name generated internally in the DOM tree.
128 std::string frame_name_; 102 std::string frame_name_;
129 103
130 // The immediate children of this specific frame. 104 // The immediate children of this specific frame.
131 ScopedVector<FrameTreeNode> children_; 105 ScopedVector<FrameTreeNode> children_;
132 106
133 // When ResetForMainFrame() is called, this is set to false and the
134 // |render_frame_host_| below is not deleted on destruction.
135 //
136 // For the mainframe, the FrameTree does not own the |render_frame_host_|.
137 // This is a transitional wart because RenderViewHostManager does not yet
138 // have the bookkeeping logic to handle creating a pending RenderFrameHost
139 // along with a pending RenderViewHost. Thus, for the main frame, the
140 // RenderViewHost currently retains ownership and the FrameTreeNode should
141 // not delete it on destruction.
142 bool owns_render_frame_host_;
143
144 // The active RenderFrameHost for this frame. The FrameTreeNode does not
145 // always own this pointer. See comments above |owns_render_frame_host_|.
146 // TODO(ajwong): Replace with RenderFrameHostManager.
147 RenderFrameHostImpl* render_frame_host_;
148
149 // Track the current frame's last committed URL, so we can estimate the 107 // Track the current frame's last committed URL, so we can estimate the
150 // process impact of out-of-process iframes. 108 // process impact of out-of-process iframes.
151 // TODO(creis): Remove this when we can store subframe URLs in the 109 // TODO(creis): Remove this when we can store subframe URLs in the
152 // NavigationController. 110 // NavigationController.
153 GURL current_url_; 111 GURL current_url_;
154 112
155 DISALLOW_COPY_AND_ASSIGN(FrameTreeNode); 113 DISALLOW_COPY_AND_ASSIGN(FrameTreeNode);
156 }; 114 };
157 115
158 } // namespace content 116 } // namespace content
159 117
160 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_H_ 118 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698