forked from mirrors/gecko-dev
Bug 1341327 - Add assertions to be sure that FileBlobImpls are created on the parent process only, r=smaug
This commit is contained in:
parent
4d5f8afdc0
commit
68feb209f4
4 changed files with 13 additions and 3 deletions
|
|
@ -13,6 +13,7 @@
|
||||||
#include "mozilla/dom/FileCreatorHelper.h"
|
#include "mozilla/dom/FileCreatorHelper.h"
|
||||||
#include "mozilla/dom/FileSystemUtils.h"
|
#include "mozilla/dom/FileSystemUtils.h"
|
||||||
#include "mozilla/dom/Promise.h"
|
#include "mozilla/dom/Promise.h"
|
||||||
|
#include "nsXULAppAPI.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
@ -60,6 +61,7 @@ File::CreateMemoryFile(nsISupports* aParent, void* aMemoryBuffer,
|
||||||
/* static */ already_AddRefed<File>
|
/* static */ already_AddRefed<File>
|
||||||
File::CreateFromFile(nsISupports* aParent, nsIFile* aFile)
|
File::CreateFromFile(nsISupports* aParent, nsIFile* aFile)
|
||||||
{
|
{
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess());
|
||||||
RefPtr<File> file = new File(aParent, new FileBlobImpl(aFile));
|
RefPtr<File> file = new File(aParent, new FileBlobImpl(aFile));
|
||||||
return file.forget();
|
return file.forget();
|
||||||
}
|
}
|
||||||
|
|
@ -68,6 +70,7 @@ File::CreateFromFile(nsISupports* aParent, nsIFile* aFile)
|
||||||
File::CreateFromFile(nsISupports* aParent, nsIFile* aFile,
|
File::CreateFromFile(nsISupports* aParent, nsIFile* aFile,
|
||||||
const nsAString& aName, const nsAString& aContentType)
|
const nsAString& aName, const nsAString& aContentType)
|
||||||
{
|
{
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess());
|
||||||
RefPtr<File> file = new File(aParent,
|
RefPtr<File> file = new File(aParent,
|
||||||
new FileBlobImpl(aFile, aName, aContentType));
|
new FileBlobImpl(aFile, aName, aContentType));
|
||||||
return file.forget();
|
return file.forget();
|
||||||
|
|
@ -166,8 +169,6 @@ File::CreateFromNsIFile(const GlobalObject& aGlobal,
|
||||||
SystemCallerGuarantee aGuarantee,
|
SystemCallerGuarantee aGuarantee,
|
||||||
ErrorResult& aRv)
|
ErrorResult& aRv)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
|
||||||
|
|
||||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
|
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
|
||||||
|
|
||||||
RefPtr<Promise> promise =
|
RefPtr<Promise> promise =
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ FileBlobImpl::FileBlobImpl(nsIFile* aFile)
|
||||||
, mWholeFile(true)
|
, mWholeFile(true)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mFile, "must have file");
|
MOZ_ASSERT(mFile, "must have file");
|
||||||
|
MOZ_ASSERT(XRE_IsParentProcess());
|
||||||
// Lazily get the content type and size
|
// Lazily get the content type and size
|
||||||
mContentType.SetIsVoid(true);
|
mContentType.SetIsVoid(true);
|
||||||
mFile->GetLeafName(mName);
|
mFile->GetLeafName(mName);
|
||||||
|
|
@ -41,6 +42,7 @@ FileBlobImpl::FileBlobImpl(const nsAString& aName,
|
||||||
, mWholeFile(true)
|
, mWholeFile(true)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mFile, "must have file");
|
MOZ_ASSERT(mFile, "must have file");
|
||||||
|
MOZ_ASSERT(XRE_IsParentProcess());
|
||||||
}
|
}
|
||||||
|
|
||||||
FileBlobImpl::FileBlobImpl(const nsAString& aName,
|
FileBlobImpl::FileBlobImpl(const nsAString& aName,
|
||||||
|
|
@ -52,6 +54,7 @@ FileBlobImpl::FileBlobImpl(const nsAString& aName,
|
||||||
, mWholeFile(true)
|
, mWholeFile(true)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mFile, "must have file");
|
MOZ_ASSERT(mFile, "must have file");
|
||||||
|
MOZ_ASSERT(XRE_IsParentProcess());
|
||||||
}
|
}
|
||||||
|
|
||||||
FileBlobImpl::FileBlobImpl(nsIFile* aFile, const nsAString& aName,
|
FileBlobImpl::FileBlobImpl(nsIFile* aFile, const nsAString& aName,
|
||||||
|
|
@ -61,6 +64,7 @@ FileBlobImpl::FileBlobImpl(nsIFile* aFile, const nsAString& aName,
|
||||||
, mWholeFile(true)
|
, mWholeFile(true)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mFile, "must have file");
|
MOZ_ASSERT(mFile, "must have file");
|
||||||
|
MOZ_ASSERT(XRE_IsParentProcess());
|
||||||
if (aContentType.IsEmpty()) {
|
if (aContentType.IsEmpty()) {
|
||||||
// Lazily get the content type and size
|
// Lazily get the content type and size
|
||||||
mContentType.SetIsVoid(true);
|
mContentType.SetIsVoid(true);
|
||||||
|
|
@ -74,6 +78,7 @@ FileBlobImpl::FileBlobImpl(const FileBlobImpl* aOther, uint64_t aStart,
|
||||||
, mWholeFile(false)
|
, mWholeFile(false)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mFile, "must have file");
|
MOZ_ASSERT(mFile, "must have file");
|
||||||
|
MOZ_ASSERT(XRE_IsParentProcess());
|
||||||
mImmutable = aOther->mImmutable;
|
mImmutable = aOther->mImmutable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ FileCreatorHelper::CreateFile(nsIGlobalObject* aGlobalObject,
|
||||||
bool aIsFromNsIFile,
|
bool aIsFromNsIFile,
|
||||||
ErrorResult& aRv)
|
ErrorResult& aRv)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_DIAGNOSTIC_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
RefPtr<Promise> promise = Promise::Create(aGlobalObject, aRv);
|
RefPtr<Promise> promise = Promise::Create(aGlobalObject, aRv);
|
||||||
if (NS_WARN_IF(aRv.Failed())) {
|
if (NS_WARN_IF(aRv.Failed())) {
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,11 @@ partial interface File {
|
||||||
|
|
||||||
[GetterThrows, ChromeOnly, NeedsCallerType]
|
[GetterThrows, ChromeOnly, NeedsCallerType]
|
||||||
readonly attribute DOMString mozFullPath;
|
readonly attribute DOMString mozFullPath;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Mozilla extensions - main-thread only
|
||||||
|
[Exposed=(Window)]
|
||||||
|
partial interface File {
|
||||||
[ChromeOnly, Throws, NeedsCallerType]
|
[ChromeOnly, Throws, NeedsCallerType]
|
||||||
static Promise<File> createFromNsIFile(nsIFile file,
|
static Promise<File> createFromNsIFile(nsIFile file,
|
||||||
optional ChromeFilePropertyBag options);
|
optional ChromeFilePropertyBag options);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue