зеркало из https://github.com/mozilla/gecko-dev.git
Merge inbound to m-c on a CLOSED TREE. a=merge
This commit is contained in:
Коммит
b8cc2a9367
|
@ -295,7 +295,7 @@ endif
|
|||
ifdef MOZ_PSEUDO_DERECURSE
|
||||
# Interdependencies for parallel export.
|
||||
js/xpconnect/src/export: dom/bindings/export xpcom/xpidl/export
|
||||
accessible/src/xpcom/export: xpcom/xpidl/export
|
||||
accessible/xpcom/export: xpcom/xpidl/export
|
||||
ifdef ENABLE_CLANG_PLUGIN
|
||||
js/src/export config/export: build/clang-plugin/export
|
||||
endif
|
||||
|
|
|
@ -121,16 +121,6 @@ namespace layers {
|
|||
class LayerManager;
|
||||
} // namespace layers
|
||||
|
||||
// Called back from DeferredFinalize. Should add 'thing' to the array of smart
|
||||
// pointers in 'pointers', creating the array if 'pointers' is null, and return
|
||||
// the array.
|
||||
typedef void* (*DeferredFinalizeAppendFunction)(void* pointers, void* thing);
|
||||
|
||||
// Called to finalize a number of objects. Slice is the number of objects
|
||||
// to finalize, or if it's UINT32_MAX, all objects should be finalized.
|
||||
// Return value indicates whether it finalized all objects in the buffer.
|
||||
typedef bool (*DeferredFinalizeFunction)(uint32_t slice, void* data);
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
class nsIBidiKeyboard;
|
||||
|
@ -1280,11 +1270,6 @@ public:
|
|||
static void DestroyAnonymousContent(nsCOMPtr<nsIContent>* aContent);
|
||||
static void DestroyAnonymousContent(nsCOMPtr<Element>* aElement);
|
||||
|
||||
static void DeferredFinalize(nsISupports* aSupports);
|
||||
static void DeferredFinalize(mozilla::DeferredFinalizeAppendFunction aAppendFunc,
|
||||
mozilla::DeferredFinalizeFunction aFunc,
|
||||
void* aThing);
|
||||
|
||||
/*
|
||||
* Notify when the first XUL menu is opened and when the all XUL menus are
|
||||
* closed. At opening, aInstalling should be TRUE, otherwise, it should be
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -5973,7 +5973,8 @@ nsContentUtils::CreateBlobBuffer(JSContext* aCx,
|
|||
nsCOMPtr<nsIDOMBlob> blob;
|
||||
if (blobData) {
|
||||
memcpy(blobData, aData.BeginReading(), blobLen);
|
||||
blob = new nsDOMMemoryFile(blobData, blobLen, EmptyString());
|
||||
blob = mozilla::dom::DOMFile::CreateMemoryFile(blobData, blobLen,
|
||||
EmptyString());
|
||||
} else {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -6065,22 +6066,6 @@ nsContentUtils::AllocClassMatchingInfo(nsINode* aRootNode,
|
|||
return info;
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
nsContentUtils::DeferredFinalize(nsISupports* aSupports)
|
||||
{
|
||||
cyclecollector::DeferredFinalize(aSupports);
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
nsContentUtils::DeferredFinalize(mozilla::DeferredFinalizeAppendFunction aAppendFunc,
|
||||
mozilla::DeferredFinalizeFunction aFunc,
|
||||
void* aThing)
|
||||
{
|
||||
cyclecollector::DeferredFinalize(aAppendFunc, aFunc, aThing);
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
nsContentUtils::IsFocusedContent(const nsIContent* aContent)
|
||||
|
|
|
@ -21,18 +21,15 @@
|
|||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsDOMMultipartFile, nsDOMFile,
|
||||
nsIJSNativeInitializer)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMMultipartFile::GetSize(uint64_t* aLength)
|
||||
nsresult
|
||||
DOMMultipartFileImpl::GetSize(uint64_t* aLength)
|
||||
{
|
||||
*aLength = mLength;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMMultipartFile::GetInternalStream(nsIInputStream** aStream)
|
||||
nsresult
|
||||
DOMMultipartFileImpl::GetInternalStream(nsIInputStream** aStream)
|
||||
{
|
||||
nsresult rv;
|
||||
*aStream = nullptr;
|
||||
|
@ -57,8 +54,8 @@ nsDOMMultipartFile::GetInternalStream(nsIInputStream** aStream)
|
|||
}
|
||||
|
||||
already_AddRefed<nsIDOMBlob>
|
||||
nsDOMMultipartFile::CreateSlice(uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
DOMMultipartFileImpl::CreateSlice(uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
{
|
||||
// If we clamped to nothing we create an empty blob
|
||||
nsTArray<nsCOMPtr<nsIDOMBlob> > blobs;
|
||||
|
@ -84,7 +81,7 @@ nsDOMMultipartFile::CreateSlice(uint64_t aStart, uint64_t aLength,
|
|||
getter_AddRefs(firstBlob));
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
// Avoid wrapping a single blob inside an nsDOMMultipartFile
|
||||
// Avoid wrapping a single blob inside an DOMMultipartFileImpl
|
||||
if (length == upperBound) {
|
||||
return firstBlob.forget();
|
||||
}
|
||||
|
@ -119,23 +116,25 @@ nsDOMMultipartFile::CreateSlice(uint64_t aStart, uint64_t aLength,
|
|||
}
|
||||
|
||||
// we can create our blob now
|
||||
nsCOMPtr<nsIDOMBlob> blob = new nsDOMMultipartFile(blobs, aContentType);
|
||||
nsCOMPtr<nsIDOMBlob> blob =
|
||||
new DOMFile(new DOMMultipartFileImpl(blobs, aContentType));
|
||||
return blob.forget();
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
nsDOMMultipartFile::NewFile(const nsAString& aName, nsISupports* *aNewObject)
|
||||
DOMMultipartFileImpl::NewFile(const nsAString& aName, nsISupports** aNewObject)
|
||||
{
|
||||
nsCOMPtr<nsISupports> file =
|
||||
do_QueryObject(new nsDOMMultipartFile(aName));
|
||||
do_QueryObject(new DOMFile(new DOMMultipartFileImpl(aName)));
|
||||
file.forget(aNewObject);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
nsDOMMultipartFile::NewBlob(nsISupports* *aNewObject)
|
||||
DOMMultipartFileImpl::NewBlob(nsISupports** aNewObject)
|
||||
{
|
||||
nsCOMPtr<nsISupports> file = do_QueryObject(new nsDOMMultipartFile());
|
||||
nsCOMPtr<nsISupports> file =
|
||||
do_QueryObject(new DOMFile(new DOMMultipartFileImpl()));
|
||||
file.forget(aNewObject);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -147,11 +146,11 @@ GetXPConnectNative(JSContext* aCx, JSObject* aObj) {
|
|||
return blob;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMMultipartFile::Initialize(nsISupports* aOwner,
|
||||
JSContext* aCx,
|
||||
JSObject* aObj,
|
||||
const JS::CallArgs& aArgs)
|
||||
nsresult
|
||||
DOMMultipartFileImpl::Initialize(nsISupports* aOwner,
|
||||
JSContext* aCx,
|
||||
JSObject* aObj,
|
||||
const JS::CallArgs& aArgs)
|
||||
{
|
||||
if (!mIsFile) {
|
||||
return InitBlob(aCx, aArgs.length(), aArgs.array(), GetXPConnectNative);
|
||||
|
@ -175,10 +174,10 @@ nsDOMMultipartFile::Initialize(nsISupports* aOwner,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsDOMMultipartFile::InitBlob(JSContext* aCx,
|
||||
uint32_t aArgc,
|
||||
JS::Value* aArgv,
|
||||
UnwrapFuncPtr aUnwrapFunc)
|
||||
DOMMultipartFileImpl::InitBlob(JSContext* aCx,
|
||||
uint32_t aArgc,
|
||||
JS::Value* aArgv,
|
||||
UnwrapFuncPtr aUnwrapFunc)
|
||||
{
|
||||
bool nativeEOL = false;
|
||||
if (aArgc > 1) {
|
||||
|
@ -200,9 +199,9 @@ nsDOMMultipartFile::InitBlob(JSContext* aCx,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsDOMMultipartFile::ParseBlobArrayArgument(JSContext* aCx, JS::Value& aValue,
|
||||
bool aNativeEOL,
|
||||
UnwrapFuncPtr aUnwrapFunc)
|
||||
DOMMultipartFileImpl::ParseBlobArrayArgument(JSContext* aCx, JS::Value& aValue,
|
||||
bool aNativeEOL,
|
||||
UnwrapFuncPtr aUnwrapFunc)
|
||||
{
|
||||
if (!aValue.isObject()) {
|
||||
return NS_ERROR_TYPE_ERR; // We're not interested
|
||||
|
@ -227,10 +226,8 @@ nsDOMMultipartFile::ParseBlobArrayArgument(JSContext* aCx, JS::Value& aValue,
|
|||
nsCOMPtr<nsIDOMBlob> blob = aUnwrapFunc(aCx, obj);
|
||||
if (blob) {
|
||||
// Flatten so that multipart blobs will never nest
|
||||
nsDOMFileBase* file = static_cast<nsDOMFileBase*>(
|
||||
static_cast<nsIDOMBlob*>(blob));
|
||||
const nsTArray<nsCOMPtr<nsIDOMBlob> >*
|
||||
subBlobs = file->GetSubBlobs();
|
||||
DOMFile* file = static_cast<DOMFile*>(static_cast<nsIDOMBlob*>(blob));
|
||||
const nsTArray<nsCOMPtr<nsIDOMBlob>>* subBlobs = file->GetSubBlobs();
|
||||
if (subBlobs) {
|
||||
blobSet.AppendBlobs(*subBlobs);
|
||||
} else {
|
||||
|
@ -268,7 +265,7 @@ nsDOMMultipartFile::ParseBlobArrayArgument(JSContext* aCx, JS::Value& aValue,
|
|||
}
|
||||
|
||||
void
|
||||
nsDOMMultipartFile::SetLengthAndModifiedDate()
|
||||
DOMMultipartFileImpl::SetLengthAndModifiedDate()
|
||||
{
|
||||
MOZ_ASSERT(mLength == UINT64_MAX);
|
||||
MOZ_ASSERT(mLastModificationDate == UINT64_MAX);
|
||||
|
@ -282,7 +279,7 @@ nsDOMMultipartFile::SetLengthAndModifiedDate()
|
|||
{
|
||||
// XXX This is only safe so long as all blob implementations in our tree
|
||||
// inherit nsDOMFileBase.
|
||||
const auto* blobBase = static_cast<nsDOMFileBase*>(blob.get());
|
||||
const auto* blobBase = static_cast<DOMFile*>(blob.get());
|
||||
|
||||
MOZ_ASSERT(!blobBase->IsSizeUnknown());
|
||||
MOZ_ASSERT(!blobBase->IsDateUnknown());
|
||||
|
@ -303,26 +300,26 @@ nsDOMMultipartFile::SetLengthAndModifiedDate()
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMMultipartFile::GetMozFullPathInternal(nsAString &aFilename)
|
||||
nsresult
|
||||
DOMMultipartFileImpl::GetMozFullPathInternal(nsAString& aFilename)
|
||||
{
|
||||
if (!mIsFromNsiFile || mBlobs.Length() == 0) {
|
||||
return nsDOMFile::GetMozFullPathInternal(aFilename);
|
||||
return DOMFileImplBase::GetMozFullPathInternal(aFilename);
|
||||
}
|
||||
|
||||
nsIDOMBlob* blob = mBlobs.ElementAt(0).get();
|
||||
nsDOMFileFile* file = static_cast<nsDOMFileFile*>(blob);
|
||||
if (!file) {
|
||||
return nsDOMFile::GetMozFullPathInternal(aFilename);
|
||||
if (!blob) {
|
||||
return DOMFileImplBase::GetMozFullPathInternal(aFilename);
|
||||
}
|
||||
|
||||
return file->GetMozFullPathInternal(aFilename);
|
||||
DOMFile* domFile = static_cast<DOMFile*>(blob);
|
||||
return domFile->GetMozFullPathInternal(aFilename);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMMultipartFile::InitChromeFile(JSContext* aCx,
|
||||
uint32_t aArgc,
|
||||
JS::Value* aArgv)
|
||||
DOMMultipartFileImpl::InitChromeFile(JSContext* aCx,
|
||||
uint32_t aArgc,
|
||||
JS::Value* aArgv)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -395,7 +392,7 @@ nsDOMMultipartFile::InitChromeFile(JSContext* aCx,
|
|||
file->GetLeafName(mName);
|
||||
}
|
||||
|
||||
nsRefPtr<nsDOMFileFile> domFile = new nsDOMFileFile(file);
|
||||
nsRefPtr<DOMFile> domFile = DOMFile::CreateFromFile(file);
|
||||
|
||||
// Pre-cache size.
|
||||
uint64_t unused;
|
||||
|
@ -424,9 +421,9 @@ nsDOMMultipartFile::InitChromeFile(JSContext* aCx,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsDOMMultipartFile::InitFile(JSContext* aCx,
|
||||
uint32_t aArgc,
|
||||
JS::Value* aArgv)
|
||||
DOMMultipartFileImpl::InitFile(JSContext* aCx,
|
||||
uint32_t aArgc,
|
||||
JS::Value* aArgv)
|
||||
{
|
||||
NS_ASSERTION(!mImmutable, "Something went wrong ...");
|
||||
NS_ENSURE_TRUE(!mImmutable, NS_ERROR_UNEXPECTED);
|
||||
|
|
|
@ -20,15 +20,14 @@
|
|||
{ 0x94, 0x96, 0xdf, 0x5d, 0x6f, 0xcd, 0xd7, 0x8f } }
|
||||
#define NS_DOMMULTIPARTFILE_CONTRACTID "@mozilla.org/dom/multipart-file;1"
|
||||
|
||||
class nsDOMMultipartFile : public nsDOMFile,
|
||||
public nsIJSNativeInitializer
|
||||
class DOMMultipartFileImpl MOZ_FINAL : public mozilla::dom::DOMFileImplBase
|
||||
{
|
||||
public:
|
||||
// Create as a file
|
||||
nsDOMMultipartFile(nsTArray<nsCOMPtr<nsIDOMBlob> > aBlobs,
|
||||
const nsAString& aName,
|
||||
const nsAString& aContentType)
|
||||
: nsDOMFile(aName, aContentType, UINT64_MAX),
|
||||
DOMMultipartFileImpl(const nsTArray<nsCOMPtr<nsIDOMBlob>>& aBlobs,
|
||||
const nsAString& aName,
|
||||
const nsAString& aContentType)
|
||||
: mozilla::dom::DOMFileImplBase(aName, aContentType, UINT64_MAX),
|
||||
mBlobs(aBlobs),
|
||||
mIsFromNsiFile(false)
|
||||
{
|
||||
|
@ -36,9 +35,9 @@ public:
|
|||
}
|
||||
|
||||
// Create as a blob
|
||||
nsDOMMultipartFile(nsTArray<nsCOMPtr<nsIDOMBlob> >& aBlobs,
|
||||
const nsAString& aContentType)
|
||||
: nsDOMFile(aContentType, UINT64_MAX),
|
||||
DOMMultipartFileImpl(const nsTArray<nsCOMPtr<nsIDOMBlob>>& aBlobs,
|
||||
const nsAString& aContentType)
|
||||
: mozilla::dom::DOMFileImplBase(aContentType, UINT64_MAX),
|
||||
mBlobs(aBlobs),
|
||||
mIsFromNsiFile(false)
|
||||
{
|
||||
|
@ -46,26 +45,22 @@ public:
|
|||
}
|
||||
|
||||
// Create as a file to be later initialized
|
||||
nsDOMMultipartFile(const nsAString& aName)
|
||||
: nsDOMFile(aName, EmptyString(), UINT64_MAX),
|
||||
explicit DOMMultipartFileImpl(const nsAString& aName)
|
||||
: mozilla::dom::DOMFileImplBase(aName, EmptyString(), UINT64_MAX),
|
||||
mIsFromNsiFile(false)
|
||||
{
|
||||
}
|
||||
|
||||
// Create as a blob to be later initialized
|
||||
nsDOMMultipartFile()
|
||||
: nsDOMFile(EmptyString(), UINT64_MAX),
|
||||
DOMMultipartFileImpl()
|
||||
: mozilla::dom::DOMFileImplBase(EmptyString(), UINT64_MAX),
|
||||
mIsFromNsiFile(false)
|
||||
{
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
// nsIJSNativeInitializer
|
||||
NS_IMETHOD Initialize(nsISupports* aOwner,
|
||||
JSContext* aCx,
|
||||
JSObject* aObj,
|
||||
const JS::CallArgs& aArgs) MOZ_OVERRIDE;
|
||||
virtual nsresult
|
||||
Initialize(nsISupports* aOwner, JSContext* aCx, JSObject* aObj,
|
||||
const JS::CallArgs& aArgs) MOZ_OVERRIDE;
|
||||
|
||||
typedef nsIDOMBlob* (*UnwrapFuncPtr)(JSContext*, JSObject*);
|
||||
nsresult InitBlob(JSContext* aCx,
|
||||
|
@ -79,33 +74,34 @@ public:
|
|||
uint32_t aArgc,
|
||||
JS::Value* aArgv);
|
||||
|
||||
already_AddRefed<nsIDOMBlob>
|
||||
CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType) MOZ_OVERRIDE;
|
||||
virtual already_AddRefed<nsIDOMBlob>
|
||||
CreateSlice(uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType) MOZ_OVERRIDE;
|
||||
|
||||
NS_IMETHOD GetSize(uint64_t*) MOZ_OVERRIDE;
|
||||
NS_IMETHOD GetInternalStream(nsIInputStream**) MOZ_OVERRIDE;
|
||||
virtual nsresult GetSize(uint64_t* aSize) MOZ_OVERRIDE;
|
||||
|
||||
static nsresult
|
||||
NewFile(const nsAString& aName, nsISupports* *aNewObject);
|
||||
virtual nsresult GetInternalStream(nsIInputStream** aInputStream) MOZ_OVERRIDE;
|
||||
|
||||
static nsresult NewFile(const nsAString& aName, nsISupports** aNewObject);
|
||||
|
||||
// DOMClassInfo constructor (for Blob([b1, "foo"], { type: "image/png" }))
|
||||
static nsresult
|
||||
NewBlob(nsISupports* *aNewObject);
|
||||
static nsresult NewBlob(nsISupports* *aNewObject);
|
||||
|
||||
// DOMClassInfo constructor (for File([b1, "foo"], { type: "image/png",
|
||||
// name: "foo.png" }))
|
||||
inline static nsresult
|
||||
NewFile(nsISupports* *aNewObject)
|
||||
inline static nsresult NewFile(nsISupports** aNewObject)
|
||||
{
|
||||
// Initialization will set the filename, so we can pass in an empty string
|
||||
// for now.
|
||||
return NewFile(EmptyString(), aNewObject);
|
||||
}
|
||||
|
||||
virtual const nsTArray<nsCOMPtr<nsIDOMBlob> >*
|
||||
GetSubBlobs() const MOZ_OVERRIDE { return &mBlobs; }
|
||||
virtual const nsTArray<nsCOMPtr<nsIDOMBlob>>* GetSubBlobs() const MOZ_OVERRIDE
|
||||
{
|
||||
return &mBlobs;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetMozFullPathInternal(nsAString& aFullPath) MOZ_OVERRIDE;
|
||||
virtual nsresult GetMozFullPathInternal(nsAString& aFullPath) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
nsresult ParseBlobArrayArgument(JSContext* aCx, JS::Value& aValue,
|
||||
|
@ -139,8 +135,8 @@ public:
|
|||
already_AddRefed<nsIDOMBlob>
|
||||
GetBlobInternal(const nsACString& aContentType)
|
||||
{
|
||||
nsCOMPtr<nsIDOMBlob> blob =
|
||||
new nsDOMMultipartFile(GetBlobs(), NS_ConvertASCIItoUTF16(aContentType));
|
||||
nsCOMPtr<nsIDOMBlob> blob = new mozilla::dom::DOMFile(
|
||||
new DOMMultipartFileImpl(GetBlobs(), NS_ConvertASCIItoUTF16(aContentType)));
|
||||
return blob.forget();
|
||||
}
|
||||
|
||||
|
@ -179,7 +175,7 @@ protected:
|
|||
// and put it on the stack
|
||||
|
||||
nsCOMPtr<nsIDOMBlob> blob =
|
||||
new nsDOMMemoryFile(mData, mDataLen, EmptyString());
|
||||
mozilla::dom::DOMFile::CreateMemoryFile(mData, mDataLen, EmptyString());
|
||||
mBlobs.AppendElement(blob);
|
||||
mData = nullptr; // The nsDOMMemoryFile takes ownership of the buffer
|
||||
mDataLen = 0;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "nsISeekableStream.h"
|
||||
#include "nsIUnicharInputStream.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsIRemoteBlob.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIUUIDGenerator.h"
|
||||
|
@ -37,8 +38,12 @@
|
|||
#include "nsThreadUtils.h"
|
||||
|
||||
#include "mozilla/dom/FileListBinding.h"
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
DOMCI_DATA(File, mozilla::dom::DOMFile)
|
||||
DOMCI_DATA(Blob, mozilla::dom::DOMFile)
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
// XXXkhuey the input stream that we pass out of a DOMFile
|
||||
// can outlive the actual DOMFile object. Thus, we must
|
||||
|
@ -49,7 +54,7 @@ class DataOwnerAdapter MOZ_FINAL : public nsIInputStream,
|
|||
public nsISeekableStream,
|
||||
public nsIIPCSerializableInputStream
|
||||
{
|
||||
typedef nsDOMMemoryFile::DataOwner DataOwner;
|
||||
typedef DOMFileImplMemory::DataOwner DataOwner;
|
||||
public:
|
||||
static nsresult Create(DataOwner* aDataOwner,
|
||||
uint32_t aStart,
|
||||
|
@ -118,86 +123,229 @@ nsresult DataOwnerAdapter::Create(DataOwner* aDataOwner,
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// nsDOMFileBase implementation
|
||||
// mozilla::dom::DOMFile implementation
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileBase::GetName(nsAString &aFileName)
|
||||
NS_INTERFACE_MAP_BEGIN(DOMFile)
|
||||
// This class should not receive any nsIRemoteBlob QI!
|
||||
MOZ_ASSERT(!aIID.Equals(NS_GET_IID(nsIRemoteBlob)));
|
||||
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMFile)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMBlob)
|
||||
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIDOMFile, IsFile())
|
||||
NS_INTERFACE_MAP_ENTRY(nsIXHRSendable)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIMutable)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIJSNativeInitializer)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_CONDITIONAL(File, IsFile())
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_CONDITIONAL(Blob, !(IsFile()))
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_ADDREF(DOMFile)
|
||||
NS_IMPL_RELEASE(DOMFile)
|
||||
|
||||
/* static */ already_AddRefed<DOMFile>
|
||||
DOMFile::Create(const nsAString& aName, const nsAString& aContentType,
|
||||
uint64_t aLength, uint64_t aLastModifiedDate)
|
||||
{
|
||||
NS_ASSERTION(mIsFile, "Should only be called on files");
|
||||
aFileName = mName;
|
||||
return NS_OK;
|
||||
nsRefPtr<DOMFile> file = new DOMFile(
|
||||
new DOMFileImplBase(aName, aContentType, aLength, aLastModifiedDate));
|
||||
return file.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<DOMFile>
|
||||
DOMFile::Create(const nsAString& aName, const nsAString& aContentType,
|
||||
uint64_t aLength)
|
||||
{
|
||||
nsRefPtr<DOMFile> file = new DOMFile(
|
||||
new DOMFileImplBase(aName, aContentType, aLength));
|
||||
return file.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<DOMFile>
|
||||
DOMFile::Create(const nsAString& aContentType, uint64_t aLength)
|
||||
{
|
||||
nsRefPtr<DOMFile> file = new DOMFile(
|
||||
new DOMFileImplBase(aContentType, aLength));
|
||||
return file.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<DOMFile>
|
||||
DOMFile::Create(const nsAString& aContentType, uint64_t aStart,
|
||||
uint64_t aLength)
|
||||
{
|
||||
nsRefPtr<DOMFile> file = new DOMFile(
|
||||
new DOMFileImplBase(aContentType, aStart, aLength));
|
||||
return file.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<DOMFile>
|
||||
DOMFile::CreateMemoryFile(void* aMemoryBuffer, uint64_t aLength,
|
||||
const nsAString& aName,
|
||||
const nsAString& aContentType,
|
||||
uint64_t aLastModifiedDate)
|
||||
{
|
||||
nsRefPtr<DOMFile> file = new DOMFile(
|
||||
new DOMFileImplMemory(aMemoryBuffer, aLength, aName,
|
||||
aContentType, aLastModifiedDate));
|
||||
return file.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<DOMFile>
|
||||
DOMFile::CreateMemoryFile(void* aMemoryBuffer, uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
{
|
||||
nsRefPtr<DOMFile> file = new DOMFile(
|
||||
new DOMFileImplMemory(aMemoryBuffer, aLength, aContentType));
|
||||
return file.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<DOMFile>
|
||||
DOMFile::CreateTemporaryFileBlob(PRFileDesc* aFD, uint64_t aStartPos,
|
||||
uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
{
|
||||
nsRefPtr<DOMFile> file = new DOMFile(
|
||||
new DOMFileImplTemporaryFileBlob(aFD, aStartPos, aLength, aContentType));
|
||||
return file.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<DOMFile>
|
||||
DOMFile::CreateFromFile(nsIFile* aFile)
|
||||
{
|
||||
nsRefPtr<DOMFile> file = new DOMFile(new DOMFileImplFile(aFile));
|
||||
return file.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<DOMFile>
|
||||
DOMFile::CreateFromFile(const nsAString& aContentType, uint64_t aLength,
|
||||
nsIFile* aFile, indexedDB::FileInfo* aFileInfo)
|
||||
{
|
||||
nsRefPtr<DOMFile> file = new DOMFile(
|
||||
new DOMFileImplFile(aContentType, aLength, aFile, aFileInfo));
|
||||
return file.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<DOMFile>
|
||||
DOMFile::CreateFromFile(const nsAString& aName,
|
||||
const nsAString& aContentType,
|
||||
uint64_t aLength, nsIFile* aFile,
|
||||
indexedDB::FileInfo* aFileInfo)
|
||||
{
|
||||
nsRefPtr<DOMFile> file = new DOMFile(
|
||||
new DOMFileImplFile(aName, aContentType, aLength, aFile, aFileInfo));
|
||||
return file.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<DOMFile>
|
||||
DOMFile::CreateFromFile(nsIFile* aFile, indexedDB::FileInfo* aFileInfo)
|
||||
{
|
||||
nsRefPtr<DOMFile> file = new DOMFile(new DOMFileImplFile(aFile, aFileInfo));
|
||||
return file.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<DOMFile>
|
||||
DOMFile::CreateFromFile(nsIFile* aFile, const nsAString& aName,
|
||||
const nsAString& aContentType)
|
||||
{
|
||||
nsRefPtr<DOMFile> file = new DOMFile(
|
||||
new DOMFileImplFile(aFile, aName, aContentType));
|
||||
return file.forget();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// mozilla::dom::DOMFileBase implementation
|
||||
|
||||
const nsTArray<nsCOMPtr<nsIDOMBlob>>*
|
||||
DOMFileBase::GetSubBlobs() const
|
||||
{
|
||||
return mImpl->GetSubBlobs();
|
||||
}
|
||||
|
||||
bool
|
||||
DOMFileBase::IsSizeUnknown() const
|
||||
{
|
||||
return mImpl->IsSizeUnknown();
|
||||
}
|
||||
|
||||
bool
|
||||
DOMFileBase::IsDateUnknown() const
|
||||
{
|
||||
return mImpl->IsDateUnknown();
|
||||
}
|
||||
|
||||
bool
|
||||
DOMFileBase::IsFile() const
|
||||
{
|
||||
return mImpl->IsFile();
|
||||
}
|
||||
|
||||
void
|
||||
DOMFileBase::SetLazyData(const nsAString& aName, const nsAString& aContentType,
|
||||
uint64_t aLength, uint64_t aLastModifiedDate)
|
||||
{
|
||||
return mImpl->SetLazyData(aName, aContentType, aLength, aLastModifiedDate);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMBlob>
|
||||
DOMFileBase::CreateSlice(uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
{
|
||||
return mImpl->CreateSlice(aStart, aLength, aContentType);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileBase::GetPath(nsAString &aPath)
|
||||
DOMFileBase::Initialize(nsISupports* aOwner, JSContext* aCx, JSObject* aObj,
|
||||
const JS::CallArgs& aArgs)
|
||||
{
|
||||
NS_ASSERTION(mIsFile, "Should only be called on files");
|
||||
aPath = mPath;
|
||||
return NS_OK;
|
||||
return mImpl->Initialize(aOwner, aCx, aObj, aArgs);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileBase::GetLastModifiedDate(JSContext* cx, JS::MutableHandle<JS::Value> aLastModifiedDate)
|
||||
DOMFileBase::GetName(nsAString& aFileName)
|
||||
{
|
||||
JS::Rooted<JSObject*> date(cx, JS_NewDateObjectMsec(cx, JS_Now() / PR_USEC_PER_MSEC));
|
||||
if (!date) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
aLastModifiedDate.setObject(*date);
|
||||
return NS_OK;
|
||||
return mImpl->GetName(aFileName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileBase::GetMozFullPath(nsAString &aFileName)
|
||||
DOMFileBase::GetPath(nsAString& aPath)
|
||||
{
|
||||
NS_ASSERTION(mIsFile, "Should only be called on files");
|
||||
|
||||
// It is unsafe to call IsCallerChrome on a non-main thread. If
|
||||
// you hit the following assertion you need to figure out some other way to
|
||||
// determine privileges and call GetMozFullPathInternal.
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
if (nsContentUtils::IsCallerChrome()) {
|
||||
return GetMozFullPathInternal(aFileName);
|
||||
}
|
||||
aFileName.Truncate();
|
||||
return NS_OK;
|
||||
return mImpl->GetPath(aPath);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileBase::GetMozFullPathInternal(nsAString &aFileName)
|
||||
DOMFileBase::GetLastModifiedDate(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aDate)
|
||||
{
|
||||
if (!mIsFile) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
aFileName.Truncate();
|
||||
return NS_OK;
|
||||
return mImpl->GetLastModifiedDate(aCx, aDate);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileBase::GetSize(uint64_t *aSize)
|
||||
DOMFileBase::GetMozFullPath(nsAString &aFileName)
|
||||
{
|
||||
*aSize = mLength;
|
||||
return NS_OK;
|
||||
return mImpl->GetMozFullPath(aFileName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileBase::GetType(nsAString &aType)
|
||||
DOMFileBase::GetMozFullPathInternal(nsAString &aFileName)
|
||||
{
|
||||
aType = mContentType;
|
||||
return NS_OK;
|
||||
return mImpl->GetMozFullPathInternal(aFileName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileBase::GetMozLastModifiedDate(uint64_t* aLastModifiedDate)
|
||||
DOMFileBase::GetSize(uint64_t* aSize)
|
||||
{
|
||||
NS_ASSERTION(mIsFile, "Should only be called on files");
|
||||
if (IsDateUnknown()) {
|
||||
mLastModificationDate = PR_Now();
|
||||
}
|
||||
*aLastModifiedDate = mLastModificationDate;
|
||||
return NS_OK;
|
||||
return mImpl->GetSize(aSize);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMFileBase::GetType(nsAString &aType)
|
||||
{
|
||||
return mImpl->GetType(aType);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMFileBase::GetMozLastModifiedDate(uint64_t* aDate)
|
||||
{
|
||||
return mImpl->GetMozLastModifiedDate(aDate);
|
||||
}
|
||||
|
||||
// Makes sure that aStart and aEnd is less then or equal to aSize and greater
|
||||
|
@ -238,9 +386,78 @@ ParseSize(int64_t aSize, int64_t& aStart, int64_t& aEnd)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileBase::Slice(int64_t aStart, int64_t aEnd,
|
||||
const nsAString& aContentType, uint8_t optional_argc,
|
||||
nsIDOMBlob **aBlob)
|
||||
DOMFileBase::Slice(int64_t aStart, int64_t aEnd,
|
||||
const nsAString& aContentType, uint8_t aArgc,
|
||||
nsIDOMBlob **aBlob)
|
||||
{
|
||||
MOZ_ASSERT(mImpl);
|
||||
return mImpl->Slice(aStart, aEnd, aContentType, aArgc, aBlob);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMFileBase::GetInternalStream(nsIInputStream** aStream)
|
||||
{
|
||||
return mImpl->GetInternalStream(aStream);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMFileBase::GetInternalUrl(nsIPrincipal* aPrincipal, nsAString& aURL)
|
||||
{
|
||||
return mImpl->GetInternalUrl(aPrincipal, aURL);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(int64_t)
|
||||
DOMFileBase::GetFileId()
|
||||
{
|
||||
return mImpl->GetFileId();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(void)
|
||||
DOMFileBase::AddFileInfo(indexedDB::FileInfo* aFileInfo)
|
||||
{
|
||||
mImpl->AddFileInfo(aFileInfo);
|
||||
}
|
||||
|
||||
indexedDB::FileInfo*
|
||||
DOMFileBase::GetFileInfo(indexedDB::FileManager* aFileManager)
|
||||
{
|
||||
return mImpl->GetFileInfo(aFileManager);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMFileBase::GetSendInfo(nsIInputStream** aBody,
|
||||
uint64_t* aContentLength,
|
||||
nsACString& aContentType,
|
||||
nsACString& aCharset)
|
||||
{
|
||||
return mImpl->GetSendInfo(aBody, aContentLength, aContentType, aCharset);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMFileBase::GetMutable(bool* aMutable)
|
||||
{
|
||||
return mImpl->GetMutable(aMutable);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMFileBase::SetMutable(bool aMutable)
|
||||
{
|
||||
return mImpl->SetMutable(aMutable);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
DOMFileBase::IsMemoryFile()
|
||||
{
|
||||
return mImpl->IsMemoryFile();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// mozilla::dom::DOMFileImpl implementation
|
||||
|
||||
nsresult
|
||||
DOMFileImpl::Slice(int64_t aStart, int64_t aEnd,
|
||||
const nsAString& aContentType, uint8_t aArgc,
|
||||
nsIDOMBlob **aBlob)
|
||||
{
|
||||
*aBlob = nullptr;
|
||||
|
||||
|
@ -249,37 +466,126 @@ nsDOMFileBase::Slice(int64_t aStart, int64_t aEnd,
|
|||
nsresult rv = GetSize(&thisLength);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (optional_argc < 2) {
|
||||
if (aArgc < 2) {
|
||||
aEnd = (int64_t)thisLength;
|
||||
}
|
||||
|
||||
ParseSize((int64_t)thisLength, aStart, aEnd);
|
||||
|
||||
// Create the new file
|
||||
*aBlob = CreateSlice((uint64_t)aStart, (uint64_t)(aEnd - aStart),
|
||||
aContentType).take();
|
||||
|
||||
// Create the new file
|
||||
nsCOMPtr<nsIDOMBlob> blob =
|
||||
CreateSlice((uint64_t)aStart, (uint64_t)(aEnd - aStart), aContentType);
|
||||
|
||||
blob.forget(aBlob);
|
||||
return *aBlob ? NS_OK : NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileBase::GetInternalStream(nsIInputStream **aStream)
|
||||
{
|
||||
// Must be overridden
|
||||
NS_NOTREACHED("Must override GetInternalStream");
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// DOMFileImplBase implementation
|
||||
|
||||
nsresult
|
||||
DOMFileImplBase::GetName(nsAString& aName)
|
||||
{
|
||||
NS_ASSERTION(mIsFile, "Should only be called on files");
|
||||
aName = mName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
DOMFileImplBase::GetPath(nsAString& aPath)
|
||||
{
|
||||
NS_ASSERTION(mIsFile, "Should only be called on files");
|
||||
aPath = mPath;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
DOMFileImplBase::GetLastModifiedDate(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aDate)
|
||||
{
|
||||
JS::Rooted<JSObject*> date(aCx, JS_NewDateObjectMsec(aCx, JS_Now() / PR_USEC_PER_MSEC));
|
||||
if (!date) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
aDate.setObject(*date);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
DOMFileImplBase::GetMozFullPath(nsAString &aFileName)
|
||||
{
|
||||
NS_ASSERTION(mIsFile, "Should only be called on files");
|
||||
|
||||
// It is unsafe to call IsCallerChrome on a non-main thread. If
|
||||
// you hit the following assertion you need to figure out some other way to
|
||||
// determine privileges and call GetMozFullPathInternal.
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
if (nsContentUtils::IsCallerChrome()) {
|
||||
return GetMozFullPathInternal(aFileName);
|
||||
}
|
||||
aFileName.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
DOMFileImplBase::GetMozFullPathInternal(nsAString& aFileName)
|
||||
{
|
||||
if (!mIsFile) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
aFileName.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
DOMFileImplBase::GetSize(uint64_t* aSize)
|
||||
{
|
||||
*aSize = mLength;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
DOMFileImplBase::GetType(nsAString& aType)
|
||||
{
|
||||
aType = mContentType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
DOMFileImplBase::GetMozLastModifiedDate(uint64_t* aLastModifiedDate)
|
||||
{
|
||||
NS_ASSERTION(mIsFile, "Should only be called on files");
|
||||
if (IsDateUnknown()) {
|
||||
mLastModificationDate = PR_Now();
|
||||
}
|
||||
*aLastModifiedDate = mLastModificationDate;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMBlob>
|
||||
DOMFileImplBase::CreateSlice(uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsresult
|
||||
DOMFileImplBase::GetInternalStream(nsIInputStream** aStream)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileBase::GetInternalUrl(nsIPrincipal* aPrincipal, nsAString& aURL)
|
||||
nsresult
|
||||
DOMFileImplBase::GetInternalUrl(nsIPrincipal* aPrincipal, nsAString& aURL)
|
||||
{
|
||||
NS_ENSURE_STATE(aPrincipal);
|
||||
|
||||
nsCString url;
|
||||
nsresult rv = nsBlobProtocolHandler::AddDataEntry(
|
||||
NS_LITERAL_CSTRING(BLOBURI_SCHEME),
|
||||
static_cast<nsIDOMBlob*>(this), aPrincipal, url);
|
||||
NS_LITERAL_CSTRING(BLOBURI_SCHEME), this, aPrincipal, url);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -288,8 +594,8 @@ nsDOMFileBase::GetInternalUrl(nsIPrincipal* aPrincipal, nsAString& aURL)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(int64_t)
|
||||
nsDOMFileBase::GetFileId()
|
||||
int64_t
|
||||
DOMFileImplBase::GetFileId()
|
||||
{
|
||||
int64_t id = -1;
|
||||
|
||||
|
@ -314,8 +620,8 @@ nsDOMFileBase::GetFileId()
|
|||
return id;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(void)
|
||||
nsDOMFileBase::AddFileInfo(indexedDB::FileInfo* aFileInfo)
|
||||
void
|
||||
DOMFileImplBase::AddFileInfo(indexedDB::FileInfo* aFileInfo)
|
||||
{
|
||||
if (indexedDB::IndexedDatabaseManager::IsClosed()) {
|
||||
NS_ERROR("Shouldn't be called after shutdown!");
|
||||
|
@ -333,8 +639,8 @@ nsDOMFileBase::AddFileInfo(indexedDB::FileInfo* aFileInfo)
|
|||
element->swap(fileInfo);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(indexedDB::FileInfo*)
|
||||
nsDOMFileBase::GetFileInfo(indexedDB::FileManager* aFileManager)
|
||||
indexedDB::FileInfo*
|
||||
DOMFileImplBase::GetFileInfo(indexedDB::FileManager* aFileManager)
|
||||
{
|
||||
if (indexedDB::IndexedDatabaseManager::IsClosed()) {
|
||||
NS_ERROR("Shouldn't be called after shutdown!");
|
||||
|
@ -365,11 +671,11 @@ nsDOMFileBase::GetFileInfo(indexedDB::FileManager* aFileManager)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileBase::GetSendInfo(nsIInputStream** aBody,
|
||||
uint64_t* aContentLength,
|
||||
nsACString& aContentType,
|
||||
nsACString& aCharset)
|
||||
nsresult
|
||||
DOMFileImplBase::GetSendInfo(nsIInputStream** aBody,
|
||||
uint64_t* aContentLength,
|
||||
nsACString& aContentType,
|
||||
nsACString& aCharset)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -392,15 +698,15 @@ nsDOMFileBase::GetSendInfo(nsIInputStream** aBody,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileBase::GetMutable(bool* aMutable)
|
||||
nsresult
|
||||
DOMFileImplBase::GetMutable(bool* aMutable) const
|
||||
{
|
||||
*aMutable = !mImmutable;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileBase::SetMutable(bool aMutable)
|
||||
nsresult
|
||||
DOMFileImplBase::SetMutable(bool aMutable)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -421,75 +727,57 @@ nsDOMFileBase::SetMutable(bool aMutable)
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
nsDOMFileBase::IsMemoryFile(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
NS_IMPL_ISUPPORTS0(DOMFileImplBase)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// nsDOMFile implementation
|
||||
// DOMFileCC implementation
|
||||
|
||||
DOMCI_DATA(File, nsDOMFile)
|
||||
DOMCI_DATA(Blob, nsDOMFile)
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(DOMFileCC)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsDOMFile)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMFile)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMBlob)
|
||||
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIDOMFile, mIsFile)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIXHRSendable)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIMutable)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_CONDITIONAL(File, mIsFile)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_CONDITIONAL(Blob, !mIsFile)
|
||||
NS_INTERFACE_MAP_END
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMFileCC)
|
||||
tmp->mImpl->Unlink();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
// Threadsafe when GetMutable() == false
|
||||
NS_IMPL_ADDREF(nsDOMFile)
|
||||
NS_IMPL_RELEASE(nsDOMFile)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// nsDOMFileCC implementation
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMFileCC)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_0(nsDOMFileCC)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMFileCC)
|
||||
// We don't have anything to traverse, but some of our subclasses do.
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMFileCC)
|
||||
tmp->mImpl->Traverse(cb);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMFileCC)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMFileCC)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMFile)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMBlob)
|
||||
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIDOMFile, mIsFile)
|
||||
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIDOMFile, IsFile())
|
||||
NS_INTERFACE_MAP_ENTRY(nsIXHRSendable)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIMutable)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_CONDITIONAL(File, mIsFile)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_CONDITIONAL(Blob, !mIsFile)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIJSNativeInitializer)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_CONDITIONAL(File, IsFile())
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_CONDITIONAL(Blob, !(IsFile()))
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMFileCC)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMFileCC)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMFileCC)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMFileCC)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// nsDOMFileFile implementation
|
||||
// DOMFileImplFile implementation
|
||||
|
||||
already_AddRefed<nsIDOMBlob>
|
||||
nsDOMFileFile::CreateSlice(uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
DOMFileImplFile::CreateSlice(uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
{
|
||||
nsCOMPtr<nsIDOMBlob> t = new nsDOMFileFile(this, aStart, aLength, aContentType);
|
||||
return t.forget();
|
||||
nsCOMPtr<nsIDOMBlob> blob =
|
||||
new DOMFile(new DOMFileImplFile(this, aStart, aLength, aContentType));
|
||||
return blob.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileFile::GetMozFullPathInternal(nsAString &aFilename)
|
||||
nsresult
|
||||
DOMFileImplFile::GetMozFullPathInternal(nsAString& aFilename)
|
||||
{
|
||||
NS_ASSERTION(mIsFile, "Should only be called on files");
|
||||
return mFile->GetPath(aFilename);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileFile::GetLastModifiedDate(JSContext* cx, JS::MutableHandle<JS::Value> aLastModifiedDate)
|
||||
nsresult
|
||||
DOMFileImplFile::GetLastModifiedDate(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aLastModifiedDate)
|
||||
{
|
||||
NS_ASSERTION(mIsFile, "Should only be called on files");
|
||||
|
||||
|
@ -502,20 +790,20 @@ nsDOMFileFile::GetLastModifiedDate(JSContext* cx, JS::MutableHandle<JS::Value> a
|
|||
msecs = mLastModificationDate;
|
||||
}
|
||||
|
||||
JSObject* date = JS_NewDateObjectMsec(cx, msecs);
|
||||
JSObject* date = JS_NewDateObjectMsec(aCx, msecs);
|
||||
if (date) {
|
||||
aLastModifiedDate.setObject(*date);
|
||||
}
|
||||
else {
|
||||
date = JS_NewDateObjectMsec(cx, JS_Now() / PR_USEC_PER_MSEC);
|
||||
date = JS_NewDateObjectMsec(aCx, JS_Now() / PR_USEC_PER_MSEC);
|
||||
aLastModifiedDate.setObject(*date);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileFile::GetSize(uint64_t *aFileSize)
|
||||
nsresult
|
||||
DOMFileImplFile::GetSize(uint64_t* aFileSize)
|
||||
{
|
||||
if (IsSizeUnknown()) {
|
||||
NS_ASSERTION(mWholeFile,
|
||||
|
@ -523,11 +811,11 @@ nsDOMFileFile::GetSize(uint64_t *aFileSize)
|
|||
int64_t fileSize;
|
||||
nsresult rv = mFile->GetFileSize(&fileSize);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
if (fileSize < 0) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
mLength = fileSize;
|
||||
}
|
||||
|
||||
|
@ -536,8 +824,8 @@ nsDOMFileFile::GetSize(uint64_t *aFileSize)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileFile::GetType(nsAString &aType)
|
||||
nsresult
|
||||
DOMFileImplFile::GetType(nsAString& aType)
|
||||
{
|
||||
if (mContentType.IsVoid()) {
|
||||
NS_ASSERTION(mWholeFile,
|
||||
|
@ -562,8 +850,8 @@ nsDOMFileFile::GetType(nsAString &aType)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileFile::GetMozLastModifiedDate(uint64_t* aLastModifiedDate)
|
||||
nsresult
|
||||
DOMFileImplFile::GetMozLastModifiedDate(uint64_t* aLastModifiedDate)
|
||||
{
|
||||
NS_ASSERTION(mIsFile, "Should only be called on files");
|
||||
if (IsDateUnknown()) {
|
||||
|
@ -581,8 +869,8 @@ const uint32_t sFileStreamFlags =
|
|||
nsIFileInputStream::REOPEN_ON_REWIND |
|
||||
nsIFileInputStream::DEFER_OPEN;
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileFile::GetInternalStream(nsIInputStream **aStream)
|
||||
nsresult
|
||||
DOMFileImplFile::GetInternalStream(nsIInputStream** aStream)
|
||||
{
|
||||
return mWholeFile ?
|
||||
NS_NewLocalFileInputStream(aStream, mFile, -1, -1, sFileStreamFlags) :
|
||||
|
@ -591,7 +879,7 @@ nsDOMFileFile::GetInternalStream(nsIInputStream **aStream)
|
|||
}
|
||||
|
||||
void
|
||||
nsDOMFileFile::SetPath(const nsAString& aPath)
|
||||
DOMFileImplFile::SetPath(const nsAString& aPath)
|
||||
{
|
||||
MOZ_ASSERT(aPath.IsEmpty() ||
|
||||
aPath[aPath.Length() - 1] == char16_t('/'),
|
||||
|
@ -600,19 +888,19 @@ nsDOMFileFile::SetPath(const nsAString& aPath)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// nsDOMMemoryFile implementation
|
||||
// DOMFileImplMemory implementation
|
||||
|
||||
already_AddRefed<nsIDOMBlob>
|
||||
nsDOMMemoryFile::CreateSlice(uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
DOMFileImplMemory::CreateSlice(uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
{
|
||||
nsCOMPtr<nsIDOMBlob> t =
|
||||
new nsDOMMemoryFile(this, aStart, aLength, aContentType);
|
||||
return t.forget();
|
||||
nsCOMPtr<nsIDOMBlob> blob =
|
||||
new DOMFile(new DOMFileImplMemory(this, aStart, aLength, aContentType));
|
||||
return blob.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMMemoryFile::GetInternalStream(nsIInputStream **aStream)
|
||||
nsresult
|
||||
DOMFileImplMemory::GetInternalStream(nsIInputStream** aStream)
|
||||
{
|
||||
if (mLength > INT32_MAX)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -620,27 +908,21 @@ nsDOMMemoryFile::GetInternalStream(nsIInputStream **aStream)
|
|||
return DataOwnerAdapter::Create(mDataOwner, mStart, mLength, aStream);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
nsDOMMemoryFile::IsMemoryFile(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */ StaticMutex
|
||||
nsDOMMemoryFile::DataOwner::sDataOwnerMutex;
|
||||
DOMFileImplMemory::DataOwner::sDataOwnerMutex;
|
||||
|
||||
/* static */ StaticAutoPtr<LinkedList<nsDOMMemoryFile::DataOwner> >
|
||||
nsDOMMemoryFile::DataOwner::sDataOwners;
|
||||
/* static */ StaticAutoPtr<LinkedList<DOMFileImplMemory::DataOwner>>
|
||||
DOMFileImplMemory::DataOwner::sDataOwners;
|
||||
|
||||
/* static */ bool
|
||||
nsDOMMemoryFile::DataOwner::sMemoryReporterRegistered;
|
||||
DOMFileImplMemory::DataOwner::sMemoryReporterRegistered = false;
|
||||
|
||||
MOZ_DEFINE_MALLOC_SIZE_OF(DOMMemoryFileDataOwnerMallocSizeOf)
|
||||
|
||||
class nsDOMMemoryFileDataOwnerMemoryReporter MOZ_FINAL
|
||||
class DOMFileImplMemoryDataOwnerMemoryReporter MOZ_FINAL
|
||||
: public nsIMemoryReporter
|
||||
{
|
||||
~nsDOMMemoryFileDataOwnerMemoryReporter() {}
|
||||
~DOMFileImplMemoryDataOwnerMemoryReporter() {}
|
||||
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
@ -648,7 +930,7 @@ public:
|
|||
NS_IMETHOD CollectReports(nsIMemoryReporterCallback *aCallback,
|
||||
nsISupports *aClosure, bool aAnonymize)
|
||||
{
|
||||
typedef nsDOMMemoryFile::DataOwner DataOwner;
|
||||
typedef DOMFileImplMemory::DataOwner DataOwner;
|
||||
|
||||
StaticMutexAutoLock lock(DataOwner::sDataOwnerMutex);
|
||||
|
||||
|
@ -713,21 +995,49 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsDOMMemoryFileDataOwnerMemoryReporter, nsIMemoryReporter)
|
||||
NS_IMPL_ISUPPORTS(DOMFileImplMemoryDataOwnerMemoryReporter, nsIMemoryReporter)
|
||||
|
||||
/* static */ void
|
||||
nsDOMMemoryFile::DataOwner::EnsureMemoryReporterRegistered()
|
||||
DOMFileImplMemory::DataOwner::EnsureMemoryReporterRegistered()
|
||||
{
|
||||
sDataOwnerMutex.AssertCurrentThreadOwns();
|
||||
if (sMemoryReporterRegistered) {
|
||||
return;
|
||||
}
|
||||
|
||||
RegisterStrongMemoryReporter(new nsDOMMemoryFileDataOwnerMemoryReporter());
|
||||
RegisterStrongMemoryReporter(new DOMFileImplMemoryDataOwnerMemoryReporter());
|
||||
|
||||
sMemoryReporterRegistered = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// DOMFileImplTemporaryFileBlob implementation
|
||||
|
||||
already_AddRefed<nsIDOMBlob>
|
||||
DOMFileImplTemporaryFileBlob::CreateSlice(uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
{
|
||||
if (aStart + aLength > mLength)
|
||||
return nullptr;
|
||||
|
||||
nsCOMPtr<nsIDOMBlob> blob =
|
||||
new DOMFile(new DOMFileImplTemporaryFileBlob(this, aStart + mStartPos,
|
||||
aLength, aContentType));
|
||||
return blob.forget();
|
||||
}
|
||||
|
||||
nsresult
|
||||
DOMFileImplTemporaryFileBlob::GetInternalStream(nsIInputStream** aStream)
|
||||
{
|
||||
nsCOMPtr<nsIInputStream> stream =
|
||||
new nsTemporaryFileInputStream(mFileDescOwner, mStartPos, mStartPos + mLength);
|
||||
stream.forget(aStream);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // dom namespace
|
||||
} // mozilla namespace
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// nsDOMFileList implementation
|
||||
|
||||
|
@ -745,7 +1055,7 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMFileList)
|
|||
JSObject*
|
||||
nsDOMFileList::WrapObject(JSContext *cx)
|
||||
{
|
||||
return FileListBinding::Wrap(cx, this);
|
||||
return mozilla::dom::FileListBinding::Wrap(cx, this);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -781,26 +1091,3 @@ nsDOMFileInternalUrlHolder::~nsDOMFileInternalUrlHolder() {
|
|||
nsBlobProtocolHandler::RemoveDataEntry(narrowUrl);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// nsDOMTemporaryFileBlob implementation
|
||||
already_AddRefed<nsIDOMBlob>
|
||||
nsDOMTemporaryFileBlob::CreateSlice(uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
{
|
||||
if (aStart + aLength > mLength)
|
||||
return nullptr;
|
||||
|
||||
nsCOMPtr<nsIDOMBlob> t =
|
||||
new nsDOMTemporaryFileBlob(this, aStart + mStartPos, aLength, aContentType);
|
||||
return t.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMTemporaryFileBlob::GetInternalStream(nsIInputStream **aStream)
|
||||
{
|
||||
nsCOMPtr<nsIInputStream> stream =
|
||||
new nsTemporaryFileInputStream(mFileDescOwner, mStartPos, mStartPos + mLength);
|
||||
stream.forget(aStream);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -883,6 +883,7 @@ GK_ATOM(perMille, "per-mille")
|
|||
GK_ATOM(percent, "percent")
|
||||
GK_ATOM(persist, "persist")
|
||||
GK_ATOM(phase, "phase")
|
||||
GK_ATOM(picture, "picture")
|
||||
GK_ATOM(ping, "ping")
|
||||
GK_ATOM(pinned,"pinned")
|
||||
GK_ATOM(placeholder, "placeholder")
|
||||
|
@ -2220,7 +2221,6 @@ GK_ATOM(menuitemradio, "menuitemradio")
|
|||
GK_ATOM(mixed, "mixed")
|
||||
GK_ATOM(multiline, "multiline")
|
||||
GK_ATOM(password, "password")
|
||||
GK_ATOM(picture, "picture")
|
||||
GK_ATOM(posinset, "posinset")
|
||||
GK_ATOM(presentation, "presentation")
|
||||
GK_ATOM(progressbar, "progressbar")
|
||||
|
|
|
@ -1171,7 +1171,17 @@ nsXMLHttpRequest::GetStatusText(nsCString& aStatusText)
|
|||
return;
|
||||
}
|
||||
|
||||
httpChannel->GetResponseStatusText(aStatusText);
|
||||
|
||||
// Check the current XHR state to see if it is valid to obtain the statusText
|
||||
// value. This check is to prevent the status text for redirects from being
|
||||
// available before all the redirects have been followed and HTTP headers have
|
||||
// been received.
|
||||
uint16_t readyState;
|
||||
GetReadyState(&readyState);
|
||||
if (readyState != OPENED && readyState != UNSENT) {
|
||||
httpChannel->GetResponseStatusText(aStatusText);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -1864,7 +1874,9 @@ bool nsXMLHttpRequest::CreateDOMFile(nsIRequest *request)
|
|||
mChannel->GetContentType(contentType);
|
||||
|
||||
mDOMFile =
|
||||
new nsDOMFileFile(file, EmptyString(), NS_ConvertASCIItoUTF16(contentType));
|
||||
DOMFile::CreateFromFile(file, EmptyString(),
|
||||
NS_ConvertASCIItoUTF16(contentType));
|
||||
|
||||
mBlobSet = nullptr;
|
||||
NS_ASSERTION(mResponseBody.IsEmpty(), "mResponseBody should be empty");
|
||||
return true;
|
||||
|
|
|
@ -52,6 +52,10 @@ class nsIJSID;
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
namespace dom {
|
||||
class DOMFile;
|
||||
}
|
||||
|
||||
// A helper for building up an ArrayBuffer object's data
|
||||
// before creating the ArrayBuffer itself. Will do doubling
|
||||
// based reallocation, up to an optional maximum growth given.
|
||||
|
@ -667,7 +671,7 @@ protected:
|
|||
nsCOMPtr<nsIDOMBlob> mResponseBlob;
|
||||
// Non-null only when we are able to get a os-file representation of the
|
||||
// response, i.e. when loading from a file.
|
||||
nsRefPtr<nsDOMFile> mDOMFile;
|
||||
nsRefPtr<mozilla::dom::DOMFile> mDOMFile;
|
||||
// We stream data to mBlobSet when response type is "blob" or "moz-blob"
|
||||
// and mDOMFile is null.
|
||||
nsAutoPtr<BlobSet> mBlobSet;
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
// Function to indicate HTTP 200 OK after redirect from file_bug1011748_redirect.sjs
|
||||
function handleRequest(request, response) {
|
||||
response.setStatusLine(null, 200, "OK");
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
// SJS handler to redirect the XMLHttpRequest object to file_bug1011748_OK.sjs
|
||||
function handleRequest(request, response) {
|
||||
response.setStatusLine(null, 302, "Moved Temporarily");
|
||||
response.setHeader("Location", "file_bug1011748_OK.sjs", false);
|
||||
}
|
|
@ -646,3 +646,6 @@ support-files = bug444546.sjs
|
|||
[test_bug503473.html]
|
||||
disabled = Disabled due to making the harness time out
|
||||
support-files = file_bug503473-frame.sjs
|
||||
[test_bug1011748.html]
|
||||
skip-if = buildapp == 'b2g' || e10s
|
||||
support-files = file_bug1011748_redirect.sjs file_bug1011748_OK.sjs
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1011748
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1011748</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 1011748 **/
|
||||
"use strict";
|
||||
|
||||
var observer = {
|
||||
observe: function (aSubject, aTopic, aData) {
|
||||
try {
|
||||
var channel = aSubject.QueryInterface(SpecialPowers.Ci.nsIHttpChannel);
|
||||
channel.getResponseHeader("Location");
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
statusTexts.push(xhr.statusText);
|
||||
}
|
||||
};
|
||||
|
||||
var statusTexts = [];
|
||||
SpecialPowers.addObserver(observer, "http-on-examine-response", false);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.addEventListener("load", function() {
|
||||
statusTexts.push(this.statusText);
|
||||
SpecialPowers.removeObserver(observer, "http-on-examine-response");
|
||||
is(statusTexts[0], "", "Empty statusText value for HTTP 302");
|
||||
is(statusTexts[1], "OK", "OK statusText value for the redirect.");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
xhr.open("GET", "file_bug1011748_redirect.sjs", true);
|
||||
xhr.send();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1011748">Mozilla Bug 1011748</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -118,6 +118,7 @@ static ImageCache* gImageCache = nullptr;
|
|||
|
||||
class CanvasImageCacheShutdownObserver MOZ_FINAL : public nsIObserver
|
||||
{
|
||||
~CanvasImageCacheShutdownObserver() {}
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
|
|
@ -24,6 +24,7 @@ class SVGMatrix;
|
|||
|
||||
class CanvasPattern MOZ_FINAL : public nsWrapperCache
|
||||
{
|
||||
~CanvasPattern() {}
|
||||
public:
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(CanvasPattern)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(CanvasPattern)
|
||||
|
|
|
@ -145,6 +145,7 @@ static int64_t gCanvasAzureMemoryUsed = 0;
|
|||
// underlying surface implementations. See bug 655638 for details.
|
||||
class Canvas2dPixelsReporter MOZ_FINAL : public nsIMemoryReporter
|
||||
{
|
||||
~Canvas2dPixelsReporter() {}
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
|
|
@ -93,9 +93,9 @@ public:
|
|||
// passed directly and we can't drop the only ref to have a raw pointer.
|
||||
CanvasPath(nsISupports* aParent,
|
||||
TemporaryRef<gfx::PathBuilder> aPathBuilder);
|
||||
virtual ~CanvasPath() {}
|
||||
|
||||
private:
|
||||
virtual ~CanvasPath() {}
|
||||
|
||||
nsCOMPtr<nsISupports> mParent;
|
||||
static gfx::Float ToFloat(double aValue) { return gfx::Float(aValue); }
|
||||
|
@ -119,9 +119,10 @@ class CanvasRenderingContext2D :
|
|||
typedef HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement
|
||||
HTMLImageOrCanvasOrVideoElement;
|
||||
|
||||
virtual ~CanvasRenderingContext2D();
|
||||
|
||||
public:
|
||||
CanvasRenderingContext2D();
|
||||
virtual ~CanvasRenderingContext2D();
|
||||
|
||||
virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE;
|
||||
|
||||
|
|
|
@ -23,6 +23,12 @@ namespace dom {
|
|||
|
||||
class ImageData MOZ_FINAL : public nsISupports
|
||||
{
|
||||
~ImageData()
|
||||
{
|
||||
MOZ_COUNT_DTOR(ImageData);
|
||||
DropData();
|
||||
}
|
||||
|
||||
public:
|
||||
ImageData(uint32_t aWidth, uint32_t aHeight, JSObject& aData)
|
||||
: mWidth(aWidth)
|
||||
|
@ -33,12 +39,6 @@ public:
|
|||
HoldData();
|
||||
}
|
||||
|
||||
~ImageData()
|
||||
{
|
||||
MOZ_COUNT_DTOR(ImageData);
|
||||
DropData();
|
||||
}
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ImageData)
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace dom {
|
|||
|
||||
class EncodingCompleteEvent : public nsRunnable
|
||||
{
|
||||
virtual ~EncodingCompleteEvent() {}
|
||||
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
||||
|
@ -30,7 +32,6 @@ public:
|
|||
, mCallback(&aCallback)
|
||||
, mFailed(false)
|
||||
{}
|
||||
virtual ~EncodingCompleteEvent() {}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
|
@ -39,8 +40,8 @@ public:
|
|||
mozilla::ErrorResult rv;
|
||||
|
||||
if (!mFailed) {
|
||||
nsRefPtr<nsDOMMemoryFile> blob =
|
||||
new nsDOMMemoryFile(mImgData, mImgSize, mType);
|
||||
nsRefPtr<DOMFile> blob =
|
||||
DOMFile::CreateMemoryFile(mImgData, mImgSize, mType);
|
||||
|
||||
if (mScriptContext) {
|
||||
JSContext* jsContext = mScriptContext->GetNativeContext();
|
||||
|
@ -89,6 +90,8 @@ NS_IMPL_ISUPPORTS(EncodingCompleteEvent, nsIRunnable);
|
|||
|
||||
class EncodingRunnable : public nsRunnable
|
||||
{
|
||||
virtual ~EncodingRunnable() {}
|
||||
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
||||
|
@ -109,7 +112,6 @@ public:
|
|||
, mSize(aSize)
|
||||
, mUsingCustomOptions(aUsingCustomOptions)
|
||||
{}
|
||||
virtual ~EncodingRunnable() {}
|
||||
|
||||
nsresult ProcessImageData(uint64_t* aImgSize, void** aImgData)
|
||||
{
|
||||
|
|
|
@ -26,8 +26,6 @@ class WebGLBuffer MOZ_FINAL
|
|||
public:
|
||||
WebGLBuffer(WebGLContext *context);
|
||||
|
||||
~WebGLBuffer();
|
||||
|
||||
void Delete();
|
||||
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
||||
|
@ -61,6 +59,7 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLBuffer)
|
||||
|
||||
protected:
|
||||
~WebGLBuffer();
|
||||
|
||||
GLuint mGLName;
|
||||
bool mHasEverBeenBound;
|
||||
|
|
|
@ -162,7 +162,6 @@ class WebGLContext :
|
|||
|
||||
public:
|
||||
WebGLContext();
|
||||
virtual ~WebGLContext();
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
|
||||
|
@ -882,6 +881,8 @@ private:
|
|||
// -----------------------------------------------------------------------------
|
||||
// PROTECTED
|
||||
protected:
|
||||
virtual ~WebGLContext();
|
||||
|
||||
void SetFakeBlackStatus(WebGLContextFakeBlackStatus x) {
|
||||
mFakeBlackStatus = x;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ class WebGLExtensionBase
|
|||
{
|
||||
public:
|
||||
WebGLExtensionBase(WebGLContext*);
|
||||
virtual ~WebGLExtensionBase();
|
||||
|
||||
WebGLContext *GetParentObject() const {
|
||||
return Context();
|
||||
|
@ -36,6 +35,8 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLExtensionBase)
|
||||
|
||||
protected:
|
||||
virtual ~WebGLExtensionBase();
|
||||
|
||||
bool mIsLost;
|
||||
};
|
||||
|
||||
|
|
|
@ -30,10 +30,6 @@ class WebGLFramebuffer MOZ_FINAL
|
|||
public:
|
||||
WebGLFramebuffer(WebGLContext* context);
|
||||
|
||||
~WebGLFramebuffer() {
|
||||
DeleteOnce();
|
||||
}
|
||||
|
||||
struct Attachment
|
||||
{
|
||||
// deleting a texture or renderbuffer immediately detaches it
|
||||
|
@ -181,6 +177,10 @@ public:
|
|||
void NotifyAttachableChanged() const;
|
||||
|
||||
private:
|
||||
~WebGLFramebuffer() {
|
||||
DeleteOnce();
|
||||
}
|
||||
|
||||
mutable GLenum mStatus;
|
||||
|
||||
GLuint mGLName;
|
||||
|
|
|
@ -25,7 +25,6 @@ class WebGLMemoryTracker : public nsIMemoryReporter
|
|||
NS_DECL_NSIMEMORYREPORTER
|
||||
|
||||
WebGLMemoryTracker();
|
||||
virtual ~WebGLMemoryTracker();
|
||||
static StaticRefPtr<WebGLMemoryTracker> sUniqueInstance;
|
||||
|
||||
// Here we store plain pointers, not RefPtrs: we don't want the
|
||||
|
@ -57,6 +56,8 @@ class WebGLMemoryTracker : public nsIMemoryReporter
|
|||
}
|
||||
|
||||
private:
|
||||
virtual ~WebGLMemoryTracker();
|
||||
|
||||
static int64_t GetTextureMemoryUsed() {
|
||||
const ContextsArrayType & contexts = Contexts();
|
||||
int64_t result = 0;
|
||||
|
|
|
@ -33,10 +33,6 @@ class WebGLProgram MOZ_FINAL
|
|||
public:
|
||||
WebGLProgram(WebGLContext *context);
|
||||
|
||||
~WebGLProgram() {
|
||||
DeleteOnce();
|
||||
}
|
||||
|
||||
void Delete();
|
||||
|
||||
void DetachShaders() {
|
||||
|
@ -115,6 +111,9 @@ public:
|
|||
std::map<GLint, nsCString> mActiveAttribMap;
|
||||
|
||||
protected:
|
||||
~WebGLProgram() {
|
||||
DeleteOnce();
|
||||
}
|
||||
|
||||
GLuint mGLName;
|
||||
bool mLinkStatus;
|
||||
|
|
|
@ -25,15 +25,10 @@ class WebGLQuery MOZ_FINAL
|
|||
public:
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// CONSTRUCTOR & DESTRUCTOR
|
||||
// CONSTRUCTOR
|
||||
|
||||
WebGLQuery(WebGLContext *context);
|
||||
|
||||
~WebGLQuery() {
|
||||
DeleteOnce();
|
||||
};
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// MEMBER FUNCTIONS
|
||||
|
||||
|
@ -67,6 +62,9 @@ public:
|
|||
// -----------------------------------------------------------------------------
|
||||
// PRIVATE
|
||||
private:
|
||||
~WebGLQuery() {
|
||||
DeleteOnce();
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// MEMBERS
|
||||
|
|
|
@ -26,10 +26,6 @@ class WebGLRenderbuffer MOZ_FINAL
|
|||
public:
|
||||
WebGLRenderbuffer(WebGLContext *context);
|
||||
|
||||
~WebGLRenderbuffer() {
|
||||
DeleteOnce();
|
||||
}
|
||||
|
||||
void Delete();
|
||||
|
||||
bool HasEverBeenBound() { return mHasEverBeenBound; }
|
||||
|
@ -67,6 +63,10 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLRenderbuffer)
|
||||
|
||||
protected:
|
||||
~WebGLRenderbuffer() {
|
||||
DeleteOnce();
|
||||
}
|
||||
|
||||
GLuint mPrimaryRB;
|
||||
GLuint mSecondaryRB;
|
||||
GLenum mInternalFormat;
|
||||
|
|
|
@ -35,10 +35,6 @@ class WebGLShader MOZ_FINAL
|
|||
public:
|
||||
WebGLShader(WebGLContext *context, GLenum stype);
|
||||
|
||||
~WebGLShader() {
|
||||
DeleteOnce();
|
||||
}
|
||||
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
||||
|
||||
GLuint GLName() { return mGLName; }
|
||||
|
@ -84,6 +80,9 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLShader)
|
||||
|
||||
protected:
|
||||
~WebGLShader() {
|
||||
DeleteOnce();
|
||||
}
|
||||
|
||||
GLuint mGLName;
|
||||
GLenum mType;
|
||||
|
|
|
@ -35,10 +35,6 @@ class WebGLTexture MOZ_FINAL
|
|||
public:
|
||||
WebGLTexture(WebGLContext *context);
|
||||
|
||||
~WebGLTexture() {
|
||||
DeleteOnce();
|
||||
}
|
||||
|
||||
void Delete();
|
||||
|
||||
bool HasEverBeenBound() const { return mHasEverBeenBound; }
|
||||
|
@ -56,6 +52,9 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLTexture)
|
||||
|
||||
protected:
|
||||
~WebGLTexture() {
|
||||
DeleteOnce();
|
||||
}
|
||||
|
||||
friend class WebGLContext;
|
||||
friend class WebGLFramebuffer;
|
||||
|
|
|
@ -19,9 +19,6 @@ class WebGLUniformLocation MOZ_FINAL
|
|||
public:
|
||||
WebGLUniformLocation(WebGLContext *context, WebGLProgram *program, GLint location, const WebGLUniformInfo& info);
|
||||
|
||||
~WebGLUniformLocation() {
|
||||
}
|
||||
|
||||
// needed for certain helper functions like ValidateObject.
|
||||
// WebGLUniformLocation's can't be 'Deleted' in the WebGL sense.
|
||||
bool IsDeleted() const { return false; }
|
||||
|
@ -39,6 +36,9 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(WebGLUniformLocation)
|
||||
|
||||
protected:
|
||||
~WebGLUniformLocation() {
|
||||
}
|
||||
|
||||
// nsRefPtr, not WebGLRefPtr, so that we don't prevent the program from being explicitly deleted.
|
||||
// we just want to avoid having a dangling pointer.
|
||||
nsRefPtr<WebGLProgram> mProgram;
|
||||
|
|
|
@ -614,8 +614,9 @@ HTMLCanvasElement::MozGetAsFileImpl(const nsAString& aName,
|
|||
}
|
||||
|
||||
// The DOMFile takes ownership of the buffer
|
||||
nsRefPtr<nsDOMMemoryFile> file =
|
||||
new nsDOMMemoryFile(imgData, (uint32_t)imgSize, aName, type, PR_Now());
|
||||
nsRefPtr<DOMFile> file =
|
||||
DOMFile::CreateMemoryFile(imgData, (uint32_t)imgSize, aName, type,
|
||||
PR_Now());
|
||||
|
||||
file.forget(aResult);
|
||||
return NS_OK;
|
||||
|
|
|
@ -374,7 +374,7 @@ public:
|
|||
if (!mNextFile) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsRefPtr<nsDOMFileFile> domFile = new nsDOMFileFile(mNextFile);
|
||||
nsRefPtr<DOMFile> domFile = DOMFile::CreateFromFile(mNextFile);
|
||||
nsCString relDescriptor;
|
||||
nsresult rv =
|
||||
mNextFile->GetRelativeDescriptor(mTopDirsParent, relDescriptor);
|
||||
|
@ -387,7 +387,10 @@ public:
|
|||
MOZ_ASSERT(length >= 0);
|
||||
if (length > 0) {
|
||||
// Note that we leave the trailing "/" on the path.
|
||||
domFile->SetPath(Substring(path, 0, uint32_t(length)));
|
||||
DOMFileImplFile* fileImpl =
|
||||
static_cast<DOMFileImplFile*>(domFile->Impl());
|
||||
MOZ_ASSERT(fileImpl);
|
||||
fileImpl->SetPath(Substring(path, 0, uint32_t(length)));
|
||||
}
|
||||
*aResult = domFile.forget().downcast<nsIDOMFile>().take();
|
||||
LookupAndCacheNext();
|
||||
|
@ -2318,7 +2321,7 @@ HTMLInputElement::MozSetFileNameArray(const Sequence< nsString >& aFileNames)
|
|||
}
|
||||
|
||||
if (file) {
|
||||
nsCOMPtr<nsIDOMFile> domFile = new nsDOMFileFile(file);
|
||||
nsCOMPtr<nsIDOMFile> domFile = DOMFile::CreateFromFile(file);
|
||||
files.AppendElement(domFile);
|
||||
} else {
|
||||
continue; // Not much we can do if the file doesn't exist
|
||||
|
|
|
@ -177,7 +177,7 @@ LOCAL_INCLUDES += [
|
|||
'/dom/xbl',
|
||||
'/editor/libeditor/base',
|
||||
'/editor/libeditor/text',
|
||||
'/editor/txmgr/src',
|
||||
'/editor/txmgr',
|
||||
'/layout/forms',
|
||||
'/layout/generic',
|
||||
'/layout/style',
|
||||
|
|
|
@ -114,15 +114,13 @@ DownmixAndInterleave(const nsTArray<const void*>& aChannelData,
|
|||
aDuration, aVolume, aOutputChannels, aOutput);
|
||||
}
|
||||
|
||||
void AudioSegment::ResampleChunks(SpeexResamplerState* aResampler)
|
||||
void AudioSegment::ResampleChunks(SpeexResamplerState* aResampler, uint32_t aInRate, uint32_t aOutRate)
|
||||
{
|
||||
uint32_t inRate, outRate;
|
||||
|
||||
if (mChunks.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
speex_resampler_get_rate(aResampler, &inRate, &outRate);
|
||||
MOZ_ASSERT(aResampler || IsNull(), "We can only be here without a resampler if this segment is null.");
|
||||
|
||||
AudioSampleFormat format = AUDIO_FORMAT_SILENCE;
|
||||
for (ChunkIterator ci(*this); !ci.IsEnded(); ci.Next()) {
|
||||
|
@ -137,10 +135,10 @@ void AudioSegment::ResampleChunks(SpeexResamplerState* aResampler)
|
|||
// the chunks duration.
|
||||
case AUDIO_FORMAT_SILENCE:
|
||||
case AUDIO_FORMAT_FLOAT32:
|
||||
Resample<float>(aResampler, inRate, outRate);
|
||||
Resample<float>(aResampler, aInRate, aOutRate);
|
||||
break;
|
||||
case AUDIO_FORMAT_S16:
|
||||
Resample<int16_t>(aResampler, inRate, outRate);
|
||||
Resample<int16_t>(aResampler, aInRate, aOutRate);
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT(false);
|
||||
|
|
|
@ -225,7 +225,9 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void ResampleChunks(SpeexResamplerState* aResampler);
|
||||
void ResampleChunks(SpeexResamplerState* aResampler,
|
||||
uint32_t aInRate,
|
||||
uint32_t aOutRate);
|
||||
|
||||
void AppendFrames(already_AddRefed<ThreadSharedObject> aBuffer,
|
||||
const nsTArray<const float*>& aChannelData,
|
||||
|
@ -287,6 +289,15 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool IsNull() {
|
||||
for (ChunkIterator ci(*this); !ci.IsEnded(); ci.Next()) {
|
||||
if (!ci->IsNull()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static Type StaticType() { return AUDIO; }
|
||||
|
||||
virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE
|
||||
|
|
|
@ -46,7 +46,8 @@ EncodedBufferCache::ExtractBlob(const nsAString &aContentType)
|
|||
nsCOMPtr<nsIDOMBlob> blob;
|
||||
if (mTempFileEnabled) {
|
||||
// generate new temporary file to write
|
||||
blob = new nsDOMTemporaryFileBlob(mFD, 0, mDataSize, aContentType);
|
||||
blob = dom::DOMFile::CreateTemporaryFileBlob(mFD, 0, mDataSize,
|
||||
aContentType);
|
||||
// fallback to memory blob
|
||||
mTempFileEnabled = false;
|
||||
mDataSize = 0;
|
||||
|
@ -61,8 +62,7 @@ EncodedBufferCache::ExtractBlob(const nsAString &aContentType)
|
|||
mEncodedBuffers.ElementAt(i).Length());
|
||||
offset += mEncodedBuffers.ElementAt(i).Length();
|
||||
}
|
||||
blob = new nsDOMMemoryFile(blobData, mDataSize,
|
||||
aContentType);
|
||||
blob = dom::DOMFile::CreateMemoryFile(blobData, mDataSize, aContentType);
|
||||
mEncodedBuffers.Clear();
|
||||
} else
|
||||
return nullptr;
|
||||
|
|
|
@ -2296,7 +2296,7 @@ SourceMediaStream::ResampleAudioToGraphSampleRate(TrackData* aTrackData, MediaSe
|
|||
#endif
|
||||
}
|
||||
}
|
||||
segment->ResampleChunks(aTrackData->mResampler);
|
||||
segment->ResampleChunks(aTrackData->mResampler, aTrackData->mInputRate, GraphImpl()->AudioSampleRate());
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<html class="reftest-wait">
|
||||
<audio id="testAudio" controls></audio>
|
||||
<script type="text/javascript">
|
||||
navigator.mozGetUserMedia({audio: true}, function(stream) {
|
||||
stream.getAudioTracks()[0].enabled = false;
|
||||
var testAudio = document.getElementById('testAudio');
|
||||
// Wait some time for good measure
|
||||
var eventReceived = 0;
|
||||
testAudio.addEventListener("timeupdate", function() {
|
||||
if (++eventReceived == 3) {
|
||||
document.querySelector("html").className = "";
|
||||
}
|
||||
})
|
||||
testAudio.mozSrcObject = stream;
|
||||
testAudio.play();
|
||||
}, function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
</script>
|
||||
|
||||
</html>
|
|
@ -72,3 +72,4 @@ skip-if(B2G) load oscillator-ended-1.html # intermittent B2G timeouts, bug 92033
|
|||
skip-if(B2G) load oscillator-ended-2.html # intermittent B2G timeouts, bug 920338
|
||||
load 1015662.html
|
||||
include ../../mediasource/test/crashtests/crashtests.list
|
||||
test-pref(media.navigator.permission.disabled,true) load 1028458.html
|
||||
|
|
|
@ -208,7 +208,7 @@ MediaEngineDefaultVideoSource::Snapshot(uint32_t aDuration, nsIDOMFile** aFile)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMFile> domFile = new nsDOMFileFile(localFile);
|
||||
nsCOMPtr<nsIDOMFile> domFile = dom::DOMFile::CreateFromFile(localFile);
|
||||
domFile.forget(aFile);
|
||||
return NS_OK;
|
||||
#endif
|
||||
|
|
|
@ -219,7 +219,7 @@ private:
|
|||
mozilla::ReentrantMonitor mCallbackMonitor; // Monitor for camera callback handling
|
||||
// This is only modified on MainThread (AllocImpl and DeallocImpl)
|
||||
nsRefPtr<ICameraControl> mCameraControl;
|
||||
nsRefPtr<nsIDOMFile> mLastCapture;
|
||||
nsCOMPtr<nsIDOMFile> mLastCapture;
|
||||
|
||||
// These are protected by mMonitor below
|
||||
int mRotation;
|
||||
|
|
|
@ -831,10 +831,9 @@ void
|
|||
MediaEngineWebRTCVideoSource::OnTakePictureComplete(uint8_t* aData, uint32_t aLength, const nsAString& aMimeType)
|
||||
{
|
||||
ReentrantMonitorAutoEnter sync(mCallbackMonitor);
|
||||
mLastCapture =
|
||||
static_cast<nsIDOMFile*>(new nsDOMMemoryFile(static_cast<void*>(aData),
|
||||
static_cast<uint64_t>(aLength),
|
||||
aMimeType));
|
||||
mLastCapture = dom::DOMFile::CreateMemoryFile(static_cast<void*>(aData),
|
||||
static_cast<uint64_t>(aLength),
|
||||
aMimeType);
|
||||
mCallbackMonitor.Notify();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
class gfxContext;
|
||||
class nsSVGPathDataParser; // IWYU pragma: keep
|
||||
|
||||
struct gfxMatrix;
|
||||
struct nsSVGMark;
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
class nsSVGElement;
|
||||
|
||||
struct gfxMatrix;
|
||||
class gfxMatrix;
|
||||
|
||||
#define MOZ_SVG_LIST_INDEX_BIT_COUNT 31 // supports > 2 billion list items
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ class Matrix;
|
|||
|
||||
}
|
||||
|
||||
struct gfxMatrix;
|
||||
class gfxMatrix;
|
||||
struct nsSVGEnumMapping;
|
||||
|
||||
typedef nsStyledElementNotElementCSSInlineStyle nsSVGElementBase;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "mozilla/gfx/2D.h"
|
||||
#include "SVGGraphicsElement.h"
|
||||
|
||||
struct gfxMatrix;
|
||||
class gfxMatrix;
|
||||
|
||||
struct nsSVGMark {
|
||||
enum Type {
|
||||
|
|
|
@ -439,7 +439,11 @@ WebappsApplication.prototype = {
|
|||
},
|
||||
|
||||
get downloadError() {
|
||||
return new this._window.DOMError(this._downloadError || '');
|
||||
// Only return DOMError when we have an error.
|
||||
if (!this._downloadError) {
|
||||
return null;
|
||||
}
|
||||
return new this._window.DOMError(this._downloadError);
|
||||
},
|
||||
|
||||
download: function() {
|
||||
|
@ -593,7 +597,8 @@ WebappsApplication.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
if (aMsg.error) {
|
||||
// Intentional use of 'in' so we unset the error if this is explicitly null.
|
||||
if ('error' in aMsg) {
|
||||
this._downloadError = aMsg.error;
|
||||
}
|
||||
|
||||
|
@ -648,6 +653,12 @@ WebappsApplication.prototype = {
|
|||
}
|
||||
|
||||
msg.eventType.forEach((aEventType) => {
|
||||
// If we are in a successful state clear any past errors.
|
||||
if (aEventType === 'downloadapplied' ||
|
||||
aEventType === 'downloadsuccess') {
|
||||
this._downloadError = null;
|
||||
}
|
||||
|
||||
if ("_on" + aEventType in this) {
|
||||
this._fireEvent(aEventType);
|
||||
} else {
|
||||
|
|
|
@ -1587,6 +1587,8 @@ this.DOMApplicationRegistry = {
|
|||
aApp.progress = 0;
|
||||
DOMApplicationRegistry._saveApps().then(() => {
|
||||
DOMApplicationRegistry.broadcastMessage("Webapps:UpdateState", {
|
||||
// Clear any previous errors.
|
||||
error: null,
|
||||
app: {
|
||||
downloading: true,
|
||||
installState: aApp.installState,
|
||||
|
@ -2782,6 +2784,8 @@ this.DOMApplicationRegistry = {
|
|||
// retrying a past download.
|
||||
yield DOMApplicationRegistry._saveApps();
|
||||
DOMApplicationRegistry.broadcastMessage("Webapps:UpdateState", {
|
||||
// Clear any previous download errors.
|
||||
error: null,
|
||||
app: oldApp,
|
||||
manifestURL: aNewApp.manifestURL
|
||||
});
|
||||
|
|
|
@ -84,11 +84,11 @@ ArchiveZipItem::File(ArchiveReader* aArchiveReader)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return new ArchiveZipFile(filename,
|
||||
NS_ConvertUTF8toUTF16(GetType()),
|
||||
StrToInt32(mCentralStruct.orglen),
|
||||
mCentralStruct,
|
||||
aArchiveReader);
|
||||
return new DOMFileCC(
|
||||
new ArchiveZipFileImpl(filename,
|
||||
NS_ConvertUTF8toUTF16(GetType()),
|
||||
StrToInt32(mCentralStruct.orglen),
|
||||
mCentralStruct, aArchiveReader));
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
|
|
@ -351,10 +351,10 @@ ArchiveInputStream::SetEOF()
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// ArchiveZipFile
|
||||
// ArchiveZipFileImpl
|
||||
|
||||
NS_IMETHODIMP
|
||||
ArchiveZipFile::GetInternalStream(nsIInputStream** aStream)
|
||||
nsresult
|
||||
ArchiveZipFileImpl::GetInternalStream(nsIInputStream** aStream)
|
||||
{
|
||||
if (mLength > INT32_MAX) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -382,30 +382,28 @@ ArchiveZipFile::GetInternalStream(nsIInputStream** aStream)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMBlob>
|
||||
ArchiveZipFile::CreateSlice(uint64_t aStart,
|
||||
uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
void
|
||||
ArchiveZipFileImpl::Unlink()
|
||||
{
|
||||
nsCOMPtr<nsIDOMBlob> t = new ArchiveZipFile(mFilename,
|
||||
mContentType,
|
||||
aStart,
|
||||
mLength,
|
||||
mCentral,
|
||||
mArchiveReader);
|
||||
return t.forget();
|
||||
ArchiveZipFileImpl* tmp = this;
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mArchiveReader);
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(ArchiveZipFile, nsDOMFileCC,
|
||||
mArchiveReader)
|
||||
void
|
||||
ArchiveZipFileImpl::Traverse(nsCycleCollectionTraversalCallback &cb)
|
||||
{
|
||||
ArchiveZipFileImpl* tmp = this;
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mArchiveReader);
|
||||
}
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ArchiveZipFile)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMFile)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMBlob)
|
||||
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIDOMFile, mIsFile)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIXHRSendable)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIMutable)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMFileCC)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(ArchiveZipFile, nsDOMFileCC)
|
||||
NS_IMPL_RELEASE_INHERITED(ArchiveZipFile, nsDOMFileCC)
|
||||
already_AddRefed<nsIDOMBlob>
|
||||
ArchiveZipFileImpl::CreateSlice(uint64_t aStart,
|
||||
uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
{
|
||||
nsCOMPtr<nsIDOMBlob> t =
|
||||
new DOMFileCC(new ArchiveZipFileImpl(mFilename, mContentType,
|
||||
aStart, mLength, mCentral,
|
||||
mArchiveReader));
|
||||
return t.forget();
|
||||
}
|
||||
|
|
|
@ -18,50 +18,50 @@
|
|||
BEGIN_ARCHIVEREADER_NAMESPACE
|
||||
|
||||
/**
|
||||
* ZipFile to DOMFileCC
|
||||
* ArchiveZipFileImpl to DOMFileImpl
|
||||
*/
|
||||
class ArchiveZipFile : public nsDOMFileCC
|
||||
class ArchiveZipFileImpl : public DOMFileImplBase
|
||||
{
|
||||
public:
|
||||
ArchiveZipFile(const nsAString& aName,
|
||||
const nsAString& aContentType,
|
||||
uint64_t aLength,
|
||||
ZipCentral& aCentral,
|
||||
ArchiveReader* aReader)
|
||||
: nsDOMFileCC(aName, aContentType, aLength),
|
||||
ArchiveZipFileImpl(const nsAString& aName,
|
||||
const nsAString& aContentType,
|
||||
uint64_t aLength,
|
||||
ZipCentral& aCentral,
|
||||
ArchiveReader* aReader)
|
||||
: DOMFileImplBase(aName, aContentType, aLength),
|
||||
mCentral(aCentral),
|
||||
mArchiveReader(aReader),
|
||||
mFilename(aName)
|
||||
{
|
||||
NS_ASSERTION(mArchiveReader, "must have a reader");
|
||||
MOZ_COUNT_CTOR(ArchiveZipFile);
|
||||
MOZ_COUNT_CTOR(ArchiveZipFileImpl);
|
||||
}
|
||||
|
||||
ArchiveZipFile(const nsAString& aName,
|
||||
const nsAString& aContentType,
|
||||
uint64_t aStart,
|
||||
uint64_t aLength,
|
||||
ZipCentral& aCentral,
|
||||
ArchiveReader* aReader)
|
||||
: nsDOMFileCC(aContentType, aStart, aLength),
|
||||
ArchiveZipFileImpl(const nsAString& aName,
|
||||
const nsAString& aContentType,
|
||||
uint64_t aStart,
|
||||
uint64_t aLength,
|
||||
ZipCentral& aCentral,
|
||||
ArchiveReader* aReader)
|
||||
: DOMFileImplBase(aContentType, aStart, aLength),
|
||||
mCentral(aCentral),
|
||||
mArchiveReader(aReader),
|
||||
mFilename(aName)
|
||||
{
|
||||
NS_ASSERTION(mArchiveReader, "must have a reader");
|
||||
MOZ_COUNT_CTOR(ArchiveZipFile);
|
||||
MOZ_COUNT_CTOR(ArchiveZipFileImpl);
|
||||
}
|
||||
|
||||
virtual ~ArchiveZipFile()
|
||||
virtual ~ArchiveZipFileImpl()
|
||||
{
|
||||
MOZ_COUNT_DTOR(ArchiveZipFile);
|
||||
MOZ_COUNT_DTOR(ArchiveZipFileImpl);
|
||||
}
|
||||
|
||||
// Overrides:
|
||||
NS_IMETHOD GetInternalStream(nsIInputStream**) MOZ_OVERRIDE;
|
||||
virtual nsresult GetInternalStream(nsIInputStream**) MOZ_OVERRIDE;
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ArchiveZipFile, nsDOMFileCC)
|
||||
virtual void Unlink() MOZ_OVERRIDE;
|
||||
virtual void Traverse(nsCycleCollectionTraversalCallback &aCb) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual already_AddRefed<nsIDOMBlob> CreateSlice(uint64_t aStart,
|
||||
|
|
|
@ -454,8 +454,8 @@ struct nsConstructorFuncMapData
|
|||
|
||||
static const nsConstructorFuncMapData kConstructorFuncMap[] =
|
||||
{
|
||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(Blob, nsDOMMultipartFile::NewBlob)
|
||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(File, nsDOMMultipartFile::NewFile)
|
||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(Blob, DOMMultipartFileImpl::NewBlob)
|
||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(File, DOMMultipartFileImpl::NewFile)
|
||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(MozSmsFilter, SmsFilter::NewSmsFilter)
|
||||
NS_DEFINE_CONSTRUCTOR_FUNC_DATA(XSLTProcessor, XSLTProcessorCtor)
|
||||
};
|
||||
|
|
|
@ -2784,7 +2784,8 @@ nsDOMWindowUtils::WrapDOMFile(nsIFile *aFile,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_ADDREF(*aDOMFile = new nsDOMFileFile(aFile));
|
||||
nsRefPtr<DOMFile> file = DOMFile::CreateFromFile(aFile);
|
||||
file.forget(aDOMFile);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2959,21 +2960,30 @@ GetFileOrBlob(const nsAString& aName, JS::Handle<JS::Value> aBlobParts,
|
|||
nsCOMPtr<nsISupports> file;
|
||||
|
||||
if (aName.IsVoid()) {
|
||||
rv = nsDOMMultipartFile::NewBlob(getter_AddRefs(file));
|
||||
rv = DOMMultipartFileImpl::NewBlob(getter_AddRefs(file));
|
||||
}
|
||||
else {
|
||||
rv = nsDOMMultipartFile::NewFile(aName, getter_AddRefs(file));
|
||||
rv = DOMMultipartFileImpl::NewFile(aName, getter_AddRefs(file));
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsDOMMultipartFile* domFile =
|
||||
static_cast<nsDOMMultipartFile*>(static_cast<nsIDOMFile*>(file.get()));
|
||||
nsCOMPtr<nsIDOMBlob> blob = do_QueryInterface(file);
|
||||
MOZ_ASSERT(blob);
|
||||
|
||||
nsRefPtr<DOMFile> domFile = static_cast<DOMFile*>(blob.get());
|
||||
|
||||
DOMFileImpl* fileImpl = domFile->Impl();
|
||||
MOZ_ASSERT(fileImpl);
|
||||
|
||||
DOMMultipartFileImpl* domFileImpl =
|
||||
static_cast<DOMMultipartFileImpl*>(fileImpl);
|
||||
|
||||
JS::AutoValueArray<2> args(aCx);
|
||||
args[0].set(aBlobParts);
|
||||
args[1].set(aParameters);
|
||||
|
||||
rv = domFile->InitBlob(aCx, aOptionalArgCount, args.begin(), GetXPConnectNative);
|
||||
rv = domFileImpl->InitBlob(aCx, aOptionalArgCount, args.begin(),
|
||||
GetXPConnectNative);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
file.forget(aResult);
|
||||
|
|
|
@ -338,9 +338,10 @@ DOMCameraControlListener::OnTakePictureComplete(uint8_t* aData, uint32_t aLength
|
|||
void
|
||||
RunCallback(nsDOMCameraControl* aDOMCameraControl) MOZ_OVERRIDE
|
||||
{
|
||||
nsCOMPtr<nsIDOMBlob> picture = new nsDOMMemoryFile(static_cast<void*>(mData),
|
||||
static_cast<uint64_t>(mLength),
|
||||
mMimeType);
|
||||
nsCOMPtr<nsIDOMBlob> picture =
|
||||
DOMFile::CreateMemoryFile(static_cast<void*>(mData),
|
||||
static_cast<uint64_t>(mLength),
|
||||
mMimeType);
|
||||
aDOMCameraControl->OnTakePictureComplete(picture);
|
||||
}
|
||||
|
||||
|
|
|
@ -117,8 +117,7 @@ DataStoreDB::HandleEvent(nsIDOMEvent* aEvent)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
MOZ_ASSUME_UNREACHABLE("This should not happen");
|
||||
return NS_OK;
|
||||
MOZ_CRASH("This should not happen");
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -53,8 +53,7 @@ DataStoreRevision::AddRevision(JSContext* aCx,
|
|||
break;
|
||||
|
||||
default:
|
||||
MOZ_ASSUME_UNREACHABLE("This should not happen");
|
||||
break;
|
||||
MOZ_CRASH("This should not happen");
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> value(aCx);
|
||||
|
@ -88,8 +87,7 @@ DataStoreRevision::HandleEvent(nsIDOMEvent* aEvent)
|
|||
}
|
||||
|
||||
if (!type.EqualsASCII("success")) {
|
||||
MOZ_ASSUME_UNREACHABLE("This should not happen");
|
||||
return NS_ERROR_FAILURE;
|
||||
MOZ_CRASH("This should not happen");
|
||||
}
|
||||
|
||||
mRequest->RemoveEventListener(NS_LITERAL_STRING("success"), this, false);
|
||||
|
|
|
@ -522,9 +522,9 @@ DeviceStorageRequestParent::PostBlobSuccessEvent::CancelableRun() {
|
|||
|
||||
nsString fullPath;
|
||||
mFile->GetFullPath(fullPath);
|
||||
nsCOMPtr<nsIDOMBlob> blob = new nsDOMFileFile(fullPath, mime, mLength,
|
||||
mFile->mFile,
|
||||
mLastModificationDate);
|
||||
nsCOMPtr<nsIDOMBlob> blob = new DOMFile(
|
||||
new DOMFileImplFile(fullPath, mime, mLength, mFile->mFile,
|
||||
mLastModificationDate));
|
||||
|
||||
ContentParent* cp = static_cast<ContentParent*>(mParent->Manager());
|
||||
BlobParent* actor = cp->GetOrCreateActorForBlob(blob);
|
||||
|
|
|
@ -1714,9 +1714,10 @@ nsIFileToJsval(nsPIDOMWindow* aWindow, DeviceStorageFile* aFile)
|
|||
MOZ_ASSERT(aFile->mLength != UINT64_MAX);
|
||||
MOZ_ASSERT(aFile->mLastModifiedDate != UINT64_MAX);
|
||||
|
||||
nsCOMPtr<nsIDOMBlob> blob = new nsDOMFileFile(fullPath, aFile->mMimeType,
|
||||
aFile->mLength, aFile->mFile,
|
||||
aFile->mLastModifiedDate);
|
||||
nsCOMPtr<nsIDOMBlob> blob = new DOMFile(
|
||||
new DOMFileImplFile(fullPath, aFile->mMimeType,
|
||||
aFile->mLength, aFile->mFile,
|
||||
aFile->mLastModifiedDate));
|
||||
return InterfaceToJsval(aWindow, blob, &NS_GET_IID(nsIDOMBlob));
|
||||
}
|
||||
|
||||
|
|
|
@ -305,7 +305,7 @@ DataTransfer::GetFiles(ErrorResult& aRv)
|
|||
if (!file)
|
||||
continue;
|
||||
|
||||
nsRefPtr<nsDOMFileFile> domFile = new nsDOMFileFile(file);
|
||||
nsRefPtr<DOMFile> domFile = DOMFile::CreateFromFile(file);
|
||||
|
||||
if (!mFiles->Append(domFile)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
|
|
|
@ -15,24 +15,22 @@ namespace dom {
|
|||
|
||||
using indexedDB::IndexedDatabaseManager;
|
||||
|
||||
// Create as a file
|
||||
File::File(const nsAString& aName, const nsAString& aContentType,
|
||||
uint64_t aLength, nsIFile* aFile, FileHandle* aFileHandle)
|
||||
: nsDOMFileCC(aName, aContentType, aLength),
|
||||
mFile(aFile), mFileHandle(aFileHandle),
|
||||
mWholeFile(true), mStoredFile(false)
|
||||
// Create as a file
|
||||
FileImpl::FileImpl(const nsAString& aName, const nsAString& aContentType,
|
||||
uint64_t aLength, nsIFile* aFile, FileHandle* aFileHandle)
|
||||
: DOMFileImplBase(aName, aContentType, aLength),
|
||||
mFile(aFile), mFileHandle(aFileHandle), mWholeFile(true), mStoredFile(false)
|
||||
{
|
||||
MOZ_ASSERT(mFile, "Null file!");
|
||||
MOZ_ASSERT(mFileHandle, "Null file handle!");
|
||||
}
|
||||
|
||||
// Create as a stored file
|
||||
File::File(const nsAString& aName, const nsAString& aContentType,
|
||||
uint64_t aLength, nsIFile* aFile, FileHandle* aFileHandle,
|
||||
FileInfo* aFileInfo)
|
||||
: nsDOMFileCC(aName, aContentType, aLength),
|
||||
mFile(aFile), mFileHandle(aFileHandle),
|
||||
mWholeFile(true), mStoredFile(true)
|
||||
FileImpl::FileImpl(const nsAString& aName, const nsAString& aContentType,
|
||||
uint64_t aLength, nsIFile* aFile, FileHandle* aFileHandle,
|
||||
indexedDB::FileInfo* aFileInfo)
|
||||
: DOMFileImplBase(aName, aContentType, aLength),
|
||||
mFile(aFile), mFileHandle(aFileHandle), mWholeFile(true), mStoredFile(true)
|
||||
{
|
||||
MOZ_ASSERT(mFile, "Null file!");
|
||||
MOZ_ASSERT(mFileHandle, "Null file handle!");
|
||||
|
@ -40,17 +38,17 @@ File::File(const nsAString& aName, const nsAString& aContentType,
|
|||
}
|
||||
|
||||
// Create slice
|
||||
File::File(const File* aOther, uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
: nsDOMFileCC(aContentType, aOther->mStart + aStart, aLength),
|
||||
mFile(aOther->mFile), mFileHandle(aOther->mFileHandle),
|
||||
mWholeFile(false), mStoredFile(aOther->mStoredFile)
|
||||
FileImpl::FileImpl(const FileImpl* aOther, uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
: DOMFileImplBase(aContentType, aOther->mStart + aStart, aLength),
|
||||
mFile(aOther->mFile), mFileHandle(aOther->mFileHandle),
|
||||
mWholeFile(false), mStoredFile(aOther->mStoredFile)
|
||||
{
|
||||
MOZ_ASSERT(mFile, "Null file!");
|
||||
MOZ_ASSERT(mFileHandle, "Null file handle!");
|
||||
|
||||
if (mStoredFile) {
|
||||
FileInfo* fileInfo;
|
||||
indexedDB::FileInfo* fileInfo;
|
||||
|
||||
if (IndexedDatabaseManager::IsClosed()) {
|
||||
fileInfo = aOther->GetFileInfo();
|
||||
|
@ -64,21 +62,26 @@ File::File(const File* aOther, uint64_t aStart, uint64_t aLength,
|
|||
}
|
||||
}
|
||||
|
||||
File::~File()
|
||||
FileImpl::~FileImpl()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(File, nsDOMFileCC,
|
||||
mFileHandle)
|
||||
void
|
||||
FileImpl::Unlink()
|
||||
{
|
||||
FileImpl* tmp = this;
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFileHandle);
|
||||
}
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(File)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMFileCC)
|
||||
void
|
||||
FileImpl::Traverse(nsCycleCollectionTraversalCallback &cb)
|
||||
{
|
||||
FileImpl* tmp = this;
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFileHandle);
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(File, nsDOMFileCC)
|
||||
NS_IMPL_RELEASE_INHERITED(File, nsDOMFileCC)
|
||||
|
||||
NS_IMETHODIMP
|
||||
File::GetInternalStream(nsIInputStream **aStream)
|
||||
nsresult
|
||||
FileImpl::GetInternalStream(nsIInputStream** aStream)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
|
@ -90,18 +93,19 @@ File::GetInternalStream(nsIInputStream **aStream)
|
|||
}
|
||||
|
||||
already_AddRefed<nsIDOMBlob>
|
||||
File::CreateSlice(uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
FileImpl::CreateSlice(uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
nsCOMPtr<nsIDOMBlob> t =
|
||||
new File(this, aStart, aLength, aContentType);
|
||||
new DOMFileCC(new FileImpl(this, aStart, aLength, aContentType));
|
||||
|
||||
return t.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
File::GetMozFullPathInternal(nsAString &aFilename)
|
||||
nsresult
|
||||
FileImpl::GetMozFullPathInternal(nsAString& aFilename)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(mIsFile, "Should only be called on files");
|
||||
|
|
|
@ -17,36 +17,36 @@ namespace mozilla {
|
|||
namespace dom {
|
||||
|
||||
class FileHandle;
|
||||
class File;
|
||||
|
||||
class File : public nsDOMFileCC
|
||||
class FileImpl : public DOMFileImplBase
|
||||
{
|
||||
friend class File;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(File, nsDOMFileCC)
|
||||
|
||||
// Create as a file
|
||||
File(const nsAString& aName, const nsAString& aContentType,
|
||||
uint64_t aLength, nsIFile* aFile, FileHandle* aFileHandle);
|
||||
FileImpl(const nsAString& aName, const nsAString& aContentType,
|
||||
uint64_t aLength, nsIFile* aFile, FileHandle* aFileHandle);
|
||||
|
||||
// Create as a stored file
|
||||
File(const nsAString& aName, const nsAString& aContentType,
|
||||
uint64_t aLength, nsIFile* aFile, FileHandle* aFileHandle,
|
||||
FileInfo* aFileInfo);
|
||||
FileImpl(const nsAString& aName, const nsAString& aContentType,
|
||||
uint64_t aLength, nsIFile* aFile, FileHandle* aFileHandle,
|
||||
indexedDB::FileInfo* aFileInfo);
|
||||
|
||||
// Overrides
|
||||
NS_IMETHOD
|
||||
GetMozFullPathInternal(nsAString& aFullPath) MOZ_OVERRIDE;
|
||||
virtual nsresult GetMozFullPathInternal(nsAString& aFullPath) MOZ_OVERRIDE;
|
||||
|
||||
NS_IMETHOD
|
||||
GetInternalStream(nsIInputStream** aStream) MOZ_OVERRIDE;
|
||||
virtual nsresult GetInternalStream(nsIInputStream** aStream) MOZ_OVERRIDE;
|
||||
|
||||
virtual void Unlink() MOZ_OVERRIDE;
|
||||
virtual void Traverse(nsCycleCollectionTraversalCallback &aCb) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
// Create slice
|
||||
File(const File* aOther, uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType);
|
||||
FileImpl(const FileImpl* aOther, uint64_t aStart, uint64_t aLength,
|
||||
const nsAString& aContentType);
|
||||
|
||||
virtual ~File();
|
||||
virtual ~FileImpl();
|
||||
|
||||
virtual already_AddRefed<nsIDOMBlob>
|
||||
CreateSlice(uint64_t aStart, uint64_t aLength,
|
||||
|
|
|
@ -106,7 +106,7 @@ already_AddRefed<nsIDOMFile>
|
|||
MutableFile::CreateFileObject(FileHandle* aFileHandle, uint32_t aFileSize)
|
||||
{
|
||||
nsCOMPtr<nsIDOMFile> file =
|
||||
new File(mName, mType, aFileSize, mFile, aFileHandle);
|
||||
new DOMFileCC(new FileImpl(mName, mType, aFileSize, mFile, aFileHandle));
|
||||
|
||||
return file.forget();
|
||||
}
|
||||
|
|
|
@ -252,7 +252,7 @@ CreateFileTask::Work()
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mTargetFile = new nsDOMFileFile(file);
|
||||
mTargetFile = DOMFile::CreateFromFile(file);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ CreateFileTask::Work()
|
|||
return NS_ERROR_DOM_FILESYSTEM_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
mTargetFile = new nsDOMFileFile(file);
|
||||
mTargetFile = DOMFile::CreateFromFile(file);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ GetFileOrDirectoryTask::Work()
|
|||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
mTargetFile = new nsDOMFileFile(file);
|
||||
mTargetFile = DOMFile::CreateFromFile(file);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -139,8 +139,8 @@ already_AddRefed<nsIDOMFile>
|
|||
IDBMutableFile::CreateFileObject(mozilla::dom::FileHandle* aFileHandle,
|
||||
uint32_t aFileSize)
|
||||
{
|
||||
nsCOMPtr<nsIDOMFile> file =
|
||||
new File(mName, mType, aFileSize, mFile, aFileHandle, mFileInfo);
|
||||
nsCOMPtr<nsIDOMFile> file = new DOMFileCC(
|
||||
new FileImpl(mName, mType, aFileSize, mFile, aFileHandle, mFileInfo));
|
||||
|
||||
return file.forget();
|
||||
}
|
||||
|
|
|
@ -740,7 +740,8 @@ ActorFromRemoteBlob(nsIDOMBlob* aBlob)
|
|||
NS_ASSERTION(!IndexedDatabaseManager::IsMainProcess(), "Wrong process!");
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(aBlob);
|
||||
nsRefPtr<DOMFile> blob = static_cast<DOMFile*>(aBlob);
|
||||
nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(blob->Impl());
|
||||
if (remoteBlob) {
|
||||
BlobChild* actor =
|
||||
static_cast<BlobChild*>(static_cast<PBlobChild*>(remoteBlob->GetPBlob()));
|
||||
|
@ -836,8 +837,8 @@ public:
|
|||
domBlob = aFile.mFile;
|
||||
}
|
||||
else {
|
||||
domBlob = new nsDOMFileFile(aData.type, aData.size, nativeFile,
|
||||
fileInfo);
|
||||
domBlob = DOMFile::CreateFromFile(aData.type, aData.size, nativeFile,
|
||||
fileInfo);
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> wrappedBlob(aCx);
|
||||
|
@ -861,8 +862,8 @@ public:
|
|||
NS_ASSERTION(domFile, "This should never fail!");
|
||||
}
|
||||
else {
|
||||
domFile = new nsDOMFileFile(aData.name, aData.type, aData.size,
|
||||
nativeFile, fileInfo);
|
||||
domFile = DOMFile::CreateFromFile(aData.name, aData.type, aData.size,
|
||||
nativeFile, fileInfo);
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> wrappedFile(aCx);
|
||||
|
@ -1790,7 +1791,8 @@ IDBObjectStore::ConvertBlobsToActors(
|
|||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMBlob> blob = new nsDOMFileFile(nativeFile, file.mFileInfo);
|
||||
nsCOMPtr<nsIDOMBlob> blob = DOMFile::CreateFromFile(nativeFile,
|
||||
file.mFileInfo);
|
||||
|
||||
BlobParent* actor =
|
||||
aContentParent->GetOrCreateActorForBlob(blob);
|
||||
|
|
|
@ -80,7 +80,7 @@ class BlobInputStreamTether : public nsIMultiplexInputStream,
|
|||
public nsIIPCSerializableInputStream
|
||||
{
|
||||
nsCOMPtr<nsIInputStream> mStream;
|
||||
nsCOMPtr<nsIDOMBlob> mSourceBlob;
|
||||
nsRefPtr<DOMFileImplBase> mSourceBlob;
|
||||
|
||||
nsIMultiplexInputStream* mWeakMultiplexStream;
|
||||
nsISeekableStream* mWeakSeekableStream;
|
||||
|
@ -93,7 +93,8 @@ public:
|
|||
NS_FORWARD_SAFE_NSISEEKABLESTREAM(mWeakSeekableStream)
|
||||
NS_FORWARD_SAFE_NSIIPCSERIALIZABLEINPUTSTREAM(mWeakSerializableStream)
|
||||
|
||||
BlobInputStreamTether(nsIInputStream* aStream, nsIDOMBlob* aSourceBlob)
|
||||
BlobInputStreamTether(nsIInputStream* aStream,
|
||||
mozilla::dom::DOMFileImplBase* aSourceBlob)
|
||||
: mStream(aStream), mSourceBlob(aSourceBlob), mWeakMultiplexStream(nullptr),
|
||||
mWeakSeekableStream(nullptr), mWeakSerializableStream(nullptr)
|
||||
{
|
||||
|
@ -154,14 +155,15 @@ class RemoteInputStream : public nsIInputStream,
|
|||
{
|
||||
mozilla::Monitor mMonitor;
|
||||
nsCOMPtr<nsIInputStream> mStream;
|
||||
nsCOMPtr<nsIDOMBlob> mSourceBlob;
|
||||
nsRefPtr<mozilla::dom::DOMFileImplBase> mSourceBlob;
|
||||
nsISeekableStream* mWeakSeekableStream;
|
||||
ActorType mOrigin;
|
||||
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
||||
RemoteInputStream(nsIDOMBlob* aSourceBlob, ActorType aOrigin)
|
||||
RemoteInputStream(mozilla::dom::DOMFileImplBase* aSourceBlob,
|
||||
ActorType aOrigin)
|
||||
: mMonitor("RemoteInputStream.mMonitor"), mSourceBlob(aSourceBlob),
|
||||
mWeakSeekableStream(nullptr), mOrigin(aOrigin)
|
||||
{
|
||||
|
@ -225,7 +227,7 @@ public:
|
|||
nsresult rv = BlockAndWaitForStream();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMBlob> sourceBlob;
|
||||
nsRefPtr<mozilla::dom::DOMFileImplBase> sourceBlob;
|
||||
mSourceBlob.swap(sourceBlob);
|
||||
|
||||
rv = mStream->Close();
|
||||
|
@ -486,13 +488,10 @@ private:
|
|||
const OptionalFileDescriptorSet& aFDs) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
nsDOMFileBase*
|
||||
DOMFile*
|
||||
ToConcreteBlob(nsIDOMBlob* aBlob)
|
||||
{
|
||||
// XXX This is only safe so long as all blob implementations in our tree
|
||||
// inherit nsDOMFileBase. If that ever changes then this will need to grow
|
||||
// a real interface or something.
|
||||
return static_cast<nsDOMFileBase*>(aBlob);
|
||||
return static_cast<DOMFile*>(aBlob);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
@ -703,9 +702,8 @@ private:
|
|||
* BlobChild::RemoteBlob Declaration
|
||||
******************************************************************************/
|
||||
|
||||
class BlobChild::RemoteBlob MOZ_FINAL
|
||||
: public nsDOMFile
|
||||
, public nsIRemoteBlob
|
||||
class BlobChild::RemoteBlob MOZ_FINAL : public DOMFileImplBase
|
||||
, public nsIRemoteBlob
|
||||
{
|
||||
class StreamHelper;
|
||||
class SliceHelper;
|
||||
|
@ -717,21 +715,21 @@ public:
|
|||
const nsAString& aContentType,
|
||||
uint64_t aLength,
|
||||
uint64_t aModDate)
|
||||
: nsDOMFile(aName, aContentType, aLength, aModDate)
|
||||
: DOMFileImplBase(aName, aContentType, aLength, aModDate)
|
||||
, mActor(nullptr)
|
||||
{
|
||||
mImmutable = true;
|
||||
}
|
||||
|
||||
RemoteBlob(const nsAString& aContentType, uint64_t aLength)
|
||||
: nsDOMFile(aContentType, aLength)
|
||||
: DOMFileImplBase(aContentType, aLength)
|
||||
, mActor(nullptr)
|
||||
{
|
||||
mImmutable = true;
|
||||
}
|
||||
|
||||
RemoteBlob()
|
||||
: nsDOMFile(EmptyString(), EmptyString(), UINT64_MAX, UINT64_MAX)
|
||||
: DOMFileImplBase(EmptyString(), EmptyString(), UINT64_MAX, UINT64_MAX)
|
||||
, mActor(nullptr)
|
||||
{
|
||||
mImmutable = true;
|
||||
|
@ -750,10 +748,10 @@ public:
|
|||
CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType)
|
||||
MOZ_OVERRIDE;
|
||||
|
||||
NS_IMETHOD
|
||||
virtual nsresult
|
||||
GetInternalStream(nsIInputStream** aStream) MOZ_OVERRIDE;
|
||||
|
||||
NS_IMETHOD
|
||||
virtual nsresult
|
||||
GetLastModifiedDate(JSContext* cx,
|
||||
JS::MutableHandle<JS::Value> aLastModifiedDate)
|
||||
MOZ_OVERRIDE;
|
||||
|
@ -775,12 +773,12 @@ class BlobChild::RemoteBlob::StreamHelper MOZ_FINAL
|
|||
{
|
||||
mozilla::Monitor mMonitor;
|
||||
BlobChild* mActor;
|
||||
nsCOMPtr<nsIDOMBlob> mSourceBlob;
|
||||
nsRefPtr<mozilla::dom::DOMFileImplBase> mSourceBlob;
|
||||
nsRefPtr<RemoteInputStream> mInputStream;
|
||||
bool mDone;
|
||||
|
||||
public:
|
||||
StreamHelper(BlobChild* aActor, nsIDOMBlob* aSourceBlob)
|
||||
StreamHelper(BlobChild* aActor, mozilla::dom::DOMFileImplBase* aSourceBlob)
|
||||
: mMonitor("BlobChild::RemoteBlob::StreamHelper::mMonitor")
|
||||
, mActor(aActor)
|
||||
, mSourceBlob(aSourceBlob)
|
||||
|
@ -995,7 +993,7 @@ private:
|
|||
* BlobChild::RemoteBlob Implementation
|
||||
******************************************************************************/
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(BlobChild::RemoteBlob, nsDOMFile, nsIRemoteBlob)
|
||||
NS_IMPL_ISUPPORTS_INHERITED(BlobChild::RemoteBlob, DOMFileImplBase, nsIRemoteBlob)
|
||||
|
||||
already_AddRefed<nsIDOMBlob>
|
||||
BlobChild::
|
||||
|
@ -1017,7 +1015,7 @@ RemoteBlob::CreateSlice(uint64_t aStart,
|
|||
return slice.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
BlobChild::
|
||||
RemoteBlob::GetInternalStream(nsIInputStream** aStream)
|
||||
{
|
||||
|
@ -1029,7 +1027,7 @@ RemoteBlob::GetInternalStream(nsIInputStream** aStream)
|
|||
return helper->GetStream(aStream);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
BlobChild::
|
||||
RemoteBlob::GetLastModifiedDate(JSContext* cx,
|
||||
JS::MutableHandle<JS::Value> aLastModifiedDate)
|
||||
|
@ -1095,9 +1093,11 @@ BlobChild::BlobChild(nsIContentChild* aManager,
|
|||
MOZ_ASSERT(remoteBlob);
|
||||
|
||||
remoteBlob->SetActor(this);
|
||||
remoteBlob.forget(&mRemoteBlob);
|
||||
|
||||
mBlob = mRemoteBlob;
|
||||
nsRefPtr<DOMFile> blob = new DOMFile(remoteBlob);
|
||||
blob.forget(&mBlob);
|
||||
|
||||
mRemoteBlob = remoteBlob;
|
||||
mOwnsBlob = true;
|
||||
}
|
||||
|
||||
|
@ -1357,7 +1357,7 @@ BlobChild::RecvResolveMystery(const ResolveMysteryParams& aParams)
|
|||
return false;
|
||||
}
|
||||
|
||||
nsDOMFileBase* blob = ToConcreteBlob(mBlob);
|
||||
DOMFile* blob = ToConcreteBlob(mBlob);
|
||||
|
||||
switch (aParams.type()) {
|
||||
case ResolveMysteryParams::TNormalBlobConstructorParams: {
|
||||
|
@ -1389,9 +1389,8 @@ BlobChild::RecvResolveMystery(const ResolveMysteryParams& aParams)
|
|||
* BlobParent::RemoteBlob Declaration
|
||||
******************************************************************************/
|
||||
|
||||
class BlobParent::RemoteBlob MOZ_FINAL
|
||||
: public nsDOMFile
|
||||
, public nsIRemoteBlob
|
||||
class BlobParent::RemoteBlob MOZ_FINAL : public mozilla::dom::DOMFileImplBase
|
||||
, public nsIRemoteBlob
|
||||
{
|
||||
class StreamHelper;
|
||||
class SliceHelper;
|
||||
|
@ -1404,21 +1403,21 @@ public:
|
|||
const nsAString& aContentType,
|
||||
uint64_t aLength,
|
||||
uint64_t aModDate)
|
||||
: nsDOMFile(aName, aContentType, aLength, aModDate)
|
||||
: DOMFileImplBase(aName, aContentType, aLength, aModDate)
|
||||
, mActor(nullptr)
|
||||
{
|
||||
mImmutable = true;
|
||||
}
|
||||
|
||||
RemoteBlob(const nsAString& aContentType, uint64_t aLength)
|
||||
: nsDOMFile(aContentType, aLength)
|
||||
: DOMFileImplBase(aContentType, aLength)
|
||||
, mActor(nullptr)
|
||||
{
|
||||
mImmutable = true;
|
||||
}
|
||||
|
||||
RemoteBlob()
|
||||
: nsDOMFile(EmptyString(), EmptyString(), UINT64_MAX, UINT64_MAX)
|
||||
: DOMFileImplBase(EmptyString(), EmptyString(), UINT64_MAX, UINT64_MAX)
|
||||
, mActor(nullptr)
|
||||
{
|
||||
mImmutable = true;
|
||||
|
@ -1447,15 +1446,15 @@ public:
|
|||
CreateSlice(uint64_t aStart, uint64_t aLength, const nsAString& aContentType)
|
||||
MOZ_OVERRIDE;
|
||||
|
||||
NS_IMETHOD
|
||||
virtual nsresult
|
||||
GetInternalStream(nsIInputStream** aStream) MOZ_OVERRIDE;
|
||||
|
||||
NS_IMETHOD
|
||||
virtual nsresult
|
||||
GetLastModifiedDate(JSContext* cx,
|
||||
JS::MutableHandle<JS::Value> aLastModifiedDate)
|
||||
MOZ_OVERRIDE;
|
||||
|
||||
virtual void*
|
||||
void*
|
||||
GetPBlob() MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
@ -1472,12 +1471,12 @@ class BlobParent::RemoteBlob::StreamHelper MOZ_FINAL
|
|||
{
|
||||
mozilla::Monitor mMonitor;
|
||||
BlobParent* mActor;
|
||||
nsCOMPtr<nsIDOMBlob> mSourceBlob;
|
||||
nsRefPtr<mozilla::dom::DOMFileImplBase> mSourceBlob;
|
||||
nsRefPtr<RemoteInputStream> mInputStream;
|
||||
bool mDone;
|
||||
|
||||
public:
|
||||
StreamHelper(BlobParent* aActor, nsIDOMBlob* aSourceBlob)
|
||||
StreamHelper(BlobParent* aActor, mozilla::dom::DOMFileImplBase* aSourceBlob)
|
||||
: mMonitor("BlobParent::RemoteBlob::StreamHelper::mMonitor")
|
||||
, mActor(aActor)
|
||||
, mSourceBlob(aSourceBlob)
|
||||
|
@ -1694,7 +1693,8 @@ private:
|
|||
* BlobChild::RemoteBlob Implementation
|
||||
******************************************************************************/
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(BlobParent::RemoteBlob, nsDOMFile, nsIRemoteBlob)
|
||||
NS_IMPL_ISUPPORTS_INHERITED(BlobParent::RemoteBlob, DOMFileImplBase,
|
||||
nsIRemoteBlob)
|
||||
|
||||
already_AddRefed<nsIDOMBlob>
|
||||
BlobParent::
|
||||
|
@ -1716,7 +1716,7 @@ RemoteBlob::CreateSlice(uint64_t aStart,
|
|||
return slice.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
BlobParent::
|
||||
RemoteBlob::GetInternalStream(nsIInputStream** aStream)
|
||||
{
|
||||
|
@ -1743,7 +1743,7 @@ RemoteBlob::GetInternalStream(nsIInputStream** aStream)
|
|||
return helper->GetStream(aStream);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
BlobParent::
|
||||
RemoteBlob::GetLastModifiedDate(JSContext* cx,
|
||||
JS::MutableHandle<JS::Value> aLastModifiedDate)
|
||||
|
@ -1810,9 +1810,11 @@ BlobParent::BlobParent(nsIContentParent* aManager,
|
|||
|
||||
remoteBlob->SetActor(this);
|
||||
remoteBlob->MaybeSetInputStream(aParams);
|
||||
remoteBlob.forget(&mRemoteBlob);
|
||||
|
||||
mBlob = mRemoteBlob;
|
||||
nsRefPtr<DOMFile> blob = new DOMFile(remoteBlob);
|
||||
blob.forget(&mBlob);
|
||||
|
||||
mRemoteBlob = remoteBlob;
|
||||
mOwnsBlob = true;
|
||||
}
|
||||
|
||||
|
@ -2061,7 +2063,8 @@ BlobParent::RecvPBlobStreamConstructor(PBlobStreamParent* aActor)
|
|||
nsresult rv = mBlob->GetInternalStream(getter_AddRefs(stream));
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(mBlob);
|
||||
nsRefPtr<DOMFile> blob = static_cast<DOMFile*>(mBlob);
|
||||
nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(blob->Impl());
|
||||
|
||||
nsCOMPtr<IPrivateRemoteInputStream> remoteStream;
|
||||
if (remoteBlob) {
|
||||
|
@ -2126,7 +2129,7 @@ BlobParent::RecvResolveMystery(const ResolveMysteryParams& aParams)
|
|||
return false;
|
||||
}
|
||||
|
||||
nsDOMFileBase* blob = ToConcreteBlob(mBlob);
|
||||
DOMFile* blob = ToConcreteBlob(mBlob);
|
||||
|
||||
switch (aParams.type()) {
|
||||
case ResolveMysteryParams::TNormalBlobConstructorParams: {
|
||||
|
|
|
@ -149,7 +149,7 @@ FilePickerParent::Done(int16_t aResult)
|
|||
iter->GetNext(getter_AddRefs(supports));
|
||||
if (supports) {
|
||||
nsCOMPtr<nsIFile> file = do_QueryInterface(supports);
|
||||
nsCOMPtr<nsIDOMFile> domfile = new nsDOMFileFile(file);
|
||||
nsCOMPtr<nsIDOMFile> domfile = DOMFile::CreateFromFile(file);
|
||||
domfiles.AppendElement(domfile);
|
||||
}
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ FilePickerParent::Done(int16_t aResult)
|
|||
nsCOMPtr<nsIFile> file;
|
||||
mFilePicker->GetFile(getter_AddRefs(file));
|
||||
if (file) {
|
||||
nsCOMPtr<nsIDOMFile> domfile = new nsDOMFileFile(file);
|
||||
nsCOMPtr<nsIDOMFile> domfile = DOMFile::CreateFromFile(file);
|
||||
domfiles.AppendElement(domfile);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,7 +102,9 @@ nsIContentChild::GetOrCreateActorForBlob(nsIDOMBlob* aBlob)
|
|||
|
||||
// If the blob represents a remote blob then we can simply pass its actor back
|
||||
// here.
|
||||
if (nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(aBlob)) {
|
||||
const auto* domFile = static_cast<DOMFile*>(aBlob);
|
||||
nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(domFile->Impl());
|
||||
if (remoteBlob) {
|
||||
BlobChild* actor =
|
||||
static_cast<BlobChild*>(
|
||||
static_cast<PBlobChild*>(remoteBlob->GetPBlob()));
|
||||
|
@ -122,9 +124,9 @@ nsIContentChild::GetOrCreateActorForBlob(nsIDOMBlob* aBlob)
|
|||
#ifdef DEBUG
|
||||
{
|
||||
// XXX This is only safe so long as all blob implementations in our tree
|
||||
// inherit nsDOMFileBase. If that ever changes then this will need to
|
||||
// inherit DOMFileImplBase. If that ever changes then this will need to
|
||||
// grow a real interface or something.
|
||||
const auto* blob = static_cast<nsDOMFileBase*>(aBlob);
|
||||
const auto* blob = static_cast<DOMFileImplBase*>(domFile->Impl());
|
||||
|
||||
MOZ_ASSERT(!blob->IsSizeUnknown());
|
||||
MOZ_ASSERT(!blob->IsDateUnknown());
|
||||
|
|
|
@ -158,7 +158,9 @@ nsIContentParent::GetOrCreateActorForBlob(nsIDOMBlob* aBlob)
|
|||
|
||||
// If the blob represents a remote blob for this ContentParent then we can
|
||||
// simply pass its actor back here.
|
||||
if (nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(aBlob)) {
|
||||
const auto* domFile = static_cast<DOMFile*>(aBlob);
|
||||
nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(domFile->Impl());
|
||||
if (remoteBlob) {
|
||||
if (BlobParent* actor = static_cast<BlobParent*>(
|
||||
static_cast<PBlobParent*>(remoteBlob->GetPBlob()))) {
|
||||
MOZ_ASSERT(actor);
|
||||
|
@ -177,9 +179,9 @@ nsIContentParent::GetOrCreateActorForBlob(nsIDOMBlob* aBlob)
|
|||
}
|
||||
|
||||
// XXX This is only safe so long as all blob implementations in our tree
|
||||
// inherit nsDOMFileBase. If that ever changes then this will need to grow
|
||||
// inherit DOMFileImplBase. If that ever changes then this will need to grow
|
||||
// a real interface or something.
|
||||
const auto* blob = static_cast<nsDOMFileBase*>(aBlob);
|
||||
const auto* blob = static_cast<DOMFileImplBase*>(domFile->Impl());
|
||||
|
||||
ChildBlobConstructorParams params;
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ DOMMobileMessageError::GetData(OwningMozSmsMessageOrMozMmsMessage& aRetVal) cons
|
|||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSUME_UNREACHABLE("Bad object with invalid mSms and mMms.");
|
||||
MOZ_CRASH("Bad object with invalid mSms and mMms.");
|
||||
}
|
||||
|
||||
JSObject*
|
||||
|
|
|
@ -382,7 +382,7 @@ MmsMessage::GetData(ContentParent* aParent,
|
|||
// doesn't have a valid last modified date, making the ContentParent
|
||||
// send a "Mystery Blob" to the ContentChild. Attempting to get the
|
||||
// last modified date of blob can force that value to be initialized.
|
||||
nsDOMFileBase* file = static_cast<nsDOMFileBase*>(element.content.get());
|
||||
DOMFile* file = static_cast<DOMFile*>(element.content.get());
|
||||
if (file->IsDateUnknown()) {
|
||||
uint64_t date;
|
||||
if (NS_FAILED(file->GetMozLastModifiedDate(&date))) {
|
||||
|
|
|
@ -341,5 +341,9 @@ socket_unrealize_cb(GtkWidget *widget, gpointer data)
|
|||
if (children) XFree(children);
|
||||
|
||||
mozilla::FinishX(display);
|
||||
#if (MOZ_WIDGET_GTK == 3)
|
||||
gdk_error_trap_pop_ignored();
|
||||
#else
|
||||
gdk_error_trap_pop();
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ TelephonyCallId::GetPresentationStr(uint16_t aPresentation) const
|
|||
case nsITelephonyService::CALL_PRESENTATION_PAYPHONE:
|
||||
return CallIdPresentation::Payphone;
|
||||
default:
|
||||
MOZ_ASSUME_UNREACHABLE("Bad presentation!");
|
||||
MOZ_CRASH("Bad presentation!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ private:
|
|||
#define USE_DLFUNC(name) \
|
||||
FUNC##name name = (FUNC##name) dlsym(GetSharedLibrary(), #name); \
|
||||
if (!name) { \
|
||||
MOZ_ASSUME_UNREACHABLE("Symbol not found in shared library : " #name); \
|
||||
MOZ_CRASH("Symbol not found in shared library : " #name); \
|
||||
}
|
||||
|
||||
#endif // WifiHotspotUtils_h
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "File.h"
|
||||
|
||||
#include "nsIDOMFile.h"
|
||||
#include "nsDOMFile.h"
|
||||
#include "nsDOMBlobBuilder.h"
|
||||
#include "nsError.h"
|
||||
|
||||
|
@ -85,8 +85,10 @@ private:
|
|||
{
|
||||
JS::CallArgs args = CallArgsFromVp(aArgc, aVp);
|
||||
|
||||
nsRefPtr<nsDOMMultipartFile> file = new nsDOMMultipartFile();
|
||||
nsresult rv = file->InitBlob(aCx, args.length(), args.array(), Unwrap);
|
||||
nsRefPtr<DOMMultipartFileImpl> fileImpl = new DOMMultipartFileImpl();
|
||||
nsRefPtr<mozilla::dom::DOMFile> file = new mozilla::dom::DOMFile(fileImpl);
|
||||
|
||||
nsresult rv = fileImpl->InitBlob(aCx, args.length(), args.array(), Unwrap);
|
||||
if (NS_FAILED(rv)) {
|
||||
return Throw(aCx, rv);
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "prprf.h"
|
||||
#include "nsNodeUtils.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsCycleCollector.h"
|
||||
|
||||
// Nasty hack. Maybe we could move some of the classinfo utility methods
|
||||
// (e.g. WrapNative) over to nsContentUtils?
|
||||
|
@ -73,7 +74,7 @@ XBLFinalize(JSFreeOp *fop, JSObject *obj)
|
|||
{
|
||||
nsXBLDocumentInfo* docInfo =
|
||||
static_cast<nsXBLDocumentInfo*>(::JS_GetPrivate(obj));
|
||||
nsContentUtils::DeferredFinalize(docInfo);
|
||||
cyclecollector::DeferredFinalize(docInfo);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
@ -4,5 +4,62 @@
|
|||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
PARALLEL_DIRS += ['public', 'src']
|
||||
TEST_DIRS += ['test']
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIEditingSession.idl',
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'composer'
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'nsComposerCommands.cpp',
|
||||
'nsComposerCommandsUpdater.cpp',
|
||||
'nsComposerController.cpp',
|
||||
'nsComposerDocumentCommands.cpp',
|
||||
'nsComposerRegistration.cpp',
|
||||
'nsComposeTxtSrvFilter.cpp',
|
||||
'nsEditingSession.cpp',
|
||||
'nsEditorSpellCheck.cpp',
|
||||
]
|
||||
|
||||
FAIL_ON_WARNINGS = True
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
RESOURCE_FILES += [
|
||||
'res/EditorOverride.css',
|
||||
'res/grabber.gif',
|
||||
'res/table-add-column-after-active.gif',
|
||||
'res/table-add-column-after-hover.gif',
|
||||
'res/table-add-column-after.gif',
|
||||
'res/table-add-column-before-active.gif',
|
||||
'res/table-add-column-before-hover.gif',
|
||||
'res/table-add-column-before.gif',
|
||||
'res/table-add-row-after-active.gif',
|
||||
'res/table-add-row-after-hover.gif',
|
||||
'res/table-add-row-after.gif',
|
||||
'res/table-add-row-before-active.gif',
|
||||
'res/table-add-row-before-hover.gif',
|
||||
'res/table-add-row-before.gif',
|
||||
'res/table-remove-column-active.gif',
|
||||
'res/table-remove-column-hover.gif',
|
||||
'res/table-remove-column.gif',
|
||||
'res/table-remove-row-active.gif',
|
||||
'res/table-remove-row-hover.gif',
|
||||
'res/table-remove-row.gif',
|
||||
'res/text_caret.png',
|
||||
'res/text_caret@1.5x.png',
|
||||
'res/text_caret@2.25x.png',
|
||||
'res/text_caret@2x.png',
|
||||
'res/text_caret_tilt_left.png',
|
||||
'res/text_caret_tilt_left@1.5x.png',
|
||||
'res/text_caret_tilt_left@2.25x.png',
|
||||
'res/text_caret_tilt_left@2x.png',
|
||||
'res/text_caret_tilt_right.png',
|
||||
'res/text_caret_tilt_right@1.5x.png',
|
||||
'res/text_caret_tilt_right@2.25x.png',
|
||||
'res/text_caret_tilt_right@2x.png',
|
||||
'res/text_selection_handle.png',
|
||||
'res/text_selection_handle@1.5.png',
|
||||
'res/text_selection_handle@2.png',
|
||||
]
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче