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

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: Add LocalFrame::detachView() + more Oilpan frame finalization comments 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 WebRemoteFrameImpl* frame = new WebRemoteFrameImpl(client);
114 #if ENABLE(OILPAN)
115 return frame;
116 #else
117 return adoptRef(frame).leakRef();
118 #endif
98 } 119 }
99 120
100 WebRemoteFrameImpl::WebRemoteFrameImpl(WebRemoteFrameClient* client) 121 WebRemoteFrameImpl::WebRemoteFrameImpl(WebRemoteFrameClient* client)
101 : m_frameClient(this) 122 : m_frameClient(this)
102 , m_client(client) 123 , m_client(client)
103 { 124 {
104 } 125 }
105 126
106 WebRemoteFrameImpl::~WebRemoteFrameImpl() 127 WebRemoteFrameImpl::~WebRemoteFrameImpl()
107 { 128 {
108 } 129 }
109 130
131 void WebRemoteFrameImpl::trace(Visitor* visitor)
132 {
133 #if ENABLE(OILPAN)
134 visitor->trace(m_frame);
135 visitor->trace(m_ownersForChildren);
136
137 WebFrame::traceChildren(visitor, this);
138 #endif
139 }
140
110 bool WebRemoteFrameImpl::isWebLocalFrame() const 141 bool WebRemoteFrameImpl::isWebLocalFrame() const
111 { 142 {
112 return false; 143 return false;
113 } 144 }
114 145
115 WebLocalFrame* WebRemoteFrameImpl::toWebLocalFrame() 146 WebLocalFrame* WebRemoteFrameImpl::toWebLocalFrame()
116 { 147 {
117 ASSERT_NOT_REACHED(); 148 ASSERT_NOT_REACHED();
118 return 0; 149 return 0;
119 } 150 }
120 151
121 bool WebRemoteFrameImpl::isWebRemoteFrame() const 152 bool WebRemoteFrameImpl::isWebRemoteFrame() const
122 { 153 {
123 return true; 154 return true;
124 } 155 }
125 156
126 WebRemoteFrame* WebRemoteFrameImpl::toWebRemoteFrame() 157 WebRemoteFrame* WebRemoteFrameImpl::toWebRemoteFrame()
127 { 158 {
128 return this; 159 return this;
129 } 160 }
130 161
131 void WebRemoteFrameImpl::close() 162 void WebRemoteFrameImpl::close()
132 { 163 {
164 if (m_frame)
165 m_frame->setHasBeenClosed();
166
167 #if ENABLE(OILPAN)
168 if (m_frame && m_frame->isMainFrame() && viewImpl())
169 viewImpl()->clearMainFrame(this);
170 #else
133 deref(); 171 deref();
172 #endif
134 } 173 }
135 174
136 WebString WebRemoteFrameImpl::uniqueName() const 175 WebString WebRemoteFrameImpl::uniqueName() const
137 { 176 {
138 ASSERT_NOT_REACHED(); 177 ASSERT_NOT_REACHED();
139 return WebString(); 178 return WebString();
140 } 179 }
141 180
142 WebString WebRemoteFrameImpl::assignedName() const 181 WebString WebRemoteFrameImpl::assignedName() const
143 { 182 {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 return false; 276 return false;
238 } 277 }
239 278
240 WebView* WebRemoteFrameImpl::view() const 279 WebView* WebRemoteFrameImpl::view() const
241 { 280 {
242 if (!frame()) 281 if (!frame())
243 return 0; 282 return 0;
244 return WebViewImpl::fromPage(frame()->page()); 283 return WebViewImpl::fromPage(frame()->page());
245 } 284 }
246 285
286 WebViewImpl* WebRemoteFrameImpl::viewImpl() const
287 {
288 if (!frame())
289 return 0;
290 return WebViewImpl::fromPage(frame()->page());
291 }
292
247 void WebRemoteFrameImpl::removeChild(WebFrame* frame) 293 void WebRemoteFrameImpl::removeChild(WebFrame* frame)
248 { 294 {
249 WebFrame::removeChild(frame); 295 WebFrame::removeChild(frame);
250 m_ownersForChildren.remove(frame); 296 m_ownersForChildren.remove(frame);
251 } 297 }
252 298
253 WebDocument WebRemoteFrameImpl::document() const 299 WebDocument WebRemoteFrameImpl::document() const
254 { 300 {
255 return WebDocument(); 301 return WebDocument();
256 } 302 }
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 831
786 WebString WebRemoteFrameImpl::layerTreeAsText(bool showDebugInfo) const 832 WebString WebRemoteFrameImpl::layerTreeAsText(bool showDebugInfo) const
787 { 833 {
788 ASSERT_NOT_REACHED(); 834 ASSERT_NOT_REACHED();
789 return WebString(); 835 return WebString();
790 } 836 }
791 837
792 WebLocalFrame* WebRemoteFrameImpl::createLocalChild(const WebString& name, WebFr ameClient* client) 838 WebLocalFrame* WebRemoteFrameImpl::createLocalChild(const WebString& name, WebFr ameClient* client)
793 { 839 {
794 WebLocalFrameImpl* child = toWebLocalFrameImpl(WebLocalFrame::create(client) ); 840 WebLocalFrameImpl* child = toWebLocalFrameImpl(WebLocalFrame::create(client) );
795 HashMap<WebFrame*, OwnPtr<FrameOwner> >::AddResult result = 841 WillBeHeapHashMap<WebFrame*, OwnPtrWillBeMember<FrameOwner> >::AddResult res ult =
796 m_ownersForChildren.add(child, adoptPtr(new RemoteBridgeFrameOwner(child ))); 842 m_ownersForChildren.add(child, RemoteBridgeFrameOwner::create(child));
797 appendChild(child); 843 appendChild(child);
798 // FIXME: currently this calls LocalFrame::init() on the created LocalFrame, which may 844 // 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 845 // 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 846 // 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. 847 // 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); 848 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, 849 // 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... 850 // if the parent is remote, it should never be detached synchronously...
805 ASSERT(child->frame()); 851 ASSERT(child->frame());
806 return child; 852 return child;
807 } 853 }
808 854
809 void WebRemoteFrameImpl::initializeCoreFrame(FrameHost* host, FrameOwner* owner, const AtomicString& name) 855 void WebRemoteFrameImpl::initializeCoreFrame(FrameHost* host, FrameOwner* owner, const AtomicString& name)
810 { 856 {
811 setCoreFrame(RemoteFrame::create(&m_frameClient, host, owner)); 857 setCoreFrame(RemoteFrame::create(&m_frameClient, host, owner));
812 m_frame->tree().setName(name, nullAtom); 858 m_frame->tree().setName(name, nullAtom);
813 } 859 }
814 860
815 WebRemoteFrame* WebRemoteFrameImpl::createRemoteChild(const WebString& name, Web RemoteFrameClient* client) 861 WebRemoteFrame* WebRemoteFrameImpl::createRemoteChild(const WebString& name, Web RemoteFrameClient* client)
816 { 862 {
817 WebRemoteFrameImpl* child = toWebRemoteFrameImpl(WebRemoteFrame::create(clie nt)); 863 WebRemoteFrameImpl* child = toWebRemoteFrameImpl(WebRemoteFrame::create(clie nt));
818 HashMap<WebFrame*, OwnPtr<FrameOwner> >::AddResult result = 864 WillBeHeapHashMap<WebFrame*, OwnPtrWillBeMember<FrameOwner> >::AddResult res ult =
819 m_ownersForChildren.add(child, adoptPtr(new PlaceholderFrameOwner)); 865 m_ownersForChildren.add(child, adoptPtrWillBeNoop(new PlaceholderFrameOw ner));
820 appendChild(child); 866 appendChild(child);
821 child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name); 867 child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name);
822 return child; 868 return child;
823 } 869 }
824 870
825 void WebRemoteFrameImpl::setCoreFrame(PassRefPtr<RemoteFrame> frame) 871 void WebRemoteFrameImpl::setCoreFrame(PassRefPtrWillBeRawPtr<RemoteFrame> frame)
826 { 872 {
827 m_frame = frame; 873 m_frame = frame;
828 } 874 }
829 875
830 WebRemoteFrameImpl* WebRemoteFrameImpl::fromFrame(RemoteFrame& frame) 876 WebRemoteFrameImpl* WebRemoteFrameImpl::fromFrame(RemoteFrame& frame)
831 { 877 {
832 if (!frame.client()) 878 if (!frame.client())
833 return 0; 879 return 0;
834 return static_cast<RemoteFrameClient*>(frame.client())->webFrame(); 880 return static_cast<RemoteFrameClient*>(frame.client())->webFrame();
835 } 881 }
836 882
837 } // namespace blink 883 } // namespace blink
838
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698