michael@0: /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "WorkerPrivate.h" michael@0: #include "ChromeWorkerScope.h" michael@0: #include "File.h" michael@0: #include "RuntimeService.h" michael@0: michael@0: #include "jsapi.h" michael@0: #include "js/OldDebugAPI.h" michael@0: #include "mozilla/dom/BindingUtils.h" michael@0: #include "mozilla/dom/ConsoleBinding.h" michael@0: #include "mozilla/dom/DOMExceptionBinding.h" michael@0: #include "mozilla/dom/EventBinding.h" michael@0: #include "mozilla/dom/EventHandlerBinding.h" michael@0: #include "mozilla/dom/EventTargetBinding.h" michael@0: #include "mozilla/dom/FileReaderSyncBinding.h" michael@0: #include "mozilla/dom/ImageData.h" michael@0: #include "mozilla/dom/ImageDataBinding.h" michael@0: #include "mozilla/dom/MessageEventBinding.h" michael@0: #include "mozilla/dom/MessagePortBinding.h" michael@0: #include "mozilla/dom/PromiseBinding.h" michael@0: #include "mozilla/dom/TextDecoderBinding.h" michael@0: #include "mozilla/dom/TextEncoderBinding.h" michael@0: #include "mozilla/dom/XMLHttpRequestBinding.h" michael@0: #include "mozilla/dom/XMLHttpRequestUploadBinding.h" michael@0: #include "mozilla/dom/URLBinding.h" michael@0: #include "mozilla/dom/URLSearchParamsBinding.h" michael@0: #include "mozilla/dom/WorkerBinding.h" michael@0: #include "mozilla/dom/WorkerLocationBinding.h" michael@0: #include "mozilla/dom/WorkerNavigatorBinding.h" michael@0: #include "mozilla/OSFileConstants.h" michael@0: michael@0: USING_WORKERS_NAMESPACE michael@0: using namespace mozilla::dom; michael@0: michael@0: bool michael@0: WorkerPrivate::RegisterBindings(JSContext* aCx, JS::Handle aGlobal) michael@0: { michael@0: JS::Rooted eventTargetProto(aCx, michael@0: EventTargetBinding::GetProtoObject(aCx, aGlobal)); michael@0: if (!eventTargetProto) { michael@0: return false; michael@0: } michael@0: michael@0: if (IsChromeWorker()) { michael@0: if (!ChromeWorkerBinding::GetConstructorObject(aCx, aGlobal) || michael@0: !DefineChromeWorkerFunctions(aCx, aGlobal) || michael@0: !DefineOSFileConstants(aCx, aGlobal)) { michael@0: return false; michael@0: } michael@0: } michael@0: michael@0: // Init other classes we care about. michael@0: if (!file::InitClasses(aCx, aGlobal)) { michael@0: return false; michael@0: } michael@0: michael@0: // Init other paris-bindings. michael@0: if (!ConsoleBinding::GetConstructorObject(aCx, aGlobal) || michael@0: !DOMExceptionBinding::GetConstructorObject(aCx, aGlobal) || michael@0: !EventBinding::GetConstructorObject(aCx, aGlobal) || michael@0: !FileReaderSyncBinding_workers::GetConstructorObject(aCx, aGlobal) || michael@0: !ImageDataBinding::GetConstructorObject(aCx, aGlobal) || michael@0: !MessageEventBinding::GetConstructorObject(aCx, aGlobal) || michael@0: !MessagePortBinding::GetConstructorObject(aCx, aGlobal) || michael@0: !PromiseBinding::GetConstructorObject(aCx, aGlobal) || michael@0: !TextDecoderBinding::GetConstructorObject(aCx, aGlobal) || michael@0: !TextEncoderBinding::GetConstructorObject(aCx, aGlobal) || michael@0: !XMLHttpRequestBinding_workers::GetConstructorObject(aCx, aGlobal) || michael@0: !XMLHttpRequestUploadBinding_workers::GetConstructorObject(aCx, aGlobal) || michael@0: !URLBinding_workers::GetConstructorObject(aCx, aGlobal) || michael@0: !URLSearchParamsBinding::GetConstructorObject(aCx, aGlobal) || michael@0: !WorkerBinding::GetConstructorObject(aCx, aGlobal) || michael@0: !WorkerLocationBinding_workers::GetConstructorObject(aCx, aGlobal) || michael@0: !WorkerNavigatorBinding_workers::GetConstructorObject(aCx, aGlobal)) { michael@0: return false; michael@0: } michael@0: michael@0: if (!JS_DefineProfilingFunctions(aCx, aGlobal)) { michael@0: return false; michael@0: } michael@0: michael@0: return true; michael@0: }