Backed out changeset a180e3f4de16 (bug 1358114)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Mon, 24 Apr 2017 15:43:05 +0200
changeset 354568 6e7b7e621dc3ce728090a7e6fbe74be1e229db69
parent 354567 3876d6661539ca114ee4e704efa3dc5f47a45487
child 354569 459116dcf7987f6b9d4dfc51ac1e42e7f782ab34
push id89494
push userarchaeopteryx@coole-files.de
push dateMon, 24 Apr 2017 13:44:28 +0000
treeherdermozilla-inbound@d8868683036b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1358114
milestone55.0a1
backs outa180e3f4de16aa456c8cd039805aa0924618d5c9
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
Backed out changeset a180e3f4de16 (bug 1358114)
dom/file/nsHostObjectProtocolHandler.cpp
dom/file/nsHostObjectProtocolHandler.h
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
dom/url/URL.cpp
--- a/dom/file/nsHostObjectProtocolHandler.cpp
+++ b/dom/file/nsHostObjectProtocolHandler.cpp
@@ -6,36 +6,40 @@
 
 #include "nsHostObjectProtocolHandler.h"
 
 #include "DOMMediaStream.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/Exceptions.h"
 #include "mozilla/dom/BlobImpl.h"
-#include "mozilla/dom/IPCBlobUtils.h"
+#include "mozilla/dom/ipc/BlobChild.h"
+#include "mozilla/dom/ipc/BlobParent.h"
 #include "mozilla/dom/MediaSource.h"
-#include "mozilla/ipc/IPCStreamUtils.h"
 #include "mozilla/LoadInfo.h"
 #include "mozilla/ModuleUtils.h"
 #include "mozilla/Preferences.h"
 #include "nsClassHashtable.h"
 #include "nsContentUtils.h"
 #include "nsError.h"
 #include "nsHostObjectURI.h"
 #include "nsIMemoryReporter.h"
 #include "nsIPrincipal.h"
 #include "nsIUUIDGenerator.h"
 #include "nsNetUtil.h"
 
 #define RELEASING_TIMER 1000
 
