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

Side by Side Diff: Source/heap/Handle.h

Issue 168963003: Make WebPrivatePtr capable of wrapping garbage collected objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Temporarily drop back to using .reset() instead of nullptr. Created 6 years, 10 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 | Source/modules/speech/SpeechGrammar.h » ('j') | public/platform/WebPrivatePtr.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 ASSERT(this == static_cast<PersistentNode*>(this)); 535 ASSERT(this == static_cast<PersistentNode*>(this));
536 const char* n = FieldAnnotationBase::fromAddress(this); 536 const char* n = FieldAnnotationBase::fromAddress(this);
537 return n ? n : "CollectionPersistent"; 537 return n ? n : "CollectionPersistent";
538 } 538 }
539 #endif 539 #endif
540 540
541 private: 541 private:
542 Collection m_collection; 542 Collection m_collection;
543 }; 543 };
544 544
545 // Template aliases for the transition period where we want to support 545 // CPP-defined type names for the transition period where we want to
546 // both reference counting and garbage collection based on a 546 // support both reference counting and garbage collection based on a
547 // compile-time flag. 547 // compile-time flag.
548 // 548 //
549 // With clang we can use c++11 template aliases which is really what 549 // C++11 template aliases were initially used (with clang only, not
550 // we want. For GCC and MSVC we simulate the template aliases with 550 // with GCC nor MSVC.) However, supporting both CPP defines and
551 // stylized macros until we can use template aliases. 551 // template aliases is problematic from outside a WebCore namespace
552 // when Oilpan is disabled: e.g.,
553 // WebCore::RefCountedWillBeGarbageCollected as a template alias would
554 // uniquely resolve from within any namespace, but if it is backed by
555 // a CPP #define, it would expand to WebCore::RefCounted, and not the
556 // required WTF::RefCounted.
557 //
558 // Having the CPP expansion instead be fully namespace qualified, and the
559 // transition type be unqualified, would dually not work for template
560 // aliases. So, slightly unfortunately, fall back/down to the lowest
561 // commmon denominator of using CPP macros only.
552 #if ENABLE(OILPAN) 562 #if ENABLE(OILPAN)
553 563 #define PassRefPtrWillBeRawPtr WTF::RawPtr
554 #if COMPILER(CLANG) 564 #define RefCountedWillBeGarbageCollected WebCore::GarbageCollected
555 template<typename T> using PassRefPtrWillBeRawPtr = RawPtr<T>; 565 #define RefCountedWillBeGarbageCollectedFinalized WebCore::GarbageCollectedFinal ized
556 template<typename T> using RefCountedWillBeGarbageCollected = GarbageCollected<T >; 566 #define RefCountedWillBeRefCountedGarbageCollected WebCore::RefCountedGarbageCol lected
557 template<typename T> using RefCountedWillBeGarbageCollectedFinalized = GarbageCo llectedFinalized<T>; 567 #define RefPtrWillBePersistent WebCore::Persistent
558 template<typename T> using RefCountedWillBeRefCountedGarbageCollected = RefCount edGarbageCollected<T>; 568 #define RefPtrWillBeRawPtr WTF::RawPtr
559 template<typename T> using RefPtrWillBePersistent = Persistent<T>; 569 #define RefPtrWillBeMember WebCore::Member
560 template<typename T> using RefPtrWillBeRawPtr = RawPtr<T>; 570 #define RawPtrWillBeMember WebCore::Member
561 template<typename T> using RefPtrWillBeMember = Member<T>; 571 #define RawPtrWillBeWeakMember WebCore::WeakMember
562 template<typename T> using RawPtrWillBeMember = Member<T>; 572 #define OwnPtrWillBeMember WebCore::Member
563 template<typename T> using RawPtrWillBeWeakMember = WeakMember<T>; 573 #define PassOwnPtrWillBeRawPtr WTF::RawPtr
564 template<typename T> using OwnPtrWillBeMember = Member<T>; 574 #define NoBaseWillBeGarbageCollected WebCore::GarbageCollected
565 template<typename T> using PassOwnPtrWillBeRawPtr = RawPtr<T>; 575 #define NoBaseWillBeGarbageCollectedFinalized WebCore::GarbageCollectedFinalized
566 template<typename T> using NoBaseWillBeGarbageCollected = GarbageCollected<T>; 576 #define WillBeHeapHashMap WebCore::HeapHashMap
567 template<typename T> using NoBaseWillBeGarbageCollectedFinalized = GarbageCollec tedFinalized<T>; 577 #define WillBePersistentHeapHashMap WebCore::PersistentHeapHashMap
568 template< 578 #define WillBeHeapHashSet WebCore::HeapHashSet
569 typename K, 579 #define WillBePersistentHeapHashSet WebCore::PersistentHeapHashSet
570 typename V, 580 #define WillBeHeapVector WebCore::HeapVector
571 typename H = typename DefaultHash<K>::Hash, 581 #define WillBePersistentHeapVector WebCore::PersistentHeapVector
572 typename KT = HashTraits<K>,
573 typename VT = HashTraits<V> >
574 using WillBeHeapHashMap = HeapHashMap<K, V, H, KT, VT>;
575 template<
576 typename K,
577 typename V,
578 typename H = typename DefaultHash<K>::Hash,
579 typename KT = HashTraits<K>,
580 typename VT = HashTraits<V> >
581 using WillBePersistentHeapHashMap = PersistentHeapHashMap<K, V, H, KT, VT>;
582 template<
583 typename V,
584 typename H = typename DefaultHash<V>::Hash,
585 typename T = HashTraits<V> >
586 using WillBeHeapHashSet = HeapHashSet<V, H, T>;
587 template<
588 typename V,
589 typename H = typename DefaultHash<V>::Hash,
590 typename T = HashTraits<V> >
591 using WillBePersistentHeapHashSet = PersistentHeapHashSet<V, H, T>;
592 template<typename T, size_t inlineCapacity = 0>
593 using WillBeHeapVector = HeapVector<T, inlineCapacity>;
594 template<typename T, size_t inlineCapacity = 0>
595 using WillBePersistentHeapVector = PersistentHeapVector<T, inlineCapacity>;
596 #else // !COMPILER(CLANG)
597 #define PassRefPtrWillBeRawPtr RawPtr
598 #define RefCountedWillBeGarbageCollected GarbageCollected
599 #define RefCountedWillBeGarbageCollectedFinalized GarbageCollectedFinalized
600 #define RefCountedWillBeRefCountedGarbageCollected RefCountedGarbageCollected
601 #define RefPtrWillBePersistent Persistent
602 #define RefPtrWillBeRawPtr RawPtr
603 #define RefPtrWillBeMember Member
604 #define RawPtrWillBeMember Member
605 #define RawPtrWillBeWeakMember WeakMember
606 #define OwnPtrWillBeMember Member
607 #define PassOwnPtrWillBeRawPtr RawPtr
608 #define NoBaseWillBeGarbageCollected GarbageCollected
609 #define NoBaseWillBeGarbageCollectedFinalized GarbageCollectedFinalized
610 #define WillBeHeapHashMap HeapHashMap
611 #define WillBePersistentHeapHashMap PersistentHeapHashMap
612 #define WillBeHeapHashSet HeapHashSet
613 #define WillBePersistentHeapHashSet PersistentHeapHashSet
614 #define WillBeHeapVector HeapVector
615 #define WillBePersistentHeapVector PersistentHeapVector
616 #endif // COMPILER(CLANG)
617 582
618 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefWillBeNoop(T* ptr) 583 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefWillBeNoop(T* ptr)
619 { 584 {
620 static const bool notRefCountedGarbageCollected = !WTF::IsSubclassOfTemplate <T, RefCountedGarbageCollected>::value; 585 static const bool notRefCountedGarbageCollected = !WTF::IsSubclassOfTemplate <T, RefCountedGarbageCollected>::value;
621 static const bool notRefCounted = !WTF::IsSubclassOfTemplate<T, RefCounted>: :value; 586 static const bool notRefCounted = !WTF::IsSubclassOfTemplate<T, RefCounted>: :value;
622 COMPILE_ASSERT(notRefCountedGarbageCollected, useAdoptRefCountedWillBeRefCou ntedGarbageCollected); 587 COMPILE_ASSERT(notRefCountedGarbageCollected, useAdoptRefCountedWillBeRefCou ntedGarbageCollected);
623 COMPILE_ASSERT(notRefCounted, youMustAdopt); 588 COMPILE_ASSERT(notRefCounted, youMustAdopt);
624 return PassRefPtrWillBeRawPtr<T>(ptr); 589 return PassRefPtrWillBeRawPtr<T>(ptr);
625 } 590 }
626 591
(...skipping 17 matching lines...) Expand all
644 609
645 #else // !ENABLE(OILPAN) 610 #else // !ENABLE(OILPAN)
646 611
647 template<typename T> 612 template<typename T>
648 class DummyBase { 613 class DummyBase {
649 public: 614 public:
650 DummyBase() { } 615 DummyBase() { }
651 ~DummyBase() { } 616 ~DummyBase() { }
652 }; 617 };
653 618
654 #if COMPILER(CLANG) 619 #define PassRefPtrWillBeRawPtr WTF::PassRefPtr
655 template<typename T> using PassRefPtrWillBeRawPtr = PassRefPtr<T>; 620 #define RefCountedWillBeGarbageCollected WTF::RefCounted
656 template<typename T> using RefCountedWillBeGarbageCollected = RefCounted<T>; 621 #define RefCountedWillBeGarbageCollectedFinalized WTF::RefCounted
657 template<typename T> using RefCountedWillBeGarbageCollectedFinalized = RefCounte d<T>; 622 #define RefCountedWillBeRefCountedGarbageCollected WTF::RefCounted
658 template<typename T> using RefCountedWillBeRefCountedGarbageCollected = RefCount ed<T>; 623 #define RefPtrWillBePersistent WTF::RefPtr
659 template<typename T> using RefPtrWillBePersistent = RefPtr<T>; 624 #define RefPtrWillBeRawPtr WTF::RefPtr
660 template<typename T> using RefPtrWillBeRawPtr = RefPtr<T>; 625 #define RefPtrWillBeMember WTF::RefPtr
661 template<typename T> using RefPtrWillBeMember = RefPtr<T>; 626 #define RawPtrWillBeMember WTF::RawPtr
662 template<typename T> using RawPtrWillBeMember = RawPtr<T>; 627 #define RawPtrWillBeWeakMember WTF::RawPtr
663 template<typename T> using RawPtrWillBeWeakMember = RawPtr<T>; 628 #define OwnPtrWillBeMember WTF::OwnPtr
664 template<typename T> using OwnPtrWillBeMember = OwnPtr<T>; 629 #define PassOwnPtrWillBeRawPtr WTF::PassOwnPtr
665 template<typename T> using PassOwnPtrWillBeRawPtr = PassOwnPtr<T>; 630 #define NoBaseWillBeGarbageCollected WebCore::DummyBase
666 template<typename T> using NoBaseWillBeGarbageCollected = DummyBase<T>; 631 #define NoBaseWillBeGarbageCollectedFinalized WebCore::DummyBase
667 template<typename T> using NoBaseWillBeGarbageCollectedFinalized = DummyBase<T>; 632 #define WillBeHeapHashMap WTF::HashMap
668 template< 633 #define WillBePersistentHeapHashMap WTF::HashMap
669 typename K, 634 #define WillBeHeapHashSet WTF::HashSet
670 typename V, 635 #define WillBePersistentHeapHashSet WTF::HashSet
671 typename H = typename DefaultHash<K>::Hash, 636 #define WillBeHeapVector WTF::Vector
672 typename KT = HashTraits<K>, 637 #define WillBePersistentHeapVector WTF::Vector
673 typename VT = HashTraits<V> >
674 using WillBeHeapHashMap = HashMap<K, V, H, KT, VT>;
675 template<
676 typename K,
677 typename V,
678 typename H = typename DefaultHash<K>::Hash,
679 typename KT = HashTraits<K>,
680 typename VT = HashTraits<V> >
681 using WillBePersistentHeapHashMap = HashMap<K, V, H, KT, VT>;
682 template<
683 typename V,
684 typename H = typename DefaultHash<V>::Hash,
685 typename T = HashTraits<V> >
686 using WillBeHeapHashSet = HashSet<V, H, T>;
687 template<
688 typename V,
689 typename H = typename DefaultHash<V>::Hash,
690 typename T = HashTraits<V> >
691 using WillBePersistentHeapHashSet = HashSet<V, H, T>;
692 template<typename T, size_t inlineCapacity = 0>
693 using WillBeHeapVector = Vector<T, inlineCapacity>;
694 template<typename T, size_t inlineCapacity = 0>
695 using WillBePersistentHeapVector = Vector<T, inlineCapacity>;
696 #else // !COMPILER(CLANG)
697 #define PassRefPtrWillBeRawPtr PassRefPtr
698 #define RefCountedWillBeGarbageCollected RefCounted
699 #define RefCountedWillBeGarbageCollectedFinalized RefCounted
700 #define RefCountedWillBeRefCountedGarbageCollected RefCounted
701 #define RefPtrWillBePersistent RefPtr
702 #define RefPtrWillBeRawPtr RefPtr
703 #define RefPtrWillBeMember RefPtr
704 #define RawPtrWillBeMember RawPtr
705 #define RawPtrWillBeWeakMember RawPtr
706 #define OwnPtrWillBeMember OwnPtr
707 #define PassOwnPtrWillBeRawPtr PassOwnPtr
708 #define NoBaseWillBeGarbageCollected DummyBase
709 #define NoBaseWillBeGarbageCollectedFinalized DummyBase
710 #define WillBeHeapHashMap HashMap
711 #define WillBePersistentHeapHashMap HashMap
712 #define WillBeHeapHashSet HashSet
713 #define WillBePersistentHeapHashSet HashSet
714 #define WillBeHeapVector Vector
715 #define WillBePersistentHeapVector Vector
716 #endif // COMPILER(CLANG)
717 638
718 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefWillBeNoop(T* ptr) { retu rn adoptRef(ptr); } 639 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefWillBeNoop(T* ptr) { retu rn adoptRef(ptr); }
719 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefCountedWillBeRefCountedGa rbageCollected(T* ptr) { return adoptRef(ptr); } 640 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefCountedWillBeRefCountedGa rbageCollected(T* ptr) { return adoptRef(ptr); }
720 template<typename T> PassOwnPtrWillBeRawPtr<T> adoptPtrWillBeNoop(T* ptr) { retu rn adoptPtr(ptr); } 641 template<typename T> PassOwnPtrWillBeRawPtr<T> adoptPtrWillBeNoop(T* ptr) { retu rn adoptPtr(ptr); }
721 642
722 #define WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED WTF_MAKE_FAST_ALLOCATED 643 #define WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED WTF_MAKE_FAST_ALLOCATED
723 644
724 #endif // ENABLE(OILPAN) 645 #endif // ENABLE(OILPAN)
725 646
726 } // namespace WebCore 647 } // namespace WebCore
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 }; 753 };
833 754
834 template<typename T> inline T* getPtr(const WebCore::Member<T>& p) 755 template<typename T> inline T* getPtr(const WebCore::Member<T>& p)
835 { 756 {
836 return p.get(); 757 return p.get();
837 } 758 }
838 759
839 } // namespace WTF 760 } // namespace WTF
840 761
841 #endif 762 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/modules/speech/SpeechGrammar.h » ('j') | public/platform/WebPrivatePtr.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698