зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1346987 - Part 2: Stop using the PContent::Msg_OpenAnonymousTemporaryFile sync IPC message for blob storage; r=baku
This commit is contained in:
Родитель
cac5d34f3c
Коммит
75b956ac5f
|
@ -111,6 +111,7 @@ public:
|
|||
: mBlobStorage(aBlobStorage)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
MOZ_ASSERT(aBlobStorage);
|
||||
}
|
||||
|
||||
|
@ -118,14 +119,11 @@ public:
|
|||
Run() override
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
PRFileDesc* tempFD = nullptr;
|
||||
nsresult rv = NS_OpenAnonymousTemporaryFile(&tempFD);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
// In sandboxed context we are not allowed to create temporary files, but
|
||||
// this doesn't mean that BlobStorage should fail. We can continue to
|
||||
// store data in memory. We don't change the storageType so that we don't
|
||||
// try to create a temporary file again.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -534,9 +532,20 @@ MutableBlobStorage::ShouldBeTemporaryStorage(uint64_t aSize) const
|
|||
nsresult
|
||||
MutableBlobStorage::MaybeCreateTemporaryFile()
|
||||
{
|
||||
nsresult rv = DispatchToIOThread(new CreateTemporaryFileRunnable(this));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
if (XRE_IsParentProcess()) {
|
||||
nsresult rv = DispatchToIOThread(new CreateTemporaryFileRunnable(this));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
} else {
|
||||
RefPtr<MutableBlobStorage> self(this);
|
||||
ContentChild::GetSingleton()->
|
||||
AsyncOpenAnonymousTemporaryFile([self](PRFileDesc* prfile) {
|
||||
if (prfile) {
|
||||
// The ownership of the prfile is moved to the FileCreatedRunnable.
|
||||
NS_DispatchToMainThread(new FileCreatedRunnable(self, prfile));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mStorageState = eWaitingForTemporaryFile;
|
||||
|
|
Загрузка…
Ссылка в новой задаче