ImageCaptureError.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_ImageCaptureError_h
  6. #define mozilla_dom_ImageCaptureError_h
  7. #include "mozilla/Attributes.h"
  8. #include "nsCOMPtr.h"
  9. #include "nsString.h"
  10. #include "nsWrapperCache.h"
  11. namespace mozilla {
  12. namespace dom {
  13. /**
  14. * This is the implementation of ImageCaptureError on W3C specification
  15. * https://dvcs.w3.org/hg/dap/raw-file/default/media-stream-capture/ImageCapture.html#idl-def-ImageCaptureError.
  16. * This object should be generated by ImageCapture object only.
  17. */
  18. class ImageCaptureError final : public nsISupports,
  19. public nsWrapperCache
  20. {
  21. public:
  22. NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  23. NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ImageCaptureError)
  24. ImageCaptureError(nsISupports* aParent, uint16_t aCode, const nsAString& aMessage);
  25. nsISupports* GetParentObject() const;
  26. virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
  27. uint16_t Code() const;
  28. enum {
  29. FRAME_GRAB_ERROR = 1,
  30. SETTINGS_ERROR = 2,
  31. PHOTO_ERROR = 3,
  32. ERROR_UNKNOWN = 4,
  33. };
  34. void GetMessage(nsAString& retval) const;
  35. private:
  36. ~ImageCaptureError();
  37. nsCOMPtr<nsISupports> mParent;
  38. nsString mMessage;
  39. uint16_t mCode;
  40. };
  41. } // namespace dom
  42. } // namespace mozilla
  43. #endif // mozilla_dom_ImageCaptureError_h