summaryrefslogtreecommitdiffstats
path: root/dom/media/MediaResult.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/media/MediaResult.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/MediaResult.h')
-rw-r--r--dom/media/MediaResult.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/dom/media/MediaResult.h b/dom/media/MediaResult.h
new file mode 100644
index 000000000..c1e0af64c
--- /dev/null
+++ b/dom/media/MediaResult.h
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef MediaResult_h_
+#define MediaResult_h_
+
+#include "nsError.h"
+#include "nsPrintfCString.h"
+
+// MediaResult can be used interchangeably with nsresult.
+// It allows to store extra information such as where the error occurred.
+// While nsresult is typically passed by value; due to its potential size, using
+// MediaResult const references is recommended.
+namespace mozilla {
+
+class MediaResult
+{
+public:
+ MOZ_IMPLICIT MediaResult(nsresult aResult)
+ : mCode(aResult)
+ {
+ }
+ MediaResult(nsresult aResult, const nsACString& aMessage)
+ : mCode(aResult)
+ , mMessage(aMessage)
+ {
+ }
+ MediaResult(nsresult aResult, const char* aMessage)
+ : mCode(aResult)
+ , mMessage(aMessage)
+ {
+ }
+ MediaResult(const MediaResult& aOther) = default;
+ MediaResult(MediaResult&& aOther) = default;
+ MediaResult& operator=(const MediaResult& aOther) = default;
+ MediaResult& operator=(MediaResult&& aOther) = default;
+
+ nsresult Code() const { return mCode; }
+ const nsCString& Message() const { return mMessage; }
+
+ // Interoperations with nsresult.
+ bool operator==(nsresult aResult) const { return aResult == mCode; }
+ bool operator!=(nsresult aResult) const { return aResult != mCode; }
+ operator nsresult () const { return mCode; }
+
+ nsCString Description() const
+ {
+ if (NS_SUCCEEDED(mCode)) {
+ return nsCString();
+ }
+ return nsPrintfCString("0x%08x: %s", mCode, mMessage.get());
+ }
+
+private:
+ nsresult mCode;
+ nsCString mMessage;
+};
+
+#define RESULT_DETAIL(arg, ...) nsPrintfCString("%s: " arg, __func__, ##__VA_ARGS__)
+
+} // namespace mozilla
+#endif // MediaResult_h_ \ No newline at end of file