Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef mozilla_dom_WorkletGlobalScope_h
8 : #define mozilla_dom_WorkletGlobalScope_h
9 :
10 : #include "mozilla/Attributes.h"
11 : #include "mozilla/ErrorResult.h"
12 : #include "mozilla/dom/BindingDeclarations.h"
13 : #include "nsIGlobalObject.h"
14 : #include "nsWrapperCache.h"
15 :
16 : #define WORKLET_IID \
17 : { 0x1b3f62e7, 0xe357, 0x44be, \
18 : { 0xbf, 0xe0, 0xdf, 0x85, 0xe6, 0x56, 0x85, 0xac } }
19 :
20 : class nsIPrincipal;
21 : class nsPIDOMWindowInner;
22 :
23 : namespace mozilla {
24 : namespace dom {
25 :
26 : class Console;
27 :
28 : class WorkletGlobalScope : public nsIGlobalObject
29 : , public nsWrapperCache
30 : {
31 : public:
32 : NS_DECLARE_STATIC_IID_ACCESSOR(WORKLET_IID)
33 :
34 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
35 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WorkletGlobalScope)
36 :
37 : explicit WorkletGlobalScope(nsPIDOMWindowInner* aWindow);
38 :
39 0 : nsIGlobalObject* GetParentObject() const
40 : {
41 0 : return nullptr;
42 : }
43 :
44 : virtual JSObject*
45 : WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
46 :
47 : virtual bool
48 : WrapGlobalObject(JSContext* aCx, nsIPrincipal* aPrincipal,
49 : JS::MutableHandle<JSObject*> aReflector) = 0;
50 :
51 : virtual JSObject*
52 0 : GetGlobalJSObject() override
53 : {
54 0 : return GetWrapper();
55 : }
56 :
57 : Console*
58 : GetConsole(ErrorResult& aRv);
59 :
60 : void
61 : Dump(const Optional<nsAString>& aString) const;
62 :
63 : protected:
64 : ~WorkletGlobalScope();
65 :
66 : private:
67 : nsCOMPtr<nsPIDOMWindowInner> mWindow;
68 : RefPtr<Console> mConsole;
69 : };
70 :
71 : NS_DEFINE_STATIC_IID_ACCESSOR(WorkletGlobalScope, WORKLET_IID)
72 :
73 : } // namespace dom
74 : } // namespace mozilla
75 :
76 : #endif // mozilla_dom_WorkletGlobalScope_h
|