#ifndef GCActivityCallback_h
#define GCActivityCallback_h
+#include "HeapTimer.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
class Heap;
-class GCActivityCallback {
+class GCActivityCallback : public HeapTimer {
+ WTF_MAKE_FAST_ALLOCATED;
public:
- virtual ~GCActivityCallback() { }
virtual void didAllocate(size_t) { }
virtual void willCollect() { }
- virtual void synchronize() { }
virtual void cancel() { }
- virtual void didStartVMShutdown() { }
- virtual void invalidate() { }
+ bool isEnabled() const { return m_enabled; }
+ void setEnabled(bool enabled) { m_enabled = enabled; }
+#if PLATFORM(IOS)
static bool s_shouldCreateGCTimer;
+#endif // PLATFORM(IOS)
protected:
- GCActivityCallback() {}
-};
+#if USE(CF)
+ GCActivityCallback(VM* vm, CFRunLoopRef runLoop)
+ : HeapTimer(vm, runLoop)
+ , m_enabled(true)
+ {
+ }
+#elif PLATFORM(EFL)
+ GCActivityCallback(VM* vm, bool flag)
+ : HeapTimer(vm)
+ , m_enabled(flag)
+ {
+ }
+#else
+ GCActivityCallback(VM* vm)
+ : HeapTimer(vm)
+ , m_enabled(true)
+ {
+ }
+#endif
-struct DefaultGCActivityCallbackPlatformData;
+ bool m_enabled;
+};
class DefaultGCActivityCallback : public GCActivityCallback {
public:
- static DefaultGCActivityCallback* create(Heap*);
+ static PassOwnPtr<DefaultGCActivityCallback> create(Heap*);
DefaultGCActivityCallback(Heap*);
- JS_EXPORT_PRIVATE virtual ~DefaultGCActivityCallback();
-
+#if PLATFORM(IOS)
JS_EXPORT_PRIVATE virtual void didAllocate(size_t);
JS_EXPORT_PRIVATE virtual void willCollect();
- JS_EXPORT_PRIVATE virtual void synchronize();
JS_EXPORT_PRIVATE virtual void cancel();
- JS_EXPORT_PRIVATE virtual void didStartVMShutdown();
- JS_EXPORT_PRIVATE virtual void invalidate();
+
+ JS_EXPORT_PRIVATE virtual void doWork();
+#else
+ virtual void didAllocate(size_t);
+ virtual void willCollect();
+ virtual void cancel();
+
+ virtual void doWork();
+#endif
#if USE(CF)
protected:
+#if PLATFORM(IOS)
JS_EXPORT_PRIVATE DefaultGCActivityCallback(Heap*, CFRunLoopRef);
- void commonConstructor(Heap*, CFRunLoopRef);
+#else
+ DefaultGCActivityCallback(Heap*, CFRunLoopRef);
+#endif // PLATFORM(IOS)
#endif
+#if USE(CF) || PLATFORM(QT) || PLATFORM(EFL)
+protected:
+ void cancelTimer();
+ void scheduleTimer(double);
private:
- OwnPtr<DefaultGCActivityCallbackPlatformData> d;
+ double m_delay;
+#endif
};
-inline DefaultGCActivityCallback* DefaultGCActivityCallback::create(Heap* heap)
+inline PassOwnPtr<DefaultGCActivityCallback> DefaultGCActivityCallback::create(Heap* heap)
{
+#if PLATFORM(IOS)
// Big hack.
if (GCActivityCallback::s_shouldCreateGCTimer)
- return new DefaultGCActivityCallback(heap);
- return 0;
+ return adoptPtr(new DefaultGCActivityCallback(heap));
+ return nullptr;
+#else
+ return adoptPtr(new DefaultGCActivityCallback(heap));
+#endif // PLATFORM(IOS)
}
}