Bug 1754004 - Part 3: Move RemoteLazyInputStream to its own toplevel protocol, r=asuth,necko-reviewers,dragana

This is a complete rewrite of RemoteLazyInputStream to run off of its own
toplevel protocol, rather than being managed by other protocols like
PBackground or PContent. This should improve performance thanks to no longer
needing to operate on a main or worker thread, and due to no longer needing the
migration step for the stream actor.

This also acts as a step towards no longer requiring a manager actor to
serialize input streams, as the type is now actor-agnostic, and should support
being sent over IPC between any pair of processes.

Differential Revision: https://phabricator.services.mozilla.com/D141040
This commit is contained in:
Nika Layzell
2022-05-03 23:30:33 +00:00
parent ad8e969304
commit 21a97e8389
60 changed files with 1149 additions and 1720 deletions

View File

@@ -7,7 +7,6 @@
#include "mozilla/NotNull.h"
#include "mozilla/RemoteLazyInputStreamChild.h"
#include "mozilla/RemoteLazyInputStreamStorage.h"
#include "mozilla/RemoteLazyInputStreamUtils.h"
#include "mozilla/dom/FetchTypes.h"
#include "mozilla/dom/IPCBlob.h"
#include "nsContentUtils.h"
@@ -35,9 +34,7 @@ NotNull<nsCOMPtr<nsIInputStream>> ToInputStream(
NotNull<nsCOMPtr<nsIInputStream>> ToInputStream(
const ParentToChildStream& aStream) {
MOZ_ASSERT(XRE_IsContentProcess());
nsCOMPtr<nsIInputStream> result =
static_cast<RemoteLazyInputStreamChild*>(aStream.actorChild())
->CreateStream();
nsCOMPtr<nsIInputStream> result = aStream.stream();
return WrapNotNull(result);
}
@@ -47,8 +44,7 @@ ParentToParentStream ToParentToParentStream(
ParentToParentStream stream;
stream.uuid() = nsID::GenerateUUID();
GetRemoteLazyInputStreamStorage()->AddStream(aStream.get(), stream.uuid(),
aStreamSize, 0);
GetRemoteLazyInputStreamStorage()->AddStream(aStream.get(), stream.uuid());
return stream;
}
@@ -58,10 +54,7 @@ ParentToChildStream ToParentToChildStream(
MOZ_ASSERT(XRE_IsParentProcess());
ParentToChildStream result;
RemoteLazyStream remoteLazyStream;
MOZ_ALWAYS_SUCCEEDS(RemoteLazyInputStreamUtils::SerializeInputStream(
aStream.get(), aStreamSize, remoteLazyStream, aBackgroundParent));
result.actorParent() = remoteLazyStream;
result.stream() = RemoteLazyInputStream::WrapStream(aStream.get());
return result;
}

View File

@@ -7,8 +7,6 @@ include IPCChannelInfo;
include PBackgroundSharedTypes;
include PerformanceTimingTypes;
include protocol PRemoteLazyInputStream;
include "mozilla/dom/FetchIPCTypes.h";
using HeadersGuardEnum from "mozilla/dom/HeadersBinding.h";
@@ -19,6 +17,7 @@ using RequestMode from "mozilla/dom/RequestBinding.h";
using RequestRedirect from "mozilla/dom/RequestBinding.h";
using ResponseType from "mozilla/dom/ResponseBinding.h";
using struct nsID from "nsID.h";
[RefCounted] using class mozilla::RemoteLazyInputStream from "mozilla/RemoteLazyInputStream.h";
namespace mozilla {
namespace dom {
@@ -34,7 +33,7 @@ struct ParentToParentStream {
};
struct ParentToChildStream {
PRemoteLazyInputStream actor;
RemoteLazyInputStream stream;
};
struct ChildToParentStream {

View File

@@ -171,9 +171,7 @@ InternalRequest::InternalRequest(const IPCInternalRequest& aIPCRequest)
// (constructed on the child side).
if (body) {
MOZ_ASSERT(body->type() == BodyStreamVariant::TParentToChildStream);
mBodyStream = static_cast<RemoteLazyInputStreamChild*>(
body->get_ParentToChildStream().actorChild())
->CreateStream();
mBodyStream = body->get_ParentToChildStream().stream();
}
}