JSWindowActorChild.h (2335B)
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_JSWindowActorChild_h 8 #define mozilla_dom_JSWindowActorChild_h 9 10 #include "js/RootingAPI.h" 11 #include "mozilla/AlreadyAddRefed.h" 12 #include "mozilla/RefPtr.h" 13 #include "mozilla/dom/BindingDeclarations.h" 14 #include "mozilla/dom/JSActor.h" 15 #include "mozilla/dom/WindowGlobalChild.h" 16 #include "nsCOMPtr.h" 17 #include "nsCycleCollectionParticipant.h" 18 #include "nsIGlobalObject.h" 19 #include "nsISupports.h" 20 #include "nsStringFwd.h" 21 22 class nsIDocShell; 23 24 namespace mozilla { 25 class ErrorResult; 26 27 namespace dom { 28 29 template <typename> 30 struct Nullable; 31 32 class BrowsingContext; 33 class Document; 34 class WindowProxyHolder; 35 36 } // namespace dom 37 } // namespace mozilla 38 39 namespace mozilla::dom { 40 41 class JSWindowActorChild final : public JSActor { 42 public: 43 NS_DECL_ISUPPORTS_INHERITED 44 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(JSWindowActorChild, JSActor) 45 46 explicit JSWindowActorChild(nsISupports* aGlobal = nullptr) 47 : JSActor(aGlobal) {} 48 49 JSObject* WrapObject(JSContext* aCx, 50 JS::Handle<JSObject*> aGivenProto) override; 51 52 static already_AddRefed<JSWindowActorChild> Constructor( 53 GlobalObject& aGlobal) { 54 return MakeAndAddRef<JSWindowActorChild>(aGlobal.GetAsSupports()); 55 } 56 57 WindowGlobalChild* GetManager() const; 58 WindowContext* GetWindowContext() const; 59 void Init(const nsACString& aName, WindowGlobalChild* aManager); 60 void ClearManager() override; 61 Document* GetDocument(ErrorResult& aRv); 62 BrowsingContext* GetBrowsingContext(ErrorResult& aRv); 63 nsIDocShell* GetDocShell(ErrorResult& aRv); 64 Nullable<WindowProxyHolder> GetContentWindow(ErrorResult& aRv); 65 66 protected: 67 void SendRawMessage(const JSActorMessageMeta& aMeta, JSIPCValue&& aData, 68 UniquePtr<ipc::StructuredCloneData> aStack, 69 ErrorResult& aRv) override; 70 71 private: 72 ~JSWindowActorChild(); 73 74 RefPtr<WindowGlobalChild> mManager; 75 76 nsCOMPtr<nsIGlobalObject> mGlobal; 77 }; 78 79 } // namespace mozilla::dom 80 81 #endif // mozilla_dom_JSWindowActorChild_h