-using namespace mozilla;
-using namespace mozilla::dom;
-using namespace mozilla::ipc;
+using mozilla::DOMMediaStream;
+using mozilla::dom::BlobImpl;
+using mozilla::dom::MediaSource;
+using mozilla::ErrorResult;
+using mozilla::net::LoadInfo;
+using mozilla::Move;
+using mozilla::Unused;
 
 // -----------------------------------------------------------------------
 // Hash table
 struct DataInfo
 {
   enum ObjectType {
     eBlobImpl,
     eMediaStream,
@@ -135,25 +139,23 @@ BroadcastBlobURLRegistration(const nsACS
 
   if (XRE_IsParentProcess()) {
     dom::ContentParent::BroadcastBlobURLRegistration(aURI, aBlobImpl,
                                                      aPrincipal);
     return;
   }
 
   dom::ContentChild* cc = dom::ContentChild::GetSingleton();
-
-  IPCBlob ipcBlob;
-  nsresult rv = IPCBlobUtils::Serialize(aBlobImpl, cc, ipcBlob);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
+  dom::BlobChild* actor = cc->GetOrCreateActorForBlobImpl(aBlobImpl);
+  if (NS_WARN_IF(!actor)) {
     return;
   }
 
   Unused << NS_WARN_IF(!cc->SendStoreAndBroadcastBlobURLRegistration(
-    nsCString(aURI), ipcBlob, IPC::Principal(aPrincipal)));
+    nsCString(aURI), actor, IPC::Principal(aPrincipal)));
 }
 
 void
 BroadcastBlobURLUnregistration(const nsACString& aURI, DataInfo* aInfo)
 {
   MOZ_ASSERT(aInfo);
   MOZ_ASSERT(NS_IsMainThread());
 
@@ -514,17 +516,17 @@ nsHostObjectProtocolHandler::AddDataEntr
   Init();
 
   nsresult rv = GenerateURIStringForBlobURL(aPrincipal, aUri);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = AddDataEntryInternal(aUri, aBlobImpl, aPrincipal);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  BroadcastBlobURLRegistration(aUri, aBlobImpl, aPrincipal);
+  mozilla::BroadcastBlobURLRegistration(aUri, aBlobImpl, aPrincipal);
   return NS_OK;
 }
 
 /* static */ nsresult
 nsHostObjectProtocolHandler::AddDataEntry(DOMMediaStream* aMediaStream,
                                           nsIPrincipal* aPrincipal,
                                           nsACString& aUri)
 {
@@ -553,50 +555,50 @@ nsHostObjectProtocolHandler::AddDataEntr
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 /* static */ nsresult
 nsHostObjectProtocolHandler::AddDataEntry(const nsACString& aURI,
                                           nsIPrincipal* aPrincipal,
-                                          BlobImpl* aBlobImpl)
+                                          mozilla::dom::BlobImpl* aBlobImpl)
 {
   return AddDataEntryInternal(aURI, aBlobImpl, aPrincipal);
 }
 
 /* static */ bool
 nsHostObjectProtocolHandler::GetAllBlobURLEntries(
-  nsTArray<BlobURLRegistrationData>& aRegistrations,
-  ContentParent* aCP)
+  nsTArray<mozilla::dom::BlobURLRegistrationData>& aRegistrations,
+  mozilla::dom::ContentParent* aCP)
 {
   MOZ_ASSERT(aCP);
 
   if (!gDataTable) {
     return true;
   }
 
   for (auto iter = gDataTable->ConstIter(); !iter.Done(); iter.Next()) {
     DataInfo* info = iter.UserData();
     MOZ_ASSERT(info);
 
     if (info->mObjectType != DataInfo::eBlobImpl) {
       continue;
     }
 
     MOZ_ASSERT(info->mBlobImpl);
-
-    IPCBlob ipcBlob;
-    nsresult rv = IPCBlobUtils::Serialize(info->mBlobImpl, aCP, ipcBlob);
-    if (NS_WARN_IF(NS_FAILED(rv))) {
+    mozilla::dom::PBlobParent* blobParent =
+      aCP->GetOrCreateActorForBlobImpl(info->mBlobImpl);
+    if (!blobParent) {
       return false;
     }
 
-    aRegistrations.AppendElement(BlobURLRegistrationData(
-      nsCString(iter.Key()), ipcBlob, IPC::Principal(info->mPrincipal)));
+    aRegistrations.AppendElement(mozilla::dom::BlobURLRegistrationData(
+      nsCString(iter.Key()), blobParent, nullptr,
+      IPC::Principal(info->mPrincipal)));
   }
 
   return true;
 }
 
 /*static */ void
 nsHostObjectProtocolHandler::RemoveDataEntry(const nsACString& aUri,
                                              bool aBroadcastToOtherProcesses)
@@ -606,21 +608,21 @@ nsHostObjectProtocolHandler::RemoveDataE
   }
 
   DataInfo* info = GetDataInfo(aUri);
   if (!info) {
     return;
   }
 
   if (aBroadcastToOtherProcesses && info->mObjectType == DataInfo::eBlobImpl) {
-    BroadcastBlobURLUnregistration(aUri, info);
+    mozilla::BroadcastBlobURLUnregistration(aUri, info);
   }
 
   if (!info->mURIs.IsEmpty()) {
-    ReleasingTimerHolder::Create(Move(info->mURIs));
+    mozilla::ReleasingTimerHolder::Create(Move(info->mURIs));
   }
 
   gDataTable->Remove(aUri);
   if (gDataTable->Count() == 0) {
     delete gDataTable;
     gDataTable = nullptr;
   }
 }
@@ -953,17 +955,17 @@ NS_GetStreamForBlobURI(nsIURI* aURI, nsI
   if (NS_WARN_IF(rv.Failed())) {
     return rv.StealNSResult();
   }
 
   return NS_OK;
 }
 
 nsresult
