JSWorkerGlobalScopeCustom.cpp [plain text]
#include "config.h"
#include "JSWorkerGlobalScope.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMGlobalObject.h"
#include "JSEventListener.h"
#include "JSEventSource.h"
#include "JSMessageChannel.h"
#include "JSMessagePort.h"
#include "JSWorkerLocation.h"
#include "JSWorkerNavigator.h"
#include "JSXMLHttpRequest.h"
#include "ScheduledAction.h"
#include "WorkerGlobalScope.h"
#include "WorkerLocation.h"
#include "WorkerNavigator.h"
#include <interpreter/Interpreter.h>
#if ENABLE(WEB_SOCKETS)
#include "JSWebSocket.h"
#endif
using namespace JSC;
namespace WebCore {
void JSWorkerGlobalScope::visitAdditionalChildren(SlotVisitor& visitor)
{
if (WorkerLocation* location = wrapped().optionalLocation())
visitor.addOpaqueRoot(location);
if (WorkerNavigator* navigator = wrapped().optionalNavigator())
visitor.addOpaqueRoot(navigator);
}
JSValue JSWorkerGlobalScope::importScripts(ExecState& state)
{
if (!state.argumentCount())
return jsUndefined();
Vector<String> urls;
for (unsigned i = 0; i < state.argumentCount(); ++i) {
urls.append(state.uncheckedArgument(i).toString(&state)->value(&state));
if (state.hadException())
return jsUndefined();
}
ExceptionCode ec = 0;
wrapped().importScripts(urls, ec);
setDOMException(&state, ec);
return jsUndefined();
}
JSValue JSWorkerGlobalScope::setTimeout(ExecState& state)
{
std::unique_ptr<ScheduledAction> action = ScheduledAction::create(&state, globalObject()->world(), wrapped().contentSecurityPolicy());
if (state.hadException())
return jsUndefined();
if (!action)
return jsNumber(0);
int delay = state.argument(1).toInt32(&state);
return jsNumber(wrapped().setTimeout(WTFMove(action), delay));
}
JSValue JSWorkerGlobalScope::setInterval(ExecState& state)
{
std::unique_ptr<ScheduledAction> action = ScheduledAction::create(&state, globalObject()->world(), wrapped().contentSecurityPolicy());
if (state.hadException())
return jsUndefined();
if (!action)
return jsNumber(0);
int delay = state.argument(1).toInt32(&state);
return jsNumber(wrapped().setInterval(WTFMove(action), delay));
}
}