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

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

Issue 217163007: Introduce RenderFrameProxyHost object and use it in RFHM. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a test for RFH lifetime during CancelPending. Created 6 years, 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_PROXY_HOST_H_
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_PROXY_HOST_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "content/browser/frame_host/render_frame_host_impl.h"
10 #include "content/browser/site_instance_impl.h"
11
12 class RenderProcessHost;
13 class RenderFrameHostImpl;
14 class RenderViewHostImpl;
15
16 namespace content {
17
18 // 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
20 // responsible for rendering and placeholder objects (i.e., RenderFrameProxies)
21 // for frames rendered by other processes.
22 //
23 // This class is the browser-side host object for the placeholder. Each node in
24 // the frame tree has a RenderFrameHost for the active SiteInstance and a set
25 // of RenderFrameProxyHost objects - one for all other SiteInstances with
26 // references to this frame. The proxies allow us to keep existing window
27 // references valid over cross-process navigations and route cross-site
28 // asynchronous JavaScript calls, such as postMessage.
29 //
30 // For now, RenderFrameProxyHost is created when a RenderFrameHost is swapped
31 // out and acts just as a wrapper. If a RenderFrameHost can be deleted, no
32 // proxy object is created. It is destroyed when the RenderFrameHost is swapped
33 // back in or is no longer referenced and is therefore deleted.
34 //
35 // Long term, RenderFrameProxyHost will be created whenever a cross-site
36 // navigation occurs and a reference to the frame navigating needs to be kept
37 // alive. A RenderFrameProxyHost and a RenderFrameHost for the same SiteInstance
38 // can exist at the same time, but only one will be "active" at a time.
39 // There are two cases where the two objects will coexist:
40 // * When navigating cross-process and there is already a RenderFrameProxyHost
41 // for the new SiteInstance. A pending RenderFrameHost is created, but it is
42 // not used until it commits. At that point, RenderFrameHostManager transitions
43 // the pending RenderFrameHost to the active one and deletes the proxy.
44 // * When navigating cross-process and the existing document has an unload
45 // event handler. When the new navigation commits, RenderFrameHostManager
46 // creates a RenderFrameProxyHost for the old SiteInstance and uses it going
47 // 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
49 // complete, the RenderFrameHost is deleted.
50 class RenderFrameProxyHost {
51 public:
52 RenderFrameProxyHost(
53 SiteInstanceImpl* site_instance,
Charlie Reis 2014/04/11 17:42:53 Why not grab this from |render_frame_host| in the
nasko 2014/04/11 18:11:21 Yeah, good idea. Tricky, but I think we are good.
54 scoped_ptr<RenderFrameHostImpl> render_frame_host);
55 ~RenderFrameProxyHost();
56
57 RenderProcessHost* GetProcess() {
58 return render_frame_host_->GetProcess();
59 }
60
61 SiteInstance* GetSiteInstance() {
62 return site_instance_.get();
63 }
64
65 // TODO(nasko): The following methods should be removed when swapping out
66 // of RenderFrameHosts is no longer used.
67 RenderFrameHostImpl* render_frame_host() {
68 return render_frame_host_.get();
69 }
70 RenderViewHostImpl* render_view_host() {
71 return render_frame_host_->render_view_host();
72 }
73 scoped_ptr<RenderFrameHostImpl> PassFrameHost() {
74 return render_frame_host_.Pass();
75 }
76
77 private:
78 scoped_refptr<SiteInstanceImpl> site_instance_;
79
80 // TODO(nasko): For now, hide the RenderFrameHost inside the proxy, but remove
81 // it once we have all the code support for proper proxy objects.
82 scoped_ptr<RenderFrameHostImpl> render_frame_host_;
83
84 DISALLOW_COPY_AND_ASSIGN(RenderFrameProxyHost);
85 };
86
87 } // namespace
88
89 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_FRAME_PROXY_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698