diff options
Diffstat (limited to 'WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp')
-rwxr-xr-x | WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp b/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp index 46bd966..446a8ea 100755 --- a/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp +++ b/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp @@ -33,10 +33,16 @@ #if ENABLE(WORKERS) #include "V8WorkerContext.h" +#if ENABLE(DATABASE) +#include "V8Database.h" +#include "V8DatabaseCallback.h" +#include "V8DatabaseSync.h" +#endif #include "DOMTimer.h" #include "ExceptionCode.h" #include "ScheduledAction.h" #include "V8Binding.h" +#include "V8BindingMacros.h" #include "V8Proxy.h" #include "V8Utilities.h" #include "V8WorkerContextEventListener.h" @@ -136,6 +142,43 @@ v8::Handle<v8::Value> toV8(WorkerContext* impl) return global; } +#if ENABLE(DATABASE) +v8::Handle<v8::Value> V8WorkerContext::openDatabaseCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.WorkerContext.openDatabase()"); + // Implementation coming soon. + return throwError(NOT_SUPPORTED_ERR); +} + +v8::Handle<v8::Value> V8WorkerContext::openDatabaseSyncCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.V8WorkerContext.openDatabaseSync()"); + if (args.Length() < 4) + return throwError(SYNTAX_ERR); + + EXCEPTION_BLOCK(String, name, toWebCoreString(args[0])); + EXCEPTION_BLOCK(String, version, toWebCoreString(args[1])); + EXCEPTION_BLOCK(String, displayName, toWebCoreString(args[2])); + EXCEPTION_BLOCK(unsigned long, estimatedSize, args[3]->Uint32Value()); + + WorkerContext* workerContext = V8WorkerContext::toNative(args.Holder()); + + RefPtr<DatabaseCallback> creationCallback; + if (args.Length() >= 5) { + if (!args[4]->IsObject()) + return throwError(TYPE_MISMATCH_ERR); + + creationCallback = V8DatabaseCallback::create(args[4], 0); + } + + ExceptionCode ec = 0; + v8::Handle<v8::Value> result = toV8(workerContext->openDatabaseSync(name, version, displayName, estimatedSize, creationCallback.release(), ec)); + + V8Proxy::setDOMException(ec); + return result; +} +#endif + } // namespace WebCore #endif // ENABLE(WORKERS) |