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

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

Issue 20123003: [oilpan] The Node hierarchy should have correct accept method chains (Closed) Base URL: svn://svn.chromium.org/blink/branches/oilpan
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 return Result<T>(static_cast<T*>(other.releaseRaw())); 755 return Result<T>(static_cast<T*>(other.releaseRaw()));
756 } 756 }
757 757
758 typedef T* (Result::*UnspecifiedBoolType); 758 typedef T* (Result::*UnspecifiedBoolType);
759 operator UnspecifiedBoolType() const 759 operator UnspecifiedBoolType() const
760 { 760 {
761 // See the comment in operator!(). 761 // See the comment in operator!().
762 return releaseRaw() ? &Result::m_raw : 0; 762 return releaseRaw() ? &Result::m_raw : 0;
763 } 763 }
764 764
765 // FIXME(oilpan): Make this private.
766 T* releaseRaw() const
767 {
768 T* raw = m_raw;
769 m_raw = 0;
770 #ifndef NDEBUG
771 m_doNotAllocate.release();
772 #endif
773 return raw;
774 }
775
776 // FIXME(oilpan): Remove once TreeShared no longer requires reference counti ng. 765 // FIXME(oilpan): Remove once TreeShared no longer requires reference counti ng.
777 PassRefPtr<T> passRefPtr() const 766 PassRefPtr<T> passRefPtr() const
778 { 767 {
779 return PassRefPtr<T>(releaseRaw()); 768 return PassRefPtr<T>(releaseRaw());
780 } 769 }
781 770
782 private: 771 private:
783 explicit Result(T* raw) 772 explicit Result(T* raw)
784 : m_raw(raw) 773 : m_raw(raw)
785 #ifndef NDEBUG 774 #ifndef NDEBUG
786 , m_doNotAllocate() 775 , m_doNotAllocate()
787 #endif 776 #endif
788 { 777 {
789 } 778 }
790 779
780 T* releaseRaw() const
781 {
782 T* raw = m_raw;
783 m_raw = 0;
784 #ifndef NDEBUG
785 m_doNotAllocate.release();
786 #endif
787 return raw;
788 }
789
791 // Mutable to allow raw() to steal the pointer when creating a 790 // Mutable to allow raw() to steal the pointer when creating a
792 // Handle from the Result. 791 // Handle from the Result.
793 mutable T* m_raw; 792 mutable T* m_raw;
794 793
795 #ifndef NDEBUG 794 #ifndef NDEBUG
796 mutable NoAllocation m_doNotAllocate; 795 mutable NoAllocation m_doNotAllocate;
797 #endif 796 #endif
798 797
799 template<typename U> friend class Persistent; 798 template<typename U> friend class Persistent;
800 template<typename U> friend class Handle; 799 template<typename U> friend class Handle;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 return *this; 955 return *this;
957 } 956 }
958 957
959 template<typename U> 958 template<typename U>
960 bool operator==(const Handle<U>& other) const 959 bool operator==(const Handle<U>& other) const
961 { 960 {
962 return other.raw() == raw(); 961 return other.raw() == raw();
963 } 962 }
964 963
965 template<typename U> 964 template<typename U>
965 bool operator!=(const Handle<U>& other) const
966 {
967 return other.raw() != raw();
968 }
969
970 template<typename U>
966 bool operator==(const Persistent<U>& other) const 971 bool operator==(const Persistent<U>& other) const
967 { 972 {
968 return other.raw() == raw(); 973 return other.raw() == raw();
969 } 974 }
970 975
971 template<typename U> 976 template<typename U>
972 bool operator==(const Member<U>& other) const 977 bool operator==(const Member<U>& other) const
973 { 978 {
974 return other.raw() == raw(); 979 return other.raw() == raw();
975 } 980 }
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 1259
1255 // PtrHash is the default hash for hash tables with members, but you can use 1260 // PtrHash is the default hash for hash tables with members, but you can use
1256 // HeapObjectHash<T> instead. 1261 // HeapObjectHash<T> instead.
1257 template<typename T> struct DefaultHash<WebCore::Member<T> > { 1262 template<typename T> struct DefaultHash<WebCore::Member<T> > {
1258 typedef PtrHash<WebCore::Member<T> > Hash; 1263 typedef PtrHash<WebCore::Member<T> > Hash;
1259 }; 1264 };
1260 1265
1261 } 1266 }
1262 1267
1263 #endif 1268 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698