Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim:set ts=2 sw=2 sts=2 et cindent: */
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_MediaStreamError_h
8 : #define mozilla_dom_MediaStreamError_h
9 :
10 : #include "mozilla/Attributes.h"
11 : #include "mozilla/ErrorResult.h"
12 : #include "nsWrapperCache.h"
13 : #include "js/TypeDecls.h"
14 : #include "nsPIDOMWindow.h"
15 : #include "mozilla/RefPtr.h"
16 :
17 : #if defined(XP_WIN) && defined(GetMessage)
18 : #undef GetMessage
19 : #endif
20 :
21 : namespace mozilla {
22 : namespace dom {
23 :
24 : #define MOZILLA_DOM_MEDIASTREAMERROR_IMPLEMENTATION_IID \
25 : { 0x95fa29aa, 0x0cc2, 0x4698, \
26 : { 0x9d, 0xa9, 0xf2, 0xeb, 0x03, 0x91, 0x0b, 0xd1 } }
27 :
28 : class MediaStreamError;
29 : } // namespace dom
30 :
31 0 : class BaseMediaMgrError
32 : {
33 : friend class dom::MediaStreamError;
34 : protected:
35 : BaseMediaMgrError(const nsAString& aName,
36 : const nsAString& aMessage,
37 : const nsAString& aConstraint);
38 : const nsString mName;
39 : nsString mMessage;
40 : const nsString mConstraint;
41 : };
42 :
43 : class MediaMgrError final : public nsISupports,
44 : public BaseMediaMgrError
45 : {
46 : public:
47 0 : explicit MediaMgrError(const nsAString& aName,
48 : const nsAString& aMessage = EmptyString(),
49 0 : const nsAString& aConstraint = EmptyString())
50 0 : : BaseMediaMgrError(aName, aMessage, aConstraint) {}
51 :
52 : NS_DECL_THREADSAFE_ISUPPORTS
53 :
54 : private:
55 0 : ~MediaMgrError() {}
56 : };
57 :
58 : namespace dom {
59 : class MediaStreamError final : public nsISupports,
60 : public BaseMediaMgrError,
61 : public nsWrapperCache
62 : {
63 : public:
64 : MediaStreamError(nsPIDOMWindowInner* aParent,
65 : const nsAString& aName,
66 0 : const nsAString& aMessage = EmptyString(),
67 0 : const nsAString& aConstraint = EmptyString());
68 :
69 0 : MediaStreamError(nsPIDOMWindowInner* aParent,
70 : const BaseMediaMgrError& aOther)
71 0 : : BaseMediaMgrError(aOther.mName, aOther.mMessage, aOther.mConstraint)
72 0 : , mParent(aParent) {}
73 :
74 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
75 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaStreamError)
76 : NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOM_MEDIASTREAMERROR_IMPLEMENTATION_IID)
77 :
78 : JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
79 :
80 0 : nsPIDOMWindowInner* GetParentObject() const
81 : {
82 0 : return mParent;
83 : }
84 : void GetName(nsAString& aName) const;
85 : void GetMessage(nsAString& aMessage) const;
86 : void GetConstraint(nsAString& aConstraint) const;
87 :
88 : private:
89 0 : virtual ~MediaStreamError() {}
90 :
91 : RefPtr<nsPIDOMWindowInner> mParent;
92 : };
93 :
94 : NS_DEFINE_STATIC_IID_ACCESSOR(MediaStreamError,
95 : MOZILLA_DOM_MEDIASTREAMERROR_IMPLEMENTATION_IID)
96 : } // namespace dom
97 : } // namespace mozilla
98 :
99 : #endif
|