Bug 1874684 - Part 6: Limit day length calculations to safe integers. r=mgaudet
[gecko.git] / dom / quota / QMResult.h
blobf47c82584ebbf103d42f1c8913406a475f2acfb1
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"
14 namespace mozilla {
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.
22 class QMResult {
23 uint64_t mStackId;
24 uint32_t mFrameId;
25 nsresult mNSResult;
27 public:
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; }
38 /**
39 * Propagate the result.
41 * This is used by GenericErrorResult<QMResult> to create a propagated
42 * result.
44 QMResult Propagate() const {
45 return QMResult{mStackId, mFrameId + 1, mNSResult};
48 private:
49 QMResult(uint64_t aStackId, uint32_t aFrameId, nsresult aNSResult)
50 : mStackId(aStackId), mFrameId(aFrameId), mNSResult(aNSResult) {}
52 #endif
54 inline QMResult ToQMResult(nsresult aValue) { return QMResult(aValue); }
56 } // namespace mozilla
58 #endif