зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1731960 - Move all Result extensions from QMResult.h to a dedicated file; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D126324
This commit is contained in:
Родитель
9818dd6ab2
Коммит
adc8da34e9
|
@ -20,6 +20,7 @@
|
|||
#include "mozilla/dom/cache/CacheCommon.h"
|
||||
#include "mozilla/dom/cache/CacheWorkerRef.h"
|
||||
#include "mozilla/dom/cache/ReadStream.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Unused.h"
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "mozilla/dom/cache/ReadStream.h"
|
||||
#include "mozilla/dom/cache/TypeUtils.h"
|
||||
#include "mozilla/dom/quota/QuotaManager.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/dom/WorkerPrivate.h"
|
||||
#include "mozilla/ipc/BackgroundChild.h"
|
||||
#include "mozilla/ipc/BackgroundUtils.h"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "mozilla/dom/cache/ManagerId.h"
|
||||
#include "mozilla/dom/quota/DirectoryLock.h"
|
||||
#include "mozilla/dom/quota/QuotaManager.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozIStorageConnection.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIRunnable.h"
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "mozilla/dom/cache/FileUtils.h"
|
||||
#include "mozilla/dom/cache/QuotaClient.h"
|
||||
#include "mozilla/dom/quota/PersistenceType.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/net/nsFileProtocolHandler.h"
|
||||
#include "mozIStorageConnection.h"
|
||||
#include "mozIStorageService.h"
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "mozilla/dom/HeadersBinding.h"
|
||||
#include "mozilla/dom/InternalHeaders.h"
|
||||
#include "mozilla/dom/InternalResponse.h"
|
||||
#include "mozilla/dom/QMResultInlines.h"
|
||||
#include "mozilla/dom/RequestBinding.h"
|
||||
#include "mozilla/dom/ResponseBinding.h"
|
||||
#include "mozilla/dom/cache/CacheCommon.h"
|
||||
|
@ -19,6 +18,7 @@
|
|||
#include "mozilla/dom/cache/SavedTypes.h"
|
||||
#include "mozilla/dom/cache/Types.h"
|
||||
#include "mozilla/dom/cache/TypeUtils.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/net/MozURL.h"
|
||||
#include "mozilla/ResultExtensions.h"
|
||||
#include "mozilla/StaticPrefs_extensions.h"
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
#include "DBSchema.h"
|
||||
#include "mozilla/dom/InternalResponse.h"
|
||||
#include "mozilla/dom/QMResultInlines.h"
|
||||
#include "mozilla/dom/quota/FileStreams.h"
|
||||
#include "mozilla/dom/quota/QuotaManager.h"
|
||||
#include "mozilla/dom/quota/QuotaObject.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
#include "mozilla/SnappyCompressOutputStream.h"
|
||||
#include "mozilla/Unused.h"
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "mozilla/dom/FlippedOnce.h"
|
||||
#include "mozilla/dom/cache/FileUtils.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
#include "ErrorList.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/QMResult.h"
|
||||
#include "mozilla/dom/QMResultInlines.h"
|
||||
#include "mozilla/dom/cache/ManagerId.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/ipc/BackgroundParent.h"
|
||||
#include "mozilla/ipc/PBackgroundParent.h"
|
||||
#include "mozilla/ipc/BackgroundUtils.h"
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
#define mozilla_dom_cache_QuotaClientImpl_h
|
||||
|
||||
#include "mozilla/dom/QMResult.h"
|
||||
#include "mozilla/dom/QMResultInlines.h"
|
||||
#include "mozilla/dom/cache/QuotaClient.h"
|
||||
#include "mozilla/dom/cache/FileUtils.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "mozilla/dom/IPCBlobUtils.h"
|
||||
#include "mozilla/dom/WorkerPrivate.h"
|
||||
#include "mozilla/dom/WorkerRunnable.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/Encoding.h"
|
||||
#include "mozilla/ipc/BackgroundUtils.h"
|
||||
#include "mozilla/ProfilerLabels.h"
|
||||
|
|
|
@ -102,7 +102,6 @@
|
|||
#include "mozilla/dom/Nullable.h"
|
||||
#include "mozilla/dom/PBackgroundMutableFileParent.h"
|
||||
#include "mozilla/dom/PContentParent.h"
|
||||
#include "mozilla/dom/QMResultInlines.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/dom/filehandle/ActorsParent.h"
|
||||
#include "mozilla/dom/indexedDB/IDBResult.h"
|
||||
|
@ -136,6 +135,7 @@
|
|||
#include "mozilla/dom/quota/QuotaCommon.h"
|
||||
#include "mozilla/dom/quota/QuotaManager.h"
|
||||
#include "mozilla/dom/quota/QuotaObject.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/dom/quota/UsageInfo.h"
|
||||
#include "mozilla/fallible.h"
|
||||
#include "mozilla/ipc/BackgroundParent.h"
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "mozilla/TelemetryScalarEnums.h"
|
||||
#include "mozilla/dom/quota/DecryptingInputStream_impl.h"
|
||||
#include "mozilla/dom/quota/QuotaCommon.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/dom/quota/ScopedLogExtraInfo.h"
|
||||
#include "mozilla/fallible.h"
|
||||
#include "mozilla/ipc/BackgroundParent.h"
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "js/StructuredClone.h"
|
||||
#include "mozIStorageConnection.h"
|
||||
#include "mozilla/dom/quota/QuotaCommon.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/ProfilerLabels.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsError.h"
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#include "FileInfo.h"
|
||||
|
||||
#include "mozilla/dom/QMResult.h"
|
||||
#include "mozilla/dom/QMResultInlines.h"
|
||||
#include "mozilla/dom/quota/QuotaCommon.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "nsIFile.h"
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
#include "mozilla/dom/indexedDB/PBackgroundIDBDatabaseFileChild.h"
|
||||
#include "mozilla/dom/indexedDB/PBackgroundIDBSharedTypes.h"
|
||||
#include "mozilla/dom/IPCBlobUtils.h"
|
||||
#include "mozilla/dom/QMResultInlines.h"
|
||||
#include "mozilla/dom/quota/QuotaManager.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/ipc/BackgroundChild.h"
|
||||
#include "mozilla/ipc/BackgroundUtils.h"
|
||||
#include "mozilla/ipc/FileDescriptor.h"
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "mozilla/dom/ErrorEventBinding.h"
|
||||
#include "mozilla/dom/WorkerScope.h"
|
||||
#include "mozilla/dom/WorkerPrivate.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/intl/LocaleCanonicalizer.h"
|
||||
#include "mozilla/ipc/BackgroundChild.h"
|
||||
#include "mozilla/ipc/PBackgroundChild.h"
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "mozilla/intl/Collator.h"
|
||||
#include "mozilla/ResultExtensions.h"
|
||||
#include "mozilla/ReverseIterator.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozIStorageStatement.h"
|
||||
#include "mozIStorageValueArray.h"
|
||||
#include "nsAlgorithm.h"
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "mozilla/dom/BlobBinding.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/dom/IDBObjectStoreBinding.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsPrintfCString.h"
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "mozilla/dom/indexedDB/Key.h"
|
||||
#include "mozilla/dom/quota/PersistenceType.h"
|
||||
#include "mozilla/dom/quota/QuotaCommon.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/fallible.h"
|
||||
#include "mozilla/ipc/BackgroundParent.h"
|
||||
#include "mozilla/mozalloc.h"
|
||||
|
|
|
@ -67,7 +67,6 @@
|
|||
#include "mozilla/dom/PBackgroundLSSharedTypes.h"
|
||||
#include "mozilla/dom/PBackgroundLSSimpleRequestParent.h"
|
||||
#include "mozilla/dom/PBackgroundLSSnapshotParent.h"
|
||||
#include "mozilla/dom/QMResultInlines.h"
|
||||
#include "mozilla/dom/SnappyUtils.h"
|
||||
#include "mozilla/dom/StorageDBUpdater.h"
|
||||
#include "mozilla/dom/StorageUtils.h"
|
||||
|
@ -84,6 +83,7 @@
|
|||
#include "mozilla/dom/quota/StorageHelpers.h"
|
||||
#include "mozilla/dom/quota/QuotaManager.h"
|
||||
#include "mozilla/dom/quota/QuotaObject.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/dom/quota/UsageInfo.h"
|
||||
#include "mozilla/ipc/BackgroundChild.h"
|
||||
#include "mozilla/ipc/BackgroundParent.h"
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/StaticPrefs_network.h"
|
||||
#include "mozilla/dom/StorageUtils.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/ipc/PBackgroundSharedTypes.h"
|
||||
#include "mozilla/net/MozURL.h"
|
||||
#include "mozilla/net/WebSocketFrame.h"
|
||||
|
|
|
@ -77,7 +77,6 @@
|
|||
#include "mozilla/dom/indexedDB/ActorsParent.h"
|
||||
#include "mozilla/dom/ipc/IdType.h"
|
||||
#include "mozilla/dom/localstorage/ActorsParent.h"
|
||||
#include "mozilla/dom/QMResultInlines.h"
|
||||
#include "mozilla/dom/quota/CheckedUnsafePtr.h"
|
||||
#include "mozilla/dom/quota/Client.h"
|
||||
#include "mozilla/dom/quota/DirectoryLock.h"
|
||||
|
@ -89,6 +88,7 @@
|
|||
#include "mozilla/dom/quota/PQuotaUsageRequest.h"
|
||||
#include "mozilla/dom/quota/PQuotaUsageRequestParent.h"
|
||||
#include "mozilla/dom/quota/QuotaManagerImpl.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/dom/quota/ScopedLogExtraInfo.h"
|
||||
#include "mozilla/dom/simpledb/ActorsParent.h"
|
||||
#include "mozilla/fallible.h"
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "mozilla/InitializedOnce.h"
|
||||
#include "mozilla/NotNull.h"
|
||||
#include "mozilla/dom/quota/QuotaCommon.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/dom/quota/ScopedLogExtraInfo.h"
|
||||
|
||||
namespace mozilla::dom::quota {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Result.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "nsDebug.h"
|
||||
#include "prio.h"
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef DOM_QUOTA_FORWARD_DECLS_H_
|
||||
#define DOM_QUOTA_FORWARD_DECLS_H_
|
||||
|
||||
#include "mozilla/dom/quota/Config.h"
|
||||
|
||||
#ifndef QM_ERROR_STACKS_ENABLED
|
||||
enum class nsresult : uint32_t;
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
class QMResult;
|
||||
#else
|
||||
using QMResult = nsresult;
|
||||
#endif
|
||||
|
||||
struct Ok;
|
||||
template <typename V, typename E>
|
||||
class Result;
|
||||
|
||||
using OkOrErr = Result<Ok, QMResult>;
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // DOM_QUOTA_FORWARD_DECLS_H_
|
|
@ -7,17 +7,13 @@
|
|||
#ifndef DOM_QUOTA_QMRESULT_H_
|
||||
#define DOM_QUOTA_QMRESULT_H_
|
||||
|
||||
#include "mozilla/dom/quota/Config.h"
|
||||
|
||||
#include "ErrorList.h"
|
||||
#include "mozilla/dom/quota/Config.h"
|
||||
#include "mozilla/dom/quota/ForwardDecls.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
struct Ok;
|
||||
template <typename V, typename E>
|
||||
class Result;
|
||||
|
||||
// A wrapped nsresult, primarily intended for use along with mozilla::Result
|
||||
// and QM_TRY macros. The wrapper contains stack id and frame id which are
|
||||
// reported in LogError besides the error result itself.
|
||||
|
@ -53,38 +49,10 @@ class QMResult {
|
|||
QMResult(uint64_t aStackId, uint32_t aFrameId, nsresult aNSResult)
|
||||
: mStackId(aStackId), mFrameId(aFrameId), mNSResult(aNSResult) {}
|
||||
};
|
||||
#else
|
||||
using QMResult = nsresult;
|
||||
#endif
|
||||
|
||||
inline QMResult ToQMResult(nsresult aValue) { return QMResult(aValue); }
|
||||
|
||||
using OkOrErr = Result<Ok, QMResult>;
|
||||
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
template <typename E = nsresult>
|
||||
inline Result<Ok, E> ToResult(const QMResult& aValue);
|
||||
|
||||
template <typename E = nsresult>
|
||||
inline Result<Ok, E> ToResult(QMResult&& aValue);
|
||||
#endif
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
// TODO: Maybe move this to mfbt/ResultExtensions.h
|
||||
#define MOZ_TO_RESULT(expr) ToResult(expr)
|
||||
|
||||
#define QM_TO_RESULT(expr) ToResult<QMResult>(expr)
|
||||
|
||||
#define QM_TO_RESULT_INVOKE(obj, methodname, ...) \
|
||||
::mozilla::ToResultInvoke<QMResult>( \
|
||||
(obj), &::mozilla::detail::DerefedType<decltype(obj)>::methodname, \
|
||||
##__VA_ARGS__)
|
||||
|
||||
#define QM_TO_RESULT_INVOKE_TYPED(resultType, obj, methodname, ...) \
|
||||
(::mozilla::ToResultInvoke<resultType, QMResult>( \
|
||||
::std::mem_fn( \
|
||||
&::mozilla::detail::DerefedType<decltype(obj)>::methodname), \
|
||||
(obj), ##__VA_ARGS__))
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "mozilla/TelemetryComms.h"
|
||||
#include "mozilla/TelemetryEventEnums.h"
|
||||
#include "mozilla/TextUtils.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/dom/quota/ScopedLogExtraInfo.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIFile.h"
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/Result.h"
|
||||
#include "mozilla/dom/Nullable.h"
|
||||
#include "mozilla/dom/QMResult.h"
|
||||
#include "mozilla/dom/ipc/IdType.h"
|
||||
#include "mozilla/dom/quota/CommonMetadata.h"
|
||||
#include "mozilla/dom/quota/ForwardDecls.h"
|
||||
#include "mozilla/dom/quota/InitializationTypes.h"
|
||||
#include "mozilla/dom/quota/PersistenceType.h"
|
||||
#include "mozilla/dom/quota/QuotaCommon.h"
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "mozilla/Variant.h"
|
||||
#include "mozilla/dom/quota/PQuota.h"
|
||||
#include "mozilla/dom/quota/PersistenceType.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/fallible.h"
|
||||
#include "mozilla/hal_sandbox/PHal.h"
|
||||
#include "mozilla/ipc/BackgroundChild.h"
|
||||
|
|
|
@ -7,15 +7,13 @@
|
|||
#ifndef DOM_QUOTA_QMRESULTINLINES_H_
|
||||
#define DOM_QUOTA_QMRESULTINLINES_H_
|
||||
|
||||
#ifndef DOM_QUOTA_QMRESULT_H_
|
||||
# error Must include QMResult.h first
|
||||
#endif
|
||||
|
||||
#include "nsError.h"
|
||||
#include "mozilla/Result.h"
|
||||
#include "mozilla/ResultExtensions.h"
|
||||
#include "mozilla/dom/QMResult.h"
|
||||
#include "mozilla/dom/quota/Config.h"
|
||||
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
# include "nsError.h"
|
||||
# include "mozilla/ResultVariant.h"
|
||||
#endif
|
||||
|
||||
|
@ -83,4 +81,20 @@ inline Result<Ok, E> ToResult(QMResult&& aValue) {
|
|||
|
||||
} // namespace mozilla
|
||||
|
||||
// TODO: Maybe move this to mfbt/ResultExtensions.h
|
||||
#define MOZ_TO_RESULT(expr) ToResult(expr)
|
||||
|
||||
#define QM_TO_RESULT(expr) ToResult<QMResult>(expr)
|
||||
|
||||
#define QM_TO_RESULT_INVOKE(obj, methodname, ...) \
|
||||
::mozilla::ToResultInvoke<QMResult>( \
|
||||
(obj), &::mozilla::detail::DerefedType<decltype(obj)>::methodname, \
|
||||
##__VA_ARGS__)
|
||||
|
||||
#define QM_TO_RESULT_INVOKE_TYPED(resultType, obj, methodname, ...) \
|
||||
(::mozilla::ToResultInvoke<resultType, QMResult>( \
|
||||
::std::mem_fn( \
|
||||
&::mozilla::detail::DerefedType<decltype(obj)>::methodname), \
|
||||
(obj), ##__VA_ARGS__))
|
||||
|
||||
#endif
|
|
@ -5,7 +5,9 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/quota/StorageHelpers.h"
|
||||
|
||||
#include "mozilla/dom/quota/QuotaCommon.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
|
||||
namespace mozilla::dom::quota {
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ XPIDL_MODULE = "dom_quota"
|
|||
|
||||
EXPORTS.mozilla.dom += [
|
||||
"QMResult.h",
|
||||
"QMResultInlines.h",
|
||||
"StorageManager.h",
|
||||
]
|
||||
|
||||
|
@ -43,6 +42,7 @@ EXPORTS.mozilla.dom.quota += [
|
|||
"FileStreams.h",
|
||||
"FirstInitializationAttempts.h",
|
||||
"FirstInitializationAttemptsImpl.h",
|
||||
"ForwardDecls.h",
|
||||
"InitializationTypes.h",
|
||||
"IPCStreamCipherStrategy.h",
|
||||
"MemoryOutputStream.h",
|
||||
|
@ -54,6 +54,7 @@ EXPORTS.mozilla.dom.quota += [
|
|||
"QuotaManagerImpl.h",
|
||||
"QuotaManagerService.h",
|
||||
"QuotaObject.h",
|
||||
"ResultExtensions.h",
|
||||
"ScopedLogExtraInfo.h",
|
||||
"SerializationHelpers.h",
|
||||
"StorageHelpers.h",
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
#include "mozilla/dom/QMResult.h"
|
||||
|
||||
namespace mozilla::dom::quota {
|
||||
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
uint64_t DOM_Quota_Test::sExpectedStackId;
|
||||
|
||||
// static
|
||||
void DOM_Quota_Test::SetUpTestCase() {
|
||||
sExpectedStackId = QMResult().StackId();
|
||||
}
|
||||
|
||||
// static
|
||||
void DOM_Quota_Test::IncreaseExpectedStackId() { sExpectedStackId++; }
|
||||
|
||||
// static
|
||||
uint64_t DOM_Quota_Test::ExpectedStackId() { return sExpectedStackId; }
|
||||
#endif
|
||||
|
||||
} // namespace mozilla::dom::quota
|
|
@ -0,0 +1,32 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef DOM_QUOTA_TEST_GTEST_COMMON_H_
|
||||
#define DOM_QUOTA_TEST_GTEST_COMMON_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include "gtest/gtest.h"
|
||||
#include "mozilla/dom/quota/Config.h"
|
||||
|
||||
namespace mozilla::dom::quota {
|
||||
|
||||
class DOM_Quota_Test : public testing::Test {
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
|
||||
static void IncreaseExpectedStackId();
|
||||
|
||||
static uint64_t ExpectedStackId();
|
||||
|
||||
private:
|
||||
static uint64_t sExpectedStackId;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace mozilla::dom::quota
|
||||
|
||||
#endif // DOM_QUOTA_TEST_GTEST_COMMON_H_
|
|
@ -0,0 +1,12 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <type_traits>
|
||||
#include "mozilla/dom/quota/ForwardDecls.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
static_assert(std::is_same_v<OkOrErr, Result<Ok, QMResult>>);
|
|
@ -4,30 +4,22 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "Common.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "mozilla/dom/QMResult.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "mozilla/dom/QMResultInlines.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom::quota;
|
||||
|
||||
static_assert(std::is_same_v<OkOrErr, Result<Ok, QMResult>>);
|
||||
|
||||
uint64_t gBaseStackId;
|
||||
|
||||
class DOM_Quota_QMResult : public testing::Test {
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
public:
|
||||
static void SetUpTestCase() { gBaseStackId = QMResult().StackId(); }
|
||||
#endif
|
||||
};
|
||||
class DOM_Quota_QMResult : public DOM_Quota_Test {};
|
||||
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
TEST_F(DOM_Quota_QMResult, Construct_Default) {
|
||||
QMResult res;
|
||||
|
||||
ASSERT_EQ(res.StackId(), gBaseStackId + 1);
|
||||
IncreaseExpectedStackId();
|
||||
|
||||
ASSERT_EQ(res.StackId(), ExpectedStackId());
|
||||
ASSERT_EQ(res.FrameId(), 1u);
|
||||
ASSERT_EQ(res.NSResult(), NS_OK);
|
||||
}
|
||||
|
@ -37,7 +29,9 @@ TEST_F(DOM_Quota_QMResult, Construct_FromNSResult) {
|
|||
QMResult res(NS_ERROR_FAILURE);
|
||||
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
ASSERT_EQ(res.StackId(), gBaseStackId + 2);
|
||||
IncreaseExpectedStackId();
|
||||
|
||||
ASSERT_EQ(res.StackId(), ExpectedStackId());
|
||||
ASSERT_EQ(res.FrameId(), 1u);
|
||||
ASSERT_EQ(res.NSResult(), NS_ERROR_FAILURE);
|
||||
#else
|
||||
|
@ -49,13 +43,15 @@ TEST_F(DOM_Quota_QMResult, Construct_FromNSResult) {
|
|||
TEST_F(DOM_Quota_QMResult, Propagate) {
|
||||
QMResult res1(NS_ERROR_FAILURE);
|
||||
|
||||
ASSERT_EQ(res1.StackId(), gBaseStackId + 3);
|
||||
IncreaseExpectedStackId();
|
||||
|
||||
ASSERT_EQ(res1.StackId(), ExpectedStackId());
|
||||
ASSERT_EQ(res1.FrameId(), 1u);
|
||||
ASSERT_EQ(res1.NSResult(), NS_ERROR_FAILURE);
|
||||
|
||||
QMResult res2 = res1.Propagate();
|
||||
|
||||
ASSERT_EQ(res2.StackId(), gBaseStackId + 3);
|
||||
ASSERT_EQ(res2.StackId(), ExpectedStackId());
|
||||
ASSERT_EQ(res2.FrameId(), 2u);
|
||||
ASSERT_EQ(res2.NSResult(), NS_ERROR_FAILURE);
|
||||
}
|
||||
|
@ -65,90 +61,12 @@ TEST_F(DOM_Quota_QMResult, ToQMResult) {
|
|||
auto res = ToQMResult(NS_ERROR_FAILURE);
|
||||
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
ASSERT_EQ(res.StackId(), gBaseStackId + 4);
|
||||
IncreaseExpectedStackId();
|
||||
|
||||
ASSERT_EQ(res.StackId(), ExpectedStackId());
|
||||
ASSERT_EQ(res.FrameId(), 1u);
|
||||
ASSERT_EQ(res.NSResult(), NS_ERROR_FAILURE);
|
||||
#else
|
||||
ASSERT_EQ(res, NS_ERROR_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_F(DOM_Quota_QMResult, ToResult) {
|
||||
// copy
|
||||
{
|
||||
const auto res = ToQMResult(NS_ERROR_FAILURE);
|
||||
auto okOrErr = ToResult<QMResult>(res);
|
||||
static_assert(std::is_same_v<decltype(okOrErr), OkOrErr>);
|
||||
ASSERT_TRUE(okOrErr.isErr());
|
||||
auto err = okOrErr.unwrapErr();
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
ASSERT_EQ(err.StackId(), gBaseStackId + 5);
|
||||
ASSERT_EQ(err.FrameId(), 1u);
|
||||
ASSERT_EQ(err.NSResult(), NS_ERROR_FAILURE);
|
||||
#else
|
||||
ASSERT_EQ(err, NS_ERROR_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
||||
// move
|
||||
{
|
||||
auto res = ToQMResult(NS_ERROR_FAILURE);
|
||||
auto okOrErr = ToResult<QMResult>(std::move(res));
|
||||
static_assert(std::is_same_v<decltype(okOrErr), OkOrErr>);
|
||||
ASSERT_TRUE(okOrErr.isErr());
|
||||
auto err = okOrErr.unwrapErr();
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
ASSERT_EQ(err.StackId(), gBaseStackId + 6);
|
||||
ASSERT_EQ(err.FrameId(), 1u);
|
||||
ASSERT_EQ(err.NSResult(), NS_ERROR_FAILURE);
|
||||
#else
|
||||
ASSERT_EQ(err, NS_ERROR_FAILURE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DOM_Quota_QMResult, ToResult_Macro) {
|
||||
auto okOrErr = QM_TO_RESULT(NS_ERROR_FAILURE);
|
||||
static_assert(std::is_same_v<decltype(okOrErr), OkOrErr>);
|
||||
ASSERT_TRUE(okOrErr.isErr());
|
||||
auto err = okOrErr.unwrapErr();
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
ASSERT_EQ(err.StackId(), gBaseStackId + 7);
|
||||
ASSERT_EQ(err.FrameId(), 1u);
|
||||
ASSERT_EQ(err.NSResult(), NS_ERROR_FAILURE);
|
||||
#else
|
||||
ASSERT_EQ(err, NS_ERROR_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_F(DOM_Quota_QMResult, ErrorPropagation) {
|
||||
OkOrErr okOrErr1 = ToResult<QMResult>(ToQMResult(NS_ERROR_FAILURE));
|
||||
const auto& err1 = okOrErr1.inspectErr();
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
ASSERT_EQ(err1.StackId(), gBaseStackId + 8);
|
||||
ASSERT_EQ(err1.FrameId(), 1u);
|
||||
ASSERT_EQ(err1.NSResult(), NS_ERROR_FAILURE);
|
||||
#else
|
||||
ASSERT_EQ(err1, NS_ERROR_FAILURE);
|
||||
#endif
|
||||
|
||||
OkOrErr okOrErr2 = okOrErr1.propagateErr();
|
||||
const auto& err2 = okOrErr2.inspectErr();
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
ASSERT_EQ(err2.StackId(), gBaseStackId + 8);
|
||||
ASSERT_EQ(err2.FrameId(), 2u);
|
||||
ASSERT_EQ(err2.NSResult(), NS_ERROR_FAILURE);
|
||||
#else
|
||||
ASSERT_EQ(err2, NS_ERROR_FAILURE);
|
||||
#endif
|
||||
|
||||
OkOrErr okOrErr3 = okOrErr2.propagateErr();
|
||||
const auto& err3 = okOrErr3.inspectErr();
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
ASSERT_EQ(err3.StackId(), gBaseStackId + 8);
|
||||
ASSERT_EQ(err3.FrameId(), 3u);
|
||||
ASSERT_EQ(err3.NSResult(), NS_ERROR_FAILURE);
|
||||
#else
|
||||
ASSERT_EQ(err3, NS_ERROR_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "mozilla/ResultVariant.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/fallible.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsLiteralString.h"
|
||||
#include "nsString.h"
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "Common.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "mozilla/dom/QMResult.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom::quota;
|
||||
|
||||
class DOM_Quota_ResultExtensions_ToResult : public DOM_Quota_Test {};
|
||||
class DOM_Quota_ResultExtensions_GenericErrorResult : public DOM_Quota_Test {};
|
||||
|
||||
TEST_F(DOM_Quota_ResultExtensions_ToResult, FromQMResult_Failure) {
|
||||
// copy
|
||||
{
|
||||
const auto res = ToQMResult(NS_ERROR_FAILURE);
|
||||
auto okOrErr = ToResult<QMResult>(res);
|
||||
static_assert(std::is_same_v<decltype(okOrErr), OkOrErr>);
|
||||
ASSERT_TRUE(okOrErr.isErr());
|
||||
auto err = okOrErr.unwrapErr();
|
||||
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
IncreaseExpectedStackId();
|
||||
|
||||
ASSERT_EQ(err.StackId(), ExpectedStackId());
|
||||
ASSERT_EQ(err.FrameId(), 1u);
|
||||
ASSERT_EQ(err.NSResult(), NS_ERROR_FAILURE);
|
||||
#else
|
||||
ASSERT_EQ(err, NS_ERROR_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
||||
// move
|
||||
{
|
||||
auto res = ToQMResult(NS_ERROR_FAILURE);
|
||||
auto okOrErr = ToResult<QMResult>(std::move(res));
|
||||
static_assert(std::is_same_v<decltype(okOrErr), OkOrErr>);
|
||||
ASSERT_TRUE(okOrErr.isErr());
|
||||
auto err = okOrErr.unwrapErr();
|
||||
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
IncreaseExpectedStackId();
|
||||
|
||||
ASSERT_EQ(err.StackId(), ExpectedStackId());
|
||||
ASSERT_EQ(err.FrameId(), 1u);
|
||||
ASSERT_EQ(err.NSResult(), NS_ERROR_FAILURE);
|
||||
#else
|
||||
ASSERT_EQ(err, NS_ERROR_FAILURE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DOM_Quota_ResultExtensions_ToResult, FromNSResult_Failure_Macro) {
|
||||
auto okOrErr = QM_TO_RESULT(NS_ERROR_FAILURE);
|
||||
static_assert(std::is_same_v<decltype(okOrErr), OkOrErr>);
|
||||
ASSERT_TRUE(okOrErr.isErr());
|
||||
auto err = okOrErr.unwrapErr();
|
||||
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
IncreaseExpectedStackId();
|
||||
|
||||
ASSERT_EQ(err.StackId(), ExpectedStackId());
|
||||
ASSERT_EQ(err.FrameId(), 1u);
|
||||
ASSERT_EQ(err.NSResult(), NS_ERROR_FAILURE);
|
||||
#else
|
||||
ASSERT_EQ(err, NS_ERROR_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_F(DOM_Quota_ResultExtensions_GenericErrorResult, ErrorPropagation) {
|
||||
OkOrErr okOrErr1 = ToResult<QMResult>(ToQMResult(NS_ERROR_FAILURE));
|
||||
const auto& err1 = okOrErr1.inspectErr();
|
||||
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
IncreaseExpectedStackId();
|
||||
|
||||
ASSERT_EQ(err1.StackId(), ExpectedStackId());
|
||||
ASSERT_EQ(err1.FrameId(), 1u);
|
||||
ASSERT_EQ(err1.NSResult(), NS_ERROR_FAILURE);
|
||||
#else
|
||||
ASSERT_EQ(err1, NS_ERROR_FAILURE);
|
||||
#endif
|
||||
|
||||
OkOrErr okOrErr2 = okOrErr1.propagateErr();
|
||||
const auto& err2 = okOrErr2.inspectErr();
|
||||
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
ASSERT_EQ(err2.StackId(), ExpectedStackId());
|
||||
ASSERT_EQ(err2.FrameId(), 2u);
|
||||
ASSERT_EQ(err2.NSResult(), NS_ERROR_FAILURE);
|
||||
#else
|
||||
ASSERT_EQ(err2, NS_ERROR_FAILURE);
|
||||
#endif
|
||||
|
||||
OkOrErr okOrErr3 = okOrErr2.propagateErr();
|
||||
const auto& err3 = okOrErr3.inspectErr();
|
||||
|
||||
#ifdef QM_ERROR_STACKS_ENABLED
|
||||
ASSERT_EQ(err3.StackId(), ExpectedStackId());
|
||||
ASSERT_EQ(err3.FrameId(), 3u);
|
||||
ASSERT_EQ(err3.NSResult(), NS_ERROR_FAILURE);
|
||||
#else
|
||||
ASSERT_EQ(err3, NS_ERROR_FAILURE);
|
||||
#endif
|
||||
}
|
|
@ -5,13 +5,16 @@
|
|||
# file, you can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
UNIFIED_SOURCES = [
|
||||
"Common.cpp",
|
||||
"TestCheckedUnsafePtr.cpp",
|
||||
"TestEncryptedStream.cpp",
|
||||
"TestFlatten.cpp",
|
||||
"TestForwardDecls.cpp",
|
||||
"TestPersistenceType.cpp",
|
||||
"TestQMResult.cpp",
|
||||
"TestQuotaCommon.cpp",
|
||||
"TestQuotaManager.cpp",
|
||||
"TestResultExtensions.cpp",
|
||||
"TestScopedLogExtraInfo.cpp",
|
||||
"TestUsageInfo.cpp",
|
||||
]
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "mozilla/dom/quota/MemoryOutputStream.h"
|
||||
#include "mozilla/dom/quota/QuotaCommon.h"
|
||||
#include "mozilla/dom/quota/QuotaManager.h"
|
||||
#include "mozilla/dom/quota/ResultExtensions.h"
|
||||
#include "mozilla/dom/quota/UsageInfo.h"
|
||||
#include "mozilla/ipc/BackgroundParent.h"
|
||||
#include "mozilla/ipc/BackgroundUtils.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче