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

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

Issue 2809183003: [wrapper-tracing] Fix node list leak (Closed)
Patch Set: Addressed comments. 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 6612 matching lines...) Expand 10 before | Expand all | Expand 10 after
6623 if (reason <= would_load_reason_ || 6623 if (reason <= would_load_reason_ ||
6624 !GetFrame()->Loader().StateMachine()->CommittedFirstRealDocumentLoad()) 6624 !GetFrame()->Loader().StateMachine()->CommittedFirstRealDocumentLoad())
6625 return; 6625 return;
6626 for (int i = static_cast<int>(would_load_reason_) + 1; 6626 for (int i = static_cast<int>(would_load_reason_) + 1;
6627 i <= static_cast<int>(reason); ++i) 6627 i <= static_cast<int>(reason); ++i)
6628 RecordLoadReasonToHistogram(static_cast<WouldLoadReason>(i)); 6628 RecordLoadReasonToHistogram(static_cast<WouldLoadReason>(i));
6629 would_load_reason_ = reason; 6629 would_load_reason_ = reason;
6630 } 6630 }
6631 6631
6632 DEFINE_TRACE_WRAPPERS(Document) { 6632 DEFINE_TRACE_WRAPPERS(Document) {
6633 // node_lists_ are traced in their corresponding NodeListsNodeData, keeping
6634 // them only alive for live nodes. Otherwise we would keep lists of dead
6635 // nodes alive that have not yet been invalidated.
6633 visitor->TraceWrappers(imports_controller_); 6636 visitor->TraceWrappers(imports_controller_);
6634 visitor->TraceWrappers(implementation_); 6637 visitor->TraceWrappers(implementation_);
6635 visitor->TraceWrappers(style_sheet_list_); 6638 visitor->TraceWrappers(style_sheet_list_);
6636 visitor->TraceWrappers(style_engine_); 6639 visitor->TraceWrappers(style_engine_);
6637 for (int i = 0; i < kNumNodeListInvalidationTypes; ++i) {
6638 for (auto list : node_lists_[i]) {
6639 if (IsHTMLCollectionType(list->GetType())) {
6640 visitor->TraceWrappersWithManualWriteBarrier(
6641 static_cast<const HTMLCollection*>(list.Get()));
6642 } else {
6643 visitor->TraceWrappersWithManualWriteBarrier(
6644 static_cast<const LiveNodeList*>(list.Get()));
6645 }
6646 }
6647 }
6648 // Cannot trace in Supplementable<Document> as it is part of platform/ and 6640 // Cannot trace in Supplementable<Document> as it is part of platform/ and
6649 // thus cannot refer to ScriptWrappableVisitor. 6641 // thus cannot refer to ScriptWrappableVisitor.
6650 visitor->TraceWrappers( 6642 visitor->TraceWrappers(
6651 static_cast<FontFaceSet*>(Supplementable<Document>::supplements_.at( 6643 static_cast<FontFaceSet*>(Supplementable<Document>::supplements_.at(
6652 FontFaceSet::SupplementName()))); 6644 FontFaceSet::SupplementName())));
6653 ContainerNode::TraceWrappers(visitor); 6645 ContainerNode::TraceWrappers(visitor);
6654 } 6646 }
6655 6647
6656 template class CORE_TEMPLATE_EXPORT Supplement<Document>; 6648 template class CORE_TEMPLATE_EXPORT Supplement<Document>;
6657 6649
6658 } // namespace blink 6650 } // namespace blink
6659 6651
6660 #ifndef NDEBUG 6652 #ifndef NDEBUG
6661 static WeakDocumentSet& liveDocumentSet() { 6653 static WeakDocumentSet& liveDocumentSet() {
6662 DEFINE_STATIC_LOCAL(WeakDocumentSet, set, ()); 6654 DEFINE_STATIC_LOCAL(WeakDocumentSet, set, ());
6663 return set; 6655 return set;
6664 } 6656 }
6665 6657
6666 void showLiveDocumentInstances() { 6658 void showLiveDocumentInstances() {
6667 WeakDocumentSet& set = liveDocumentSet(); 6659 WeakDocumentSet& set = liveDocumentSet();
6668 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6660 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6669 for (blink::Document* document : set) 6661 for (blink::Document* document : set)
6670 fprintf(stderr, "- Document %p URL: %s\n", document, 6662 fprintf(stderr, "- Document %p URL: %s\n", document,
6671 document->Url().GetString().Utf8().Data()); 6663 document->Url().GetString().Utf8().Data());
6672 } 6664 }
6673 #endif 6665 #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