Bug 1234192 - part 1 - FileSystemBase should not be thread-safe, r=smaug

This commit is contained in:
Andrea Marchesini 2015-12-29 20:41:37 +00:00
parent cfed21018c
commit db31b0db61
2 changed files with 30 additions and 1 deletions

View File

@ -20,7 +20,7 @@ class Directory;
class FileSystemBase
{
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileSystemBase)
NS_INLINE_DECL_REFCOUNTING(FileSystemBase)
public:
// Create file system object from its string representation.

View File

@ -16,10 +16,33 @@
#include "mozilla/dom/PContent.h"
#include "mozilla/dom/ipc/BlobParent.h"
#include "mozilla/unused.h"
#include "nsProxyRelease.h"
namespace mozilla {
namespace dom {
namespace {
class FileSystemReleaseRunnable : public nsRunnable
{
public:
explicit FileSystemReleaseRunnable(RefPtr<FileSystemBase>& aDoomed)
{
aDoomed.swap(mDoomed);
}
NS_IMETHOD Run()
{
mDoomed->Release();
return NS_OK;
}
private:
FileSystemBase* MOZ_OWNING_REF mDoomed;
};
} // anonymous namespace
FileSystemTaskBase::FileSystemTaskBase(FileSystemBase* aFileSystem)
: mErrorValue(NS_OK)
, mFileSystem(aFileSystem)
@ -43,6 +66,12 @@ FileSystemTaskBase::FileSystemTaskBase(FileSystemBase* aFileSystem,
FileSystemTaskBase::~FileSystemTaskBase()
{
if (!NS_IsMainThread()) {
RefPtr<FileSystemReleaseRunnable> runnable =
new FileSystemReleaseRunnable(mFileSystem);
MOZ_ASSERT(!mFileSystem);
NS_DispatchToMainThread(runnable);
}
}
FileSystemBase*