MediaKeyMessageEvent.h (2020B)
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 file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_MediaKeyMessageEvent_h__ 8 #define mozilla_dom_MediaKeyMessageEvent_h__ 9 10 #include "js/TypeDecls.h" 11 #include "mozilla/dom/Event.h" 12 #include "mozilla/dom/MediaKeyMessageEventBinding.h" 13 #include "mozilla/dom/TypedArray.h" 14 #include "nsCOMPtr.h" 15 #include "nsCycleCollectionParticipant.h" 16 #include "nsWrapperCache.h" 17 18 namespace mozilla { 19 class ErrorResult; 20 21 namespace dom { 22 23 struct MediaKeyMessageEventInit; 24 25 class MediaKeyMessageEvent final : public Event { 26 public: 27 NS_DECL_ISUPPORTS_INHERITED 28 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MediaKeyMessageEvent, 29 Event) 30 protected: 31 virtual ~MediaKeyMessageEvent(); 32 explicit MediaKeyMessageEvent(EventTarget* aOwner); 33 34 MediaKeyMessageType mMessageType; 35 JS::Heap<JSObject*> mMessage; 36 37 public: 38 virtual MediaKeyMessageEvent* AsMediaKeyMessageEvent(); 39 40 JSObject* WrapObjectInternal(JSContext* aCx, 41 JS::Handle<JSObject*> aGivenProto) override; 42 43 static already_AddRefed<MediaKeyMessageEvent> Constructor( 44 EventTarget* aOwner, MediaKeyMessageType aMessageType, 45 const nsTArray<uint8_t>& aMessage); 46 47 static already_AddRefed<MediaKeyMessageEvent> Constructor( 48 const GlobalObject& aGlobal, const nsAString& aType, 49 const MediaKeyMessageEventInit& aEventInitDict, ErrorResult& aRv); 50 51 MediaKeyMessageType MessageType() const { return mMessageType; } 52 53 void GetMessage(JSContext* cx, JS::MutableHandle<JSObject*> aMessage, 54 ErrorResult& aRv); 55 56 private: 57 nsTArray<uint8_t> mRawMessage; 58 }; 59 60 } // namespace dom 61 } // namespace mozilla 62 63 #endif // mozilla_dom_MediaKeyMessageEvent_h__