зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1234192 - part 1 - FileSystemBase should not be thread-safe, r=smaug
This commit is contained in:
Родитель
96dd413273
Коммит
e234f69eff
|
@ -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.
|
||||
|
|
|
@ -16,10 +16,34 @@
|
|||
#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)
|
||||
: mDoomed(nullptr)
|
||||
{
|
||||
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 +67,12 @@ FileSystemTaskBase::FileSystemTaskBase(FileSystemBase* aFileSystem,
|
|||
|
||||
FileSystemTaskBase::~FileSystemTaskBase()
|
||||
{
|
||||
if (!NS_IsMainThread()) {
|
||||
RefPtr<FileSystemReleaseRunnable> runnable =
|
||||
new FileSystemReleaseRunnable(mFileSystem);
|
||||
MOZ_ASSERT(!mFileSystem);
|
||||
NS_DispatchToMainThread(runnable);
|
||||
}
|
||||
}
|
||||
|
||||
FileSystemBase*
|
||||
|
|
Загрузка…
Ссылка в новой задаче