tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

QMResult.h (1622B)


      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/. */
      6 
      7 #ifndef DOM_QUOTA_QMRESULT_H_
      8 #define DOM_QUOTA_QMRESULT_H_
      9 
     10 #include "ErrorList.h"
     11 #include "mozilla/dom/quota/Config.h"
     12 #include "mozilla/dom/quota/ForwardDecls.h"
     13 
     14 namespace mozilla {
     15 
     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.
     20 //
     21 // XXX Document the general situation more, bug 1709777.
     22 class QMResult {
     23  uint64_t mStackId;
     24  uint32_t mFrameId;
     25  nsresult mNSResult;
     26 
     27 public:
     28  QMResult() : QMResult(NS_OK) {}
     29 
     30  explicit QMResult(nsresult aNSResult);
     31 
     32  uint64_t StackId() const { return mStackId; }
     33 
     34  uint32_t FrameId() const { return mFrameId; }
     35 
     36  nsresult NSResult() const { return mNSResult; }
     37 
     38  /**
     39   * Propagate the result.
     40   *
     41   * This is used by GenericErrorResult<QMResult> to create a propagated
     42   * result.
     43   */
     44  QMResult Propagate() const {
     45    return QMResult{mStackId, mFrameId + 1, mNSResult};
     46  }
     47 
     48 private:
     49  QMResult(uint64_t aStackId, uint32_t aFrameId, nsresult aNSResult)
     50      : mStackId(aStackId), mFrameId(aFrameId), mNSResult(aNSResult) {}
     51 };
     52 #endif
     53 
     54 inline QMResult ToQMResult(nsresult aValue) { return QMResult(aValue); }
     55 
     56 }  // namespace mozilla
     57 
     58 #endif