1/*
2 This file is part of the WebKit open source project.
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#include "config.h"
22#include "JSFileSystemEntriesCallback.h"
23
24#include "JSDOMConvertInterface.h"
25#include "JSDOMConvertSequences.h"
26#include "JSDOMExceptionHandling.h"
27#include "JSDOMGlobalObject.h"
28#include "JSFileSystemEntry.h"
29#include "ScriptExecutionContext.h"
30#include <JavaScriptCore/JSArray.h>
31
32
33namespace WebCore {
34using namespace JSC;
35
36JSFileSystemEntriesCallback::JSFileSystemEntriesCallback(JSObject* callback, JSDOMGlobalObject* globalObject)
37 : FileSystemEntriesCallback(globalObject->scriptExecutionContext())
38 , m_data(new JSCallbackDataStrong(callback, globalObject, this))
39{
40}
41
42JSFileSystemEntriesCallback::~JSFileSystemEntriesCallback()
43{
44 ScriptExecutionContext* context = scriptExecutionContext();
45 // When the context is destroyed, all tasks with a reference to a callback
46 // should be deleted. So if the context is 0, we are on the context thread.
47 if (!context || context->isContextThread())
48 delete m_data;
49 else
50 context->postTask(DeleteCallbackDataTask(m_data));
51#ifndef NDEBUG
52 m_data = nullptr;
53#endif
54}
55
56CallbackResult<typename IDLVoid::ImplementationType> JSFileSystemEntriesCallback::handleEvent(typename IDLSequence<IDLInterface<FileSystemEntry>>::ParameterType entries)
57{
58 if (!canInvokeCallback())
59 return CallbackResultType::UnableToExecute;
60
61 Ref<JSFileSystemEntriesCallback> protectedThis(*this);
62
63 auto& globalObject = *m_data->globalObject();
64 auto& vm = globalObject.vm();
65
66 JSLockHolder lock(vm);
67 auto& state = *globalObject.globalExec();
68 JSValue thisValue = jsUndefined();
69 MarkedArgumentBuffer args;
70 args.append(toJS<IDLSequence<IDLInterface<FileSystemEntry>>>(state, globalObject, entries));
71 ASSERT(!args.hasOverflowed());
72
73 NakedPtr<JSC::Exception> returnedException;
74 m_data->invokeCallback(thisValue, args, JSCallbackData::CallbackType::Function, Identifier(), returnedException);
75 if (returnedException) {
76 reportException(&state, returnedException);
77 return CallbackResultType::ExceptionThrown;
78 }
79
80 return { };
81}
82
83JSC::JSValue toJS(FileSystemEntriesCallback& impl)
84{
85 if (!static_cast<JSFileSystemEntriesCallback&>(impl).callbackData())
86 return jsNull();
87
88 return static_cast<JSFileSystemEntriesCallback&>(impl).callbackData()->callback();
89}
90
91} // namespace WebCore
92