WorkerContextNotifications.cpp [plain text]
#include "config.h"
#include "WorkerContextNotifications.h"
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
#include "NotificationCenter.h"
#include "WorkerContext.h"
#include "WorkerThread.h"
namespace WebCore {
WorkerContextNotifications::WorkerContextNotifications(WorkerContext* context)
: m_context(context)
{
}
WorkerContextNotifications::~WorkerContextNotifications()
{
}
const char* WorkerContextNotifications::supplementName()
{
return "WorkerContextNotifications";
}
WorkerContextNotifications* WorkerContextNotifications::from(WorkerContext* context)
{
WorkerContextNotifications* supplement = static_cast<WorkerContextNotifications*>(Supplement<ScriptExecutionContext>::from(context, supplementName()));
if (!supplement) {
supplement = new WorkerContextNotifications(context);
Supplement<ScriptExecutionContext>::provideTo(context, supplementName(), adoptPtr(supplement));
}
return supplement;
}
NotificationCenter* WorkerContextNotifications::webkitNotifications(WorkerContext* context)
{
return WorkerContextNotifications::from(context)->webkitNotifications();
}
NotificationCenter* WorkerContextNotifications::webkitNotifications()
{
if (!m_notificationCenter)
m_notificationCenter = NotificationCenter::create(m_context, m_context->thread()->getNotificationClient());
return m_notificationCenter.get();
}
}
#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)