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

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 r181764 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(WebFrameClient*) 111 WebRemoteFrame* WebRemoteFrame::create(WebFrameClient*)
96 { 112 {
97 return adoptRef(new WebRemoteFrameImpl()).leakRef(); 113 WebRemoteFrameImpl* frame = new WebRemoteFrameImpl();
114 #if ENABLE(OILPAN)
115 return frame;
116 #else
117 return adoptRef(frame).leakRef();
118 #endif
98 } 119 }
99 120
100 WebRemoteFrameImpl::WebRemoteFrameImpl() 121 WebRemoteFrameImpl::WebRemoteFrameImpl()
101 : m_frameClient(this) 122 : m_frameClient(this)
102 { 123 {
103 } 124 }
104 125
105 WebRemoteFrameImpl::~WebRemoteFrameImpl() 126 WebRemoteFrameImpl::~WebRemoteFrameImpl()
106 { 127 {
107 } 128 }
108 129
130 void WebRemoteFrameImpl::trace(Visitor* visitor)
131 {
132 #if ENABLE(OILPAN)
133 visitor->trace(m_frame);
134 visitor->trace(m_ownersForChildren);
135
136 WebFrame::trace(visitor, this);
137 #endif
138 }
139
109 bool WebRemoteFrameImpl::isWebLocalFrame() const 140 bool WebRemoteFrameImpl::isWebLocalFrame() const
110 { 141 {
111 return false; 142 return false;
112 } 143 }
113 144
114 WebLocalFrame* WebRemoteFrameImpl::toWebLocalFrame() 145 WebLocalFrame* WebRemoteFrameImpl::toWebLocalFrame()
115 { 146 {
116 ASSERT_NOT_REACHED(); 147 ASSERT_NOT_REACHED();
117 return 0; 148 return 0;
118 } 149 }
119 150
120 bool WebRemoteFrameImpl::isWebRemoteFrame() const 151 bool WebRemoteFrameImpl::isWebRemoteFrame() const
121 { 152 {
122 return true; 153 return true;
123 } 154 }
124 155
125 WebRemoteFrame* WebRemoteFrameImpl::toWebRemoteFrame() 156 WebRemoteFrame* WebRemoteFrameImpl::toWebRemoteFrame()
126 { 157 {
127 return this; 158 return this;
128 } 159 }
129 160
130 void WebRemoteFrameImpl::close() 161 void WebRemoteFrameImpl::close()
131 { 162 {
163 #if ENABLE(OILPAN)
164 if (m_frame)
165 m_frame->setHasBeenClosed();
166 #else
132 deref(); 167 deref();
168 #endif
133 } 169 }
134 170
135 WebString WebRemoteFrameImpl::uniqueName() const 171 WebString WebRemoteFrameImpl::uniqueName() const
136 { 172 {
137 ASSERT_NOT_REACHED(); 173 ASSERT_NOT_REACHED();
138 return WebString(); 174 return WebString();
139 } 175 }
140 176
141 WebString WebRemoteFrameImpl::assignedName() const 177 WebString WebRemoteFrameImpl::assignedName() const
142 { 178 {
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 820
785 WebString WebRemoteFrameImpl::layerTreeAsText(bool showDebugInfo) const 821 WebString WebRemoteFrameImpl::layerTreeAsText(bool showDebugInfo) const
786 { 822 {
787 ASSERT_NOT_REACHED(); 823 ASSERT_NOT_REACHED();
788 return WebString(); 824 return WebString();
789 } 825 }
790 826
791 WebLocalFrame* WebRemoteFrameImpl::createLocalChild(const WebString& name, WebFr ameClient* client) 827 WebLocalFrame* WebRemoteFrameImpl::createLocalChild(const WebString& name, WebFr ameClient* client)
792 { 828 {
793 WebLocalFrameImpl* child = toWebLocalFrameImpl(WebLocalFrame::create(client) ); 829 WebLocalFrameImpl* child = toWebLocalFrameImpl(WebLocalFrame::create(client) );
794 HashMap<WebFrame*, OwnPtr<FrameOwner> >::AddResult result = 830 WillBeHeapHashMap<WebFrame*, OwnPtrWillBeMember<FrameOwner> >::AddResult res ult =
795 m_ownersForChildren.add(child, adoptPtr(new RemoteBridgeFrameOwner(child ))); 831 m_ownersForChildren.add(child, RemoteBridgeFrameOwner::create(child));
796 appendChild(child); 832 appendChild(child);
797 // FIXME: currently this calls LocalFrame::init() on the created LocalFrame, which may 833 // FIXME: currently this calls LocalFrame::init() on the created LocalFrame, which may
798 // result in the browser observing two navigations to about:blank (one from the initial 834 // result in the browser observing two navigations to about:blank (one from the initial
799 // frame creation, and one from swapping it into the remote process). FrameL oader might 835 // frame creation, and one from swapping it into the remote process). FrameL oader might
800 // need a special initialization function for this case to avoid that duplic ate navigation. 836 // need a special initialization function for this case to avoid that duplic ate navigation.
801 child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name, nullAtom); 837 child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name, nullAtom);
802 // Partially related with the above FIXME--the init() call may trigger JS di spatch. However, 838 // Partially related with the above FIXME--the init() call may trigger JS di spatch. However,
803 // if the parent is remote, it should never be detached synchronously... 839 // if the parent is remote, it should never be detached synchronously...
804 ASSERT(child->frame()); 840 ASSERT(child->frame());
805 return child; 841 return child;
806 } 842 }
807 843
808 void WebRemoteFrameImpl::initializeCoreFrame(FrameHost* host, FrameOwner* owner, const AtomicString& name) 844 void WebRemoteFrameImpl::initializeCoreFrame(FrameHost* host, FrameOwner* owner, const AtomicString& name)
809 { 845 {
810 setCoreFrame(RemoteFrame::create(&m_frameClient, host, owner)); 846 setCoreFrame(RemoteFrame::create(&m_frameClient, host, owner));
811 m_frame->tree().setName(name, nullAtom); 847 m_frame->tree().setName(name, nullAtom);
812 } 848 }
813 849
814 WebRemoteFrame* WebRemoteFrameImpl::createRemoteChild(const WebString& name, Web FrameClient* client) 850 WebRemoteFrame* WebRemoteFrameImpl::createRemoteChild(const WebString& name, Web FrameClient* client)
815 { 851 {
816 WebRemoteFrameImpl* child = toWebRemoteFrameImpl(WebRemoteFrame::create(clie nt)); 852 WebRemoteFrameImpl* child = toWebRemoteFrameImpl(WebRemoteFrame::create(clie nt));
817 HashMap<WebFrame*, OwnPtr<FrameOwner> >::AddResult result = 853 WillBeHeapHashMap<WebFrame*, OwnPtrWillBeMember<FrameOwner> >::AddResult res ult =
818 m_ownersForChildren.add(child, adoptPtr(new PlaceholderFrameOwner)); 854 m_ownersForChildren.add(child, adoptPtrWillBeNoop(new PlaceholderFrameOw ner));
819 appendChild(child); 855 appendChild(child);
820 child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name); 856 child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name);
821 return child; 857 return child;
822 } 858 }
823 859
824 void WebRemoteFrameImpl::setCoreFrame(PassRefPtr<RemoteFrame> frame) 860 void WebRemoteFrameImpl::setCoreFrame(PassRefPtrWillBeRawPtr<RemoteFrame> frame)
825 { 861 {
826 m_frame = frame; 862 m_frame = frame;
827 } 863 }
828 864
829 WebRemoteFrameImpl* WebRemoteFrameImpl::fromFrame(RemoteFrame& frame) 865 WebRemoteFrameImpl* WebRemoteFrameImpl::fromFrame(RemoteFrame& frame)
830 { 866 {
831 if (!frame.client()) 867 if (!frame.client())
832 return 0; 868 return 0;
833 return static_cast<RemoteFrameClient*>(frame.client())->webFrame(); 869 return static_cast<RemoteFrameClient*>(frame.client())->webFrame();
834 } 870 }
835 871
836 } // namespace blink 872 } // namespace blink
837
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698