Index: third_party/WebKit/Source/platform/AsyncMethodRunner.h |
diff --git a/third_party/WebKit/Source/platform/AsyncMethodRunner.h b/third_party/WebKit/Source/platform/AsyncMethodRunner.h |
index 1167dedaf1f00f86e101daa004a3cd0350832907..ae09aaad531e3ed3430391dd3289561677c29f3d 100644 |
--- a/third_party/WebKit/Source/platform/AsyncMethodRunner.h |
+++ b/third_party/WebKit/Source/platform/AsyncMethodRunner.h |
@@ -38,18 +38,17 @@ |
namespace blink { |
template <typename TargetClass> |
-class AsyncMethodRunner final { |
+class AsyncMethodRunner final : public GarbageCollectedFinalized<AsyncMethodRunner<TargetClass>> { |
WTF_MAKE_NONCOPYABLE(AsyncMethodRunner); |
- USING_FAST_MALLOC(AsyncMethodRunner); |
public: |
typedef void (TargetClass::*TargetMethod)(); |
- AsyncMethodRunner(TargetClass* object, TargetMethod method) |
- : m_timer(this, &AsyncMethodRunner<TargetClass>::fired) |
- , m_object(object) |
- , m_method(method) |
- , m_suspended(false) |
- , m_runWhenResumed(false) |
+ static AsyncMethodRunner* create(TargetClass* object, TargetMethod method) |
+ { |
+ return new AsyncMethodRunner(object, method); |
+ } |
+ |
+ ~AsyncMethodRunner() |
{ |
} |
@@ -119,23 +118,37 @@ public: |
return m_timer.isActive(); |
} |
+ DEFINE_INLINE_TRACE() |
+ { |
+#if ENABLE(OILPAN) |
+ visitor->trace(m_object); |
+#else |
+ TraceIfNeeded<typename RawPtrOrMemberTrait<TargetClass>::Type>::trace(visitor, m_object); |
+#endif |
+ } |
+ |
private: |
+ AsyncMethodRunner(TargetClass* object, TargetMethod method) |
+ : m_timer(this, &AsyncMethodRunner<TargetClass>::fired) |
+ , m_object(object) |
+ , m_method(method) |
+ , m_suspended(false) |
+ , m_runWhenResumed(false) |
+ { |
+ } |
+ |
void fired(Timer<AsyncMethodRunner<TargetClass>>*) |
{ |
- // TODO(Oilpan): when AsyncMethodRunner is on the heap, this check becomes |
- // redundant; handled directly by Timer<> instead. |
- if (!TimerIsObjectAliveTrait<TargetClass>::isHeapObjectAlive(m_object)) |
- return; |
(m_object->*m_method)(); |
} |
Timer<AsyncMethodRunner<TargetClass>> m_timer; |
- // TODO(Oilpan): AsyncMethodRunner should be moved to the heap and m_object should be traced. |
- // This raw pointer is safe as long as AsyncMethodRunner<X> is held by the X itself |
- // (That's the case in the current code base). |
- GC_PLUGIN_IGNORE("363031") |
- TargetClass* m_object; |
+#if ENABLE(OILPAN) |
+ Member<TargetClass> m_object; |
+#else |
+ typename RawPtrOrMemberTrait<TargetClass>::Type m_object; |
+#endif |
TargetMethod m_method; |
bool m_suspended; |