Chromium Code Reviews| 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 13 matching lines...) Expand all Loading... | |
| 24 class NavigationRequest; | 24 class NavigationRequest; |
| 25 class Navigator; | 25 class Navigator; |
| 26 class RenderFrameHostImpl; | 26 class RenderFrameHostImpl; |
| 27 | 27 |
| 28 // When a page contains iframes, its renderer process maintains a tree structure | 28 // When a page contains iframes, its renderer process maintains a tree structure |
| 29 // of those frames. We are mirroring this tree in the browser process. This | 29 // of those frames. We are mirroring this tree in the browser process. This |
| 30 // class represents a node in this tree and is a wrapper for all objects that | 30 // class represents a node in this tree and is a wrapper for all objects that |
| 31 // are frame-specific (as opposed to page-specific). | 31 // are frame-specific (as opposed to page-specific). |
| 32 class CONTENT_EXPORT FrameTreeNode { | 32 class CONTENT_EXPORT FrameTreeNode { |
| 33 public: | 33 public: |
| 34 class Observer { | |
| 35 public: | |
| 36 // Invoked when a FrameTreeNode is being destroyed. | |
| 37 virtual void OnFrameTreeNodeDestroyed(FrameTreeNode* node) {} | |
| 38 | |
| 39 virtual ~Observer() {} | |
| 40 }; | |
| 41 | |
| 34 // Returns the FrameTreeNode with the given global |frame_tree_node_id|, | 42 // Returns the FrameTreeNode with the given global |frame_tree_node_id|, |
| 35 // regardless of which FrameTree it is in. | 43 // regardless of which FrameTree it is in. |
| 36 static FrameTreeNode* GloballyFindByID(int frame_tree_node_id); | 44 static FrameTreeNode* GloballyFindByID(int frame_tree_node_id); |
| 37 | 45 |
| 38 FrameTreeNode(FrameTree* frame_tree, | 46 FrameTreeNode(FrameTree* frame_tree, |
| 39 Navigator* navigator, | 47 Navigator* navigator, |
| 40 RenderFrameHostDelegate* render_frame_delegate, | 48 RenderFrameHostDelegate* render_frame_delegate, |
| 41 RenderViewHostDelegate* render_view_delegate, | 49 RenderViewHostDelegate* render_view_delegate, |
| 42 RenderWidgetHostDelegate* render_widget_delegate, | 50 RenderWidgetHostDelegate* render_widget_delegate, |
| 43 RenderFrameHostManager::Delegate* manager_delegate, | 51 RenderFrameHostManager::Delegate* manager_delegate, |
| 44 blink::WebTreeScopeType scope, | 52 blink::WebTreeScopeType scope, |
| 45 const std::string& name, | 53 const std::string& name, |
| 46 blink::WebSandboxFlags sandbox_flags); | 54 blink::WebSandboxFlags sandbox_flags); |
| 47 | 55 |
| 48 ~FrameTreeNode(); | 56 ~FrameTreeNode(); |
| 49 | 57 |
| 58 void AddObserver(Observer* observer); | |
| 59 void RemoveObserver(Observer* observer); | |
| 60 | |
| 50 bool IsMainFrame() const; | 61 bool IsMainFrame() const; |
| 51 | 62 |
| 52 void AddChild(scoped_ptr<FrameTreeNode> child, | 63 void AddChild(scoped_ptr<FrameTreeNode> child, |
| 53 int process_id, | 64 int process_id, |
| 54 int frame_routing_id); | 65 int frame_routing_id); |
| 55 void RemoveChild(FrameTreeNode* child); | 66 void RemoveChild(FrameTreeNode* child); |
| 56 | 67 |
| 57 // Clears process specific-state in this node to prepare for a new process. | 68 // Clears process specific-state in this node to prepare for a new process. |
| 58 void ResetForNewProcess(); | 69 void ResetForNewProcess(); |
| 59 | 70 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 76 const std::string& frame_name() const { | 87 const std::string& frame_name() const { |
| 77 return replication_state_.name; | 88 return replication_state_.name; |
| 78 } | 89 } |
| 79 | 90 |
| 80 size_t child_count() const { | 91 size_t child_count() const { |
| 81 return children_.size(); | 92 return children_.size(); |
| 82 } | 93 } |
| 83 | 94 |
| 84 FrameTreeNode* parent() const { return parent_; } | 95 FrameTreeNode* parent() const { return parent_; } |
| 85 | 96 |
| 97 FrameTreeNode* opener() const { return opener_; } | |
| 98 | |
| 99 void SetOpener(FrameTreeNode* opener); | |
|
Charlie Reis
2015/06/03 20:01:37
Worth mentioning a bit of what else this does.
alexmos
2015/06/05 22:34:31
Done.
| |
| 100 | |
| 86 FrameTreeNode* child_at(size_t index) const { | 101 FrameTreeNode* child_at(size_t index) const { |
| 87 return children_[index]; | 102 return children_[index]; |
| 88 } | 103 } |
| 89 | 104 |
| 90 const GURL& current_url() const { | 105 const GURL& current_url() const { |
| 91 return current_url_; | 106 return current_url_; |
| 92 } | 107 } |
| 93 | 108 |
| 94 void set_current_url(const GURL& url) { | 109 void set_current_url(const GURL& url) { |
| 95 current_url_ = url; | 110 current_url_ = url; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 | 180 |
| 166 // A RenderFrameHost in this node stopped loading. | 181 // A RenderFrameHost in this node stopped loading. |
| 167 void DidStopLoading(); | 182 void DidStopLoading(); |
| 168 | 183 |
| 169 // The load progress for a RenderFrameHost in this node was updated to | 184 // The load progress for a RenderFrameHost in this node was updated to |
| 170 // |load_progress|. This will notify the FrameTree which will in turn notify | 185 // |load_progress|. This will notify the FrameTree which will in turn notify |
| 171 // the WebContents. | 186 // the WebContents. |
| 172 void DidChangeLoadProgress(double load_progress); | 187 void DidChangeLoadProgress(double load_progress); |
| 173 | 188 |
| 174 private: | 189 private: |
| 190 class OpenerDestroyedObserver; | |
| 191 | |
| 175 void set_parent(FrameTreeNode* parent) { parent_ = parent; } | 192 void set_parent(FrameTreeNode* parent) { parent_ = parent; } |
| 176 | 193 |
| 177 // The next available browser-global FrameTreeNode ID. | 194 // The next available browser-global FrameTreeNode ID. |
| 178 static int next_frame_tree_node_id_; | 195 static int next_frame_tree_node_id_; |
| 179 | 196 |
| 180 // The FrameTree that owns us. | 197 // The FrameTree that owns us. |
| 181 FrameTree* frame_tree_; // not owned. | 198 FrameTree* frame_tree_; // not owned. |
| 182 | 199 |
| 183 // The Navigator object responsible for managing navigations at this node | 200 // The Navigator object responsible for managing navigations at this node |
| 184 // of the frame tree. | 201 // of the frame tree. |
| 185 scoped_refptr<Navigator> navigator_; | 202 scoped_refptr<Navigator> navigator_; |
| 186 | 203 |
| 187 // Manages creation and swapping of RenderFrameHosts for this frame. This | 204 // Manages creation and swapping of RenderFrameHosts for this frame. This |
| 188 // must be declared before |children_| so that it gets deleted after them. | 205 // must be declared before |children_| so that it gets deleted after them. |
| 189 // That's currently necessary so that RenderFrameHostImpl's destructor can | 206 // That's currently necessary so that RenderFrameHostImpl's destructor can |
| 190 // call GetProcess. | 207 // call GetProcess. |
| 191 RenderFrameHostManager render_manager_; | 208 RenderFrameHostManager render_manager_; |
| 192 | 209 |
| 193 // A browser-global identifier for the frame in the page, which stays stable | 210 // A browser-global identifier for the frame in the page, which stays stable |
| 194 // even if the frame does a cross-process navigation. | 211 // even if the frame does a cross-process navigation. |
| 195 const int frame_tree_node_id_; | 212 const int frame_tree_node_id_; |
| 196 | 213 |
| 197 // The parent node of this frame. NULL if this node is the root or if it has | 214 // The parent node of this frame. NULL if this node is the root or if it has |
| 198 // not yet been attached to the frame tree. | 215 // not yet been attached to the frame tree. |
| 199 FrameTreeNode* parent_; | 216 FrameTreeNode* parent_; |
| 200 | 217 |
| 218 // The frame that opened this frame, if any. Will be set to null if the | |
| 219 // opener is closed, or if the frame disowns its opener by setting its | |
|
Charlie Reis
2015/06/03 20:01:37
nit: this frame
alexmos
2015/06/05 22:34:31
Done.
| |
| 220 // window.opener to null. | |
| 221 FrameTreeNode* opener_; | |
| 222 | |
| 223 // An observer that clears this node's |opener_| if the opener is destroyed. | |
| 224 // This observer is added to the |opener_|'s observer list when the |opener_| | |
| 225 // is set to a non-null node, and it is removed from that list when |opener_| | |
| 226 // changes or when this node is destroyed. | |
|
Charlie Reis
2015/06/03 20:01:37
Should we also delete it from here if this node's
alexmos
2015/06/05 22:34:31
Do you mean delete opener_observer_ in SetOpener,
| |
| 227 scoped_ptr<OpenerDestroyedObserver> opener_observer_; | |
| 228 | |
| 201 // The immediate children of this specific frame. | 229 // The immediate children of this specific frame. |
| 202 ScopedVector<FrameTreeNode> children_; | 230 ScopedVector<FrameTreeNode> children_; |
| 203 | 231 |
| 204 // Track the current frame's last committed URL, so we can estimate the | 232 // Track the current frame's last committed URL, so we can estimate the |
| 205 // process impact of out-of-process iframes. | 233 // process impact of out-of-process iframes. |
| 206 // TODO(creis): Remove this when we can store subframe URLs in the | 234 // TODO(creis): Remove this when we can store subframe URLs in the |
| 207 // NavigationController. | 235 // NavigationController. |
| 208 GURL current_url_; | 236 GURL current_url_; |
| 209 | 237 |
| 210 // Track information that needs to be replicated to processes that have | 238 // Track information that needs to be replicated to processes that have |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 222 blink::WebSandboxFlags effective_sandbox_flags_; | 250 blink::WebSandboxFlags effective_sandbox_flags_; |
| 223 | 251 |
| 224 // Used to track this node's loading progress (from 0 to 1). | 252 // Used to track this node's loading progress (from 0 to 1). |
| 225 double loading_progress_; | 253 double loading_progress_; |
| 226 | 254 |
| 227 // PlzNavigate | 255 // PlzNavigate |
| 228 // Owns an ongoing NavigationRequest until it is ready to commit. It will then | 256 // Owns an ongoing NavigationRequest until it is ready to commit. It will then |
| 229 // be reset and a RenderFrameHost will be responsible for the navigation. | 257 // be reset and a RenderFrameHost will be responsible for the navigation. |
| 230 scoped_ptr<NavigationRequest> navigation_request_; | 258 scoped_ptr<NavigationRequest> navigation_request_; |
| 231 | 259 |
| 260 // List of objects observing this FrameTreeNode. | |
| 261 ObserverList<Observer> observers_; | |
| 262 | |
| 232 DISALLOW_COPY_AND_ASSIGN(FrameTreeNode); | 263 DISALLOW_COPY_AND_ASSIGN(FrameTreeNode); |
| 233 }; | 264 }; |
| 234 | 265 |
| 235 } // namespace content | 266 } // namespace content |
| 236 | 267 |
| 237 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_H_ | 268 #endif // CONTENT_BROWSER_FRAME_HOST_FRAME_TREE_NODE_H_ |
| OLD | NEW |