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