Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: content/browser/frame_host/render_frame_proxy_host.h

Issue 281663002: Create RenderFrameProxyHost at time of swap-out instead of commit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for review Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_PROXY_HOST_H_ 5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_PROXY_HOST_H_
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_PROXY_HOST_H_ 6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_PROXY_HOST_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "content/browser/frame_host/render_frame_host_impl.h" 9 #include "content/browser/frame_host/render_frame_host_impl.h"
10 #include "content/browser/site_instance_impl.h" 10 #include "content/browser/site_instance_impl.h"
11 #include "ipc/ipc_listener.h"
12 #include "ipc/ipc_sender.h"
11 13
14 class FrameTreeNode;
12 class RenderProcessHost; 15 class RenderProcessHost;
13 class RenderFrameHostImpl; 16 class RenderFrameHostImpl;
14 class RenderViewHostImpl; 17 class RenderViewHostImpl;
15 18
16 namespace content { 19 namespace content {
17 20
18 // When a page's frames are rendered by multiple processes, each renderer has a 21 // When a page's frames are rendered by multiple processes, each renderer has a
19 // full copy of the frame tree. It has full RenderFrames for the frames it is 22 // full copy of the frame tree. It has full RenderFrames for the frames it is
20 // responsible for rendering and placeholder objects (i.e., RenderFrameProxies) 23 // responsible for rendering and placeholder objects (i.e., RenderFrameProxies)
21 // for frames rendered by other processes. 24 // for frames rendered by other processes.
(...skipping 18 matching lines...) Expand all
40 // * When navigating cross-process and there is already a RenderFrameProxyHost 43 // * When navigating cross-process and there is already a RenderFrameProxyHost
41 // for the new SiteInstance. A pending RenderFrameHost is created, but it is 44 // for the new SiteInstance. A pending RenderFrameHost is created, but it is
42 // not used until it commits. At that point, RenderFrameHostManager transitions 45 // not used until it commits. At that point, RenderFrameHostManager transitions
43 // the pending RenderFrameHost to the active one and deletes the proxy. 46 // the pending RenderFrameHost to the active one and deletes the proxy.
44 // * When navigating cross-process and the existing document has an unload 47 // * When navigating cross-process and the existing document has an unload
45 // event handler. When the new navigation commits, RenderFrameHostManager 48 // event handler. When the new navigation commits, RenderFrameHostManager
46 // creates a RenderFrameProxyHost for the old SiteInstance and uses it going 49 // creates a RenderFrameProxyHost for the old SiteInstance and uses it going
47 // forward. It also instructs the RenderFrameHost to run the unload event 50 // forward. It also instructs the RenderFrameHost to run the unload event
48 // handler and is kept alive for the duration. Once the event handling is 51 // handler and is kept alive for the duration. Once the event handling is
49 // complete, the RenderFrameHost is deleted. 52 // complete, the RenderFrameHost is deleted.
50 class RenderFrameProxyHost { 53 class RenderFrameProxyHost
54 : public IPC::Listener,
55 public IPC::Sender {
51 public: 56 public:
52 explicit RenderFrameProxyHost( 57 RenderFrameProxyHost(SiteInstance* site_instance,
53 scoped_ptr<RenderFrameHostImpl> render_frame_host); 58 FrameTreeNode* frame_tree_node);
54 ~RenderFrameProxyHost(); 59 virtual ~RenderFrameProxyHost();
55 60
56 RenderProcessHost* GetProcess() { 61 RenderProcessHost* GetProcess() {
57 return render_frame_host_->GetProcess(); 62 return site_instance_->GetProcess();
63 }
64
65 int GetRoutingID() {
66 return routing_id_;
58 } 67 }
59 68
60 SiteInstance* GetSiteInstance() { 69 SiteInstance* GetSiteInstance() {
61 return site_instance_.get(); 70 return site_instance_.get();
62 } 71 }
63 72
73 // This method deletes the RenderFrameProxy object in the renderer process,
Charlie Reis 2014/05/15 00:32:50 nit: Remove comma
nasko 2014/05/15 18:47:13 Done.
74 // which corresponds to this RenderFrameProxyHost. Must be called before
Charlie Reis 2014/05/15 00:32:50 I'm a bit concerned about missing cases where the
nasko 2014/05/15 18:47:13 In the case of a renderer process crashing, we del
75 // deleting the RenderFrameProxyHost if the renderer process exists and is
76 // responsive.
77 void DeleteRendererProxy();
Charlie Reis 2014/05/15 00:32:50 nit: DeleteRenderFrameProxy()
nasko 2014/05/15 18:47:13 Done.
78
64 // TODO(nasko): The following methods should be removed when swapping out 79 // TODO(nasko): The following methods should be removed when swapping out
65 // of RenderFrameHosts is no longer used. 80 // of RenderFrameHosts is no longer used.
66 RenderFrameHostImpl* render_frame_host() { 81 RenderFrameHostImpl* render_frame_host() {
67 return render_frame_host_.get(); 82 return render_frame_host_.get();
68 } 83 }
69 RenderViewHostImpl* render_view_host() { 84 RenderViewHostImpl* render_view_host() {
Charlie Reis 2014/05/15 00:32:50 This isn't a one liner anymore, so it should be in
nasko 2014/05/15 18:47:13 This is no longer needed.
70 return render_frame_host_->render_view_host(); 85 if (render_frame_host_.get())
86 return render_frame_host_->render_view_host();
87 return NULL;
71 } 88 }
72 scoped_ptr<RenderFrameHostImpl> PassFrameHost() { 89 void TakeFrameHostOwnership(
90 scoped_ptr<RenderFrameHostImpl> render_frame_host) {
91 render_frame_host_ = render_frame_host.Pass();
92 }
93 scoped_ptr<RenderFrameHostImpl> PassFrameHostOwnership() {
Charlie Reis 2014/05/15 00:32:50 nit: Move implementation to .cc file.
nasko 2014/05/15 18:47:13 Done.
94 DeleteRendererProxy();
73 return render_frame_host_.Pass(); 95 return render_frame_host_.Pass();
74 } 96 }
75 97
98 // IPC::Sender
99 virtual bool Send(IPC::Message* msg) OVERRIDE;
100
76 private: 101 private:
102 // IPC::Listener
103 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
104
105 // This RenderFrameProxyHost's routing id.
106 int routing_id_;
107
108 // The SiteInstance this proxy is associated with.
77 scoped_refptr<SiteInstance> site_instance_; 109 scoped_refptr<SiteInstance> site_instance_;
78 110
111 // The node in the frame tree where this proxy is located.
112 FrameTreeNode* frame_tree_node_;
113
79 // TODO(nasko): For now, hide the RenderFrameHost inside the proxy, but remove 114 // TODO(nasko): For now, hide the RenderFrameHost inside the proxy, but remove
80 // it once we have all the code support for proper proxy objects. 115 // it once we have all the code support for proper proxy objects.
81 scoped_ptr<RenderFrameHostImpl> render_frame_host_; 116 scoped_ptr<RenderFrameHostImpl> render_frame_host_;
82 117
83 DISALLOW_COPY_AND_ASSIGN(RenderFrameProxyHost); 118 DISALLOW_COPY_AND_ASSIGN(RenderFrameProxyHost);
84 }; 119 };
85 120
86 } // namespace 121 } // namespace
87 122
88 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_PROXY_HOST_H_ 123 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_PROXY_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698