#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 operator()() {}
- virtual void synchronize() {}
+ virtual void didAllocate(size_t) { }
+ virtual void willCollect() { }
+ virtual void cancel() { }
+ 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 PassOwnPtr<DefaultGCActivityCallback> create(Heap*);
DefaultGCActivityCallback(Heap*);
- ~DefaultGCActivityCallback();
-
- void operator()();
- void synchronize();
+#if PLATFORM(IOS)
+ JS_EXPORT_PRIVATE virtual void didAllocate(size_t);
+ JS_EXPORT_PRIVATE virtual void willCollect();
+ JS_EXPORT_PRIVATE virtual void cancel();
+
+ 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);
+#else
DefaultGCActivityCallback(Heap*, CFRunLoopRef);
- void commonConstructor(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 PassOwnPtr<DefaultGCActivityCallback> DefaultGCActivityCallback::create(Heap* heap)
{
+#if PLATFORM(IOS)
+ // Big hack.
+ if (GCActivityCallback::s_shouldCreateGCTimer)
+ return adoptPtr(new DefaultGCActivityCallback(heap));
+ return nullptr;
+#else
return adoptPtr(new DefaultGCActivityCallback(heap));
+#endif // PLATFORM(IOS)
}
}