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_WEB_CONTENTS_FRAME_TREE_NODE_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_FRAME_TREE_NODE_H_ |
| 6 #define CONTENT_BROWSER_WEB_CONTENTS_FRAME_TREE_NODE_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_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/scoped_ptr.h" | |
| 11 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 12 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 13 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 14 | 15 |
| 15 namespace content { | 16 namespace content { |
| 16 | 17 |
| 18 class RenderFrameHostImpl; | |
| 19 | |
| 17 // Any page that contains iframes has a tree structure of the frames in the | 20 // Any page that contains iframes has a tree structure of the frames in the |
| 18 // renderer process. We are mirroring this tree in the browser process. This | 21 // renderer process. We are mirroring this tree in the browser process. This |
| 19 // class represents a node in this tree and is a wrapper for all objects that | 22 // class represents a node in this tree and is a wrapper for all objects that |
| 20 // are frame-specific (as opposed to page-specific). | 23 // are frame-specific (as opposed to page-specific). |
| 21 class CONTENT_EXPORT FrameTreeNode { | 24 class CONTENT_EXPORT FrameTreeNode { |
| 22 public: | 25 public: |
| 23 FrameTreeNode(int64 frame_id, const std::string& name); | 26 static const int64 kInvalidFrameId = -1; |
| 27 | |
| 28 FrameTreeNode(int64 frame_id, const std::string& name, | |
| 29 scoped_ptr<RenderFrameHostImpl> render_frame_host); | |
| 24 ~FrameTreeNode(); | 30 ~FrameTreeNode(); |
| 25 | 31 |
| 26 // This method takes ownership of the child pointer. | 32 void AddChild(scoped_ptr<FrameTreeNode> child); |
| 27 void AddChild(FrameTreeNode* child); | |
| 28 void RemoveChild(int64 child_id); | 33 void RemoveChild(int64 child_id); |
| 29 | 34 |
| 35 scoped_ptr<RenderFrameHostImpl> ResetRenderFrameHost( | |
|
Charlie Reis
2013/09/11 22:25:04
Why Reset rather than Swap or Set?
awong
2013/09/21 01:19:56
Since it destroys the children, it's not just a se
| |
| 36 scoped_ptr<RenderFrameHostImpl> new_render_frame_host); | |
| 37 | |
| 38 void set_frame_id(int64 frame_id) { | |
| 39 DCHECK_EQ(frame_id_, kInvalidFrameId); | |
| 40 frame_id_ = frame_id; | |
| 41 } | |
| 42 | |
| 30 int64 frame_id() const { | 43 int64 frame_id() const { |
| 31 return frame_id_; | 44 return frame_id_; |
| 32 } | 45 } |
| 33 | 46 |
| 34 const std::string& frame_name() const { | 47 const std::string& frame_name() const { |
| 35 return frame_name_; | 48 return frame_name_; |
| 36 } | 49 } |
| 37 | 50 |
| 38 size_t child_count() const { | 51 size_t child_count() const { |
| 39 return children_.size(); | 52 return children_.size(); |
| 40 } | 53 } |
| 41 | 54 |
| 42 FrameTreeNode* child_at(size_t index) const { | 55 FrameTreeNode* child_at(size_t index) const { |
| 43 return children_[index]; | 56 return children_[index]; |
| 44 } | 57 } |
| 45 | 58 |
| 46 const GURL& current_url() const { | 59 const GURL& current_url() const { |
| 47 return current_url_; | 60 return current_url_; |
| 48 } | 61 } |
| 49 | 62 |
| 50 void set_current_url(const GURL& url) { | 63 void set_current_url(const GURL& url) { |
| 51 current_url_ = url; | 64 current_url_ = url; |
| 52 } | 65 } |
| 53 | 66 |
| 67 RenderFrameHostImpl* render_frame_host() const { | |
| 68 return render_frame_host_.get(); | |
| 69 } | |
| 70 | |
| 54 private: | 71 private: |
| 55 // The unique identifier for the frame in the page. | 72 // The unique identifier for the frame in the page. |
| 56 int64 frame_id_; | 73 int64 frame_id_; |
| 57 | 74 |
| 58 // The assigned name of the frame. This name can be empty, unlike the unique | 75 // The assigned name of the frame. This name can be empty, unlike the unique |
| 59 // name generated internally in the DOM tree. | 76 // name generated internally in the DOM tree. |
| 60 std::string frame_name_; | 77 std::string frame_name_; |
| 61 | 78 |
| 62 // The immediate children of this specific frame. | 79 // The immediate children of this specific frame. |
| 63 ScopedVector<FrameTreeNode> children_; | 80 ScopedVector<FrameTreeNode> children_; |
| 64 | 81 |
| 82 // The active RenderFrameHost for this frame. | |
| 83 // TODO(ajwong): Replace with RenderFrameHostManager. | |
| 84 scoped_ptr<RenderFrameHostImpl> render_frame_host_; | |
| 85 | |
| 65 // Track the current frame's last committed URL, so we can estimate the | 86 // Track the current frame's last committed URL, so we can estimate the |
| 66 // process impact of out-of-process iframes. | 87 // process impact of out-of-process iframes. |
| 67 // TODO(creis): Remove this when we can store subframe URLs in the | 88 // TODO(creis): Remove this when we can store subframe URLs in the |
| 68 // NavigationController. | 89 // NavigationController. |
| 69 GURL current_url_; | 90 GURL current_url_; |
| 70 | 91 |
| 71 DISALLOW_COPY_AND_ASSIGN(FrameTreeNode); | 92 DISALLOW_COPY_AND_ASSIGN(FrameTreeNode); |
| 72 }; | 93 }; |
| 73 | 94 |
| 74 } // namespace content | 95 } // namespace content |
| 75 | 96 |
| 76 #endif // CONTENT_BROWSER_WEB_CONTENTS_FRAME_TREE_NODE_H_ | 97 #endif // CONTENT_BROWSER_WEB_CONTENTS_FRAME_TREE_NODE_H_ |
| OLD | NEW |