зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1681529 - Part 11: Avoid using DelayedStart when serialzing the reply from SendOpenStream, r=asuth
Streams serialized with the default nsIInputStream serializer will be serialized with delayedStart, meaning that when sent from the parent process to the content process it will be serialized as a RemoteLazyInputStream. In the specific case of SendOpenStream this causes issues, as the content process code depends on the synchronous nature of nsIFileInputStream to allow it to be wrapped in a SnappyUncompressInputStream, which requires a sync stream. Relying on this property is not generally correct and only works because we know only nsFileInputStream will be sent by the parent process. Other types of sync streams may be received as async if they are sufficiently large, such as nsStringInputStream. Differential Revision: https://phabricator.services.mozilla.com/D103227
This commit is contained in:
Родитель
daf01f9769
Коммит
6720e65c4e
|
@ -108,8 +108,9 @@ void CacheStreamControlChild::OpenStream(const nsID& aId,
|
|||
SendOpenStream(aId)->Then(
|
||||
GetCurrentSerialEventTarget(), __func__,
|
||||
[aResolver,
|
||||
holder = holder.clonePtr()](RefPtr<nsIInputStream>&& aOptionalStream) {
|
||||
aResolver(nsCOMPtr<nsIInputStream>(std::move(aOptionalStream)));
|
||||
holder = holder.clonePtr()](const Maybe<IPCStream>& aOptionalStream) {
|
||||
nsCOMPtr<nsIInputStream> stream = DeserializeIPCStream(aOptionalStream);
|
||||
aResolver(std::move(stream));
|
||||
},
|
||||
[aResolver, holder = holder.clonePtr()](ResponseRejectReason&& aReason) {
|
||||
aResolver(nullptr);
|
||||
|
|
|
@ -109,8 +109,14 @@ mozilla::ipc::IPCResult CacheStreamControlParent::RecvOpenStream(
|
|||
const nsID& aStreamId, OpenStreamResolver&& aResolver) {
|
||||
NS_ASSERT_OWNINGTHREAD(CacheStreamControlParent);
|
||||
|
||||
OpenStream(aStreamId, [aResolver](nsCOMPtr<nsIInputStream>&& aStream) {
|
||||
aResolver(aStream);
|
||||
OpenStream(aStreamId, [aResolver, self = RefPtr{this}](
|
||||
nsCOMPtr<nsIInputStream>&& aStream) {
|
||||
AutoIPCStream autoStream;
|
||||
if (self->CanSend() && autoStream.Serialize(aStream, self->Manager())) {
|
||||
aResolver(autoStream.TakeOptionalValue());
|
||||
} else {
|
||||
aResolver(Nothing());
|
||||
}
|
||||
});
|
||||
|
||||
return IPC_OK();
|
||||
|
|
|
@ -6,9 +6,9 @@ include protocol PBackground;
|
|||
include protocol PFileDescriptorSet;
|
||||
include protocol PChildToParentStream;
|
||||
include protocol PParentToChildStream;
|
||||
include IPCStream;
|
||||
|
||||
using struct nsID from "nsID.h";
|
||||
using refcounted class nsIInputStream from "mozilla/ipc/IPCStreamUtils.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -19,7 +19,7 @@ refcounted protocol PCacheStreamControl
|
|||
manager PBackground;
|
||||
|
||||
parent:
|
||||
async OpenStream(nsID aStreamId) returns(nsIInputStream aStream);
|
||||
async OpenStream(nsID aStreamId) returns(IPCStream? aStream);
|
||||
async NoteClosed(nsID aStreamId);
|
||||
|
||||
child:
|
||||
|
|
Загрузка…
Ссылка в новой задаче