# HG changeset patch # User Nika Layzell # Date 1519417794 18000 # Fri Feb 23 15:29:54 2018 -0500 # Node ID cd28092ce59a3055258af00afc35b2d05ef93d88 # Parent 02049d16a352bd71963579c0b7b29c96efb5244d Bug 1440771 - Part 4: Use nsCOMPtr directly in PNecko, r=baku MozReview-Commit-ID: COnMiadbCjn diff --git a/netwerk/ipc/NeckoParent.cpp b/netwerk/ipc/NeckoParent.cpp --- a/netwerk/ipc/NeckoParent.cpp +++ b/netwerk/ipc/NeckoParent.cpp @@ -57,17 +57,16 @@ using mozilla::dom::ServiceWorkerManager using mozilla::dom::TabContext; using mozilla::dom::TabParent; using mozilla::net::PTCPSocketParent; using mozilla::dom::TCPSocketParent; using mozilla::net::PTCPServerSocketParent; using mozilla::dom::TCPServerSocketParent; using mozilla::net::PUDPSocketParent; using mozilla::dom::UDPSocketParent; -using mozilla::ipc::AutoIPCStream; using mozilla::ipc::OptionalPrincipalInfo; using mozilla::ipc::PrincipalInfo; using mozilla::ipc::LoadInfoArgsToLoadInfo; using IPC::SerializedLoadContext; namespace mozilla { namespace net { @@ -961,30 +960,27 @@ NeckoParent::RecvGetExtensionStream(cons // Ask the ExtensionProtocolHandler to give us a new input stream for // this URI. The request comes from an ExtensionProtocolHandler in the // child process, but is not guaranteed to be a valid moz-extension URI, // and not guaranteed to represent a resource that the child should be // allowed to access. The ExtensionProtocolHandler is responsible for // validating the request. Specifically, only URI's for local files that // an extension is allowed to access via moz-extension URI's should be // accepted. - AutoIPCStream autoStream; nsCOMPtr inputStream; bool terminateSender = true; auto inputStreamOrReason = ph->NewStream(deserializedURI, &terminateSender); if (inputStreamOrReason.isOk()) { inputStream = inputStreamOrReason.unwrap(); - ContentParent* contentParent = static_cast(Manager()); - Unused << autoStream.Serialize(inputStream, contentParent); } // If NewStream failed, we send back an invalid stream to the child so // it can handle the error. MozPromise rejection is reserved for channel // errors/disconnects. - aResolve(autoStream.TakeOptionalValue()); + aResolve(inputStream); if (terminateSender) { return IPC_FAIL_NO_REASON(this); } else { return IPC_OK(); } } diff --git a/netwerk/ipc/PNecko.ipdl b/netwerk/ipc/PNecko.ipdl --- a/netwerk/ipc/PNecko.ipdl +++ b/netwerk/ipc/PNecko.ipdl @@ -31,16 +31,17 @@ include IPCStream; include URIParams; include NeckoChannelParams; include PBrowserOrId; include protocol PAltDataOutputStream; using class IPC::SerializedLoadContext from "SerializedLoadContext.h"; using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h"; using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h"; +using nsCOMPtr from "mozilla/ipc/IPCStreamUtils.h"; namespace mozilla { namespace net { //------------------------------------------------------------------- nested(upto inside_cpow) sync protocol PNecko { manager PContent; @@ -122,17 +123,17 @@ parent: async PAltDataOutputStream(nsCString type, PHttpChannel channel); async PStunAddrsRequest(); /** * WebExtension-specific remote resource loading */ - async GetExtensionStream(URIParams uri) returns (OptionalIPCStream stream); + async GetExtensionStream(URIParams uri) returns (nsCOMPtr stream); async GetExtensionFD(URIParams uri) returns (FileDescriptor fd); child: /* * Bring up the http auth prompt for a nested remote mozbrowser. * NestedFrameId is the id corresponding to the PBrowser. It is the same id * that was passed to the PBrowserOrId param in to the PHttpChannel constructor */ diff --git a/netwerk/protocol/res/ExtensionProtocolHandler.cpp b/netwerk/protocol/res/ExtensionProtocolHandler.cpp --- a/netwerk/protocol/res/ExtensionProtocolHandler.cpp +++ b/netwerk/protocol/res/ExtensionProtocolHandler.cpp @@ -234,22 +234,18 @@ ExtensionStreamGetter::GetAsync(nsIStrea ); return Ok(); } // Request an input stream for this moz-extension URI gNeckoChild->SendGetExtensionStream(uri)->Then( mMainThreadEventTarget, __func__, - [self] (const OptionalIPCStream& stream) { - nsCOMPtr inputStream; - if (stream.type() == OptionalIPCStream::OptionalIPCStream::TIPCStream) { - inputStream = ipc::DeserializeIPCStream(stream); - } - self->OnStream(inputStream.forget()); + [self] (const nsCOMPtr& stream) { + self->OnStream(do_AddRef(stream)); }, [self] (const mozilla::ipc::ResponseRejectReason) { self->OnStream(nullptr); } ); return Ok(); }