Bug 1360185 - Use of IPCBlob in IndexedDB - part 2 - Lazy Data set to any received blob, r=janv

This commit is contained in:
Andrea Marchesini 2017-05-23 07:50:54 +02:00
Родитель f9c4fde785
Коммит c15f78065c
1 изменённых файлов: 5 добавлений и 67 удалений

Просмотреть файл

@ -39,7 +39,6 @@
#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"
@ -428,32 +427,6 @@ GetAddInfoCallback(JSContext* aCx, void* aClosure)
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,
@ -464,33 +437,6 @@ ResolveMysteryMutableFile(IDBMutableFile* aMutableFile,
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)
@ -689,12 +635,8 @@ public:
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);
@ -706,13 +648,9 @@ public:
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();