Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Unified Diff: third_party/WebKit/Source/platform/AsyncMethodRunner.h

Issue 1580883002: Oilpan: move AsyncMethodRunner to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rename to RawPtrOrMemberTrait<> Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
« no previous file with comments | « third_party/WebKit/Source/modules/notifications/Notification.cpp ('k') | third_party/WebKit/Source/platform/heap/Handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698