Chromium Code Reviews| Index: Source/web/WebRemoteFrameImpl.cpp |
| diff --git a/Source/web/WebRemoteFrameImpl.cpp b/Source/web/WebRemoteFrameImpl.cpp |
| index 6bb811146337a1dbdf913f1fe46aaeea58f9e8de..d811851a5ab8efefe298bc4f041973047ecc1675 100644 |
| --- a/Source/web/WebRemoteFrameImpl.cpp |
| +++ b/Source/web/WebRemoteFrameImpl.cpp |
| @@ -9,6 +9,7 @@ |
| #include "core/frame/RemoteFrame.h" |
| #include "core/frame/Settings.h" |
| #include "core/page/Page.h" |
| +#include "platform/heap/Handle.h" |
| #include "public/platform/WebFloatRect.h" |
| #include "public/platform/WebRect.h" |
| #include "public/web/WebDocument.h" |
| @@ -27,23 +28,37 @@ namespace { |
| // 1. Allows the local frame's loader to retrieve sandbox flags associated with |
| // its owner element in another process. |
| // 2. Trigger a load event on its owner element once it finishes a load. |
| -class RemoteBridgeFrameOwner : public FrameOwner { |
| +class RemoteBridgeFrameOwner : public NoBaseWillBeGarbageCollectedFinalized<RemoteBridgeFrameOwner>, public FrameOwner { |
| + WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(RemoteBridgeFrameOwner); |
| public: |
| - explicit RemoteBridgeFrameOwner(PassRefPtr<WebLocalFrameImpl>); |
| + static PassOwnPtrWillBeRawPtr<RemoteBridgeFrameOwner> create(PassRefPtrWillBeRawPtr<WebLocalFrameImpl> frame) |
| + { |
| + return adoptPtrWillBeNoop(new RemoteBridgeFrameOwner(frame)); |
| + } |
| virtual bool isLocal() const OVERRIDE; |
| virtual SandboxFlags sandboxFlags() const OVERRIDE; |
| virtual void dispatchLoad() OVERRIDE; |
| + virtual void trace(Visitor*); |
| + |
| private: |
| - RefPtr<WebLocalFrameImpl> m_frame; |
| + explicit RemoteBridgeFrameOwner(PassRefPtrWillBeRawPtr<WebLocalFrameImpl>); |
| + |
| + RefPtrWillBeMember<WebLocalFrameImpl> m_frame; |
| }; |
| -RemoteBridgeFrameOwner::RemoteBridgeFrameOwner(PassRefPtr<WebLocalFrameImpl> frame) |
| +RemoteBridgeFrameOwner::RemoteBridgeFrameOwner(PassRefPtrWillBeRawPtr<WebLocalFrameImpl> frame) |
| : m_frame(frame) |
| { |
| } |
| +void RemoteBridgeFrameOwner::trace(Visitor* visitor) |
| +{ |
| + visitor->trace(m_frame); |
| + FrameOwner::trace(visitor); |
| +} |
| + |
| bool RemoteBridgeFrameOwner::isLocal() const |
| { |
| return false; |
| @@ -67,7 +82,8 @@ void RemoteBridgeFrameOwner::dispatchLoad() |
| // the RemoteFrame itself load a document). In most circumstances, the check for |
| // frame->owner() can be replaced with a check for frame->tree().parent(). Once |
| // that's done, this class can be removed. |
| -class PlaceholderFrameOwner : public FrameOwner { |
| +class PlaceholderFrameOwner : public NoBaseWillBeGarbageCollectedFinalized<PlaceholderFrameOwner>, public FrameOwner { |
| + WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PlaceholderFrameOwner); |
| public: |
| virtual bool isLocal() const OVERRIDE; |
| virtual SandboxFlags sandboxFlags() const OVERRIDE; |
| @@ -94,7 +110,18 @@ void PlaceholderFrameOwner::dispatchLoad() |
| WebRemoteFrame* WebRemoteFrame::create(WebRemoteFrameClient* client) |
| { |
| - return adoptRef(new WebRemoteFrameImpl(client)).leakRef(); |
| + return WebRemoteFrameImpl::create(client); |
| +} |
| + |
| +WebRemoteFrame* WebRemoteFrameImpl::create(WebRemoteFrameClient* client) |
| +{ |
| + WebRemoteFrameImpl* frame = new WebRemoteFrameImpl(client); |
| +#if ENABLE(OILPAN) |
| + frame->m_selfKeepAlive = frame; |
|
Mads Ager (chromium)
2014/09/18 12:00:59
Maybe move to constructor?
: m_selfKeepAlive(this
|
| + return frame; |
| +#else |
| + return adoptRef(frame).leakRef(); |
| +#endif |
| } |
| WebRemoteFrameImpl::WebRemoteFrameImpl(WebRemoteFrameClient* client) |
| @@ -107,6 +134,16 @@ WebRemoteFrameImpl::~WebRemoteFrameImpl() |
| { |
| } |
| +void WebRemoteFrameImpl::trace(Visitor* visitor) |
| +{ |
| +#if ENABLE(OILPAN) |
| + visitor->trace(m_frame); |
| + visitor->trace(m_ownersForChildren); |
| + |
| + WebFrame::traceChildren(visitor, this); |
| +#endif |
| +} |
| + |
| bool WebRemoteFrameImpl::isWebLocalFrame() const |
| { |
| return false; |
| @@ -130,7 +167,11 @@ WebRemoteFrame* WebRemoteFrameImpl::toWebRemoteFrame() |
| void WebRemoteFrameImpl::close() |
| { |
| +#if ENABLE(OILPAN) |
| + m_selfKeepAlive.clear(); |
| +#else |
| deref(); |
| +#endif |
| } |
| WebString WebRemoteFrameImpl::uniqueName() const |
| @@ -244,6 +285,13 @@ WebView* WebRemoteFrameImpl::view() const |
| return WebViewImpl::fromPage(frame()->page()); |
| } |
| +WebViewImpl* WebRemoteFrameImpl::viewImpl() const |
| +{ |
| + if (!frame()) |
| + return 0; |
| + return WebViewImpl::fromPage(frame()->page()); |
| +} |
| + |
| void WebRemoteFrameImpl::removeChild(WebFrame* frame) |
| { |
| WebFrame::removeChild(frame); |
| @@ -792,8 +840,8 @@ WebString WebRemoteFrameImpl::layerTreeAsText(bool showDebugInfo) const |
| WebLocalFrame* WebRemoteFrameImpl::createLocalChild(const WebString& name, WebFrameClient* client) |
| { |
| WebLocalFrameImpl* child = toWebLocalFrameImpl(WebLocalFrame::create(client)); |
| - HashMap<WebFrame*, OwnPtr<FrameOwner> >::AddResult result = |
| - m_ownersForChildren.add(child, adoptPtr(new RemoteBridgeFrameOwner(child))); |
| + WillBeHeapHashMap<WebFrame*, OwnPtrWillBeMember<FrameOwner> >::AddResult result = |
| + m_ownersForChildren.add(child, RemoteBridgeFrameOwner::create(child)); |
| appendChild(child); |
| // FIXME: currently this calls LocalFrame::init() on the created LocalFrame, which may |
| // result in the browser observing two navigations to about:blank (one from the initial |
| @@ -815,14 +863,14 @@ void WebRemoteFrameImpl::initializeCoreFrame(FrameHost* host, FrameOwner* owner, |
| WebRemoteFrame* WebRemoteFrameImpl::createRemoteChild(const WebString& name, WebRemoteFrameClient* client) |
| { |
| WebRemoteFrameImpl* child = toWebRemoteFrameImpl(WebRemoteFrame::create(client)); |
| - HashMap<WebFrame*, OwnPtr<FrameOwner> >::AddResult result = |
| - m_ownersForChildren.add(child, adoptPtr(new PlaceholderFrameOwner)); |
| + WillBeHeapHashMap<WebFrame*, OwnPtrWillBeMember<FrameOwner> >::AddResult result = |
| + m_ownersForChildren.add(child, adoptPtrWillBeNoop(new PlaceholderFrameOwner)); |
| appendChild(child); |
| child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name); |
| return child; |
| } |
| -void WebRemoteFrameImpl::setCoreFrame(PassRefPtr<RemoteFrame> frame) |
| +void WebRemoteFrameImpl::setCoreFrame(PassRefPtrWillBeRawPtr<RemoteFrame> frame) |
| { |
| m_frame = frame; |
| } |