| OLD | NEW |
| 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 WeakPtr<T> createWeakPtr() { return WeakPtr<T>(m_ref); } | 133 WeakPtr<T> createWeakPtr() { return WeakPtr<T>(m_ref); } |
| 134 | 134 |
| 135 void revokeAll() | 135 void revokeAll() |
| 136 { | 136 { |
| 137 T* ptr = m_ref->get(); | 137 T* ptr = m_ref->get(); |
| 138 m_ref->clear(); | 138 m_ref->clear(); |
| 139 // We create a new WeakReference so that future calls to createWeakPtr()
create nonzero WeakPtrs. | 139 // We create a new WeakReference so that future calls to createWeakPtr()
create nonzero WeakPtrs. |
| 140 m_ref = WeakReference<T>::create(ptr); | 140 m_ref = WeakReference<T>::create(ptr); |
| 141 } | 141 } |
| 142 | 142 |
| 143 bool hasWeakPtrs() const |
| 144 { |
| 145 return m_ref->refCount() > 1; |
| 146 } |
| 147 |
| 143 private: | 148 private: |
| 144 RefPtr<WeakReference<T>> m_ref; | 149 RefPtr<WeakReference<T>> m_ref; |
| 145 }; | 150 }; |
| 146 | 151 |
| 147 } // namespace WTF | 152 } // namespace WTF |
| 148 | 153 |
| 149 using WTF::WeakPtr; | 154 using WTF::WeakPtr; |
| 150 using WTF::WeakPtrFactory; | 155 using WTF::WeakPtrFactory; |
| 151 using WTF::WeakReference; | 156 using WTF::WeakReference; |
| 152 | 157 |
| 153 #endif | 158 #endif |
| OLD | NEW |