dom/workers/RegisterBindings.cpp

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:56b9cf8068bf
1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #include "WorkerPrivate.h"
7 #include "ChromeWorkerScope.h"
8 #include "File.h"
9 #include "RuntimeService.h"
10
11 #include "jsapi.h"
12 #include "js/OldDebugAPI.h"
13 #include "mozilla/dom/BindingUtils.h"
14 #include "mozilla/dom/ConsoleBinding.h"
15 #include "mozilla/dom/DOMExceptionBinding.h"
16 #include "mozilla/dom/EventBinding.h"
17 #include "mozilla/dom/EventHandlerBinding.h"
18 #include "mozilla/dom/EventTargetBinding.h"
19 #include "mozilla/dom/FileReaderSyncBinding.h"
20 #include "mozilla/dom/ImageData.h"
21 #include "mozilla/dom/ImageDataBinding.h"
22 #include "mozilla/dom/MessageEventBinding.h"
23 #include "mozilla/dom/MessagePortBinding.h"
24 #include "mozilla/dom/PromiseBinding.h"
25 #include "mozilla/dom/TextDecoderBinding.h"
26 #include "mozilla/dom/TextEncoderBinding.h"
27 #include "mozilla/dom/XMLHttpRequestBinding.h"
28 #include "mozilla/dom/XMLHttpRequestUploadBinding.h"
29 #include "mozilla/dom/URLBinding.h"
30 #include "mozilla/dom/URLSearchParamsBinding.h"
31 #include "mozilla/dom/WorkerBinding.h"
32 #include "mozilla/dom/WorkerLocationBinding.h"
33 #include "mozilla/dom/WorkerNavigatorBinding.h"
34 #include "mozilla/OSFileConstants.h"
35
36 USING_WORKERS_NAMESPACE
37 using namespace mozilla::dom;
38
39 bool
40 WorkerPrivate::RegisterBindings(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
41 {
42 JS::Rooted<JSObject*> eventTargetProto(aCx,
43 EventTargetBinding::GetProtoObject(aCx, aGlobal));
44 if (!eventTargetProto) {
45 return false;
46 }
47
48 if (IsChromeWorker()) {
49 if (!ChromeWorkerBinding::GetConstructorObject(aCx, aGlobal) ||
50 !DefineChromeWorkerFunctions(aCx, aGlobal) ||
51 !DefineOSFileConstants(aCx, aGlobal)) {
52 return false;
53 }
54 }
55
56 // Init other classes we care about.
57 if (!file::InitClasses(aCx, aGlobal)) {
58 return false;
59 }
60
61 // Init other paris-bindings.
62 if (!ConsoleBinding::GetConstructorObject(aCx, aGlobal) ||
63 !DOMExceptionBinding::GetConstructorObject(aCx, aGlobal) ||
64 !EventBinding::GetConstructorObject(aCx, aGlobal) ||
65 !FileReaderSyncBinding_workers::GetConstructorObject(aCx, aGlobal) ||
66 !ImageDataBinding::GetConstructorObject(aCx, aGlobal) ||
67 !MessageEventBinding::GetConstructorObject(aCx, aGlobal) ||
68 !MessagePortBinding::GetConstructorObject(aCx, aGlobal) ||
69 !PromiseBinding::GetConstructorObject(aCx, aGlobal) ||
70 !TextDecoderBinding::GetConstructorObject(aCx, aGlobal) ||
71 !TextEncoderBinding::GetConstructorObject(aCx, aGlobal) ||
72 !XMLHttpRequestBinding_workers::GetConstructorObject(aCx, aGlobal) ||
73 !XMLHttpRequestUploadBinding_workers::GetConstructorObject(aCx, aGlobal) ||
74 !URLBinding_workers::GetConstructorObject(aCx, aGlobal) ||
75 !URLSearchParamsBinding::GetConstructorObject(aCx, aGlobal) ||
76 !WorkerBinding::GetConstructorObject(aCx, aGlobal) ||
77 !WorkerLocationBinding_workers::GetConstructorObject(aCx, aGlobal) ||
78 !WorkerNavigatorBinding_workers::GetConstructorObject(aCx, aGlobal)) {
79 return false;
80 }
81
82 if (!JS_DefineProfilingFunctions(aCx, aGlobal)) {
83 return false;
84 }
85
86 return true;
87 }

mercurial