JSCustomSQLStatementErrorCallback.cpp [plain text]
#include "config.h"
#include "JSCustomSQLStatementErrorCallback.h"
#if ENABLE(DATABASE)
#include "Frame.h"
#include "ScriptController.h"
#include "JSSQLError.h"
#include "JSSQLTransaction.h"
#include <runtime/JSLock.h>
namespace WebCore {
using namespace JSC;
JSCustomSQLStatementErrorCallback::JSCustomSQLStatementErrorCallback(JSObject* callback, Frame* frame)
: m_callback(callback)
, m_frame(frame)
{
}
bool JSCustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLError* error)
{
ASSERT(m_callback);
ASSERT(m_frame);
if (!m_frame->script()->isEnabled())
return true;
JSGlobalObject* globalObject = m_frame->script()->globalObject();
ExecState* exec = globalObject->globalExec();
JSC::JSLock lock(false);
JSValue handleEventFunction = m_callback->get(exec, Identifier(exec, "handleEvent"));
CallData handleEventCallData;
CallType handleEventCallType = handleEventFunction.getCallData(handleEventCallData);
CallData callbackCallData;
CallType callbackCallType = CallTypeNone;
if (handleEventCallType == CallTypeNone) {
callbackCallType = m_callback->getCallData(callbackCallData);
if (callbackCallType == CallTypeNone) {
return true;
}
}
RefPtr<JSCustomSQLStatementErrorCallback> protect(this);
MarkedArgumentBuffer args;
args.append(toJS(exec, transaction));
args.append(toJS(exec, error));
JSValue result;
globalObject->globalData()->timeoutChecker.start();
if (handleEventCallType != CallTypeNone)
result = call(exec, handleEventFunction, handleEventCallType, handleEventCallData, m_callback, args);
else
result = call(exec, m_callback, callbackCallType, callbackCallData, m_callback, args);
globalObject->globalData()->timeoutChecker.stop();
if (exec->hadException()) {
reportCurrentException(exec);
return true;
}
Document::updateStyleForAllDocuments();
return result.toBoolean(exec);
}
}
#endif // ENABLE(DATABASE)