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

Unified Diff: trunk/Source/core/frame/DOMWindowProperty.cpp

Issue 564013002: Revert 181758 "Simplify DOMWindowProperty and its unregistration." (Closed) Base URL: svn://svn.chromium.org/blink/
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trunk/Source/core/frame/DOMWindowProperty.h ('k') | trunk/Source/core/frame/LocalDOMWindow.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/Source/core/frame/DOMWindowProperty.cpp
===================================================================
--- trunk/Source/core/frame/DOMWindowProperty.cpp (revision 181866)
+++ trunk/Source/core/frame/DOMWindowProperty.cpp (working copy)
@@ -34,24 +34,39 @@
DOMWindowProperty::DOMWindowProperty(LocalFrame* frame)
: m_frame(frame)
+ , m_associatedDOMWindow(nullptr)
{
// FIXME: For now it *is* acceptable for a DOMWindowProperty to be created with a null frame.
// See fast/dom/navigator-detached-no-crash.html for the recipe.
// We should fix that. <rdar://problem/11567132>
- if (m_frame)
- m_frame->domWindow()->registerProperty(this);
+ if (m_frame) {
+ m_associatedDOMWindow = m_frame->domWindow();
+ m_associatedDOMWindow->registerProperty(this);
+ }
}
-DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(DOMWindowProperty);
+#if !ENABLE(OILPAN)
+DOMWindowProperty::~DOMWindowProperty()
+{
+ if (m_associatedDOMWindow)
+ m_associatedDOMWindow->unregisterProperty(this);
+ m_associatedDOMWindow = nullptr;
+ m_frame = nullptr;
+}
+#endif
+
void DOMWindowProperty::willDestroyGlobalObjectInFrame()
{
// If the property is getting this callback it must have been created with a LocalFrame/LocalDOMWindow and it should still have them.
ASSERT(m_frame);
+ ASSERT(m_associatedDOMWindow);
- // DOMWindowProperty's registered lifetime is controlled by LocalDOMWindow. After
- // the willDestroyGlobalObjectInFrame() notifications, LocalDOMWindow clears out
- // all registrations. Hence no need to unregister.
+ // DOMWindowProperty lifetime isn't tied directly to the LocalDOMWindow itself so it is important that it unregister
+ // itself from any LocalDOMWindow it is associated with if that LocalDOMWindow is going away.
+ if (m_associatedDOMWindow)
+ m_associatedDOMWindow->unregisterProperty(this);
+ m_associatedDOMWindow = nullptr;
m_frame = nullptr;
}
@@ -59,6 +74,12 @@
{
// If the property is getting this callback it must have been created with a LocalFrame/LocalDOMWindow and it should still have them.
ASSERT(m_frame);
+ ASSERT(m_associatedDOMWindow);
}
-} // namespace blink
+void DOMWindowProperty::trace(Visitor* visitor)
+{
+ visitor->trace(m_associatedDOMWindow);
+}
+
+}
« no previous file with comments | « trunk/Source/core/frame/DOMWindowProperty.h ('k') | trunk/Source/core/frame/LocalDOMWindow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698