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

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 r181245 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(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->willBeDestroyed();
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 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 826
791 WebString WebRemoteFrameImpl::layerTreeAsText(bool showDebugInfo) const 827 WebString WebRemoteFrameImpl::layerTreeAsText(bool showDebugInfo) const
792 { 828 {
793 ASSERT_NOT_REACHED(); 829 ASSERT_NOT_REACHED();
794 return WebString(); 830 return WebString();
795 } 831 }
796 832
797 WebLocalFrame* WebRemoteFrameImpl::createLocalChild(const WebString& name, WebFr ameClient* client) 833 WebLocalFrame* WebRemoteFrameImpl::createLocalChild(const WebString& name, WebFr ameClient* client)
798 { 834 {
799 WebLocalFrameImpl* child = toWebLocalFrameImpl(WebLocalFrame::create(client) ); 835 WebLocalFrameImpl* child = toWebLocalFrameImpl(WebLocalFrame::create(client) );
800 HashMap<WebFrame*, OwnPtr<FrameOwner> >::AddResult result = 836 WillBeHeapHashMap<WebFrame*, OwnPtrWillBeMember<FrameOwner> >::AddResult res ult =
801 m_ownersForChildren.add(child, adoptPtr(new RemoteBridgeFrameOwner(child ))); 837 m_ownersForChildren.add(child, RemoteBridgeFrameOwner::create(child));
802 appendChild(child); 838 appendChild(child);
803 // FIXME: currently this calls LocalFrame::init() on the created LocalFrame, which may 839 // FIXME: currently this calls LocalFrame::init() on the created LocalFrame, which may
804 // result in the browser observing two navigations to about:blank (one from the initial 840 // result in the browser observing two navigations to about:blank (one from the initial
805 // frame creation, and one from swapping it into the remote process). FrameL oader might 841 // frame creation, and one from swapping it into the remote process). FrameL oader might
806 // need a special initialization function for this case to avoid that duplic ate navigation. 842 // need a special initialization function for this case to avoid that duplic ate navigation.
807 child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name, nullAtom); 843 child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name, nullAtom);
808 // Partially related with the above FIXME--the init() call may trigger JS di spatch. However, 844 // Partially related with the above FIXME--the init() call may trigger JS di spatch. However,
809 // if the parent is remote, it should never be detached synchronously... 845 // if the parent is remote, it should never be detached synchronously...
810 ASSERT(child->frame()); 846 ASSERT(child->frame());
811 return child; 847 return child;
812 } 848 }
813 849
814 void WebRemoteFrameImpl::initializeCoreFrame(FrameHost* host, FrameOwner* owner, const AtomicString& name) 850 void WebRemoteFrameImpl::initializeCoreFrame(FrameHost* host, FrameOwner* owner, const AtomicString& name)
815 { 851 {
816 setCoreFrame(RemoteFrame::create(&m_frameClient, host, owner)); 852 setCoreFrame(RemoteFrame::create(&m_frameClient, host, owner));
817 m_frame->tree().setName(name, nullAtom); 853 m_frame->tree().setName(name, nullAtom);
818 } 854 }
819 855
820 WebRemoteFrame* WebRemoteFrameImpl::createRemoteChild(const WebString& name, Web FrameClient* client) 856 WebRemoteFrame* WebRemoteFrameImpl::createRemoteChild(const WebString& name, Web FrameClient* client)
821 { 857 {
822 WebRemoteFrameImpl* child = toWebRemoteFrameImpl(WebRemoteFrame::create(clie nt)); 858 WebRemoteFrameImpl* child = toWebRemoteFrameImpl(WebRemoteFrame::create(clie nt));
823 HashMap<WebFrame*, OwnPtr<FrameOwner> >::AddResult result = 859 WillBeHeapHashMap<WebFrame*, OwnPtrWillBeMember<FrameOwner> >::AddResult res ult =
824 m_ownersForChildren.add(child, adoptPtr(new PlaceholderFrameOwner)); 860 m_ownersForChildren.add(child, adoptPtrWillBeNoop(new PlaceholderFrameOw ner));
825 appendChild(child); 861 appendChild(child);
826 child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name); 862 child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name);
827 return child; 863 return child;
828 } 864 }
829 865
830 void WebRemoteFrameImpl::setCoreFrame(PassRefPtr<RemoteFrame> frame) 866 void WebRemoteFrameImpl::setCoreFrame(PassRefPtrWillBeRawPtr<RemoteFrame> frame)
831 { 867 {
832 m_frame = frame; 868 m_frame = frame;
Mads Ager (chromium) 2014/09/03 10:07:54 In the oilpan build, shouldn't we do a willBeDestr
833 } 869 }
834 870
835 WebRemoteFrameImpl* WebRemoteFrameImpl::fromFrame(RemoteFrame& frame) 871 WebRemoteFrameImpl* WebRemoteFrameImpl::fromFrame(RemoteFrame& frame)
836 { 872 {
837 if (!frame.client()) 873 if (!frame.client())
838 return 0; 874 return 0;
839 return static_cast<RemoteFrameClient*>(frame.client())->webFrame(); 875 return static_cast<RemoteFrameClient*>(frame.client())->webFrame();
840 } 876 }
841 877
842 } // namespace blink 878 } // namespace blink
843
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698