OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CancellableTaskFactory_h | 5 #ifndef CancellableTaskFactory_h |
6 #define CancellableTaskFactory_h | 6 #define CancellableTaskFactory_h |
7 | 7 |
8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
9 #include "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
10 #include "public/platform/WebScheduler.h" | 10 #include "public/platform/WebScheduler.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 // In the Oilpan case, as WTF::Closure objects are off-heap, we have to cons
truct the | 33 // In the Oilpan case, as WTF::Closure objects are off-heap, we have to cons
truct the |
34 // closure in such a manner that it doesn't end up referring back to the own
ing heap | 34 // closure in such a manner that it doesn't end up referring back to the own
ing heap |
35 // object with a strong Persistent<> GC root reference. If we do, this will
create | 35 // object with a strong Persistent<> GC root reference. If we do, this will
create |
36 // a heap <-> off-heap cycle and leak, the owning object can never be GCed. | 36 // a heap <-> off-heap cycle and leak, the owning object can never be GCed. |
37 // Instead, the closure will keep an off-heap persistent reference of the we
ak | 37 // Instead, the closure will keep an off-heap persistent reference of the we
ak |
38 // variety, which will refer back to the owner heap object safely (but weakl
y.) | 38 // variety, which will refer back to the owner heap object safely (but weakl
y.) |
39 // | 39 // |
40 template<typename T> | 40 template<typename T> |
41 static PassOwnPtr<CancellableTaskFactory> create(T* thisObject, void (T::*me
thod)(), typename std::enable_if<IsGarbageCollectedType<T>::value>::type* = null
ptr) | 41 static PassOwnPtr<CancellableTaskFactory> create(T* thisObject, void (T::*me
thod)(), typename std::enable_if<IsGarbageCollectedType<T>::value>::type* = null
ptr) |
42 { | 42 { |
43 return adoptPtr(new CancellableTaskFactory(WTF::bind(method, AllowCrossT
hreadWeakPersistent<T>(thisObject)))); | 43 return adoptPtr(new CancellableTaskFactory(WTF::bind(method, CrossThread
WeakPersistentThisPointer<T>(thisObject)))); |
44 } | 44 } |
45 | 45 |
46 template<typename T> | 46 template<typename T> |
47 static PassOwnPtr<CancellableTaskFactory> create(T* thisObject, void (T::*me
thod)(), typename std::enable_if<!IsGarbageCollectedType<T>::value>::type* = nul
lptr) | 47 static PassOwnPtr<CancellableTaskFactory> create(T* thisObject, void (T::*me
thod)(), typename std::enable_if<!IsGarbageCollectedType<T>::value>::type* = nul
lptr) |
48 { | 48 { |
49 return adoptPtr(new CancellableTaskFactory(WTF::bind(method, thisObject)
)); | 49 return adoptPtr(new CancellableTaskFactory(WTF::bind(method, thisObject)
)); |
50 } | 50 } |
51 | 51 |
52 bool isPending() const | 52 bool isPending() const |
53 { | 53 { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 WeakPtr<CancellableTaskFactory> m_weakPtr; | 86 WeakPtr<CancellableTaskFactory> m_weakPtr; |
87 }; | 87 }; |
88 | 88 |
89 OwnPtr<Closure> m_closure; | 89 OwnPtr<Closure> m_closure; |
90 WeakPtrFactory<CancellableTaskFactory> m_weakPtrFactory; | 90 WeakPtrFactory<CancellableTaskFactory> m_weakPtrFactory; |
91 }; | 91 }; |
92 | 92 |
93 } // namespace blink | 93 } // namespace blink |
94 | 94 |
95 #endif // CancellableTaskFactory_h | 95 #endif // CancellableTaskFactory_h |
OLD | NEW |