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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2810253003: [wrapper-tracing] Fix node list leak (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/NodeListsNodeData.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 6608 matching lines...) Expand 10 before | Expand all | Expand 10 after
6619 DCHECK(frame()->isCrossOriginSubframe()); 6619 DCHECK(frame()->isCrossOriginSubframe());
6620 if (reason <= m_wouldLoadReason || 6620 if (reason <= m_wouldLoadReason ||
6621 !frame()->loader().stateMachine()->committedFirstRealDocumentLoad()) 6621 !frame()->loader().stateMachine()->committedFirstRealDocumentLoad())
6622 return; 6622 return;
6623 for (int i = m_wouldLoadReason + 1; i <= reason; ++i) 6623 for (int i = m_wouldLoadReason + 1; i <= reason; ++i)
6624 recordLoadReasonToHistogram(static_cast<WouldLoadReason>(i)); 6624 recordLoadReasonToHistogram(static_cast<WouldLoadReason>(i));
6625 m_wouldLoadReason = reason; 6625 m_wouldLoadReason = reason;
6626 } 6626 }
6627 6627
6628 DEFINE_TRACE_WRAPPERS(Document) { 6628 DEFINE_TRACE_WRAPPERS(Document) {
6629 // m_nodeLists are traced in their corresponding NodeListsNodeData, keeping
6630 // them only alive for live nodes. Otherwise we would keep lists of dead
6631 // nodes alive that have not yet been invalidated.
6629 visitor->traceWrappers(m_importsController); 6632 visitor->traceWrappers(m_importsController);
6630 visitor->traceWrappers(m_implementation); 6633 visitor->traceWrappers(m_implementation);
6631 visitor->traceWrappers(m_styleSheetList); 6634 visitor->traceWrappers(m_styleSheetList);
6632 visitor->traceWrappers(m_styleEngine); 6635 visitor->traceWrappers(m_styleEngine);
6633 for (int i = 0; i < numNodeListInvalidationTypes; ++i) {
6634 for (auto list : m_nodeLists[i]) {
6635 if (isHTMLCollectionType(list->type())) {
6636 visitor->traceWrappersWithManualWriteBarrier(
6637 static_cast<const HTMLCollection*>(list.get()));
6638 } else {
6639 visitor->traceWrappersWithManualWriteBarrier(
6640 static_cast<const LiveNodeList*>(list.get()));
6641 }
6642 }
6643 }
6644 // Cannot trace in Supplementable<Document> as it is part of platform/ and 6636 // Cannot trace in Supplementable<Document> as it is part of platform/ and
6645 // thus cannot refer to ScriptWrappableVisitor. 6637 // thus cannot refer to ScriptWrappableVisitor.
6646 visitor->traceWrappers( 6638 visitor->traceWrappers(
6647 static_cast<FontFaceSet*>(Supplementable<Document>::m_supplements.at( 6639 static_cast<FontFaceSet*>(Supplementable<Document>::m_supplements.at(
6648 FontFaceSet::supplementName()))); 6640 FontFaceSet::supplementName())));
6649 ContainerNode::traceWrappers(visitor); 6641 ContainerNode::traceWrappers(visitor);
6650 } 6642 }
6651 6643
6652 template class CORE_TEMPLATE_EXPORT Supplement<Document>; 6644 template class CORE_TEMPLATE_EXPORT Supplement<Document>;
6653 6645
6654 } // namespace blink 6646 } // namespace blink
6655 6647
6656 #ifndef NDEBUG 6648 #ifndef NDEBUG
6657 static WeakDocumentSet& liveDocumentSet() { 6649 static WeakDocumentSet& liveDocumentSet() {
6658 DEFINE_STATIC_LOCAL(WeakDocumentSet, set, ()); 6650 DEFINE_STATIC_LOCAL(WeakDocumentSet, set, ());
6659 return set; 6651 return set;
6660 } 6652 }
6661 6653
6662 void showLiveDocumentInstances() { 6654 void showLiveDocumentInstances() {
6663 WeakDocumentSet& set = liveDocumentSet(); 6655 WeakDocumentSet& set = liveDocumentSet();
6664 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6656 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6665 for (blink::Document* document : set) 6657 for (blink::Document* document : set)
6666 fprintf(stderr, "- Document %p URL: %s\n", document, 6658 fprintf(stderr, "- Document %p URL: %s\n", document,
6667 document->url().getString().utf8().data()); 6659 document->url().getString().utf8().data());
6668 } 6660 }
6669 #endif 6661 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/NodeListsNodeData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698