/src/mozilla-central/dom/media/MediaStreamError.cpp
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 | | #include "MediaStreamError.h" |
8 | | #include "mozilla/dom/MediaStreamErrorBinding.h" |
9 | | #include "nsContentUtils.h" |
10 | | |
11 | | namespace mozilla { |
12 | | |
13 | | BaseMediaMgrError::BaseMediaMgrError(Name aName, |
14 | | const nsAString& aMessage, |
15 | | const nsAString& aConstraint) |
16 | | : mMessage(aMessage) |
17 | | , mConstraint(aConstraint) |
18 | | , mName(aName) |
19 | 0 | { |
20 | 0 |
|
21 | 0 | #define MAP_MEDIAERR(name, msg) { Name::name, #name, msg } |
22 | 0 |
|
23 | 0 | static struct { |
24 | 0 | Name mName; |
25 | 0 | const char* mNameString; |
26 | 0 | const char* mMessage; |
27 | 0 | } map[] = { |
28 | 0 | MAP_MEDIAERR(AbortError, "The operation was aborted."), |
29 | 0 | MAP_MEDIAERR(InvalidStateError, "The object is in an invalid state."), |
30 | 0 | MAP_MEDIAERR(NotAllowedError, "The request is not allowed by the user agent " |
31 | 0 | "or the platform in the current context."), |
32 | 0 | MAP_MEDIAERR(NotFoundError, "The object can not be found here."), |
33 | 0 | MAP_MEDIAERR(NotReadableError, "The I/O read operation failed."), |
34 | 0 | MAP_MEDIAERR(NotSupportedError, "The operation is not supported."), |
35 | 0 | MAP_MEDIAERR(OverconstrainedError, "Constraints could be not satisfied."), |
36 | 0 | MAP_MEDIAERR(SecurityError, "The operation is insecure."), |
37 | 0 | MAP_MEDIAERR(TypeError, ""), |
38 | 0 | }; |
39 | 0 | for (auto& entry : map) { |
40 | 0 | if (entry.mName == mName) { |
41 | 0 | mNameString.AssignASCII(entry.mNameString); |
42 | 0 | if (mMessage.IsEmpty()) { |
43 | 0 | mMessage.AssignASCII(entry.mMessage); |
44 | 0 | } |
45 | 0 | return; |
46 | 0 | } |
47 | 0 | } |
48 | 0 | MOZ_ASSERT_UNREACHABLE("Unknown error type"); |
49 | 0 | } |
50 | | |
51 | | NS_IMPL_ISUPPORTS0(MediaMgrError) |
52 | | |
53 | | namespace dom { |
54 | | |
55 | | MediaStreamError::MediaStreamError( |
56 | | nsPIDOMWindowInner* aParent, |
57 | | Name aName, |
58 | | const nsAString& aMessage, |
59 | | const nsAString& aConstraint) |
60 | | : BaseMediaMgrError(aName, aMessage, aConstraint) |
61 | 0 | , mParent(aParent) {} |
62 | | |
63 | | NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MediaStreamError, mParent) |
64 | | NS_IMPL_CYCLE_COLLECTING_ADDREF(MediaStreamError) |
65 | | NS_IMPL_CYCLE_COLLECTING_RELEASE(MediaStreamError) |
66 | 0 | NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MediaStreamError) |
67 | 0 | NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY |
68 | 0 | NS_INTERFACE_MAP_ENTRY(nsISupports) |
69 | 0 | NS_INTERFACE_MAP_ENTRY(MediaStreamError) |
70 | 0 | NS_INTERFACE_MAP_END |
71 | | |
72 | | JSObject* |
73 | | MediaStreamError::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) |
74 | 0 | { |
75 | 0 | return MediaStreamError_Binding::Wrap(aCx, this, aGivenProto); |
76 | 0 | } |
77 | | |
78 | | void |
79 | | MediaStreamError::GetName(nsAString& aName) const |
80 | 0 | { |
81 | 0 | aName = mNameString; |
82 | 0 | } |
83 | | |
84 | | void |
85 | | MediaStreamError::GetMessage(nsAString& aMessage) const |
86 | 0 | { |
87 | 0 | aMessage = mMessage; |
88 | 0 | } |
89 | | |
90 | | void |
91 | | MediaStreamError::GetConstraint(nsAString& aConstraint) const |
92 | 0 | { |
93 | 0 | aConstraint = mConstraint; |
94 | 0 | } |
95 | | |
96 | | } // namespace dom |
97 | | } // namespace mozilla |