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_MediaError_h 8 #define mozilla_dom_MediaError_h 9 10 #include "mozilla/dom/HTMLMediaElement.h" 11 #include "nsWrapperCache.h" 12 #include "nsISupports.h" 13 #include "mozilla/Attributes.h" 14 15 namespace mozilla { 16 namespace dom { 17 18 class MediaError final : public nsISupports, public nsWrapperCache { 19 ~MediaError() = default; 20 21 public: 22 MediaError(HTMLMediaElement* aParent, uint16_t aCode, 23 const nsACString& aMessage = nsCString()); 24 25 // nsISupports 26 NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaError)27 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaError) 28 29 HTMLMediaElement* GetParentObject() const { return mParent; } 30 31 virtual JSObject* WrapObject(JSContext* aCx, 32 JS::Handle<JSObject*> aGivenProto) override; 33 Code()34 uint16_t Code() const { return mCode; } 35 36 void GetMessage(nsAString& aResult) const; 37 38 private: 39 RefPtr<HTMLMediaElement> mParent; 40 41 // Error code 42 const uint16_t mCode; 43 // Error details; 44 const nsCString mMessage; 45 }; 46 47 } // namespace dom 48 } // namespace mozilla 49 50 #endif // mozilla_dom_MediaError_h 51