| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 void clear() | 51 void clear() |
| 52 { | 52 { |
| 53 ASSERT(m_boundThread == currentThread()); | 53 ASSERT(m_boundThread == currentThread()); |
| 54 m_ptr = 0; | 54 m_ptr = 0; |
| 55 } | 55 } |
| 56 | 56 |
| 57 void bindTo(T* ptr) | 57 void bindTo(T* ptr) |
| 58 { | 58 { |
| 59 ASSERT(!m_ptr); | 59 ASSERT(!m_ptr); |
| 60 #ifndef NDEBUG | 60 #if ENABLE(ASSERT) |
| 61 m_boundThread = currentThread(); | 61 m_boundThread = currentThread(); |
| 62 #endif | 62 #endif |
| 63 m_ptr = ptr; | 63 m_ptr = ptr; |
| 64 } | 64 } |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 WeakReference() : m_ptr(0) { } | 67 WeakReference() : m_ptr(0) { } |
| 68 | 68 |
| 69 explicit WeakReference(T* ptr) | 69 explicit WeakReference(T* ptr) |
| 70 : m_ptr(ptr) | 70 : m_ptr(ptr) |
| 71 #ifndef NDEBUG | 71 #if ENABLE(ASSERT) |
| 72 , m_boundThread(currentThread()) | 72 , m_boundThread(currentThread()) |
| 73 #endif | 73 #endif |
| 74 { | 74 { |
| 75 } | 75 } |
| 76 | 76 |
| 77 T* m_ptr; | 77 T* m_ptr; |
| 78 #ifndef NDEBUG | 78 #if ENABLE(ASSERT) |
| 79 ThreadIdentifier m_boundThread; | 79 ThreadIdentifier m_boundThread; |
| 80 #endif | 80 #endif |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 template<typename T> | 83 template<typename T> |
| 84 class WeakPtr { | 84 class WeakPtr { |
| 85 WTF_MAKE_FAST_ALLOCATED; | 85 WTF_MAKE_FAST_ALLOCATED; |
| 86 public: | 86 public: |
| 87 WeakPtr() { } | 87 WeakPtr() { } |
| 88 WeakPtr(std::nullptr_t) { } | 88 WeakPtr(std::nullptr_t) { } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 RefPtr<WeakReference<T> > m_ref; | 144 RefPtr<WeakReference<T> > m_ref; |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 } // namespace WTF | 147 } // namespace WTF |
| 148 | 148 |
| 149 using WTF::WeakPtr; | 149 using WTF::WeakPtr; |
| 150 using WTF::WeakPtrFactory; | 150 using WTF::WeakPtrFactory; |
| 151 using WTF::WeakReference; | 151 using WTF::WeakReference; |
| 152 | 152 |
| 153 #endif | 153 #endif |
| OLD | NEW |