-NS_GetStreamForMediaStreamURI(nsIURI* aURI, DOMMediaStream** aStream)
+NS_GetStreamForMediaStreamURI(nsIURI* aURI, mozilla::DOMMediaStream** aStream)
 {
   DataInfo* info = GetDataInfoFromURI(aURI);
   if (!info || info->mObjectType != DataInfo::eMediaStream) {
     return NS_ERROR_DOM_BAD_URI;
   }
 
   RefPtr<DOMMediaStream> mediaStream = info->mMediaStream;
   mediaStream.forget(aStream);
@@ -1000,17 +1002,17 @@ nsFontTableProtocolHandler::NewURI(const
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   uri.forget(aResult);
   return NS_OK;
 }
 
 nsresult
-NS_GetSourceForMediaSourceURI(nsIURI* aURI, MediaSource** aSource)
+NS_GetSourceForMediaSourceURI(nsIURI* aURI, mozilla::dom::MediaSource** aSource)
 {
   *aSource = nullptr;
 
   DataInfo* info = GetDataInfoFromURI(aURI);
   if (!info || info->mObjectType != DataInfo::eMediaSource) {
     return NS_ERROR_DOM_BAD_URI;
   }
 
--- a/dom/file/nsHostObjectProtocolHandler.h
+++ b/dom/file/nsHostObjectProtocolHandler.h
@@ -18,17 +18,16 @@
 #define FONTTABLEURI_SCHEME "moz-fonttable"
 #define RTSPURI_SCHEME "rtsp"
 
 class nsIPrincipal;
 
 namespace mozilla {
 class BlobURLsReporter;
 class DOMMediaStream;
-
 namespace dom {
 class BlobImpl;
 class BlobURLRegistrationData;
 class ContentParent;
 class MediaSource;
 } // namespace dom
 } // namespace mozilla
 
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -2417,17 +2417,18 @@ ContentChild::RecvInitServiceWorkers(con
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ContentChild::RecvInitBlobURLs(nsTArray<BlobURLRegistrationData>&& aRegistrations)
 {
   for (uint32_t i = 0; i < aRegistrations.Length(); ++i) {
     BlobURLRegistrationData& registration = aRegistrations[i];
-    RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(registration.blob());
+    RefPtr<BlobImpl> blobImpl =
+      static_cast<BlobChild*>(registration.blobChild())->GetBlobImpl();
     MOZ_ASSERT(blobImpl);
 
     nsHostObjectProtocolHandler::AddDataEntry(registration.url(),
                                               registration.principal(),
                                               blobImpl);
   }
 
   return IPC_OK();
@@ -3067,21 +3068,20 @@ ContentChild::RecvNotifyPushSubscription
                                                           const IPC::Principal& aPrincipal)
 {
   PushSubscriptionModifiedDispatcher dispatcher(aScope, aPrincipal);
   Unused << NS_WARN_IF(NS_FAILED(dispatcher.NotifyObservers()));
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
-ContentChild::RecvBlobURLRegistration(const nsCString& aURI,
-                                      const IPCBlob& aBlob,
+ContentChild::RecvBlobURLRegistration(const nsCString& aURI, PBlobChild* aBlobChild,
                                       const IPC::Principal& aPrincipal)
 {
-  RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(aBlob);
+  RefPtr<BlobImpl> blobImpl = static_cast<BlobChild*>(aBlobChild)->GetBlobImpl();
   MOZ_ASSERT(blobImpl);
 
   nsHostObjectProtocolHandler::AddDataEntry(aURI, aPrincipal, blobImpl);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ContentChild::RecvBlobURLUnregistration(const nsCString& aURI)
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -576,17 +576,17 @@ public:
   void
   DeleteGetFilesRequest(nsID& aUUID, GetFilesHelperChild* aChild);
 
   virtual mozilla::ipc::IPCResult
   RecvGetFilesResponse(const nsID& aUUID,
                        const GetFilesResponseResult& aResult) override;
 
   virtual mozilla::ipc::IPCResult
-  RecvBlobURLRegistration(const nsCString& aURI, const IPCBlob& aBlob,
+  RecvBlobURLRegistration(const nsCString& aURI, PBlobChild* aBlobChild,
                           const IPC::Principal& aPrincipal) override;
 
   virtual mozilla::ipc::IPCResult
   RecvBlobURLUnregistration(const nsCString& aURI) override;
 
   virtual mozilla::ipc::IPCResult
   RecvFileCreationResponse(const nsID& aUUID,
                            const FileCreationResult& aResult) override;
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -4849,23 +4849,20 @@ ContentParent::BroadcastBlobURLRegistrat
                                             nsIPrincipal* aPrincipal,
                                             ContentParent* aIgnoreThisCP)
 {
   nsCString uri(aURI);
   IPC::Principal principal(aPrincipal);
 
   for (auto* cp : AllProcesses(eLive)) {
     if (cp != aIgnoreThisCP) {
-      IPCBlob ipcBlob;
-      nsresult rv = IPCBlobUtils::Serialize(aBlobImpl, cp, ipcBlob);
-      if (NS_WARN_IF(NS_FAILED(rv))) {
-        break;
+      PBlobParent* blobParent = cp->GetOrCreateActorForBlobImpl(aBlobImpl);
+      if (blobParent) {
+        Unused << cp->SendBlobURLRegistration(uri, blobParent, principal);
       }
-
-      Unused << cp->SendBlobURLRegistration(uri, ipcBlob, principal);
     }
   }
 }
 
 /* static */ void
 ContentParent::BroadcastBlobURLUnregistration(const nsACString& aURI,
                                               ContentParent* aIgnoreThisCP)
 {
@@ -4875,20 +4872,21 @@ ContentParent::BroadcastBlobURLUnregistr
     if (cp != aIgnoreThisCP) {
       Unused << cp->SendBlobURLUnregistration(uri);
     }
   }
 }
 
 mozilla::ipc::IPCResult
 ContentParent::RecvStoreAndBroadcastBlobURLRegistration(const nsCString& aURI,
-                                                        const IPCBlob& aBlob,
+                                                        PBlobParent* aBlobParent,
                                                         const Principal& aPrincipal)
 {
-  RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(aBlob);
+  RefPtr<BlobImpl> blobImpl =
+    static_cast<BlobParent*>(aBlobParent)->GetBlobImpl();
   if (NS_WARN_IF(!blobImpl)) {
     return IPC_FAIL_NO_REASON(this);
   }
 
   if (NS_SUCCEEDED(nsHostObjectProtocolHandler::AddDataEntry(aURI, aPrincipal,
                                                              blobImpl))) {
     BroadcastBlobURLRegistration(aURI, blobImpl, aPrincipal, this);
 
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -579,17 +579,17 @@ public:
                                ContentParent* aIgnoreThisCP = nullptr);
 
   static void
   BroadcastBlobURLUnregistration(const nsACString& aURI,
                                  ContentParent* aIgnoreThisCP = nullptr);
 
   virtual mozilla::ipc::IPCResult
   RecvStoreAndBroadcastBlobURLRegistration(const nsCString& aURI,
-                                           const IPCBlob& aBlob,
+                                           PBlobParent* aBlobParent,
                                            const Principal& aPrincipal) override;
 
   virtual mozilla::ipc::IPCResult
   RecvUnstoreAndBroadcastBlobURLUnregistration(const nsCString& aURI) override;
 
   virtual mozilla::ipc::IPCResult
   RecvBroadcastLocalStorageChange(const nsString& aDocumentURI,
                                   const nsString& aKey,
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -224,17 +224,17 @@ union FileCreationResult
 {
   FileCreationSuccessResult;
   FileCreationErrorResult;
 };
 
 struct BlobURLRegistrationData
 {
     nsCString url;
-    IPCBlob blob;
+    PBlob blob;
     Principal principal;
 };
 
 struct GMPAPITags
 {
     nsCString api;
     nsCString[] tags;
 };
@@ -573,17 +573,17 @@ child:
      * audio session.
      */
     async SetAudioSessionData(nsID aID,
                               nsString aDisplayName,
                               nsString aIconPath);
 
     async GetFilesResponse(nsID aID, GetFilesResponseResult aResult);
 
-    async BlobURLRegistration(nsCString aURI, IPCBlob aBlob,
+    async BlobURLRegistration(nsCString aURI, PBlob aBlob,
                               Principal aPrincipal);
 
     async BlobURLUnregistration(nsCString aURI);
 
     async DispatchLocalStorageChange(nsString documentURI,
                                      nsString key,
                                      nsString oldValue,
                                      nsString newValue,
@@ -1076,17 +1076,17 @@ parent:
      async GetFilesRequest(nsID aID, nsString aDirectory, bool aRecursiveFlag);
      async DeleteGetFilesRequest(nsID aID);
 
      async FileCreationRequest(nsID aID, nsString aFullPath, nsString aType,
                                nsString aName, bool lastModifiedPassed,
                                int64_t lastModified, bool aExistenceCheck,
                                bool aIsFromNsIFile);
 
-     async StoreAndBroadcastBlobURLRegistration(nsCString url, IPCBlob blob,
+     async StoreAndBroadcastBlobURLRegistration(nsCString url, PBlob blob,
                                                 Principal principal);
 
      async UnstoreAndBroadcastBlobURLUnregistration(nsCString url);
 
      async BroadcastLocalStorageChange(nsString documentURI,
                                        nsString key,
                                        nsString oldValue,
                                        nsString newValue,
--- a/dom/url/URL.cpp
+++ b/dom/url/URL.cpp
@@ -5,16 +5,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "URL.h"
 
 #include "DOMMediaStream.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/MediaSource.h"
 #include "mozilla/dom/URLBinding.h"
+#include "mozilla/dom/ipc/BlobChild.h"
+#include "mozilla/dom/ipc/nsIRemoteBlob.h"
 #include "mozilla/ipc/BackgroundChild.h"
 #include "nsContentUtils.h"
 #include "nsEscape.h"
 #include "nsHostObjectProtocolHandler.h"
 #include "nsIIOService.h"
 #include "nsIURL.h"
 #include "nsNetCID.h"
 #include "nsNetUtil.h"
@@ -760,16 +762,40 @@ public:
 
   bool
   MainThreadRun()
   {
     using namespace mozilla::ipc;
 
     AssertIsOnMainThread();
 
+    RefPtr<BlobImpl> newBlobImplHolder;
+
+    if (nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(mBlobImpl)) {
+      if (BlobChild* blobChild = remoteBlob->GetBlobChild()) {
+        if (PBackgroundChild* blobManager = blobChild->GetBackgroundManager()) {
+          PBackgroundChild* backgroundManager =
+            BackgroundChild::GetForCurrentThread();
+          MOZ_ASSERT(backgroundManager);
+
+          if (blobManager != backgroundManager) {
+            // Always make sure we have a blob from an actor we can use on this
+            // thread.
+            blobChild = BlobChild::GetOrCreate(backgroundManager, mBlobImpl);
+            MOZ_ASSERT(blobChild);
+
+            newBlobImplHolder = blobChild->GetBlobImpl();
+            MOZ_ASSERT(newBlobImplHolder);
+
+            mBlobImpl = newBlobImplHolder;
+          }
+        }
+      }
+    }
+
     DebugOnly<bool> isMutable;
     MOZ_ASSERT(NS_SUCCEEDED(mBlobImpl->GetMutable(&isMutable)));
     MOZ_ASSERT(!isMutable);
 
     nsCOMPtr<nsIPrincipal> principal = mWorkerPrivate->GetPrincipal();
 
     nsAutoCString url;
     nsresult rv =