Commit 24986e95 authored by ager@chromium.org's avatar ager@chromium.org

Oilpan: Remove ~HTMLMediaElement document access when the document is destructed.

The document() accessor on all Nodes end up touching the document. The
reason is that the document accessor gets the document from the
TreeScope which is often the document itself. Therefore, we cannot
use the document() accessor in Node destructors. Fortunately, there
is a more direct way of checking if the Document has been destructed.
HTMLMediaElement is an ActiveDOMObject which is a
ContextLifecycleObserver. Therefore, ActiveDOMObject::executionContext
will tell us if the Document is still alive so that we can access it.

R=haraken@chromium.org, oilpan-reviews@chromium.org, sigbjornf@chromium.org, zerny@chromium.org

Review URL: https://codereview.chromium.org/310333003

git-svn-id: svn://svn.chromium.org/blink/trunk@175465 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 7078e89d
......@@ -126,13 +126,8 @@ typedef WillBeHeapHashSet<RawPtrWillBeWeakMember<HTMLMediaElement> > WeakMediaEl
typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<Document>, WeakMediaElementSet> DocumentElementSetMap;
static DocumentElementSetMap& documentToElementSetMap()
{
#if ENABLE(OILPAN)
DEFINE_STATIC_LOCAL(Persistent<DocumentElementSetMap>, map, (new DocumentElementSetMap()));
DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<DocumentElementSetMap>, map, (adoptPtrWillBeNoop(new DocumentElementSetMap())));
return *map;
#else
DEFINE_STATIC_LOCAL(DocumentElementSetMap, map, ());
return map;
#endif
}
static void addElementToDocumentMap(HTMLMediaElement* element, Document* document)
......@@ -318,10 +313,10 @@ HTMLMediaElement::~HTMLMediaElement()
// document there is no need to change the delayed load counts
// because no load event will fire anyway. If the document is
// still alive we do have to decrement the load delay counts. We
// determine if the document is alive by inspecting the weak
// documentToElementSetMap. If the document is dead it has been
// removed from the map during weak processing.
if (documentToElementSetMap().contains(&document()))
// determine if the document is alive via the ActiveDOMObject
// which is a context lifecycle observer. If the Document has been
// destructed ActiveDOMObject::executionContext() returns 0.
if (ActiveDOMObject::executionContext())
setShouldDelayLoadEvent(false);
#else
setShouldDelayLoadEvent(false);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment