dom/workers/RegisterBindings.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/workers/RegisterBindings.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,87 @@
     1.4 +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.7 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "WorkerPrivate.h"
    1.10 +#include "ChromeWorkerScope.h"
    1.11 +#include "File.h"
    1.12 +#include "RuntimeService.h"
    1.13 +
    1.14 +#include "jsapi.h"
    1.15 +#include "js/OldDebugAPI.h"
    1.16 +#include "mozilla/dom/BindingUtils.h"
    1.17 +#include "mozilla/dom/ConsoleBinding.h"
    1.18 +#include "mozilla/dom/DOMExceptionBinding.h"
    1.19 +#include "mozilla/dom/EventBinding.h"
    1.20 +#include "mozilla/dom/EventHandlerBinding.h"
    1.21 +#include "mozilla/dom/EventTargetBinding.h"
    1.22 +#include "mozilla/dom/FileReaderSyncBinding.h"
    1.23 +#include "mozilla/dom/ImageData.h"
    1.24 +#include "mozilla/dom/ImageDataBinding.h"
    1.25 +#include "mozilla/dom/MessageEventBinding.h"
    1.26 +#include "mozilla/dom/MessagePortBinding.h"
    1.27 +#include "mozilla/dom/PromiseBinding.h"
    1.28 +#include "mozilla/dom/TextDecoderBinding.h"
    1.29 +#include "mozilla/dom/TextEncoderBinding.h"
    1.30 +#include "mozilla/dom/XMLHttpRequestBinding.h"
    1.31 +#include "mozilla/dom/XMLHttpRequestUploadBinding.h"
    1.32 +#include "mozilla/dom/URLBinding.h"
    1.33 +#include "mozilla/dom/URLSearchParamsBinding.h"
    1.34 +#include "mozilla/dom/WorkerBinding.h"
    1.35 +#include "mozilla/dom/WorkerLocationBinding.h"
    1.36 +#include "mozilla/dom/WorkerNavigatorBinding.h"
    1.37 +#include "mozilla/OSFileConstants.h"
    1.38 +
    1.39 +USING_WORKERS_NAMESPACE
    1.40 +using namespace mozilla::dom;
    1.41 +
    1.42 +bool
    1.43 +WorkerPrivate::RegisterBindings(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
    1.44 +{
    1.45 +  JS::Rooted<JSObject*> eventTargetProto(aCx,
    1.46 +    EventTargetBinding::GetProtoObject(aCx, aGlobal));
    1.47 +  if (!eventTargetProto) {
    1.48 +    return false;
    1.49 +  }
    1.50 +
    1.51 +  if (IsChromeWorker()) {
    1.52 +    if (!ChromeWorkerBinding::GetConstructorObject(aCx, aGlobal) ||
    1.53 +        !DefineChromeWorkerFunctions(aCx, aGlobal) ||
    1.54 +        !DefineOSFileConstants(aCx, aGlobal)) {
    1.55 +      return false;
    1.56 +    }
    1.57 +  }
    1.58 +
    1.59 +  // Init other classes we care about.
    1.60 +  if (!file::InitClasses(aCx, aGlobal)) {
    1.61 +    return false;
    1.62 +  }
    1.63 +
    1.64 +  // Init other paris-bindings.
    1.65 +  if (!ConsoleBinding::GetConstructorObject(aCx, aGlobal) ||
    1.66 +      !DOMExceptionBinding::GetConstructorObject(aCx, aGlobal) ||
    1.67 +      !EventBinding::GetConstructorObject(aCx, aGlobal) ||
    1.68 +      !FileReaderSyncBinding_workers::GetConstructorObject(aCx, aGlobal) ||
    1.69 +      !ImageDataBinding::GetConstructorObject(aCx, aGlobal) ||
    1.70 +      !MessageEventBinding::GetConstructorObject(aCx, aGlobal) ||
    1.71 +      !MessagePortBinding::GetConstructorObject(aCx, aGlobal) ||
    1.72 +      !PromiseBinding::GetConstructorObject(aCx, aGlobal) ||
    1.73 +      !TextDecoderBinding::GetConstructorObject(aCx, aGlobal) ||
    1.74 +      !TextEncoderBinding::GetConstructorObject(aCx, aGlobal) ||
    1.75 +      !XMLHttpRequestBinding_workers::GetConstructorObject(aCx, aGlobal) ||
    1.76 +      !XMLHttpRequestUploadBinding_workers::GetConstructorObject(aCx, aGlobal) ||
    1.77 +      !URLBinding_workers::GetConstructorObject(aCx, aGlobal) ||
    1.78 +      !URLSearchParamsBinding::GetConstructorObject(aCx, aGlobal) ||
    1.79 +      !WorkerBinding::GetConstructorObject(aCx, aGlobal) ||
    1.80 +      !WorkerLocationBinding_workers::GetConstructorObject(aCx, aGlobal) ||
    1.81 +      !WorkerNavigatorBinding_workers::GetConstructorObject(aCx, aGlobal)) {
    1.82 +    return false;
    1.83 +  }
    1.84 +
    1.85 +  if (!JS_DefineProfilingFunctions(aCx, aGlobal)) {
    1.86 +    return false;
    1.87 +  }
    1.88 +
    1.89 +  return true;
    1.90 +}

mercurial