Backed out changeset 73f62ae76c08 (bug 1358111)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Mon, 24 Apr 2017 15:43:10 +0200
changeset 354569 459116dcf7987f6b9d4dfc51ac1e42e7f782ab34
parent 354568 6e7b7e621dc3ce728090a7e6fbe74be1e229db69
child 354570 9f488fa8dae133819c3b26a7ffee8758962e16bf
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)
bugs1358111
milestone55.0a1
backs out73f62ae76c08245b15223918602b6b9db31809a2
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 73f62ae76c08 (bug 1358111)
dom/filesystem/FileSystemTaskBase.cpp
dom/filesystem/FileSystemTaskBase.h
dom/filesystem/GetDirectoryListingTask.cpp
dom/filesystem/GetFileOrDirectoryTask.cpp
dom/filesystem/GetFilesTask.cpp
dom/filesystem/PFileSystemParams.ipdlh
dom/filesystem/PFileSystemRequest.ipdl
--- a/dom/filesystem/FileSystemTaskBase.cpp
+++ b/dom/filesystem/FileSystemTaskBase.cpp
@@ -7,16 +7,17 @@
 #include "mozilla/dom/FileSystemTaskBase.h"
 
 #include "nsNetCID.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/FileSystemBase.h"
 #include "mozilla/dom/FileSystemRequestParent.h"
 #include "mozilla/dom/FileSystemUtils.h"
 #include "mozilla/dom/Promise.h"
