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

Side by Side Diff: Source/web/WebRemoteFrameImpl.cpp

Issue 517043003: Move Frame to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase past r182224 conflict Created 6 years, 3 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
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 #include "config.h" 5 #include "config.h"
6 #include "web/WebRemoteFrameImpl.h" 6 #include "web/WebRemoteFrameImpl.h"
7 7
8 #include "core/frame/FrameOwner.h" 8 #include "core/frame/FrameOwner.h"
9 #include "core/frame/RemoteFrame.h" 9 #include "core/frame/RemoteFrame.h"
10 #include "core/frame/Settings.h" 10 #include "core/frame/Settings.h"
11 #include "core/page/Page.h" 11 #include "core/page/Page.h"
12 #include "platform/heap/Handle.h"
12 #include "public/platform/WebFloatRect.h" 13 #include "public/platform/WebFloatRect.h"
13 #include "public/platform/WebRect.h" 14 #include "public/platform/WebRect.h"
14 #include "public/web/WebDocument.h" 15 #include "public/web/WebDocument.h"
15 #include "public/web/WebPerformance.h" 16 #include "public/web/WebPerformance.h"
16 #include "public/web/WebRange.h" 17 #include "public/web/WebRange.h"
17 #include "web/WebLocalFrameImpl.h" 18 #include "web/WebLocalFrameImpl.h"
18 #include "web/WebViewImpl.h" 19 #include "web/WebViewImpl.h"
19 #include <v8/include/v8.h> 20 #include <v8/include/v8.h>
20 21
21 namespace blink { 22 namespace blink {
22 23
23 namespace { 24 namespace {
24 25
25 // Helper class to bridge communication for a local frame with a remote parent. 26 // Helper class to bridge communication for a local frame with a remote parent.
26 // Currently, it serves two purposes: 27 // Currently, it serves two purposes:
27 // 1. Allows the local frame's loader to retrieve sandbox flags associated with 28 // 1. Allows the local frame's loader to retrieve sandbox flags associated with
28 // its owner element in another process. 29 // its owner element in another process.
29 // 2. Trigger a load event on its owner element once it finishes a load. 30 // 2. Trigger a load event on its owner element once it finishes a load.
30 class RemoteBridgeFrameOwner : public FrameOwner { 31 class RemoteBridgeFrameOwner : public NoBaseWillBeGarbageCollectedFinalized<Remo teBridgeFrameOwner>, public FrameOwner {
32 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(RemoteBridgeFrameOwner);
31 public: 33 public:
32 explicit RemoteBridgeFrameOwner(PassRefPtr<WebLocalFrameImpl>); 34 static PassOwnPtrWillBeRawPtr<RemoteBridgeFrameOwner> create(PassRefPtrWillB eRawPtr<WebLocalFrameImpl> frame)
35 {
36 return adoptPtrWillBeNoop(new RemoteBridgeFrameOwner(frame));
37 }
33 38
34 virtual bool isLocal() const OVERRIDE; 39 virtual bool isLocal() const OVERRIDE;
35 virtual SandboxFlags sandboxFlags() const OVERRIDE; 40 virtual SandboxFlags sandboxFlags() const OVERRIDE;
36 virtual void dispatchLoad() OVERRIDE; 41 virtual void dispatchLoad() OVERRIDE;
37 42
43 virtual void trace(Visitor*);
44
38 private: 45 private:
39 RefPtr<WebLocalFrameImpl> m_frame; 46 explicit RemoteBridgeFrameOwner(PassRefPtrWillBeRawPtr<WebLocalFrameImpl>);
47
48 RefPtrWillBeMember<WebLocalFrameImpl> m_frame;
40 }; 49 };
41 50
42 RemoteBridgeFrameOwner::RemoteBridgeFrameOwner(PassRefPtr<WebLocalFrameImpl> fra me) 51 RemoteBridgeFrameOwner::RemoteBridgeFrameOwner(PassRefPtrWillBeRawPtr<WebLocalFr ameImpl> frame)
43 : m_frame(frame) 52 : m_frame(frame)
44 { 53 {
45 } 54 }
46 55
56 void RemoteBridgeFrameOwner::trace(Visitor* visitor)
57 {
58 visitor->trace(m_frame);
59 FrameOwner::trace(visitor);
60 }
61
47 bool RemoteBridgeFrameOwner::isLocal() const 62 bool RemoteBridgeFrameOwner::isLocal() const
48 { 63 {
49 return false; 64 return false;
50 } 65 }
51 66
52 SandboxFlags RemoteBridgeFrameOwner::sandboxFlags() const 67 SandboxFlags RemoteBridgeFrameOwner::sandboxFlags() const
53 { 68 {
54 // FIXME: Implement. Most likely grab it from m_frame. 69 // FIXME: Implement. Most likely grab it from m_frame.
55 return 0; 70 return 0;
56 } 71 }
57 72
58 void RemoteBridgeFrameOwner::dispatchLoad() 73 void RemoteBridgeFrameOwner::dispatchLoad()
59 { 74 {
60 // FIXME: Implement. Most likely goes through m_frame->client(). 75 // FIXME: Implement. Most likely goes through m_frame->client().
61 } 76 }
62 77
63 // FIXME: This is just a placeholder frame owner to supply to RemoteFrame when 78 // FIXME: This is just a placeholder frame owner to supply to RemoteFrame when
64 // the parent is also a remote frame. Strictly speaking, this shouldn't be 79 // the parent is also a remote frame. Strictly speaking, this shouldn't be
65 // necessary, since a remote frame shouldn't ever need to communicate with a 80 // necessary, since a remote frame shouldn't ever need to communicate with a
66 // remote parent (there are no sandbox flags to retrieve in this case, nor can 81 // remote parent (there are no sandbox flags to retrieve in this case, nor can
67 // the RemoteFrame itself load a document). In most circumstances, the check for 82 // the RemoteFrame itself load a document). In most circumstances, the check for
68 // frame->owner() can be replaced with a check for frame->tree().parent(). Once 83 // frame->owner() can be replaced with a check for frame->tree().parent(). Once
69 // that's done, this class can be removed. 84 // that's done, this class can be removed.
70 class PlaceholderFrameOwner : public FrameOwner { 85 class PlaceholderFrameOwner : public NoBaseWillBeGarbageCollectedFinalized<Place holderFrameOwner>, public FrameOwner {
86 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PlaceholderFrameOwner);
71 public: 87 public:
72 virtual bool isLocal() const OVERRIDE; 88 virtual bool isLocal() const OVERRIDE;
73 virtual SandboxFlags sandboxFlags() const OVERRIDE; 89 virtual SandboxFlags sandboxFlags() const OVERRIDE;
74 virtual void dispatchLoad() OVERRIDE; 90 virtual void dispatchLoad() OVERRIDE;
75 }; 91 };
76 92
77 bool PlaceholderFrameOwner::isLocal() const 93 bool PlaceholderFrameOwner::isLocal() const
78 { 94 {
79 return false; 95 return false;
80 } 96 }
81 97
82 SandboxFlags PlaceholderFrameOwner::sandboxFlags() const 98 SandboxFlags PlaceholderFrameOwner::sandboxFlags() const
83 { 99 {
84 ASSERT_NOT_REACHED(); 100 ASSERT_NOT_REACHED();
85 return 0; 101 return 0;
86 } 102 }
87 103
88 void PlaceholderFrameOwner::dispatchLoad() 104 void PlaceholderFrameOwner::dispatchLoad()
89 { 105 {
90 ASSERT_NOT_REACHED(); 106 ASSERT_NOT_REACHED();
91 } 107 }
92 108
93 } // namespace 109 } // namespace
94 110
95 WebRemoteFrame* WebRemoteFrame::create(WebRemoteFrameClient* client) 111 WebRemoteFrame* WebRemoteFrame::create(WebRemoteFrameClient* client)
96 { 112 {
97 return adoptRef(new WebRemoteFrameImpl(client)).leakRef(); 113 return WebRemoteFrameImpl::create(client);
114 }
115
116 WebRemoteFrame* WebRemoteFrameImpl::create(WebRemoteFrameClient* client)
117 {
118 WebRemoteFrameImpl* frame = new WebRemoteFrameImpl(client);
119 #if ENABLE(OILPAN)
120 frame->m_selfKeepAlive = frame;
Mads Ager (chromium) 2014/09/18 12:00:59 Maybe move to constructor? : m_selfKeepAlive(this
121 return frame;
122 #else
123 return adoptRef(frame).leakRef();
124 #endif
98 } 125 }
99 126
100 WebRemoteFrameImpl::WebRemoteFrameImpl(WebRemoteFrameClient* client) 127 WebRemoteFrameImpl::WebRemoteFrameImpl(WebRemoteFrameClient* client)
101 : m_frameClient(this) 128 : m_frameClient(this)
102 , m_client(client) 129 , m_client(client)
103 { 130 {
104 } 131 }
105 132
106 WebRemoteFrameImpl::~WebRemoteFrameImpl() 133 WebRemoteFrameImpl::~WebRemoteFrameImpl()
107 { 134 {
108 } 135 }
109 136
137 void WebRemoteFrameImpl::trace(Visitor* visitor)
138 {
139 #if ENABLE(OILPAN)
140 visitor->trace(m_frame);
141 visitor->trace(m_ownersForChildren);
142
143 WebFrame::traceChildren(visitor, this);
144 #endif
145 }
146
110 bool WebRemoteFrameImpl::isWebLocalFrame() const 147 bool WebRemoteFrameImpl::isWebLocalFrame() const
111 { 148 {
112 return false; 149 return false;
113 } 150 }
114 151
115 WebLocalFrame* WebRemoteFrameImpl::toWebLocalFrame() 152 WebLocalFrame* WebRemoteFrameImpl::toWebLocalFrame()
116 { 153 {
117 ASSERT_NOT_REACHED(); 154 ASSERT_NOT_REACHED();
118 return 0; 155 return 0;
119 } 156 }
120 157
121 bool WebRemoteFrameImpl::isWebRemoteFrame() const 158 bool WebRemoteFrameImpl::isWebRemoteFrame() const
122 { 159 {
123 return true; 160 return true;
124 } 161 }
125 162
126 WebRemoteFrame* WebRemoteFrameImpl::toWebRemoteFrame() 163 WebRemoteFrame* WebRemoteFrameImpl::toWebRemoteFrame()
127 { 164 {
128 return this; 165 return this;
129 } 166 }
130 167
131 void WebRemoteFrameImpl::close() 168 void WebRemoteFrameImpl::close()
132 { 169 {
170 #if ENABLE(OILPAN)
171 m_selfKeepAlive.clear();
172 #else
133 deref(); 173 deref();
174 #endif
134 } 175 }
135 176
136 WebString WebRemoteFrameImpl::uniqueName() const 177 WebString WebRemoteFrameImpl::uniqueName() const
137 { 178 {
138 ASSERT_NOT_REACHED(); 179 ASSERT_NOT_REACHED();
139 return WebString(); 180 return WebString();
140 } 181 }
141 182
142 WebString WebRemoteFrameImpl::assignedName() const 183 WebString WebRemoteFrameImpl::assignedName() const
143 { 184 {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 return false; 278 return false;
238 } 279 }
239 280
240 WebView* WebRemoteFrameImpl::view() const 281 WebView* WebRemoteFrameImpl::view() const
241 { 282 {
242 if (!frame()) 283 if (!frame())
243 return 0; 284 return 0;
244 return WebViewImpl::fromPage(frame()->page()); 285 return WebViewImpl::fromPage(frame()->page());
245 } 286 }
246 287
288 WebViewImpl* WebRemoteFrameImpl::viewImpl() const
289 {
290 if (!frame())
291 return 0;
292 return WebViewImpl::fromPage(frame()->page());
293 }
294
247 void WebRemoteFrameImpl::removeChild(WebFrame* frame) 295 void WebRemoteFrameImpl::removeChild(WebFrame* frame)
248 { 296 {
249 WebFrame::removeChild(frame); 297 WebFrame::removeChild(frame);
250 m_ownersForChildren.remove(frame); 298 m_ownersForChildren.remove(frame);
251 } 299 }
252 300
253 WebDocument WebRemoteFrameImpl::document() const 301 WebDocument WebRemoteFrameImpl::document() const
254 { 302 {
255 return WebDocument(); 303 return WebDocument();
256 } 304 }
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 833
786 WebString WebRemoteFrameImpl::layerTreeAsText(bool showDebugInfo) const 834 WebString WebRemoteFrameImpl::layerTreeAsText(bool showDebugInfo) const
787 { 835 {
788 ASSERT_NOT_REACHED(); 836 ASSERT_NOT_REACHED();
789 return WebString(); 837 return WebString();
790 } 838 }
791 839
792 WebLocalFrame* WebRemoteFrameImpl::createLocalChild(const WebString& name, WebFr ameClient* client) 840 WebLocalFrame* WebRemoteFrameImpl::createLocalChild(const WebString& name, WebFr ameClient* client)
793 { 841 {
794 WebLocalFrameImpl* child = toWebLocalFrameImpl(WebLocalFrame::create(client) ); 842 WebLocalFrameImpl* child = toWebLocalFrameImpl(WebLocalFrame::create(client) );
795 HashMap<WebFrame*, OwnPtr<FrameOwner> >::AddResult result = 843 WillBeHeapHashMap<WebFrame*, OwnPtrWillBeMember<FrameOwner> >::AddResult res ult =
796 m_ownersForChildren.add(child, adoptPtr(new RemoteBridgeFrameOwner(child ))); 844 m_ownersForChildren.add(child, RemoteBridgeFrameOwner::create(child));
797 appendChild(child); 845 appendChild(child);
798 // FIXME: currently this calls LocalFrame::init() on the created LocalFrame, which may 846 // FIXME: currently this calls LocalFrame::init() on the created LocalFrame, which may
799 // result in the browser observing two navigations to about:blank (one from the initial 847 // result in the browser observing two navigations to about:blank (one from the initial
800 // frame creation, and one from swapping it into the remote process). FrameL oader might 848 // frame creation, and one from swapping it into the remote process). FrameL oader might
801 // need a special initialization function for this case to avoid that duplic ate navigation. 849 // need a special initialization function for this case to avoid that duplic ate navigation.
802 child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name, nullAtom); 850 child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name, nullAtom);
803 // Partially related with the above FIXME--the init() call may trigger JS di spatch. However, 851 // Partially related with the above FIXME--the init() call may trigger JS di spatch. However,
804 // if the parent is remote, it should never be detached synchronously... 852 // if the parent is remote, it should never be detached synchronously...
805 ASSERT(child->frame()); 853 ASSERT(child->frame());
806 return child; 854 return child;
807 } 855 }
808 856
809 void WebRemoteFrameImpl::initializeCoreFrame(FrameHost* host, FrameOwner* owner, const AtomicString& name) 857 void WebRemoteFrameImpl::initializeCoreFrame(FrameHost* host, FrameOwner* owner, const AtomicString& name)
810 { 858 {
811 setCoreFrame(RemoteFrame::create(&m_frameClient, host, owner)); 859 setCoreFrame(RemoteFrame::create(&m_frameClient, host, owner));
812 m_frame->tree().setName(name, nullAtom); 860 m_frame->tree().setName(name, nullAtom);
813 } 861 }
814 862
815 WebRemoteFrame* WebRemoteFrameImpl::createRemoteChild(const WebString& name, Web RemoteFrameClient* client) 863 WebRemoteFrame* WebRemoteFrameImpl::createRemoteChild(const WebString& name, Web RemoteFrameClient* client)
816 { 864 {
817 WebRemoteFrameImpl* child = toWebRemoteFrameImpl(WebRemoteFrame::create(clie nt)); 865 WebRemoteFrameImpl* child = toWebRemoteFrameImpl(WebRemoteFrame::create(clie nt));
818 HashMap<WebFrame*, OwnPtr<FrameOwner> >::AddResult result = 866 WillBeHeapHashMap<WebFrame*, OwnPtrWillBeMember<FrameOwner> >::AddResult res ult =
819 m_ownersForChildren.add(child, adoptPtr(new PlaceholderFrameOwner)); 867 m_ownersForChildren.add(child, adoptPtrWillBeNoop(new PlaceholderFrameOw ner));
820 appendChild(child); 868 appendChild(child);
821 child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name); 869 child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name);
822 return child; 870 return child;
823 } 871 }
824 872
825 void WebRemoteFrameImpl::setCoreFrame(PassRefPtr<RemoteFrame> frame) 873 void WebRemoteFrameImpl::setCoreFrame(PassRefPtrWillBeRawPtr<RemoteFrame> frame)
826 { 874 {
827 m_frame = frame; 875 m_frame = frame;
828 } 876 }
829 877
830 WebRemoteFrameImpl* WebRemoteFrameImpl::fromFrame(RemoteFrame& frame) 878 WebRemoteFrameImpl* WebRemoteFrameImpl::fromFrame(RemoteFrame& frame)
831 { 879 {
832 if (!frame.client()) 880 if (!frame.client())
833 return 0; 881 return 0;
834 return static_cast<RemoteFrameClient*>(frame.client())->webFrame(); 882 return static_cast<RemoteFrameClient*>(frame.client())->webFrame();
835 } 883 }
836 884
837 } // namespace blink 885 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698