зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1358697 - Don't capture the Promise raw pointer and make static analysis happy. r=billm
MozReview-Commit-ID: 7lMVMcNBDHJ --HG-- extra : rebase_source : 3526408144e9d0486e0c212151682bc98275c8e5
This commit is contained in:
Родитель
28a432c0ec
Коммит
6c2259f717
|
@ -717,7 +717,7 @@ MessageChannel::Clear()
|
|||
|
||||
gUnresolvedPromises -= mPendingPromises.size();
|
||||
for (auto& pair : mPendingPromises) {
|
||||
pair.second.mRejectFunction(__func__);
|
||||
pair.second.mRejectFunction(pair.second.mPromise, __func__);
|
||||
}
|
||||
mPendingPromises.clear();
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ class MessageChannel : HasResultCodes, MessageLoop::DestructionObserver
|
|||
struct PromiseHolder
|
||||
{
|
||||
RefPtr<MozPromiseRefcountable> mPromise;
|
||||
std::function<void(const char*)> mRejectFunction;
|
||||
std::function<void(MozPromiseRefcountable*, const char*)> mRejectFunction;
|
||||
};
|
||||
static Atomic<size_t> gUnresolvedPromises;
|
||||
friend class PromiseReporter;
|
||||
|
@ -186,8 +186,10 @@ class MessageChannel : HasResultCodes, MessageLoop::DestructionObserver
|
|||
}
|
||||
PromiseHolder holder;
|
||||
holder.mPromise = aPromise;
|
||||
holder.mRejectFunction = [aPromise](const char* aRejectSite) {
|
||||
aPromise->Reject(PromiseRejectReason::ChannelClosed, aRejectSite);
|
||||
holder.mRejectFunction = [](MozPromiseRefcountable* aRejectPromise,
|
||||
const char* aRejectSite) {
|
||||
static_cast<Promise*>(aRejectPromise)->Reject(
|
||||
PromiseRejectReason::ChannelClosed, aRejectSite);
|
||||
};
|
||||
mPendingPromises.insert(std::make_pair(seqno, Move(holder)));
|
||||
gUnresolvedPromises++;
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "IPDLUnitTests.h" // fail etc.
|
||||
|
||||
#include "mozilla/Unused.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace _ipdltest {
|
||||
|
||||
|
@ -79,7 +81,7 @@ mozilla::ipc::IPCResult
|
|||
TestAsyncReturnsChild::RecvNoReturn(RefPtr<NoReturnPromise>&& aPromise)
|
||||
{
|
||||
// Leak the promise intentionally
|
||||
aPromise->AddRef();
|
||||
Unused << do_AddRef(aPromise);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче