Bug 1360185 - Use of IPCBlob in IndexedDB - part 2 - Lazy Data set to any received blob, r=janv
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 23 May 2017 07:50:54 +0200
changeset 360068 71c72184817762288854adb28fddf0f463cebec8
parent 360067 f95212c33517a22afe320c0dc65e9e2f12b5080f
child 360069 2132c33a4fa7a8cec858706622c7dca5f9a396a5
push id31867
push userryanvm@gmail.com
push dateTue, 23 May 2017 14:09:01 +0000
treeherdermozilla-central@4f874bc1e424 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanv
bugs1360185
milestone55.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 1360185 - Use of IPCBlob in IndexedDB - part 2 - Lazy Data set to any received blob, r=janv
dom/indexedDB/IDBObjectStore.cpp
--- a/dom/indexedDB/IDBObjectStore.cpp
+++ b/dom/indexedDB/IDBObjectStore.cpp
@@ -34,17 +34,16 @@
 #include "mozilla/dom/IDBMutableFileBinding.h"
 #include "mozilla/dom/BlobBinding.h"
 #include "mozilla/dom/IDBObjectStoreBinding.h"
 #include "mozilla/dom/MemoryBlobImpl.h"
 #include "mozilla/dom/StructuredCloneHolder.h"
 #include "mozilla/dom/StructuredCloneTags.h"
 #include "mozilla/dom/indexedDB/PBackgroundIDBSharedTypes.h"
 #include "mozilla/dom/ipc/BlobChild.h"
-#include "mozilla/dom/ipc/nsIRemoteBlob.h"
 #include "mozilla/ipc/BackgroundChild.h"
 #include "mozilla/ipc/PBackgroundSharedTypes.h"
 #include "nsCOMPtr.h"
 #include "nsQueryObject.h"
 #include "ProfilerHelpers.h"
 #include "ReportInternalError.h"
 #include "WorkerPrivate.h"
 #include "WorkerScope.h"
@@ -423,80 +422,27 @@ GetAddInfoCallback(JSContext* aCx, void*
                                                 &kStructuredCloneCallbacks,
                                                 &data->mCloneWriteInfo)) {
     return NS_ERROR_DOM_DATA_CLONE_ERR;
   }
 
   return NS_OK;
 }
 
-BlobChild*
-ActorFromRemoteBlobImpl(BlobImpl* aImpl)
-{
-  MOZ_ASSERT(aImpl);
-
-  nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(aImpl);
-  if (remoteBlob) {
-    BlobChild* actor = remoteBlob->GetBlobChild();
-    MOZ_ASSERT(actor);
-
-    if (actor->GetContentManager()) {
-      return nullptr;
-    }
-
-    MOZ_ASSERT(actor->GetBackgroundManager());
-    MOZ_ASSERT(BackgroundChild::GetForCurrentThread());
-    MOZ_ASSERT(actor->GetBackgroundManager() ==
-                 BackgroundChild::GetForCurrentThread(),
-               "Blob actor is not bound to this thread!");
-
-    return actor;
-  }
-
-  return nullptr;
-}
-
 bool
 ResolveMysteryMutableFile(IDBMutableFile* aMutableFile,
                           const nsString& aName,
                           const nsString& aType)
 {
   MOZ_ASSERT(aMutableFile);
   aMutableFile->SetLazyData(aName, aType);
   return true;
 }
 
 bool
-ResolveMysteryFile(BlobImpl* aImpl,
-                   const nsString& aName,
-                   const nsString& aContentType,
-                   uint64_t aSize,
-                   uint64_t aLastModifiedDate)
-{
-  BlobChild* actor = ActorFromRemoteBlobImpl(aImpl);
-  if (actor) {
-    return actor->SetMysteryBlobInfo(aName, aContentType,
-                                     aSize, aLastModifiedDate);
-  }
-  return true;
-}
-
-bool
-ResolveMysteryBlob(BlobImpl* aImpl,
-                   const nsString& aContentType,
-                   uint64_t aSize)
-{
-  BlobChild* actor = ActorFromRemoteBlobImpl(aImpl);
-  if (actor) {
-    return actor->SetMysteryBlobInfo(aContentType, aSize);
-  }
-  return true;
-}
-
-bool
 StructuredCloneReadString(JSStructuredCloneReader* aReader,
                           nsCString& aString)
 {
   uint32_t length;
   if (!JS_ReadBytes(aReader, &length, sizeof(uint32_t))) {
     NS_WARNING("Failed to read length!");
     return false;
   }
@@ -684,40 +630,32 @@ public:
       MOZ_ASSERT(globalScope);
 
       parent = do_QueryObject(globalScope);
     }
 
     MOZ_ASSERT(parent);
 
     if (aData.tag == SCTAG_DOM_BLOB) {
-      if (NS_WARN_IF(!ResolveMysteryBlob(aFile.mBlob->Impl(),
-                                         aData.type,
-                                         aData.size))) {
-        return false;
-      }
-
+      aFile.mBlob->Impl()->SetLazyData(
+        NullString(), aData.type, aData.size, INT64_MAX);
       MOZ_ASSERT(!aFile.mBlob->IsFile());
 
       JS::Rooted<JS::Value> wrappedBlob(aCx);
       if (!ToJSValue(aCx, aFile.mBlob, &wrappedBlob)) {
         return false;
       }
 
       aResult.set(&wrappedBlob.toObject());
       return true;
     }
 
-    if (NS_WARN_IF(!ResolveMysteryFile(aFile.mBlob->Impl(),
-                                       aData.name,
-                                       aData.type,
-                                       aData.size,
-                                       aData.lastModifiedDate))) {
-      return false;
-    }
+    aFile.mBlob->Impl()->SetLazyData(
+      aData.name, aData.type, aData.size,
+      aData.lastModifiedDate * PR_USEC_PER_MSEC);
 
     MOZ_ASSERT(aFile.mBlob->IsFile());
     RefPtr<File> file = aFile.mBlob->ToFile();
     MOZ_ASSERT(file);
 
     JS::Rooted<JS::Value> wrappedFile(aCx);
     if (!ToJSValue(aCx, file, &wrappedFile)) {
       return false;