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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(PassRefPtr<WeakReference<T> > ref) : m_ref(ref) { } | 88 WeakPtr(PassRefPtr<WeakReference<T> > ref) : m_ref(ref) { } |
89 | 89 |
90 T* get() const { return m_ref->get(); } | 90 T* get() const { return m_ref ? m_ref->get() : 0; } |
91 | 91 |
92 private: | 92 private: |
93 RefPtr<WeakReference<T> > m_ref; | 93 RefPtr<WeakReference<T> > m_ref; |
94 }; | 94 }; |
95 | 95 |
96 template<typename T> | 96 template<typename T> |
97 class WeakPtrFactory { | 97 class WeakPtrFactory { |
98 WTF_MAKE_NONCOPYABLE(WeakPtrFactory<T>); | 98 WTF_MAKE_NONCOPYABLE(WeakPtrFactory<T>); |
99 WTF_MAKE_FAST_ALLOCATED; | 99 WTF_MAKE_FAST_ALLOCATED; |
100 public: | 100 public: |
(...skipping 22 matching lines...) Expand all Loading... |
123 RefPtr<WeakReference<T> > m_ref; | 123 RefPtr<WeakReference<T> > m_ref; |
124 }; | 124 }; |
125 | 125 |
126 } // namespace WTF | 126 } // namespace WTF |
127 | 127 |
128 using WTF::WeakPtr; | 128 using WTF::WeakPtr; |
129 using WTF::WeakPtrFactory; | 129 using WTF::WeakPtrFactory; |
130 using WTF::WeakReference; | 130 using WTF::WeakReference; |
131 | 131 |
132 #endif | 132 #endif |
OLD | NEW |