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

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

Issue 1263313003: Oilpan: lazily create SelfKeepAlive<>'s persistent reference. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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
« no previous file with comments | « no previous file | no next file » | 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) 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 913 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 // SelfKeepAlive m_keepAlive; 924 // SelfKeepAlive m_keepAlive;
925 // }; 925 // };
926 // 926 //
927 // The responsibility to call clear() in a timely fashion resides with the imple mentation 927 // The responsibility to call clear() in a timely fashion resides with the imple mentation
928 // of the object. 928 // of the object.
929 // 929 //
930 // 930 //
931 template<typename Self> 931 template<typename Self>
932 class SelfKeepAlive { 932 class SelfKeepAlive {
933 public: 933 public:
934 SelfKeepAlive()
935 {
936 }
937
938 explicit SelfKeepAlive(Self* self)
939 {
940 assign(self);
941 }
942
934 SelfKeepAlive& operator=(Self* self) 943 SelfKeepAlive& operator=(Self* self)
935 { 944 {
936 ASSERT(!m_keepAlive || m_keepAlive.get() == self); 945 assign(self);
937 m_keepAlive = self;
938 return *this; 946 return *this;
939 } 947 }
940 948
941 void clear() 949 void clear()
942 { 950 {
943 m_keepAlive = nullptr; 951 m_keepAlive.clear();
944 } 952 }
945 953
946 typedef Persistent<Self> (SelfKeepAlive::*UnspecifiedBoolType); 954 typedef OwnPtr<Persistent<Self>> (SelfKeepAlive::*UnspecifiedBoolType);
947 operator UnspecifiedBoolType() const { return m_keepAlive ? &SelfKeepAlive:: m_keepAlive : 0; } 955 operator UnspecifiedBoolType() const { return m_keepAlive ? &SelfKeepAlive:: m_keepAlive : 0; }
948 956
949 private: 957 private:
958 void assign(Self* self)
959 {
960 ASSERT(!m_keepAlive || m_keepAlive->get() == self);
961 if (!m_keepAlive)
962 m_keepAlive = adoptPtr(new Persistent<Self>);
963 *m_keepAlive = self;
964 }
965
950 GC_PLUGIN_IGNORE("420515") 966 GC_PLUGIN_IGNORE("420515")
951 Persistent<Self> m_keepAlive; 967 OwnPtr<Persistent<Self>> m_keepAlive;
952 }; 968 };
953 969
954 } // namespace blink 970 } // namespace blink
955 971
956 namespace WTF { 972 namespace WTF {
957 973
958 template <typename T> struct VectorTraits<blink::Member<T>> : VectorTraitsBase<b link::Member<T>> { 974 template <typename T> struct VectorTraits<blink::Member<T>> : VectorTraitsBase<b link::Member<T>> {
959 static const bool needsDestruction = false; 975 static const bool needsDestruction = false;
960 static const bool canInitializeWithMemset = true; 976 static const bool canInitializeWithMemset = true;
961 static const bool canClearUnusedSlotsWithMemset = true; 977 static const bool canClearUnusedSlotsWithMemset = true;
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin k::IsGarbageCollectedType<T>::value> { 1156 struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin k::IsGarbageCollectedType<T>::value> {
1141 static_assert(sizeof(T), "T must be fully defined"); 1157 static_assert(sizeof(T), "T must be fully defined");
1142 }; 1158 };
1143 1159
1144 template<typename T> 1160 template<typename T>
1145 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; 1161 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete;
1146 1162
1147 } // namespace WTF 1163 } // namespace WTF
1148 1164
1149 #endif 1165 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698