summaryrefslogtreecommitdiffstats
path: root/dom/system/IOUtils.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
commit40a355a42d4a9444dc753c04c6608dade2f06a23 (patch)
tree871fc667d2de662f171103ce5ec067014ef85e61 /dom/system/IOUtils.h
parentAdding upstream version 124.0.1. (diff)
downloadfirefox-upstream/125.0.1.tar.xz
firefox-upstream/125.0.1.zip
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/system/IOUtils.h')
-rw-r--r--dom/system/IOUtils.h52
1 files changed, 32 insertions, 20 deletions
diff --git a/dom/system/IOUtils.h b/dom/system/IOUtils.h
index 82ea30eaa8..6acfcbfb24 100644
--- a/dom/system/IOUtils.h
+++ b/dom/system/IOUtils.h
@@ -69,8 +69,8 @@ class IOUtils final {
};
template <typename T>
- using PhaseArray =
- EnumeratedArray<IOUtils::ShutdownPhase, IOUtils::ShutdownPhase::Count, T>;
+ using PhaseArray = EnumeratedArray<IOUtils::ShutdownPhase, T,
+ size_t(IOUtils::ShutdownPhase::Count)>;
static already_AddRefed<Promise> Read(GlobalObject& aGlobal,
const nsAString& aPath,
@@ -148,6 +148,7 @@ class IOUtils final {
const nsAString& aPath,
const Optional<int64_t>& aNewTime,
SetTimeFn aSetTimeFn,
+ const char* const aTimeKind,
ErrorResult& aError);
public:
@@ -653,23 +654,34 @@ class IOUtils::EventQueue final {
*/
class IOUtils::IOError {
public:
- MOZ_IMPLICIT IOError(nsresult aCode) : mCode(aCode), mMessage(Nothing()) {}
-
- /**
- * Replaces the message associated with this error.
- */
- template <typename... Args>
- IOError WithMessage(const char* const aMessage, Args... aArgs) {
- mMessage.emplace(nsPrintfCString(aMessage, aArgs...));
- return *this;
+ IOError(nsresult aCode, const nsCString& aMsg)
+ : mCode(aCode), mMessage(aMsg) {}
+
+ IOError(nsresult aCode, const char* const aFmt, ...) MOZ_FORMAT_PRINTF(3, 4)
+ : mCode(aCode) {
+ va_list ap;
+ va_start(ap, aFmt);
+ mMessage.AppendVprintf(aFmt, ap);
+ va_end(ap);
}
- IOError WithMessage(const char* const aMessage) {
- mMessage.emplace(nsCString(aMessage));
- return *this;
+
+ static IOError WithCause(const IOError& aCause, const nsCString& aMsg) {
+ IOError e(aCause.mCode, aMsg);
+ e.mMessage.AppendPrintf(": %s", aCause.mMessage.get());
+ return e;
}
- IOError WithMessage(const nsCString& aMessage) {
- mMessage.emplace(aMessage);
- return *this;
+
+ static IOError WithCause(const IOError& aCause, const char* const aFmt, ...)
+ MOZ_FORMAT_PRINTF(2, 3) {
+ va_list ap;
+ va_start(ap, aFmt);
+
+ IOError e(aCause.mCode, EmptyCString());
+ e.mMessage.AppendVprintf(aFmt, ap);
+ e.mMessage.AppendPrintf(": %s", aCause.mMessage.get());
+
+ va_end(ap);
+ return e;
}
/**
@@ -678,13 +690,13 @@ class IOUtils::IOError {
nsresult Code() const { return mCode; }
/**
- * Maybe returns a message associated with this error.
+ * Returns the message associated with this error.
*/
- const Maybe<nsCString>& Message() const { return mMessage; }
+ const nsCString& Message() const { return mMessage; }
private:
nsresult mCode;
- Maybe<nsCString> mMessage;
+ nsCString mMessage;
};
/**