| // Copyright 2013 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
| #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |
| |
| #include <string> |
| |
| #include "base/compiler_specific.h" |
| #include "content/common/content_export.h" |
| #include "content/public/browser/render_frame_host.h" |
| |
| class GURL; |
| struct FrameHostMsg_DidFailProvisionalLoadWithError_Params; |
| |
| namespace base { |
| class FilePath; |
| } |
| |
| namespace content { |
| |
| class CrossProcessFrameConnector; |
| class FrameTree; |
| class FrameTreeNode; |
| class RenderFrameHostDelegate; |
| class RenderProcessHost; |
| class RenderViewHostImpl; |
| |
| class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost { |
| public: |
| static RenderFrameHostImpl* FromID(int process_id, int routing_id); |
| |
| virtual ~RenderFrameHostImpl(); |
| |
| // RenderFrameHost |
| virtual SiteInstance* GetSiteInstance() OVERRIDE; |
| virtual RenderProcessHost* GetProcess() OVERRIDE; |
| virtual int GetRoutingID() OVERRIDE; |
| virtual gfx::NativeView GetNativeView() OVERRIDE; |
| virtual RenderViewHost* GetRenderViewHost() OVERRIDE; |
| |
| // IPC::Sender |
| virtual bool Send(IPC::Message* msg) OVERRIDE; |
| |
| // IPC::Listener |
| virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| |
| void Init(); |
| int routing_id() const { return routing_id_; } |
| void OnCreateChildFrame(int new_frame_routing_id, |
| int64 parent_frame_id, |
| int64 frame_id, |
| const std::string& frame_name); |
| |
| RenderViewHostImpl* render_view_host() { return render_view_host_; } |
| RenderFrameHostDelegate* delegate() { return delegate_; } |
| FrameTreeNode* frame_tree_node() { return frame_tree_node_; } |
| |
| // This function is called when this is a swapped out RenderFrameHost that |
| // lives in the same process as the parent frame. The |
| // |cross_process_frame_connector| allows the non-swapped-out |
| // RenderFrameHost for a frame to communicate with the parent process |
| // so that it may composite drawing data. |
| // |
| // Ownership is not transfered. |
| void set_cross_process_frame_connector( |
| CrossProcessFrameConnector* cross_process_frame_connector) { |
| cross_process_frame_connector_ = cross_process_frame_connector; |
| } |
| |
| // Hack to get this subframe to swap out, without yet moving over all the |
| // SwapOut state and machinery from RenderViewHost. |
| void SwapOut(); |
| void OnSwappedOut(bool timed_out); |
| bool is_swapped_out() { return is_swapped_out_; } |
| void set_swapped_out(bool is_swapped_out) { |
| is_swapped_out_ = is_swapped_out; |
| } |
| |
| protected: |
| friend class RenderFrameHostFactory; |
| |
| // TODO(nasko): Remove dependency on RenderViewHost here. RenderProcessHost |
| // should be the abstraction needed here, but we need RenderViewHost to pass |
| // into WebContentsObserver::FrameDetached for now. |
| RenderFrameHostImpl(RenderViewHostImpl* render_view_host, |
| RenderFrameHostDelegate* delegate, |
| FrameTree* frame_tree, |
| FrameTreeNode* frame_tree_node, |
| int routing_id, |
| bool is_swapped_out); |
| |
| private: |
| friend class TestRenderViewHost; |
| |
| // IPC Message handlers. |
| void OnDetach(int64 parent_frame_id, int64 frame_id); |
| void OnDidStartProvisionalLoadForFrame(int64 frame_id, |
| int64 parent_frame_id, |
| bool main_frame, |
| const GURL& url); |
| void OnDidFailProvisionalLoadWithError( |
| const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params); |
| void OnDidRedirectProvisionalLoad(int32 page_id, |
| const GURL& source_url, |
| const GURL& target_url); |
| void OnSwapOutACK(); |
| |
| // For now, RenderFrameHosts indirectly keep RenderViewHosts alive via a |
| // refcount that calls Shutdown when it reaches zero. This allows each |
| // RenderFrameHostManager to just care about RenderFrameHosts, while ensuring |
| // we have a RenderViewHost for each RenderFrameHost. |
| // TODO(creis): RenderViewHost will eventually go away and be replaced with |
| // some form of page context. |
| RenderViewHostImpl* render_view_host_; |
| |
| RenderFrameHostDelegate* delegate_; |
| |
| // |cross_process_frame_connector_| passes messages from an out-of-process |
| // child frame to the parent process for compositing. |
| // |
| // This is only non-NULL when this is the swapped out RenderFrameHost in |
| // the same site instance as this frame's parent. |
| // |
| // See the class comment above CrossProcessFrameConnector for more |
| // information. |
| // |
| // This will move to RenderFrameProxyHost when that class is created. |
| CrossProcessFrameConnector* cross_process_frame_connector_; |
| |
| // Reference to the whole frame tree that this RenderFrameHost belongs to. |
| // Allows this RenderFrameHost to add and remove nodes in response to |
| // messages from the renderer requesting DOM manipulation. |
| FrameTree* frame_tree_; |
| |
| // The FrameTreeNode which this RenderFrameHostImpl is hosted in. |
| FrameTreeNode* frame_tree_node_; |
| |
| int routing_id_; |
| bool is_swapped_out_; |
| |
| DISALLOW_COPY_AND_ASSIGN(RenderFrameHostImpl); |
| }; |
| |
| } // namespace content |
| |
| #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_HOST_IMPL_H_ |