| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 DCHECK(get()); | 100 DCHECK(get()); |
| 101 return *get(); | 101 return *get(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 T* operator->() const | 104 T* operator->() const |
| 105 { | 105 { |
| 106 DCHECK(get()); | 106 DCHECK(get()); |
| 107 return get(); | 107 return get(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 typedef RefPtr<WeakReference<T>> (WeakPtr::*UnspecifiedBoolType); | 110 explicit operator bool() const { return get(); } |
| 111 operator UnspecifiedBoolType() const { return get() ? &WeakPtr::m_ref : 0; } | |
| 112 | 111 |
| 113 private: | 112 private: |
| 114 RefPtr<WeakReference<T>> m_ref; | 113 RefPtr<WeakReference<T>> m_ref; |
| 115 }; | 114 }; |
| 116 | 115 |
| 117 template<typename T, typename U> inline bool operator==(const WeakPtr<T>& a, con
st WeakPtr<U>& b) | 116 template<typename T, typename U> inline bool operator==(const WeakPtr<T>& a, con
st WeakPtr<U>& b) |
| 118 { | 117 { |
| 119 return a.get() == b.get(); | 118 return a.get() == b.get(); |
| 120 } | 119 } |
| 121 | 120 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 RefPtr<WeakReference<T>> m_ref; | 158 RefPtr<WeakReference<T>> m_ref; |
| 160 }; | 159 }; |
| 161 | 160 |
| 162 } // namespace WTF | 161 } // namespace WTF |
| 163 | 162 |
| 164 using WTF::WeakPtr; | 163 using WTF::WeakPtr; |
| 165 using WTF::WeakPtrFactory; | 164 using WTF::WeakPtrFactory; |
| 166 using WTF::WeakReference; | 165 using WTF::WeakReference; |
| 167 | 166 |
| 168 #endif | 167 #endif |
| OLD | NEW |