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