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 : #include "MediaStreamError.h"
8 : #include "mozilla/dom/MediaStreamErrorBinding.h"
9 : #include "nsContentUtils.h"
10 :
11 : namespace mozilla {
12 :
13 0 : BaseMediaMgrError::BaseMediaMgrError(const nsAString& aName,
14 : const nsAString& aMessage,
15 0 : const nsAString& aConstraint)
16 : : mName(aName)
17 : , mMessage(aMessage)
18 0 : , mConstraint(aConstraint)
19 : {
20 0 : if (mMessage.IsEmpty()) {
21 0 : if (mName.EqualsLiteral("NotFoundError")) {
22 0 : mMessage.AssignLiteral("The object can not be found here.");
23 0 : } else if (mName.EqualsLiteral("NotAllowedError")) {
24 0 : mMessage.AssignLiteral("The request is not allowed by the user agent "
25 0 : "or the platform in the current context.");
26 0 : } else if (mName.EqualsLiteral("SecurityError")) {
27 0 : mMessage.AssignLiteral("The operation is insecure.");
28 0 : } else if (mName.EqualsLiteral("NotReadableError")) {
29 0 : mMessage.AssignLiteral("The I/O read operation failed.");
30 0 : } else if (mName.EqualsLiteral("InternalError")) {
31 0 : mMessage.AssignLiteral("Internal error.");
32 0 : } else if (mName.EqualsLiteral("NotSupportedError")) {
33 0 : mMessage.AssignLiteral("The operation is not supported.");
34 0 : } else if (mName.EqualsLiteral("OverconstrainedError")) {
35 0 : mMessage.AssignLiteral("Constraints could be not satisfied.");
36 : }
37 : }
38 0 : }
39 :
40 :
41 0 : NS_IMPL_ISUPPORTS0(MediaMgrError)
42 :
43 : namespace dom {
44 :
45 0 : MediaStreamError::MediaStreamError(
46 : nsPIDOMWindowInner* aParent,
47 : const nsAString& aName,
48 : const nsAString& aMessage,
49 0 : const nsAString& aConstraint)
50 : : BaseMediaMgrError(aName, aMessage, aConstraint)
51 0 : , mParent(aParent) {}
52 :
53 0 : NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MediaStreamError, mParent)
54 0 : NS_IMPL_CYCLE_COLLECTING_ADDREF(MediaStreamError)
55 0 : NS_IMPL_CYCLE_COLLECTING_RELEASE(MediaStreamError)
56 0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MediaStreamError)
57 0 : NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
58 0 : NS_INTERFACE_MAP_ENTRY(nsISupports)
59 0 : NS_INTERFACE_MAP_ENTRY(MediaStreamError)
60 0 : NS_INTERFACE_MAP_END
61 :
62 : JSObject*
63 0 : MediaStreamError::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
64 : {
65 0 : return MediaStreamErrorBinding::Wrap(aCx, this, aGivenProto);
66 : }
67 :
68 : void
69 0 : MediaStreamError::GetName(nsAString& aName) const
70 : {
71 0 : aName = mName;
72 0 : }
73 :
74 : void
75 0 : MediaStreamError::GetMessage(nsAString& aMessage) const
76 : {
77 0 : aMessage = mMessage;
78 0 : }
79 :
80 : void
81 0 : MediaStreamError::GetConstraint(nsAString& aConstraint) const
82 : {
83 0 : aConstraint = mConstraint;
84 0 : }
85 :
86 : } // namespace dom
87 : } // namespace mozilla
|