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

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

Powered by Google App Engine
This is Rietveld 408576698