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

Unified Diff: Source/core/frame/LocalFrame.cpp

Issue 603193005: Move the Widget hierarchy to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Switch LocalFrame::m_pluginElements rep to HashSet<HTMLPlugInElement*> Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/frame/LocalFrame.cpp
diff --git a/Source/core/frame/LocalFrame.cpp b/Source/core/frame/LocalFrame.cpp
index 365bb0381a686066e5ba2fe36b0bb26730278847..7c852b36fb9cea1ed03e8351197e60cb2319737b 100644
--- a/Source/core/frame/LocalFrame.cpp
+++ b/Source/core/frame/LocalFrame.cpp
@@ -48,6 +48,7 @@
#include "core/frame/LocalDOMWindow.h"
#include "core/frame/Settings.h"
#include "core/html/HTMLFrameElementBase.h"
+#include "core/html/HTMLPlugInElement.h"
#include "core/inspector/ConsoleMessageStorage.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/loader/FrameLoaderClient.h"
@@ -145,6 +146,7 @@ void LocalFrame::trace(Visitor* visitor)
visitor->trace(m_destructionObservers);
visitor->trace(m_loader);
visitor->trace(m_navigationScheduler);
+ visitor->trace(m_view);
visitor->trace(m_pagePopupOwner);
visitor->trace(m_script);
visitor->trace(m_editor);
@@ -153,11 +155,27 @@ void LocalFrame::trace(Visitor* visitor)
visitor->trace(m_eventHandler);
visitor->trace(m_console);
visitor->trace(m_inputMethodController);
+ visitor->registerWeakMembers<LocalFrame, &LocalFrame::clearWeakMembers>(this);
HeapSupplementable<LocalFrame>::trace(visitor);
#endif
Frame::trace(visitor);
}
+#if ENABLE(OILPAN)
+void LocalFrame::clearWeakMembers(Visitor* visitor)
+{
+ Vector<HTMLPlugInElement*> deadPlugins;
+ for (HashSet<HTMLPlugInElement*>::const_iterator it = m_pluginElements.begin(); it != m_pluginElements.end(); ++it) {
+ if (!visitor->isAlive(*it)) {
+ (*it)->shouldDisposePlugin();
+ deadPlugins.append(*it);
+ }
+ }
+ for (unsigned i = 0; i < deadPlugins.size(); ++i)
+ m_pluginElements.remove(deadPlugins[i]);
+}
+#endif
+
void LocalFrame::navigate(Document& originDocument, const KURL& url, bool lockBackForwardList)
{
m_navigationScheduler.scheduleLocationChange(&originDocument, url.string(), lockBackForwardList);
@@ -202,8 +220,9 @@ void LocalFrame::detachView()
m_view->prepareForDetach();
}
-void LocalFrame::setView(PassRefPtr<FrameView> view)
+void LocalFrame::setView(PassRefPtrWillBeRawPtr<FrameView> view)
{
+ ASSERT(!m_view || m_view != view);
detachView();
// Prepare for destruction now, so any unload event handlers get run and the LocalDOMWindow is
@@ -448,7 +467,7 @@ void LocalFrame::createView(const IntSize& viewportSize, const Color& background
setView(nullptr);
- RefPtr<FrameView> frameView;
+ RefPtrWillBeRawPtr<FrameView> frameView = nullptr;
if (isLocalRoot) {
frameView = FrameView::create(this, viewportSize);
@@ -723,6 +742,12 @@ void LocalFrame::disconnectOwnerElement()
if (Document* document = this->document())
document->topDocument().clearAXObjectCache();
#if ENABLE(OILPAN)
+ // First give the plugin elements holding persisted,
+ // renderer-less plugins the opportunity to dispose of them.
+ for (HashSet<HTMLPlugInElement*>::const_iterator it = m_pluginElements.begin(); it != m_pluginElements.end(); ++it)
+ (*it)->disconnectContentFrame();
+ m_pluginElements.clear();
+
// Clear the FrameView and FrameLoader right here rather than
// during finalization. Too late to access various heap objects
// at that stage.
@@ -747,4 +772,17 @@ void LocalFrame::setPagePopupOwner(Element& owner)
m_pagePopupOwner = &owner;
}
+#if ENABLE(OILPAN)
+void LocalFrame::registerPluginElement(HTMLPlugInElement* plugin)
+{
+ m_pluginElements.add(plugin);
+}
+
+void LocalFrame::unregisterPluginElement(HTMLPlugInElement* plugin)
+{
+ ASSERT(m_pluginElements.contains(plugin));
+ m_pluginElements.remove(plugin);
+}
+#endif
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698