Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/media/MediaStreamError.h
Line
Count
Source (jump to first uncovered line)
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
23
namespace dom {
24
25
#define MOZILLA_DOM_MEDIASTREAMERROR_IMPLEMENTATION_IID \
26
{ 0x95fa29aa, 0x0cc2, 0x4698, \
27
 { 0x9d, 0xa9, 0xf2, 0xeb, 0x03, 0x91, 0x0b, 0xd1 } }
28
29
class MediaStreamError;
30
} // namespace dom
31
32
class BaseMediaMgrError
33
{
34
  friend class dom::MediaStreamError;
35
public:
36
  enum class Name
37
  {
38
    AbortError,
39
    InvalidStateError,
40
    NotAllowedError,
41
    NotFoundError,
42
    NotReadableError,
43
    NotSupportedError,
44
    OverconstrainedError,
45
    SecurityError,
46
    TypeError,
47
  };
48
49
protected:
50
  BaseMediaMgrError(Name aName,
51
                    const nsAString& aMessage,
52
                    const nsAString& aConstraint);
53
  nsString mNameString;
54
  nsString mMessage;
55
  const nsString mConstraint;
56
private:
57
  const Name mName;
58
};
59
60
class MediaMgrError final : public nsISupports,
61
                            public BaseMediaMgrError
62
{
63
public:
64
  explicit MediaMgrError(Name aName,
65
                         const nsAString& aMessage =  EmptyString(),
66
                         const nsAString& aConstraint =  EmptyString())
67
  : BaseMediaMgrError(aName, aMessage, aConstraint) {}
68
69
  NS_DECL_THREADSAFE_ISUPPORTS
70
71
private:
72
0
  ~MediaMgrError() {}
73
};
74
75
namespace dom {
76
class MediaStreamError final : public nsISupports,
77
                               public BaseMediaMgrError,
78
                               public nsWrapperCache
79
{
80
public:
81
  MediaStreamError(nsPIDOMWindowInner* aParent,
82
                   Name aName,
83
                   const nsAString& aMessage = EmptyString(),
84
                   const nsAString& aConstraint =  EmptyString());
85
86
  MediaStreamError(nsPIDOMWindowInner* aParent,
87
                   const BaseMediaMgrError& aOther)
88
  : BaseMediaMgrError(aOther.mName, aOther.mMessage, aOther.mConstraint)
89
  , mParent(aParent) {}
90
91
  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
92
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaStreamError)
93
  NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOM_MEDIASTREAMERROR_IMPLEMENTATION_IID)
94
95
  JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
96
97
  nsPIDOMWindowInner* GetParentObject() const
98
  {
99
    return mParent;
100
  }
101
  void GetName(nsAString& aName) const;
102
  void GetMessage(nsAString& aMessage) const;
103
  void GetConstraint(nsAString& aConstraint) const;
104
105
private:
106
0
  virtual ~MediaStreamError() {}
107
108
  RefPtr<nsPIDOMWindowInner> mParent;
109
};
110
111
NS_DEFINE_STATIC_IID_ACCESSOR(MediaStreamError,
112
                              MOZILLA_DOM_MEDIASTREAMERROR_IMPLEMENTATION_IID)
113
} // namespace dom
114
} // namespace mozilla
115
116
#endif