MediaError.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_MediaError_h
  6. #define mozilla_dom_MediaError_h
  7. #include "mozilla/dom/HTMLMediaElement.h"
  8. #include "nsWrapperCache.h"
  9. #include "nsISupports.h"
  10. #include "mozilla/Attributes.h"
  11. namespace mozilla {
  12. namespace dom {
  13. class MediaError final : public nsISupports,
  14. public nsWrapperCache
  15. {
  16. ~MediaError() {}
  17. public:
  18. MediaError(HTMLMediaElement* aParent, uint16_t aCode,
  19. const nsACString& aMessage = nsCString());
  20. // nsISupports
  21. NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  22. NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaError)
  23. HTMLMediaElement* GetParentObject() const
  24. {
  25. return mParent;
  26. }
  27. virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
  28. uint16_t Code() const
  29. {
  30. return mCode;
  31. }
  32. void GetMessage(nsAString& aResult) const;
  33. private:
  34. RefPtr<HTMLMediaElement> mParent;
  35. // Error code
  36. const uint16_t mCode;
  37. // Error details;
  38. const nsCString mMessage;
  39. };
  40. } // namespace dom
  41. } // namespace mozilla
  42. #endif // mozilla_dom_MediaError_h