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 #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" |
(...skipping 21 matching lines...) Expand all Loading... |
32 FrameTreeNode(Navigator* navigator, | 32 FrameTreeNode(Navigator* navigator, |
33 RenderFrameHostDelegate* render_frame_delegate, | 33 RenderFrameHostDelegate* render_frame_delegate, |
34 RenderViewHostDelegate* render_view_delegate, | 34 RenderViewHostDelegate* render_view_delegate, |
35 RenderWidgetHostDelegate* render_widget_delegate, | 35 RenderWidgetHostDelegate* render_widget_delegate, |
36 RenderFrameHostManager::Delegate* manager_delegate, | 36 RenderFrameHostManager::Delegate* manager_delegate, |
37 int64 frame_id, | 37 int64 frame_id, |
38 const std::string& name); | 38 const std::string& name); |
39 | 39 |
40 ~FrameTreeNode(); | 40 ~FrameTreeNode(); |
41 | 41 |
42 void AddChild(scoped_ptr<FrameTreeNode> child); | 42 void AddChild(scoped_ptr<FrameTreeNode> child, int render_frame_host_id); |
43 void RemoveChild(FrameTreeNode* child); | 43 void RemoveChild(FrameTreeNode* child); |
44 | 44 |
45 // TODO(nasko): This method should be removed once RenderFrameHosts are | 45 // Clears process specific-state after a main frame process swap. |
46 // created by RenderFrameHostManager. | 46 // TODO(creis): Look into how we can remove the need for this method. |
47 void set_render_frame_host( | 47 void ResetForMainFrameSwap(); |
48 RenderFrameHostImpl* render_frame_host, | |
49 bool owns_render_frame_host) { | |
50 render_frame_host_ = render_frame_host; | |
51 owns_render_frame_host_ = owns_render_frame_host; | |
52 } | |
53 | |
54 // Transitional API allowing the RenderFrameHost of a FrameTreeNode | |
55 // representing the main frame to be provided by someone else. After | |
56 // this is called, the FrameTreeNode no longer owns its RenderFrameHost. | |
57 // | |
58 // This should only be used for the main frame (aka root) in a frame tree. | |
59 // | |
60 // TODO(ajwong): Remove this method once the main frame RenderFrameHostImpl is | |
61 // no longer owned by the RenderViewHostImpl. | |
62 void ResetForMainFrame(RenderFrameHostImpl* new_render_frame_host); | |
63 | 48 |
64 Navigator* navigator() { | 49 Navigator* navigator() { |
65 return navigator_.get(); | 50 return navigator_.get(); |
66 } | 51 } |
67 | 52 |
68 RenderFrameHostManager* render_manager() { | 53 RenderFrameHostManager* render_manager() { |
69 return &render_manager_; | 54 return &render_manager_; |
70 } | 55 } |
71 | 56 |
72 int64 frame_tree_node_id() const { | 57 int64 frame_tree_node_id() const { |
(...skipping 23 matching lines...) Expand all Loading... |
96 } | 81 } |
97 | 82 |
98 const GURL& current_url() const { | 83 const GURL& current_url() const { |
99 return current_url_; | 84 return current_url_; |
100 } | 85 } |
101 | 86 |
102 void set_current_url(const GURL& url) { | 87 void set_current_url(const GURL& url) { |
103 current_url_ = url; | 88 current_url_ = url; |
104 } | 89 } |
105 | 90 |
106 RenderFrameHostImpl* render_frame_host() const { | 91 RenderFrameHostImpl* current_render_frame_host() const { |
107 return render_frame_host_; | 92 return render_manager_.current_frame(); |
108 } | 93 } |
109 | 94 |
110 private: | 95 private: |
111 // The next available browser-global FrameTreeNode ID. | 96 // The next available browser-global FrameTreeNode ID. |
112 static int64 next_frame_tree_node_id_; | 97 static int64 next_frame_tree_node_id_; |
113 | 98 |
114 // The Navigator object responsible for managing navigations at this node | 99 // The Navigator object responsible for managing navigations at this node |
115 // of the frame tree. | 100 // of the frame tree. |
116 scoped_refptr<Navigator> navigator_; | 101 scoped_refptr<Navigator> navigator_; |
117 | 102 |
118 // Manages creation and swapping of RenderViewHosts for this frame. This must | 103 // Manages creation and swapping of RenderFrameHosts for this frame. This |
119 // be declared before |children_| so that it gets deleted after them. That's | 104 // must be declared before |children_| so that it gets deleted after them. |
120 // currently necessary so that RenderFrameHostImpl's destructor can call | 105 // That's currently necessary so that RenderFrameHostImpl's destructor can |
121 // GetProcess. | 106 // call GetProcess. |
122 // TODO(creis): This will eliminate the need for |render_frame_host_| below. | |
123 RenderFrameHostManager render_manager_; | 107 RenderFrameHostManager render_manager_; |
124 | 108 |
125 // A browser-global identifier for the frame in the page, which stays stable | 109 // A browser-global identifier for the frame in the page, which stays stable |
126 // even if the frame does a cross-process navigation. | 110 // even if the frame does a cross-process navigation. |
127 const int64 frame_tree_node_id_; | 111 const int64 frame_tree_node_id_; |
128 | 112 |
129 // The renderer-specific identifier for the frame in the page. | 113 // The renderer-specific identifier for the frame in the page. |
130 // TODO(creis): Remove this in favor of the RenderFrameHost's routing ID once | 114 // TODO(creis): Remove this in favor of the RenderFrameHost's routing ID once |
131 // we create FrameTreeNodes for all frames (even without a flag), since this | 115 // we create FrameTreeNodes for all frames (even without a flag), since this |
132 // value can change after cross-process navigations. | 116 // value can change after cross-process navigations. |
133 int64 frame_id_; | 117 int64 frame_id_; |
134 | 118 |
135 // The assigned name of the frame. This name can be empty, unlike the unique | 119 // The assigned name of the frame. This name can be empty, unlike the unique |
136 // name generated internally in the DOM tree. | 120 // name generated internally in the DOM tree. |
137 std::string frame_name_; | 121 std::string frame_name_; |
138 | 122 |
139 // The immediate children of this specific frame. | 123 // The immediate children of this specific frame. |
140 ScopedVector<FrameTreeNode> children_; | 124 ScopedVector<FrameTreeNode> children_; |
141 | 125 |
142 // When ResetForMainFrame() is called, this is set to false and the | |
143 // |render_frame_host_| below is not deleted on destruction. | |
144 // | |
145 // For the mainframe, the FrameTree does not own the |render_frame_host_|. | |
146 // This is a transitional wart because RenderFrameHostManager does not yet | |
147 // have the bookkeeping logic to handle creating a pending RenderFrameHost | |
148 // along with a pending RenderViewHost. Thus, for the main frame, the | |
149 // RenderViewHost currently retains ownership and the FrameTreeNode should | |
150 // not delete it on destruction. | |
151 bool owns_render_frame_host_; | |
152 | |
153 // The active RenderFrameHost for this frame. The FrameTreeNode does not | |
154 // always own this pointer. See comments above |owns_render_frame_host_|. | |
155 // TODO(ajwong): Replace with RenderFrameHostManager. | |
156 RenderFrameHostImpl* render_frame_host_; | |
157 | |
158 // Track the current frame's last committed URL, so we can estimate the | 126 // Track the current frame's last committed URL, so we can estimate the |
159 // process impact of out-of-process iframes. | 127 // process impact of out-of-process iframes. |
160 // TODO(creis): Remove this when we can store subframe URLs in the | 128 // TODO(creis): Remove this when we can store subframe URLs in the |
161 // NavigationController. | 129 // NavigationController. |
162 GURL current_url_; | 130 GURL current_url_; |
163 | 131 |
164 DISALLOW_COPY_AND_ASSIGN(FrameTreeNode); | 132 DISALLOW_COPY_AND_ASSIGN(FrameTreeNode); |
165 }; | 133 }; |
166 | 134 |
167 } // namespace content | 135 } // namespace content |
168 | 136 |
169 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_H_ | 137 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_H_ |
OLD | NEW |