OLD | NEW |
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 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 { | 1148 { |
1149 assign(self); | 1149 assign(self); |
1150 return *this; | 1150 return *this; |
1151 } | 1151 } |
1152 | 1152 |
1153 void clear() | 1153 void clear() |
1154 { | 1154 { |
1155 m_keepAlive.clear(); | 1155 m_keepAlive.clear(); |
1156 } | 1156 } |
1157 | 1157 |
1158 typedef OwnPtr<Persistent<Self>> (SelfKeepAlive::*UnspecifiedBoolType); | 1158 typedef Persistent<Self> (SelfKeepAlive::*UnspecifiedBoolType); |
1159 operator UnspecifiedBoolType() const { return m_keepAlive ? &SelfKeepAlive::
m_keepAlive : 0; } | 1159 operator UnspecifiedBoolType() const { return m_keepAlive ? &SelfKeepAlive::
m_keepAlive : 0; } |
1160 | 1160 |
1161 private: | 1161 private: |
1162 void assign(Self* self) | 1162 void assign(Self* self) |
1163 { | 1163 { |
1164 ASSERT(!m_keepAlive || m_keepAlive->get() == self); | 1164 ASSERT(!m_keepAlive || m_keepAlive.get() == self); |
1165 if (!m_keepAlive) | 1165 m_keepAlive = self; |
1166 m_keepAlive = adoptPtr(new Persistent<Self>); | |
1167 *m_keepAlive = self; | |
1168 } | 1166 } |
1169 | 1167 |
1170 GC_PLUGIN_IGNORE("420515") | 1168 GC_PLUGIN_IGNORE("420515") |
1171 OwnPtr<Persistent<Self>> m_keepAlive; | 1169 Persistent<Self> m_keepAlive; |
1172 }; | 1170 }; |
1173 | 1171 |
1174 template<typename T> | 1172 template<typename T> |
1175 class AllowCrossThreadWeakPersistent { | 1173 class AllowCrossThreadWeakPersistent { |
1176 STACK_ALLOCATED(); | 1174 STACK_ALLOCATED(); |
1177 public: | 1175 public: |
1178 explicit AllowCrossThreadWeakPersistent(T* value) : m_value(value) { } | 1176 explicit AllowCrossThreadWeakPersistent(T* value) : m_value(value) { } |
1179 CrossThreadWeakPersistent<T> value() const { return m_value; } | 1177 CrossThreadWeakPersistent<T> value() const { return m_value; } |
1180 private: | 1178 private: |
1181 CrossThreadWeakPersistent<T> m_value; | 1179 CrossThreadWeakPersistent<T> m_value; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1382 // TODO(sof): extend WTF::FunctionWrapper call overloading to also handle (C
rossThread)WeakPersistent. | 1380 // TODO(sof): extend WTF::FunctionWrapper call overloading to also handle (C
rossThread)WeakPersistent. |
1383 static T* unwrap(const StorageType& value) { return value.get(); } | 1381 static T* unwrap(const StorageType& value) { return value.get(); } |
1384 }; | 1382 }; |
1385 | 1383 |
1386 template<typename T> | 1384 template<typename T> |
1387 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; | 1385 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; |
1388 | 1386 |
1389 } // namespace WTF | 1387 } // namespace WTF |
1390 | 1388 |
1391 #endif | 1389 #endif |
OLD | NEW |