Bug 1440771 - Part 4: Use nsCOMPtr<nsIInputStream> directly in PNecko, r=baku
authorNika Layzell <nika@thelayzells.com>
Fri, 23 Feb 2018 15:29:54 -0500
changeset 406591 cd28092ce59a3055258af00afc35b2d05ef93d88
parent 406590 02049d16a352bd71963579c0b7b29c96efb5244d
child 406592 d45bbc02ad0ddab649f1c7387c6942a1a19381a6
push id100472
push usernika@thelayzells.com
push dateMon, 05 Mar 2018 21:01:31 +0000
treeherdermozilla-inbound@cd28092ce59a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1440771
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1440771 - Part 4: Use nsCOMPtr<nsIInputStream> directly in PNecko, r=baku MozReview-Commit-ID: COnMiadbCjn
netwerk/ipc/NeckoParent.cpp
netwerk/ipc/PNecko.ipdl
netwerk/protocol/res/ExtensionProtocolHandler.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<nsIInputStream> inputStream;
   bool terminateSender = true;
   auto inputStreamOrReason = ph->NewStream(deserializedURI, &terminateSender);
   if (inputStreamOrReason.isOk()) {
     inputStream = inputStreamOrReason.unwrap();
-    ContentParent* contentParent = static_cast<ContentParent*>(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();
   }
 }
 
--- 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<nsIInputStream> 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<nsIInputStream> 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
    */
--- 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<nsIInputStream> inputStream;
-      if (stream.type() == OptionalIPCStream::OptionalIPCStream::TIPCStream) {
-        inputStream = ipc::DeserializeIPCStream(stream);
-      }
-      self->OnStream(inputStream.forget());
+    [self] (const nsCOMPtr<nsIInputStream>& stream) {
+      self->OnStream(do_AddRef(stream));
     },
     [self] (const mozilla::ipc::ResponseRejectReason) {
       self->OnStream(nullptr);
     }
   );
   return Ok();
 }