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