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

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

Issue 117693002: Make RenderFrameHostManager swap RenderFrameHosts, not RenderViewHosts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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_frame_host_impl.h" 14 #include "content/browser/frame_host/render_frame_host_impl.h"
15 #include "content/browser/frame_host/render_frame_host_manager.h" 15 #include "content/browser/frame_host/render_frame_host_manager.h"
16 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
17 #include "url/gurl.h" 17 #include "url/gurl.h"
18 18
19 namespace content { 19 namespace content {
20 20
21 class FrameTree;
21 class Navigator; 22 class Navigator;
22 class RenderFrameHostImpl; 23 class RenderFrameHostImpl;
23 24
24 // 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
25 // 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
26 // 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
27 // are frame-specific (as opposed to page-specific). 28 // are frame-specific (as opposed to page-specific).
28 class CONTENT_EXPORT FrameTreeNode { 29 class CONTENT_EXPORT FrameTreeNode {
29 public: 30 public:
30 static const int64 kInvalidFrameId; 31 static const int64 kInvalidFrameId;
31 32
32 FrameTreeNode(Navigator* navigator, 33 FrameTreeNode(FrameTree* frame_tree,
34 Navigator* navigator,
33 RenderFrameHostDelegate* render_frame_delegate, 35 RenderFrameHostDelegate* render_frame_delegate,
34 RenderViewHostDelegate* render_view_delegate, 36 RenderViewHostDelegate* render_view_delegate,
35 RenderWidgetHostDelegate* render_widget_delegate, 37 RenderWidgetHostDelegate* render_widget_delegate,
36 RenderFrameHostManager::Delegate* manager_delegate, 38 RenderFrameHostManager::Delegate* manager_delegate,
37 int64 frame_id, 39 int64 frame_id,
38 const std::string& name); 40 const std::string& name);
39 41
40 ~FrameTreeNode(); 42 ~FrameTreeNode();
41 43
42 void AddChild(scoped_ptr<FrameTreeNode> child); 44 bool IsMainFrame() const;
45
46 void AddChild(scoped_ptr<FrameTreeNode> child, int frame_routing_id);
43 void RemoveChild(FrameTreeNode* child); 47 void RemoveChild(FrameTreeNode* child);
44 48
45 // TODO(nasko): This method should be removed once RenderFrameHosts are 49 // Clears process specific-state after a main frame process swap.
46 // created by RenderFrameHostManager. 50 // TODO(creis): Look into how we can remove the need for this method.
47 void set_render_frame_host( 51 void ResetForMainFrameSwap();
48 RenderFrameHostImpl* render_frame_host, 52
49 bool owns_render_frame_host) { 53 FrameTree* frame_tree() const {
50 render_frame_host_ = render_frame_host; 54 return frame_tree_;
51 owns_render_frame_host_ = owns_render_frame_host;
52 } 55 }
53 56
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
64 Navigator* navigator() { 57 Navigator* navigator() {
65 return navigator_.get(); 58 return navigator_.get();
66 } 59 }
67 60
68 RenderFrameHostManager* render_manager() { 61 RenderFrameHostManager* render_manager() {
69 return &render_manager_; 62 return &render_manager_;
70 } 63 }
71 64
72 int64 frame_tree_node_id() const { 65 int64 frame_tree_node_id() const {
73 return frame_tree_node_id_; 66 return frame_tree_node_id_;
(...skipping 22 matching lines...) Expand all
96 } 89 }
97 90
98 const GURL& current_url() const { 91 const GURL& current_url() const {
99 return current_url_; 92 return current_url_;
100 } 93 }
101 94
102 void set_current_url(const GURL& url) { 95 void set_current_url(const GURL& url) {
103 current_url_ = url; 96 current_url_ = url;
104 } 97 }
105 98
106 RenderFrameHostImpl* render_frame_host() const { 99 RenderFrameHostImpl* current_frame_host() const {
107 return render_frame_host_; 100 return render_manager_.current_frame_host();
108 } 101 }
109 102
110 private: 103 private:
111 // The next available browser-global FrameTreeNode ID. 104 // The next available browser-global FrameTreeNode ID.
112 static int64 next_frame_tree_node_id_; 105 static int64 next_frame_tree_node_id_;
113 106
107 // The FrameTree that owns us.
108 FrameTree* frame_tree_; // not owned.
109
114 // The Navigator object responsible for managing navigations at this node 110 // The Navigator object responsible for managing navigations at this node
115 // of the frame tree. 111 // of the frame tree.
116 scoped_refptr<Navigator> navigator_; 112 scoped_refptr<Navigator> navigator_;
117 113
118 // Manages creation and swapping of RenderViewHosts for this frame. This must 114 // Manages creation and swapping of RenderFrameHosts for this frame. This
119 // be declared before |children_| so that it gets deleted after them. That's 115 // must be declared before |children_| so that it gets deleted after them.
120 // currently necessary so that RenderFrameHostImpl's destructor can call 116 // That's currently necessary so that RenderFrameHostImpl's destructor can
121 // GetProcess. 117 // call GetProcess.
122 // TODO(creis): This will eliminate the need for |render_frame_host_| below.
123 RenderFrameHostManager render_manager_; 118 RenderFrameHostManager render_manager_;
124 119
125 // A browser-global identifier for the frame in the page, which stays stable 120 // A browser-global identifier for the frame in the page, which stays stable
126 // even if the frame does a cross-process navigation. 121 // even if the frame does a cross-process navigation.
127 const int64 frame_tree_node_id_; 122 const int64 frame_tree_node_id_;
128 123
129 // The renderer-specific identifier for the frame in the page. 124 // The renderer-specific identifier for the frame in the page.
130 // TODO(creis): Remove this in favor of the RenderFrameHost's routing ID once 125 // 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 126 // we create FrameTreeNodes for all frames (even without a flag), since this
132 // value can change after cross-process navigations. 127 // value can change after cross-process navigations.
133 int64 frame_id_; 128 int64 frame_id_;
134 129
135 // The assigned name of the frame. This name can be empty, unlike the unique 130 // The assigned name of the frame. This name can be empty, unlike the unique
136 // name generated internally in the DOM tree. 131 // name generated internally in the DOM tree.
137 std::string frame_name_; 132 std::string frame_name_;
138 133
139 // The immediate children of this specific frame. 134 // The immediate children of this specific frame.
140 ScopedVector<FrameTreeNode> children_; 135 ScopedVector<FrameTreeNode> children_;
141 136
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 137 // Track the current frame's last committed URL, so we can estimate the
159 // process impact of out-of-process iframes. 138 // process impact of out-of-process iframes.
160 // TODO(creis): Remove this when we can store subframe URLs in the 139 // TODO(creis): Remove this when we can store subframe URLs in the
161 // NavigationController. 140 // NavigationController.
162 GURL current_url_; 141 GURL current_url_;
163 142
164 DISALLOW_COPY_AND_ASSIGN(FrameTreeNode); 143 DISALLOW_COPY_AND_ASSIGN(FrameTreeNode);
165 }; 144 };
166 145
167 } // namespace content 146 } // namespace content
168 147
169 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_H_ 148 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698