summaryrefslogtreecommitdiffstats
path: root/dom/quota
diff options
context:
space:
mode:
Diffstat (limited to 'dom/quota')
-rw-r--r--dom/quota/QuotaCommon.cpp6
-rw-r--r--dom/quota/QuotaCommon.h54
-rw-r--r--dom/quota/StorageManager.cpp8
-rw-r--r--dom/quota/test/gtest/TestEncryptedStream.cpp17
4 files changed, 64 insertions, 21 deletions
diff --git a/dom/quota/QuotaCommon.cpp b/dom/quota/QuotaCommon.cpp
index 71b6186d00..a05d52ee3c 100644
--- a/dom/quota/QuotaCommon.cpp
+++ b/dom/quota/QuotaCommon.cpp
@@ -38,18 +38,18 @@
namespace mozilla {
-RefPtr<BoolPromise> CreateAndRejectBoolPromise(const char* aFunc,
+RefPtr<BoolPromise> CreateAndRejectBoolPromise(StaticString aFunc,
nsresult aRv) {
return CreateAndRejectMozPromise<BoolPromise>(aFunc, aRv);
}
-RefPtr<Int64Promise> CreateAndRejectInt64Promise(const char* aFunc,
+RefPtr<Int64Promise> CreateAndRejectInt64Promise(StaticString aFunc,
nsresult aRv) {
return CreateAndRejectMozPromise<Int64Promise>(aFunc, aRv);
}
RefPtr<BoolPromise> CreateAndRejectBoolPromiseFromQMResult(
- const char* aFunc, const QMResult& aRv) {
+ StaticString aFunc, const QMResult& aRv) {
return CreateAndRejectMozPromise<BoolPromise>(aFunc, aRv);
}
diff --git a/dom/quota/QuotaCommon.h b/dom/quota/QuotaCommon.h
index 74855dd16b..166e8de969 100644
--- a/dom/quota/QuotaCommon.h
+++ b/dom/quota/QuotaCommon.h
@@ -22,6 +22,7 @@
#include "mozilla/MacroArgs.h"
#include "mozilla/Maybe.h"
#include "mozilla/ResultExtensions.h"
+#include "mozilla/StaticString.h"
#include "mozilla/Try.h"
#if defined(QM_LOG_ERROR_ENABLED) && defined(QM_ERROR_STACKS_ENABLED)
# include "mozilla/Variant.h"
@@ -1133,7 +1134,7 @@ auto ErrToDefaultOk(const nsresult aValue) -> Result<V, nsresult> {
}
template <typename MozPromiseType, typename RejectValueT = nsresult>
-auto CreateAndRejectMozPromise(const char* aFunc, const RejectValueT& aRv)
+auto CreateAndRejectMozPromise(StaticString aFunc, const RejectValueT& aRv)
-> decltype(auto) {
if constexpr (std::is_same_v<RejectValueT, nsresult>) {
return MozPromiseType::CreateAndReject(aRv, aFunc);
@@ -1142,12 +1143,13 @@ auto CreateAndRejectMozPromise(const char* aFunc, const RejectValueT& aRv)
}
}
-RefPtr<BoolPromise> CreateAndRejectBoolPromise(const char* aFunc, nsresult aRv);
+RefPtr<BoolPromise> CreateAndRejectBoolPromise(StaticString aFunc,
+ nsresult aRv);
-RefPtr<Int64Promise> CreateAndRejectInt64Promise(const char* aFunc,
+RefPtr<Int64Promise> CreateAndRejectInt64Promise(StaticString aFunc,
nsresult aRv);
-RefPtr<BoolPromise> CreateAndRejectBoolPromiseFromQMResult(const char* aFunc,
+RefPtr<BoolPromise> CreateAndRejectBoolPromiseFromQMResult(StaticString aFunc,
const QMResult& aRv);
// Like Rust's collect with a step function, not a generic iterator/range.
@@ -1493,9 +1495,49 @@ Nothing HandleErrorWithCleanupReturnNothing(const char* aExpr, const T& aRv,
return Nothing();
}
-template <size_t NFunc, size_t NExpr, typename T, typename CustomRetVal>
+// Implementation of workaround for GCC bug #114812.
+#if defined(__GNUC__) && !defined(__clang__)
+namespace gcc_detail {
+// usual case: identity function
+template <typename T>
+struct invokabilize_impl {
+ auto operator()(T t) -> T { return t; }
+};
+// reference-to-function: wrap in std::function
+template <typename R, typename... Args>
+struct invokabilize_impl<R (&)(Args...)> {
+ auto operator()(R (&t)(Args...)) -> std::function<R(Args...)> {
+ return std::function{t};
+ }
+};
+// pointer-to-function: wrap in std::function
+template <typename R, typename... Args>
+struct invokabilize_impl<R (*)(Args...)> {
+ auto operator()(R (*t)(Args...)) -> std::function<R(Args...)> {
+ return std::function{t};
+ }
+};
+// entry point
+template <typename T>
+auto invokabilize(T t) {
+ return invokabilize_impl<T>{}(std::forward<T>(t));
+}
+} // namespace gcc_detail
+#endif
+
+template <size_t NFunc, size_t NExpr, typename T, typename CustomRetVal_>
auto HandleCustomRetVal(const char (&aFunc)[NFunc], const char (&aExpr)[NExpr],
- const T& aRv, CustomRetVal&& aCustomRetVal) {
+ const T& aRv, CustomRetVal_&& aCustomRetVal_) {
+#if defined(__GNUC__) && !defined(__clang__)
+ // Workaround for gcc bug #114812. (See either that bug, or our bug 1891541,
+ // for more details.)
+ auto aCustomRetVal =
+ gcc_detail::invokabilize(std::forward<CustomRetVal_>(aCustomRetVal_));
+ using CustomRetVal = decltype(aCustomRetVal);
+#else
+ using CustomRetVal = CustomRetVal_;
+ CustomRetVal& aCustomRetVal = aCustomRetVal_;
+#endif
if constexpr (std::is_invocable<CustomRetVal, const char[NFunc],
const char[NExpr]>::value) {
return std::forward<CustomRetVal>(aCustomRetVal)(aFunc, aExpr);
diff --git a/dom/quota/StorageManager.cpp b/dom/quota/StorageManager.cpp
index ec1e5b274f..cfff5cf202 100644
--- a/dom/quota/StorageManager.cpp
+++ b/dom/quota/StorageManager.cpp
@@ -119,13 +119,13 @@ class RequestResolver final : public nsIQuotaCallback {
};
// This class is used to return promise on worker thread.
-class RequestResolver::FinishWorkerRunnable final : public WorkerRunnable {
+class RequestResolver::FinishWorkerRunnable final
+ : public WorkerThreadRunnable {
RefPtr<RequestResolver> mResolver;
public:
explicit FinishWorkerRunnable(RequestResolver* aResolver)
- : WorkerRunnable(aResolver->mProxy->GetWorkerPrivate(),
- "RequestResolver::FinishWorkerRunnable"),
+ : WorkerThreadRunnable("RequestResolver::FinishWorkerRunnable"),
mResolver(aResolver) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aResolver);
@@ -565,7 +565,7 @@ nsresult RequestResolver::Finish() {
}
RefPtr<FinishWorkerRunnable> runnable = new FinishWorkerRunnable(this);
- if (NS_WARN_IF(!runnable->Dispatch())) {
+ if (NS_WARN_IF(!runnable->Dispatch(mProxy->GetWorkerPrivate()))) {
return NS_ERROR_FAILURE;
}
}
diff --git a/dom/quota/test/gtest/TestEncryptedStream.cpp b/dom/quota/test/gtest/TestEncryptedStream.cpp
index 8937b0c4e7..04fe43f38e 100644
--- a/dom/quota/test/gtest/TestEncryptedStream.cpp
+++ b/dom/quota/test/gtest/TestEncryptedStream.cpp
@@ -127,20 +127,20 @@ ArrayBufferInputStream::Read(char* aBuf, uint32_t aCount,
NS_IMETHODIMP
ArrayBufferInputStream::ReadSegments(nsWriteSegmentFun writer, void* closure,
uint32_t aCount, uint32_t* result) {
- MOZ_ASSERT(result, "null ptr");
- MOZ_ASSERT(mBufferLength >= mPos, "bad stream state");
+ MOZ_RELEASE_ASSERT(result, "null ptr");
+ MOZ_RELEASE_ASSERT(mBufferLength >= mPos, "bad stream state");
if (mClosed) {
return NS_BASE_STREAM_CLOSED;
}
- MOZ_ASSERT(mArrayBuffer || (mPos == mBufferLength),
- "stream inited incorrectly");
+ MOZ_RELEASE_ASSERT(mArrayBuffer || (mPos == mBufferLength),
+ "stream inited incorrectly");
*result = 0;
while (mPos < mBufferLength) {
uint32_t remaining = mBufferLength - mPos;
- MOZ_ASSERT(mArrayBuffer);
+ MOZ_RELEASE_ASSERT(mArrayBuffer);
uint32_t count = std::min(aCount, remaining);
if (count == 0) {
@@ -155,8 +155,9 @@ ArrayBufferInputStream::ReadSegments(nsWriteSegmentFun writer, void* closure,
return NS_OK;
}
- MOZ_ASSERT(written <= count,
- "writer should not write more than we asked it to write");
+ MOZ_RELEASE_ASSERT(
+ written <= count,
+ "writer should not write more than we asked it to write");
mPos += written;
*result += written;
aCount -= written;
@@ -174,7 +175,7 @@ ArrayBufferInputStream::IsNonBlocking(bool* aNonBlocking) {
}
NS_IMETHODIMP ArrayBufferInputStream::Tell(int64_t* const aRetval) {
- MOZ_ASSERT(aRetval);
+ MOZ_RELEASE_ASSERT(aRetval);
*aRetval = mPos;