mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1036500 - Fix crash caused by non-thread safe DOMFile. r=ehsan
This commit is contained in:
parent
e6b58e4411
commit
8e2b54f984
@ -71,7 +71,7 @@ private:
|
||||
InfallibleTArray<uint8_t> mArrayData;
|
||||
bool mReplace;
|
||||
|
||||
// This cannot be a DOMFile bacause this object is created on a different
|
||||
// This cannot be a DOMFile because this object is created on a different
|
||||
// thread and DOMFile is not thread-safe. Let's use the DOMFileImpl instead.
|
||||
nsRefPtr<DOMFileImpl> mTargetFileImpl;
|
||||
};
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsDeviceStorage.h"
|
||||
#include "nsIDOMFile.h"
|
||||
#include "nsDOMFile.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
@ -114,7 +114,7 @@ DeviceStorageFileSystem::GetLocalFile(const nsAString& aRealPath) const
|
||||
}
|
||||
|
||||
bool
|
||||
DeviceStorageFileSystem::GetRealPath(nsIDOMFile* aFile, nsAString& aRealPath) const
|
||||
DeviceStorageFileSystem::GetRealPath(DOMFileImpl* aFile, nsAString& aRealPath) const
|
||||
{
|
||||
MOZ_ASSERT(FileSystemUtils::IsParentProcess(),
|
||||
"Should be on parent process!");
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
GetLocalFile(const nsAString& aRealPath) const MOZ_OVERRIDE;
|
||||
|
||||
virtual bool
|
||||
GetRealPath(nsIDOMFile* aFile, nsAString& aRealPath) const MOZ_OVERRIDE;
|
||||
GetRealPath(DOMFileImpl* aFile, nsAString& aRealPath) const MOZ_OVERRIDE;
|
||||
|
||||
virtual const nsAString&
|
||||
GetRootName() const MOZ_OVERRIDE;
|
||||
|
@ -195,12 +195,12 @@ Directory::RemoveInternal(const StringOrFileOrDirectory& aPath, bool aRecursive,
|
||||
{
|
||||
nsresult error = NS_OK;
|
||||
nsString realPath;
|
||||
nsCOMPtr<nsIDOMFile> file;
|
||||
nsRefPtr<DOMFileImpl> file;
|
||||
|
||||
// Check and get the target path.
|
||||
|
||||
if (aPath.IsFile()) {
|
||||
file = aPath.GetAsFile();
|
||||
file = static_cast<DOMFile*>(aPath.GetAsFile())->Impl();
|
||||
goto parameters_check_done;
|
||||
}
|
||||
|
||||
|
@ -10,13 +10,13 @@
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsIDOMFile;
|
||||
class nsPIDOMWindow;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class Directory;
|
||||
class DOMFileImpl;
|
||||
|
||||
class FileSystemBase
|
||||
{
|
||||
@ -73,7 +73,7 @@ public:
|
||||
* empty string.
|
||||
*/
|
||||
virtual bool
|
||||
GetRealPath(nsIDOMFile* aFile, nsAString& aRealPath) const = 0;
|
||||
GetRealPath(DOMFileImpl* aFile, nsAString& aRealPath) const = 0;
|
||||
|
||||
/*
|
||||
* Get the permission name required to access this file system.
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "mozilla/dom/FileSystemBase.h"
|
||||
#include "mozilla/dom/FileSystemUtils.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "nsIDOMFile.h"
|
||||
#include "nsDOMFile.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsStringGlue.h"
|
||||
|
||||
@ -19,13 +19,13 @@ namespace dom {
|
||||
|
||||
RemoveTask::RemoveTask(FileSystemBase* aFileSystem,
|
||||
const nsAString& aDirPath,
|
||||
nsIDOMFile* aTargetFile,
|
||||
DOMFileImpl* aTargetFile,
|
||||
const nsAString& aTargetPath,
|
||||
bool aRecursive,
|
||||
ErrorResult& aRv)
|
||||
: FileSystemTaskBase(aFileSystem)
|
||||
, mDirRealPath(aDirPath)
|
||||
, mTargetFile(aTargetFile)
|
||||
, mTargetFileImpl(aTargetFile)
|
||||
, mTargetRealPath(aTargetPath)
|
||||
, mRecursive(aRecursive)
|
||||
, mReturnValue(false)
|
||||
@ -65,8 +65,8 @@ RemoveTask::RemoveTask(FileSystemBase* aFileSystem,
|
||||
|
||||
BlobParent* bp = static_cast<BlobParent*>(static_cast<PBlobParent*>(target));
|
||||
nsCOMPtr<nsIDOMBlob> blob = bp->GetBlob();
|
||||
mTargetFile = do_QueryInterface(blob);
|
||||
MOZ_ASSERT(mTargetFile, "mTargetFile should not be null.");
|
||||
MOZ_ASSERT(blob);
|
||||
mTargetFileImpl = static_cast<DOMFile*>(blob.get())->Impl();
|
||||
}
|
||||
|
||||
RemoveTask::~RemoveTask()
|
||||
@ -90,9 +90,10 @@ RemoveTask::GetRequestParams(const nsString& aFileSystem) const
|
||||
param.filesystem() = aFileSystem;
|
||||
param.directory() = mDirRealPath;
|
||||
param.recursive() = mRecursive;
|
||||
if (mTargetFile) {
|
||||
if (mTargetFileImpl) {
|
||||
nsRefPtr<DOMFile> file = new DOMFile(mTargetFileImpl);
|
||||
BlobChild* actor
|
||||
= ContentChild::GetSingleton()->GetOrCreateActorForBlob(mTargetFile);
|
||||
= ContentChild::GetSingleton()->GetOrCreateActorForBlob(file);
|
||||
if (actor) {
|
||||
param.target() = actor;
|
||||
}
|
||||
@ -129,8 +130,8 @@ RemoveTask::Work()
|
||||
}
|
||||
|
||||
// Get the DOM path if a DOMFile is passed as the target.
|
||||
if (mTargetFile) {
|
||||
if (!mFileSystem->GetRealPath(mTargetFile, mTargetRealPath)) {
|
||||
if (mTargetFileImpl) {
|
||||
if (!mFileSystem->GetRealPath(mTargetFileImpl, mTargetRealPath)) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
if (!FileSystemUtils::IsDescendantPath(mDirRealPath, mTargetRealPath)) {
|
||||
|
@ -14,6 +14,7 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class DOMFileImpl;
|
||||
class Promise;
|
||||
|
||||
class RemoveTask MOZ_FINAL
|
||||
@ -22,7 +23,7 @@ class RemoveTask MOZ_FINAL
|
||||
public:
|
||||
RemoveTask(FileSystemBase* aFileSystem,
|
||||
const nsAString& aDirPath,
|
||||
nsIDOMFile* aTargetFile,
|
||||
DOMFileImpl* aTargetFile,
|
||||
const nsAString& aTargetPath,
|
||||
bool aRecursive,
|
||||
ErrorResult& aRv);
|
||||
@ -58,7 +59,9 @@ protected:
|
||||
private:
|
||||
nsRefPtr<Promise> mPromise;
|
||||
nsString mDirRealPath;
|
||||
nsCOMPtr<nsIDOMFile> mTargetFile;
|
||||
// This cannot be a DOMFile because this object will be used on a different
|
||||
// thread and DOMFile is not thread-safe. Let's use the DOMFileImpl instead.
|
||||
nsRefPtr<DOMFileImpl> mTargetFileImpl;
|
||||
nsString mTargetRealPath;
|
||||
bool mRecursive;
|
||||
bool mReturnValue;
|
||||
|
Loading…
Reference in New Issue
Block a user