1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef DOM_QUOTA_QMRESULT_H_
8 #define DOM_QUOTA_QMRESULT_H_
10 #include "ErrorList.h"
11 #include "mozilla/dom/quota/Config.h"
12 #include "mozilla/dom/quota/ForwardDecls.h"
16 #ifdef QM_ERROR_STACKS_ENABLED
17 // A wrapped nsresult, primarily intended for use along with mozilla::Result
18 // and QM_TRY macros. The wrapper contains stack id and frame id which are
19 // reported in LogError besides the error result itself.
21 // XXX Document the general situation more, bug 1709777.
28 QMResult() : QMResult(NS_OK
) {}
30 explicit QMResult(nsresult aNSResult
);
32 uint64_t StackId() const { return mStackId
; }
34 uint32_t FrameId() const { return mFrameId
; }
36 nsresult
NSResult() const { return mNSResult
; }
39 * Propagate the result.
41 * This is used by GenericErrorResult<QMResult> to create a propagated
44 QMResult
Propagate() const {
45 return QMResult
{mStackId
, mFrameId
+ 1, mNSResult
};
49 QMResult(uint64_t aStackId
, uint32_t aFrameId
, nsresult aNSResult
)
50 : mStackId(aStackId
), mFrameId(aFrameId
), mNSResult(aNSResult
) {}
54 inline QMResult
ToQMResult(nsresult aValue
) { return QMResult(aValue
); }
56 } // namespace mozilla