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 10 matching lines...) Expand all Loading... |
21 class FrameTree; | 21 class FrameTree; |
22 class Navigator; | 22 class Navigator; |
23 class RenderFrameHostImpl; | 23 class RenderFrameHostImpl; |
24 | 24 |
25 // When a page contains iframes, its renderer process maintains a tree structure | 25 // When a page contains iframes, its renderer process maintains a tree structure |
26 // of those frames. We are mirroring this tree in the browser process. This | 26 // of those frames. We are mirroring this tree in the browser process. This |
27 // class represents a node in this tree and is a wrapper for all objects that | 27 // class represents a node in this tree and is a wrapper for all objects that |
28 // are frame-specific (as opposed to page-specific). | 28 // are frame-specific (as opposed to page-specific). |
29 class CONTENT_EXPORT FrameTreeNode { | 29 class CONTENT_EXPORT FrameTreeNode { |
30 public: | 30 public: |
31 static const int64 kInvalidFrameId; | |
32 | |
33 FrameTreeNode(FrameTree* frame_tree, | 31 FrameTreeNode(FrameTree* frame_tree, |
34 Navigator* navigator, | 32 Navigator* navigator, |
35 RenderFrameHostDelegate* render_frame_delegate, | 33 RenderFrameHostDelegate* render_frame_delegate, |
36 RenderViewHostDelegate* render_view_delegate, | 34 RenderViewHostDelegate* render_view_delegate, |
37 RenderWidgetHostDelegate* render_widget_delegate, | 35 RenderWidgetHostDelegate* render_widget_delegate, |
38 RenderFrameHostManager::Delegate* manager_delegate, | 36 RenderFrameHostManager::Delegate* manager_delegate, |
39 int64 frame_id, | |
40 const std::string& name); | 37 const std::string& name); |
41 | 38 |
42 ~FrameTreeNode(); | 39 ~FrameTreeNode(); |
43 | 40 |
44 bool IsMainFrame() const; | 41 bool IsMainFrame() const; |
45 | 42 |
46 void AddChild(scoped_ptr<FrameTreeNode> child, int frame_routing_id); | 43 void AddChild(scoped_ptr<FrameTreeNode> child, int frame_routing_id); |
47 void RemoveChild(FrameTreeNode* child); | 44 void RemoveChild(FrameTreeNode* child); |
48 | 45 |
49 // Clears process specific-state after a main frame process swap. | 46 // Clears process specific-state after a main frame process swap. |
50 // TODO(creis): Look into how we can remove the need for this method. | 47 // TODO(creis): Look into how we can remove the need for this method. |
51 void ResetForMainFrameSwap(); | 48 void ResetForMainFrameSwap(); |
52 | 49 |
53 FrameTree* frame_tree() const { | 50 FrameTree* frame_tree() const { |
54 return frame_tree_; | 51 return frame_tree_; |
55 } | 52 } |
56 | 53 |
57 Navigator* navigator() { | 54 Navigator* navigator() { |
58 return navigator_.get(); | 55 return navigator_.get(); |
59 } | 56 } |
60 | 57 |
61 RenderFrameHostManager* render_manager() { | 58 RenderFrameHostManager* render_manager() { |
62 return &render_manager_; | 59 return &render_manager_; |
63 } | 60 } |
64 | 61 |
| 62 // This is the browser-wide unique ID for the FrameTreeNode. If you have a |
| 63 // renderer-specific frame ID, you can look up the corresponding FrameTreeNode |
| 64 // ID using RenderViewHostImpl::GetFrameTreeNodeID(frame_id). |
65 int64 frame_tree_node_id() const { | 65 int64 frame_tree_node_id() const { |
66 return frame_tree_node_id_; | 66 return frame_tree_node_id_; |
67 } | 67 } |
68 | 68 |
69 // DO NOT USE. Only used by FrameTree until we replace renderer-specific | |
70 // frame IDs with RenderFrameHost routing IDs. | |
71 void set_frame_id(int64 frame_id) { | |
72 DCHECK_EQ(frame_id_, kInvalidFrameId); | |
73 frame_id_ = frame_id; | |
74 } | |
75 int64 frame_id() const { | |
76 return frame_id_; | |
77 } | |
78 | |
79 const std::string& frame_name() const { | 69 const std::string& frame_name() const { |
80 return frame_name_; | 70 return frame_name_; |
81 } | 71 } |
82 | 72 |
83 size_t child_count() const { | 73 size_t child_count() const { |
84 return children_.size(); | 74 return children_.size(); |
85 } | 75 } |
86 | 76 |
87 FrameTreeNode* child_at(size_t index) const { | 77 FrameTreeNode* child_at(size_t index) const { |
88 return children_[index]; | 78 return children_[index]; |
(...skipping 17 matching lines...) Expand all Loading... |
106 | 96 |
107 // The FrameTree that owns us. | 97 // The FrameTree that owns us. |
108 FrameTree* frame_tree_; // not owned. | 98 FrameTree* frame_tree_; // not owned. |
109 | 99 |
110 // The Navigator object responsible for managing navigations at this node | 100 // The Navigator object responsible for managing navigations at this node |
111 // of the frame tree. | 101 // of the frame tree. |
112 scoped_refptr<Navigator> navigator_; | 102 scoped_refptr<Navigator> navigator_; |
113 | 103 |
114 // Manages creation and swapping of RenderFrameHosts for this frame. This | 104 // Manages creation and swapping of RenderFrameHosts for this frame. This |
115 // must be declared before |children_| so that it gets deleted after them. | 105 // must be declared before |children_| so that it gets deleted after them. |
116 // That's currently necessary so that RenderFrameHostImpl's destructor can | 106 // That's currently necessary so that RenderFrameHostImpl's destructor can |
117 // call GetProcess. | 107 // call GetProcess. |
118 RenderFrameHostManager render_manager_; | 108 RenderFrameHostManager render_manager_; |
119 | 109 |
120 // A browser-global identifier for the frame in the page, which stays stable | 110 // A browser-global identifier for the frame in the page, which stays stable |
121 // even if the frame does a cross-process navigation. | 111 // even if the frame does a cross-process navigation. |
122 const int64 frame_tree_node_id_; | 112 const int64 frame_tree_node_id_; |
123 | 113 |
124 // The renderer-specific identifier for the frame in the page. | |
125 // TODO(creis): Remove this in favor of the RenderFrameHost's routing ID once | |
126 // we create FrameTreeNodes for all frames (even without a flag), since this | |
127 // value can change after cross-process navigations. | |
128 int64 frame_id_; | |
129 | |
130 // The assigned name of the frame. This name can be empty, unlike the unique | 114 // The assigned name of the frame. This name can be empty, unlike the unique |
131 // name generated internally in the DOM tree. | 115 // name generated internally in the DOM tree. |
132 std::string frame_name_; | 116 std::string frame_name_; |
133 | 117 |
134 // The immediate children of this specific frame. | 118 // The immediate children of this specific frame. |
135 ScopedVector<FrameTreeNode> children_; | 119 ScopedVector<FrameTreeNode> children_; |
136 | 120 |
137 // Track the current frame's last committed URL, so we can estimate the | 121 // Track the current frame's last committed URL, so we can estimate the |
138 // process impact of out-of-process iframes. | 122 // process impact of out-of-process iframes. |
139 // TODO(creis): Remove this when we can store subframe URLs in the | 123 // TODO(creis): Remove this when we can store subframe URLs in the |
140 // NavigationController. | 124 // NavigationController. |
141 GURL current_url_; | 125 GURL current_url_; |
142 | 126 |
143 DISALLOW_COPY_AND_ASSIGN(FrameTreeNode); | 127 DISALLOW_COPY_AND_ASSIGN(FrameTreeNode); |
144 }; | 128 }; |
145 | 129 |
146 } // namespace content | 130 } // namespace content |
147 | 131 |
148 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_H_ | 132 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_H_ |
OLD | NEW |