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_RENDER_FRAME_HOST_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "content/public/browser/render_frame_host.h" | 11 #include "content/public/browser/render_frame_host.h" |
12 | 12 |
13 class GURL; | 13 class GURL; |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 class FrameTree; | 17 class FrameTree; |
| 18 class FrameTreeNode; |
18 class RenderProcessHost; | 19 class RenderProcessHost; |
19 class RenderViewHostImpl; | 20 class RenderViewHostImpl; |
20 | 21 |
21 class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost { | 22 class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost { |
22 public: | 23 public: |
23 static RenderFrameHostImpl* FromID(int process_id, int routing_id); | 24 static RenderFrameHostImpl* FromID(int process_id, int routing_id); |
24 | 25 |
25 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost | 26 // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost |
26 // should be the abstraction needed here, but we need RenderViewHost to pass | 27 // should be the abstraction needed here, but we need RenderViewHost to pass |
27 // into WebContentsObserver::FrameDetached for now. | 28 // into WebContentsObserver::FrameDetached for now. |
28 RenderFrameHostImpl(RenderViewHostImpl* render_view_host, | 29 RenderFrameHostImpl(RenderViewHostImpl* render_view_host, |
29 FrameTree* frame_tree, | 30 FrameTree* frame_tree, |
| 31 FrameTreeNode* frame_tree_node, |
30 int routing_id, | 32 int routing_id, |
31 bool is_swapped_out); | 33 bool is_swapped_out); |
32 virtual ~RenderFrameHostImpl(); | 34 virtual ~RenderFrameHostImpl(); |
33 | 35 |
34 // IPC::Sender | 36 // IPC::Sender |
35 virtual bool Send(IPC::Message* msg) OVERRIDE; | 37 virtual bool Send(IPC::Message* msg) OVERRIDE; |
36 | 38 |
37 // IPC::Listener | 39 // IPC::Listener |
38 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; | 40 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
39 | 41 |
40 void Init(); | 42 void Init(); |
41 RenderProcessHost* GetProcess() const; | 43 RenderProcessHost* GetProcess() const; |
42 int routing_id() const { return routing_id_; } | 44 int routing_id() const { return routing_id_; } |
43 void OnCreateChildFrame(int new_frame_routing_id, | 45 void OnCreateChildFrame(int new_frame_routing_id, |
44 int64 parent_frame_id, | 46 int64 parent_frame_id, |
45 int64 frame_id, | 47 int64 frame_id, |
46 const std::string& frame_name); | 48 const std::string& frame_name); |
47 | 49 |
48 RenderViewHostImpl* render_view_host() { | 50 RenderViewHostImpl* render_view_host() { |
49 return render_view_host_; | 51 return render_view_host_; |
50 } | 52 } |
51 | 53 |
| 54 // TODO(creis): Think about where this API belongs. |
| 55 bool is_main_frame() const; |
| 56 |
| 57 // Hack to get this subframe to swap out, without yet moving over all the |
| 58 // state and machinery from RenderViewHost. |
| 59 void SwapOut(); |
| 60 void OnSwappedOut(bool timed_out); |
| 61 bool is_swapped_out() { return is_swapped_out_; } |
| 62 void set_swapped_out(bool is_swapped_out) { |
| 63 is_swapped_out_ = is_swapped_out; |
| 64 } |
| 65 |
52 private: | 66 private: |
53 // IPC Message handlers. | 67 // IPC Message handlers. |
54 void OnDetach(int64 parent_frame_id, int64 frame_id); | 68 void OnDetach(int64 parent_frame_id, int64 frame_id); |
55 void OnDidStartProvisionalLoadForFrame(int64 frame_id, | 69 void OnDidStartProvisionalLoadForFrame(int64 frame_id, |
56 int64 parent_frame_id, | 70 int64 parent_frame_id, |
57 bool main_frame, | 71 bool main_frame, |
58 const GURL& url); | 72 const GURL& url); |
| 73 void OnSwapOutACK(); |
59 | 74 |
60 bool is_swapped_out() { return is_swapped_out_; } | 75 // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via the |
61 | 76 // refcount on FrameTree. This allows each RenderFrameHostManager to just |
62 // TODO(nasko): This should be removed and replaced by RenderProcessHost. | 77 // care about RenderFrameHosts, while ensuring we have a RenderViewHost for |
63 RenderViewHostImpl* render_view_host_; // Not owned. | 78 // each RenderFrameHost. |
| 79 // TODO(creis): RenderViewHost will eventually go away and be replaced with |
| 80 // some form of page context. |
| 81 RenderViewHostImpl* render_view_host_; |
64 | 82 |
65 // Reference to the whole frame tree that this RenderFrameHost belongs too. | 83 // Reference to the whole frame tree that this RenderFrameHost belongs too. |
66 // Allows this RenderFrameHost to add and remove nodes in response to | 84 // Allows this RenderFrameHost to add and remove nodes in response to |
67 // messages from the renderer requesting DOM manipulation. | 85 // messages from the renderer requesting DOM manipulation. |
68 FrameTree* frame_tree_; | 86 FrameTree* frame_tree_; |
| 87 FrameTreeNode* frame_tree_node_; |
69 int routing_id_; | 88 int routing_id_; |
70 bool is_swapped_out_; | 89 bool is_swapped_out_; |
71 | 90 |
72 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); | 91 DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); |
73 }; | 92 }; |
74 | 93 |
75 } // namespace content | 94 } // namespace content |
76 | 95 |
77 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ | 96 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
OLD | NEW |