OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_H_ | |
6 #define CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/callback.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "content/browser/renderer_host/frame_tree_node.h" | |
13 #include "content/common/content_export.h" | |
14 | |
15 namespace content { | |
16 | |
17 class FrameTreeNode; | |
18 class RenderProcessHost; | |
19 | |
20 // Represents the frame tree for a page. Used to manage RenderFrameHost during | |
Charlie Reis
2013/09/11 22:25:04
FrameTree doesn't manage RFHs; FrameTreeNode does.
awong
2013/09/21 01:19:56
Done.
| |
21 // navigation. Eventually each node in this class will optionally contain a | |
Charlie Reis
2013/09/11 22:25:04
This seems hard to understand unless you know our
awong
2013/09/21 01:19:56
Moved to TODO
| |
22 // NavigationController. The main frame node is guaranteed to have a | |
Charlie Reis
2013/09/11 22:25:04
frame node -> FrameTreeNode (here and below)
(Too
awong
2013/09/21 01:19:56
Yep...rewrote the comment.
| |
23 // NavigationController. Because of this, the main frame node cannot change | |
24 // during navigation. Instead, we reset its children and navigation related | |
25 // state variables. | |
26 class CONTENT_EXPORT FrameTree { | |
27 public: | |
28 explicit FrameTree(); | |
nasko
2013/09/11 22:26:24
Isn't explicit needed only for one argument constr
awong
2013/09/21 01:19:56
Done.
| |
29 ~FrameTree(); | |
30 | |
31 // Indiates the that RenderFrameHost for the main frame needs to be changed. | |
nasko
2013/09/11 22:26:24
nit: Indicates
awong
2013/09/21 01:19:56
Done.
| |
32 // This effectively resets the frame tree but retains the root node so that | |
33 // navigation state may be kept on it between process swaps. | |
34 scoped_ptr<RenderFrameHostImpl> SwapMainFrame( | |
Charlie Reis
2013/09/11 22:25:04
I'm not sure I understand why this is an operation
awong
2013/09/21 01:19:56
I think the name didn't match the semantics. Also
| |
35 scoped_ptr<RenderFrameHostImpl> render_frame_host); | |
36 | |
37 // Returns the FrameTreeNode with the given |frame_id|. | |
38 FrameTreeNode* FindByID(int64 frame_id); | |
39 | |
40 // Executes |on_node| on each node in the frame tree. If |on_node| returns | |
41 // false, terminates the loop without continuing. | |
42 void ForEach(const base::Callback<bool(FrameTreeNode*)>& on_node) const; | |
43 | |
44 // After the FrameTree is created, or after SwapMainFrame() has been called, | |
45 // the root node does not yet have a frame id. This is allocated by the | |
46 // renderer and is published to the browser process on the first navigation. | |
47 // These two functions are used to set the root node's frame id. | |
48 // | |
49 // TODO(ajwong): Remove these once RenderFrameHost's routing id replaces | |
50 // frame_id. | |
51 bool IsFirstNavigation() const; | |
52 void OnFirstNavigation(int main_frame_id); | |
Charlie Reis
2013/09/11 22:25:04
Which kind of frame ID are we talking about here,
awong
2013/09/21 01:19:56
It's the render-allocated frame_id. It's only rele
| |
53 | |
54 // Frame tree manipulation routines. | |
55 void AddFrame(int render_frame_host_id, int64 parent_frame_id, | |
56 int64 frame_id, const std::string& frame_name); | |
57 void RemoveFrame(int64 parent_frame_id, int64 frame_id); | |
58 void SetFrameUrl(int64 frame_id, const GURL& url); | |
59 | |
60 // Convenience accessor for the main frame's RenderFrameHostImpl. | |
61 RenderFrameHostImpl* GetMainFrame() const; | |
62 | |
63 // Allows a client to listen for frame removal. | |
64 void SetFrameRemoveListener( | |
65 const base::Callback<void(int64)>& on_frame_removed); | |
66 | |
67 FrameTreeNode* GetRootForTesting() { return root_.get(); } | |
68 | |
69 private: | |
70 scoped_ptr<FrameTreeNode> CreateNode(int64 frame_id, | |
71 const std::string& frame_name, | |
72 int render_frame_host_id, | |
73 RenderProcessHost* render_process_host); | |
74 | |
75 scoped_ptr<FrameTreeNode> root_; | |
76 | |
77 base::Callback<void(int64)> on_frame_removed_; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(FrameTree); | |
80 }; | |
81 | |
82 } // namespace content | |
83 | |
84 #endif // CONTENT_BROWSER_RENDERER_HOST_FRAME_TREE_H_ | |
OLD | NEW |