mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-15 04:39:31 +00:00
Bug 1927476 - Part 1: Switch ResolveCallback/RejectCallback to be MoveOnlyFunction, r=ipc-reviewers,mccr8
This requires a small change to the filesystem code, as the FileSystemManager::BeginRequest signature explicitly uses the type outside of IPC code. We never need to copy the request object, so using std::function applies unnecessary restrictions. Differential Revision: https://phabricator.services.mozilla.com/D228098
This commit is contained in:
parent
a01fb0411e
commit
84e123fcb1
@ -93,8 +93,8 @@ void FileSystemManager::UnregisterPromiseRequestHolder(
|
||||
}
|
||||
|
||||
void FileSystemManager::BeginRequest(
|
||||
std::function<void(RefPtr<FileSystemManagerChild>)>&& aSuccess,
|
||||
std::function<void(nsresult)>&& aFailure) {
|
||||
MoveOnlyFunction<void(RefPtr<FileSystemManagerChild>)>&& aSuccess,
|
||||
MoveOnlyFunction<void(nsresult)>&& aFailure) {
|
||||
MOZ_ASSERT(!mShutdown);
|
||||
|
||||
MOZ_ASSERT(mGlobal);
|
||||
@ -123,7 +123,7 @@ void FileSystemManager::BeginRequest(
|
||||
[self = RefPtr<FileSystemManager>(this), holder,
|
||||
success = std::move(aSuccess), failure = std::move(aFailure)](
|
||||
const FileSystemManagerChild::ActorPromise::ResolveOrRejectValue&
|
||||
aValue) {
|
||||
aValue) mutable {
|
||||
holder->Complete();
|
||||
|
||||
if (aValue.IsResolve()) {
|
||||
|
@ -77,8 +77,8 @@ class FileSystemManager : public nsISupports {
|
||||
PromiseRequestHolder<FileSystemManagerChild::ActorPromise>* aHolder);
|
||||
|
||||
void BeginRequest(
|
||||
std::function<void(RefPtr<FileSystemManagerChild>)>&& aSuccess,
|
||||
std::function<void(nsresult)>&& aFailure);
|
||||
MoveOnlyFunction<void(RefPtr<FileSystemManagerChild>)>&& aSuccess,
|
||||
MoveOnlyFunction<void(nsresult)>&& aFailure);
|
||||
|
||||
already_AddRefed<Promise> GetDirectory(ErrorResult& aError);
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "mozilla/BaseProfilerMarkers.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "mozilla/MoveOnlyFunction.h"
|
||||
#include "mozilla/Vector.h"
|
||||
#if defined(XP_WIN)
|
||||
# include "mozilla/ipc/Neutering.h"
|
||||
@ -93,9 +94,9 @@ enum class ResponseRejectReason {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using ResolveCallback = std::function<void(T&&)>;
|
||||
using ResolveCallback = MoveOnlyFunction<void(T&&)>;
|
||||
|
||||
using RejectCallback = std::function<void(ResponseRejectReason)>;
|
||||
using RejectCallback = MoveOnlyFunction<void(ResponseRejectReason)>;
|
||||
|
||||
enum ChannelState {
|
||||
ChannelClosed,
|
||||
|
Loading…
x
Reference in New Issue
Block a user