+#include "mozilla/dom/ipc/BlobParent.h"
 #include "mozilla/ipc/BackgroundChild.h"
 #include "mozilla/ipc/BackgroundParent.h"
 #include "mozilla/ipc/PBackgroundChild.h"
 #include "mozilla/Unused.h"
 #include "nsProxyRelease.h"
 
 namespace mozilla {
 namespace dom {
--- a/dom/filesystem/FileSystemTaskBase.h
+++ b/dom/filesystem/FileSystemTaskBase.h
@@ -14,16 +14,17 @@
 #include "nsThreadUtils.h"
 
 namespace mozilla {
 namespace dom {
 
 class BlobImpl;
 class FileSystemBase;
 class FileSystemParams;
+class PBlobParent;
 
 /*
  * The base class to implement a Task class.
  * The file system operations can only be performed in the parent process. In
  * order to avoid duplicated code, we used PBackground for child-parent and
  * parent-parent communications.
  *
  * The following diagram illustrates the how a API call from the content page
--- a/dom/filesystem/GetDirectoryListingTask.cpp
+++ b/dom/filesystem/GetDirectoryListingTask.cpp
@@ -6,20 +6,21 @@
 
 #include "GetDirectoryListingTask.h"
 
 #include "HTMLSplitOnSpacesTokenizer.h"
 #include "js/Value.h"
 #include "mozilla/dom/FileBlobImpl.h"
 #include "mozilla/dom/FileSystemBase.h"
 #include "mozilla/dom/FileSystemUtils.h"
-#include "mozilla/dom/IPCBlobUtils.h"
 #include "mozilla/dom/PFileSystemParams.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/dom/UnionTypes.h"
+#include "mozilla/dom/ipc/BlobChild.h"
+#include "mozilla/dom/ipc/BlobParent.h"
 #include "nsIFile.h"
 #include "nsISimpleEnumerator.h"
 #include "nsStringGlue.h"
 
 namespace mozilla {
 namespace dom {
 
 /**
@@ -125,17 +126,18 @@ GetDirectoryListingTaskChild::SetSuccess
       aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
       return;
     }
 
     if (data.type() == FileSystemDirectoryListingResponseData::TFileSystemDirectoryListingResponseFile) {
       const FileSystemDirectoryListingResponseFile& d =
         data.get_FileSystemDirectoryListingResponseFile();
 
-      RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(d.blob());
+      RefPtr<BlobImpl> blobImpl =
+        static_cast<BlobChild*>(d.blobChild())->GetBlobImpl();
       MOZ_ASSERT(blobImpl);
 
       RefPtr<File> file = File::Create(mFileSystem->GetParentObject(), blobImpl);
       MOZ_ASSERT(file);
 
       ofd->SetAsFile() = file;
     } else {
       MOZ_ASSERT(data.type() == FileSystemDirectoryListingResponseData::TFileSystemDirectoryListingResponseDirectory);
@@ -215,16 +217,18 @@ GetDirectoryListingTaskParent::GetDirect
   MOZ_ASSERT(aFileSystem);
 }
 
 FileSystemResponseValue
 GetDirectoryListingTaskParent::GetSuccessRequestResult(ErrorResult& aRv) const
 {
   AssertIsOnBackgroundThread();
 
+  InfallibleTArray<PBlobParent*> blobs;
+
   nsTArray<FileSystemDirectoryListingResponseData> inputs;
 
   for (unsigned i = 0; i < mTargetData.Length(); i++) {
     if (mTargetData[i].mType == FileOrDirectoryPath::eFilePath) {
       nsCOMPtr<nsIFile> path;
       nsresult rv = NS_NewLocalFile(mTargetData[i].mPath, true,
                                     getter_AddRefs(path));
       if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -242,24 +246,18 @@ GetDirectoryListingTaskParent::GetSucces
         filePath.AppendLiteral(FILESYSTEM_DOM_PATH_SEPARATOR_LITERAL);
       }
 
       nsAutoString name;
       blobImpl->GetName(name);
       filePath.Append(name);
       blobImpl->SetDOMPath(filePath);
 
-      IPCBlob ipcBlob;
-      rv =
-        IPCBlobUtils::Serialize(blobImpl, mRequestParent->Manager(), ipcBlob);
-      if (NS_WARN_IF(NS_FAILED(rv))) {
-        return FileSystemErrorResponse(rv);
-      }
-
-      fileData.blob() = ipcBlob;
+      fileData.blobParent() =
+        BlobParent::GetOrCreate(mRequestParent->Manager(), blobImpl);
       inputs.AppendElement(fileData);
     } else {
       MOZ_ASSERT(mTargetData[i].mType == FileOrDirectoryPath::eDirectoryPath);
       FileSystemDirectoryListingResponseDirectory directoryData;
       directoryData.directoryRealPath() = mTargetData[i].mPath;
       inputs.AppendElement(directoryData);
     }
   }
--- a/dom/filesystem/GetFileOrDirectoryTask.cpp
+++ b/dom/filesystem/GetFileOrDirectoryTask.cpp
@@ -7,17 +7,18 @@
 #include "GetFileOrDirectoryTask.h"
 
 #include "js/Value.h"
 #include "mozilla/dom/FileBlobImpl.h"
 #include "mozilla/dom/FileSystemBase.h"
 #include "mozilla/dom/FileSystemUtils.h"
 #include "mozilla/dom/PFileSystemParams.h"
 #include "mozilla/dom/Promise.h"
-#include "mozilla/dom/IPCBlobUtils.h"
+#include "mozilla/dom/ipc/BlobChild.h"
+#include "mozilla/dom/ipc/BlobParent.h"
 #include "nsIFile.h"
 #include "nsStringGlue.h"
 
 namespace mozilla {
 namespace dom {
 
 /**
  * GetFileOrDirectoryTaskChild
@@ -92,17 +93,18 @@ void
 GetFileOrDirectoryTaskChild::SetSuccessRequestResult(const FileSystemResponseValue& aValue,
                                                      ErrorResult& aRv)
 {
   MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!");
   switch (aValue.type()) {
     case FileSystemResponseValue::TFileSystemFileResponse: {
       FileSystemFileResponse r = aValue;
 
-      RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(r.blob());
+      RefPtr<BlobImpl> blobImpl =
+        static_cast<BlobChild*>(r.blobChild())->GetBlobImpl();
       MOZ_ASSERT(blobImpl);
 
       mResultFile = File::Create(mFileSystem->GetParentObject(), blobImpl);
       MOZ_ASSERT(mResultFile);
       break;
     }
     case FileSystemResponseValue::TFileSystemDirectoryResponse: {
       FileSystemDirectoryResponse r = aValue;
@@ -201,24 +203,19 @@ GetFileOrDirectoryTaskParent::GetSuccess
     return FileSystemDirectoryResponse();
   }
 
   if (mIsDirectory) {
     return FileSystemDirectoryResponse(path);
   }
 
   RefPtr<BlobImpl> blobImpl = new FileBlobImpl(mTargetPath);
-
-  IPCBlob ipcBlob;
-  aRv = IPCBlobUtils::Serialize(blobImpl, mRequestParent->Manager(), ipcBlob);
-  if (NS_WARN_IF(aRv.Failed())) {
-    return FileSystemDirectoryResponse();
-  }
-
-  return FileSystemFileResponse(ipcBlob);
+  BlobParent* blobParent =
+    BlobParent::GetOrCreate(mRequestParent->Manager(), blobImpl);
+  return FileSystemFileResponse(blobParent, nullptr);
 }
 
 nsresult
 GetFileOrDirectoryTaskParent::IOWork()
 {
   MOZ_ASSERT(XRE_IsParentProcess(),
              "Only call from parent process!");
   MOZ_ASSERT(!NS_IsMainThread(), "Only call on worker thread!");
--- a/dom/filesystem/GetFilesTask.cpp
+++ b/dom/filesystem/GetFilesTask.cpp
@@ -6,19 +6,20 @@
 
 #include "GetFilesTask.h"
 
 #include "HTMLSplitOnSpacesTokenizer.h"
 #include "js/Value.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/FileSystemBase.h"
 #include "mozilla/dom/FileSystemUtils.h"
-#include "mozilla/dom/IPCBlobUtils.h"
 #include "mozilla/dom/PFileSystemParams.h"
 #include "mozilla/dom/Promise.h"
+#include "mozilla/dom/ipc/BlobChild.h"
+#include "mozilla/dom/ipc/BlobParent.h"
 #include "nsIFile.h"
 #include "nsStringGlue.h"
 
 namespace mozilla {
 namespace dom {
 
 /**
  * GetFilesTaskChild
@@ -117,17 +118,18 @@ GetFilesTaskChild::SetSuccessRequestResu
 
   if (!mTargetData.SetLength(r.data().Length(), mozilla::fallible_t())) {
     aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     return;
   }
 
   for (uint32_t i = 0; i < r.data().Length(); ++i) {
     const FileSystemFileResponse& data = r.data()[i];
-    RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(data.blob());
+    RefPtr<BlobImpl> blobImpl =
+      static_cast<BlobChild*>(data.blobChild())->GetBlobImpl();
     MOZ_ASSERT(blobImpl);
 
     mTargetData[i] = File::Create(mFileSystem->GetParentObject(), blobImpl);
   }
 }
 
 void
 GetFilesTaskChild::HandlerCallback()
@@ -186,33 +188,30 @@ GetFilesTaskParent::GetFilesTaskParent(F
   MOZ_ASSERT(aFileSystem);
 }
 
 FileSystemResponseValue
 GetFilesTaskParent::GetSuccessRequestResult(ErrorResult& aRv) const
 {
   AssertIsOnBackgroundThread();
 
+  InfallibleTArray<PBlobParent*> blobs;
+
   FallibleTArray<FileSystemFileResponse> inputs;
   if (!inputs.SetLength(mTargetBlobImplArray.Length(), mozilla::fallible_t())) {
     FileSystemFilesResponse response;
     aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     return response;
   }
 
   for (unsigned i = 0; i < mTargetBlobImplArray.Length(); i++) {
-    IPCBlob ipcBlob;
-    aRv = IPCBlobUtils::Serialize(mTargetBlobImplArray[i],
-                                  mRequestParent->Manager(), ipcBlob);
-    if (NS_WARN_IF(aRv.Failed())) {
-      FileSystemFilesResponse response;
-      return response;
-    }
-
-    inputs[i] = FileSystemFileResponse(ipcBlob);
+    BlobParent* blobParent =
+      BlobParent::GetOrCreate(mRequestParent->Manager(),
+                              mTargetBlobImplArray[i]);
+    inputs[i] = FileSystemFileResponse(blobParent, nullptr);
   }
 
   FileSystemFilesResponse response;
   response.data().SwapElements(inputs);
   return response;
 }
 
 nsresult
--- a/dom/filesystem/PFileSystemParams.ipdlh
+++ b/dom/filesystem/PFileSystemParams.ipdlh
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+include protocol PBlob;
+
 namespace mozilla {
 namespace dom {
 
 struct FileSystemGetDirectoryListingParams
 {
   nsString filesystem;
   nsString realPath;
   nsString domPath;
--- a/dom/filesystem/PFileSystemRequest.ipdl
+++ b/dom/filesystem/PFileSystemRequest.ipdl
@@ -1,38 +1,33 @@
 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
 /* vim: set ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 include protocol PBackground;
-include protocol PIPCBlobInputStream;
-include protocol PChildToParentStream;
-include protocol PParentToChildStream;
-include protocol PFileDescriptorSet;
-
-include IPCBlob;
+include protocol PBlob;
 
 namespace mozilla {
 namespace dom {
 
 struct FileSystemFileResponse
 {
-  IPCBlob blob;
+  PBlob blob;
 };
 
 struct FileSystemDirectoryResponse
 {
   nsString realPath;
 };
 
 struct FileSystemDirectoryListingResponseFile
 {
-  IPCBlob blob;
+  PBlob blob;
 };
 
 struct FileSystemDirectoryListingResponseDirectory
 {
   // This is the full real path for the directory that we are sending via IPC.
   nsString directoryRealPath;
 };