dom/indexedDB/ReportInternalError.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=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
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef mozilla_dom_indexeddb_reportinternalerror_h__
     8 #define mozilla_dom_indexeddb_reportinternalerror_h__
    10 #include "nsDebug.h"
    12 #include "IndexedDatabase.h"
    14 #define IDB_WARNING(x)                                                         \
    15   mozilla::dom::indexedDB::ReportInternalError(__FILE__, __LINE__, x);         \
    16   NS_WARNING(x)
    18 #define IDB_REPORT_INTERNAL_ERR()                                              \
    19   mozilla::dom::indexedDB::ReportInternalError(__FILE__, __LINE__,             \
    20                                                "UnknownErr")
    22 // Based on NS_ENSURE_TRUE
    23 #define IDB_ENSURE_TRUE(x, ret)                                                \
    24   do {                                                                         \
    25     if (MOZ_UNLIKELY(!(x))) {                                                  \
    26        IDB_REPORT_INTERNAL_ERR();                                              \
    27        NS_WARNING("IDB_ENSURE_TRUE(" #x ") failed");                           \
    28        return ret;                                                             \
    29     }                                                                          \
    30   } while(0)
    32 // Based on NS_ENSURE_SUCCESS
    33 #define IDB_ENSURE_SUCCESS(res, ret)                                           \
    34   do {                                                                         \
    35     nsresult __rv = res; /* Don't evaluate |res| more than once */             \
    36     if (NS_FAILED(__rv)) {                                                     \
    37       IDB_REPORT_INTERNAL_ERR();                                               \
    38       NS_ENSURE_SUCCESS_BODY(res, ret)                                         \
    39       return ret;                                                              \
    40     }                                                                          \
    41   } while(0)
    44 BEGIN_INDEXEDDB_NAMESPACE
    46 void
    47 ReportInternalError(const char* aFile, uint32_t aLine, const char* aStr);
    49 END_INDEXEDDB_NAMESPACE
    51 #endif  // mozilla_dom_indexeddb_reportinternalerror_h__

mercurial