void DOMWindowExtension::willDetachPage() { // willDetachPage might be called multiple times but we only want to react once. if (m_wasDetached) return; // Calling out to the client might result in this DOMWindowExtension being destroyed // while there is still work to do. RefPtr<DOMWindowExtension> protector = this; Frame* frame = m_disconnectedFrame.get(); if (!frame) frame = this->frame(); ASSERT(frame); // DOMWindowExtension lifetime isn't tied directly to the DOMWindow itself so it is important that it unregister // itself from any DOMWindow it is associated with when detached. // This might be the disconnected DOMWindow if the DOMWindow is in a CachedPage that is pruned. DOMWindow* associatedDOMWindow = m_disconnectedDOMWindow ? m_disconnectedDOMWindow : frame->domWindow(); associatedDOMWindow->unregisterProperty(this); m_disconnectedDOMWindow = 0; frame->loader()->client()->dispatchWillDestroyGlobalObjectForDOMWindowExtension(this); m_disconnectedFrame = 0; DOMWindowProperty::willDetachPage(); m_wasDetached = true; }