summaryrefslogtreecommitdiffstats
path: root/dom/system/IOUtils.h
diff options
context:
space:
mode:
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;
};
/**