Bug 1773088 - Part 3: Remove StealFromAndBuildClonedMessageData, r=asuth

This API should no longer be necessary, as there's nothing tied to a specific
actor in the serialized IPCBlob form any longer, so the value can be directly
transferred without special handling or re-serialization.

Differential Revision: https://phabricator.services.mozilla.com/D148533
This commit is contained in:
Nika Layzell 2022-06-08 15:24:28 +00:00
Родитель 7eef772214
Коммит 6c2d8c7bf5
3 изменённых файлов: 12 добавлений и 65 удалений

Просмотреть файл

@ -32,30 +32,6 @@ ServiceWorkerCloneData::ServiceWorkerCloneData()
MOZ_DIAGNOSTIC_ASSERT(mEventTarget);
}
bool ServiceWorkerCloneData::StealFromAndBuildClonedMessageData(
ClonedOrErrorMessageData& aFromClonedData,
ClonedOrErrorMessageData& aToClonedData) {
if (aFromClonedData.type() == ClonedOrErrorMessageData::TErrorMessageData) {
mIsErrorMessageData = true;
aToClonedData = ErrorMessageData();
return true;
}
MOZ_DIAGNOSTIC_ASSERT(aFromClonedData.type() ==
ClonedOrErrorMessageData::TClonedMessageData);
StructuredCloneData::StealFromClonedMessageData(aFromClonedData);
ClonedMessageData messageData;
if (!StructuredCloneData::BuildClonedMessageData(messageData)) {
return false;
}
aToClonedData = std::move(messageData);
return true;
}
bool ServiceWorkerCloneData::BuildClonedMessageData(
ClonedOrErrorMessageData& aClonedData) {
if (IsErrorMessageData()) {

Просмотреть файл

@ -54,13 +54,6 @@ class ServiceWorkerCloneData final : public ipc::StructuredCloneData {
public:
ServiceWorkerCloneData();
// FIXME: Now that there's nothing in ClonedOrErrorMessageData tied to a
// specific actor, it should be possible to just pass on the same cloned data,
// which means this method is effectively an expensive no-op.
bool StealFromAndBuildClonedMessageData(
ClonedOrErrorMessageData& aFromClonedData,
ClonedOrErrorMessageData& aToClonedData);
bool BuildClonedMessageData(ClonedOrErrorMessageData& aClonedData);
void CopyFromClonedMessageData(const ClonedOrErrorMessageData& aClonedData);

Просмотреть файл

@ -464,42 +464,20 @@ bool RemoteWorkerController::PendingServiceWorkerOp::MaybeStart(
return false;
}
const auto send = [this, &aOwner](const ServiceWorkerOpArgs& args) {
MaybeReportServiceWorkerShutdownProgress(args);
MaybeReportServiceWorkerShutdownProgress(mArgs);
aOwner->mActor->SendExecServiceWorkerOp(args)->Then(
GetCurrentSerialEventTarget(), __func__,
[promise = std::move(mPromise)](
PRemoteWorkerParent::ExecServiceWorkerOpPromise::
ResolveOrRejectValue&& aResult) {
if (NS_WARN_IF(aResult.IsReject())) {
promise->Reject(NS_ERROR_DOM_ABORT_ERR, __func__);
return;
}
aOwner->mActor->SendExecServiceWorkerOp(mArgs)->Then(
GetCurrentSerialEventTarget(), __func__,
[promise = std::move(mPromise)](
PRemoteWorkerParent::ExecServiceWorkerOpPromise::
ResolveOrRejectValue&& aResult) {
if (NS_WARN_IF(aResult.IsReject())) {
promise->Reject(NS_ERROR_DOM_ABORT_ERR, __func__);
return;
}
promise->Resolve(std::move(aResult.ResolveValue()), __func__);
});
};
if (mArgs.type() == ServiceWorkerOpArgs::TServiceWorkerMessageEventOpArgs) {
auto& args = mArgs.get_ServiceWorkerMessageEventOpArgs();
ServiceWorkerMessageEventOpArgs copyArgs;
copyArgs.clientInfoAndState() = std::move(args.clientInfoAndState());
RefPtr<ServiceWorkerCloneData> copyData = new ServiceWorkerCloneData();
if (!copyData->StealFromAndBuildClonedMessageData(args.clonedData(),
copyArgs.clonedData())) {
mPromise->Reject(NS_ERROR_DOM_DATA_CLONE_ERR, __func__);
mPromise = nullptr;
return true;
}
// copyArgs depends on mArgs due to BuildClonedMessageData.
send(std::move(copyArgs));
} else {
send(mArgs);
}
promise->Resolve(std::move(aResult.ResolveValue()), __func__);
});
return true;
}