mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-27 01:27:30 +09:00
Merge remote-tracking branch 'origin/tracking' into custom
This commit is contained in:
commit
e361ce2b32
8 changed files with 137 additions and 153 deletions
|
|
@ -87,7 +87,8 @@ async function _resolveAndFetch(generatedSource) : SourceMapConsumer {
|
||||||
// Fetch the sourcemap over the network and create it.
|
// Fetch the sourcemap over the network and create it.
|
||||||
const sourceMapURL = _resolveSourceMapURL(generatedSource);
|
const sourceMapURL = _resolveSourceMapURL(generatedSource);
|
||||||
const fetched = await fetch(
|
const fetched = await fetch(
|
||||||
sourceMapURL, { loadFromCache: false }
|
sourceMapURL, { loadFromCache: false,
|
||||||
|
redirect: error }
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create the source map and fix it up.
|
// Create the source map and fix it up.
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
#include "nsISupports.idl"
|
#include "nsISupports.idl"
|
||||||
|
|
||||||
[scriptable, uuid(9c9252a1-fdaf-40a2-9c2b-a3dc45e28dde)]
|
[scriptable, uuid(6e8476d5-ba95-4fee-85d9-f96729b387d8)]
|
||||||
interface nsIMIMEHeaderParam : nsISupports {
|
interface nsIMIMEHeaderParam : nsISupports {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -132,7 +132,7 @@ interface nsIMIMEHeaderParam : nsISupports {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
[noscript]
|
[noscript]
|
||||||
string getParameterInternal(in string aHeaderVal,
|
string getParameterInternal(in ACString aHeaderVal,
|
||||||
in string aParamName,
|
in string aParamName,
|
||||||
out string aCharset,
|
out string aCharset,
|
||||||
out string aLang);
|
out string aLang);
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,28 @@ nsMIMEHeaderParamImpl::GetParameterHTTP(const nsACString& aHeaderVal,
|
||||||
aFallbackCharset, aTryLocaleCharset, aLang, aResult);
|
aFallbackCharset, aTryLocaleCharset, aLang, aResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
// Detects the presence of any non-null characters past null in a header.
|
||||||
|
bool
|
||||||
|
nsMIMEHeaderParamImpl::ContainsTrailingCharPastNull(const nsACString& aVal) {
|
||||||
|
nsACString::const_iterator first;
|
||||||
|
aVal.BeginReading(first);
|
||||||
|
nsACString::const_iterator end;
|
||||||
|
aVal.EndReading(end);
|
||||||
|
|
||||||
|
if (FindCharInReadable(L'\0', first, end)) {
|
||||||
|
while (first != end) {
|
||||||
|
if (*first != '\0') {
|
||||||
|
// Header contains trailing characters past the null character
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
++first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// No stray non-null characters found.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// XXX : aTryLocaleCharset is not yet effective.
|
// XXX : aTryLocaleCharset is not yet effective.
|
||||||
nsresult
|
nsresult
|
||||||
nsMIMEHeaderParamImpl::DoGetParameter(const nsACString& aHeaderVal,
|
nsMIMEHeaderParamImpl::DoGetParameter(const nsACString& aHeaderVal,
|
||||||
|
|
@ -81,9 +103,8 @@ nsMIMEHeaderParamImpl::DoGetParameter(const nsACString& aHeaderVal,
|
||||||
// aDecoding (5987 being a subset of 2231) and return charset.)
|
// aDecoding (5987 being a subset of 2231) and return charset.)
|
||||||
nsXPIDLCString med;
|
nsXPIDLCString med;
|
||||||
nsXPIDLCString charset;
|
nsXPIDLCString charset;
|
||||||
rv = DoParameterInternal(PromiseFlatCString(aHeaderVal).get(), aParamName,
|
rv = DoParameterInternal(aHeaderVal, aParamName, aDecoding,
|
||||||
aDecoding, getter_Copies(charset), aLang,
|
getter_Copies(charset), aLang, getter_Copies(med));
|
||||||
getter_Copies(med));
|
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
|
|
@ -346,7 +367,7 @@ bool IsValidOctetSequenceForCharset(nsACString& aCharset, const char *aOctets)
|
||||||
// The format of these header lines is
|
// The format of these header lines is
|
||||||
// <token> [ ';' <token> '=' <token-or-quoted-string> ]*
|
// <token> [ ';' <token> '=' <token-or-quoted-string> ]*
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsMIMEHeaderParamImpl::GetParameterInternal(const char *aHeaderValue,
|
nsMIMEHeaderParamImpl::GetParameterInternal(const nsACString& aHeaderValue,
|
||||||
const char* aParamName,
|
const char* aParamName,
|
||||||
char** aCharset,
|
char** aCharset,
|
||||||
char** aLang,
|
char** aLang,
|
||||||
|
|
@ -358,7 +379,7 @@ nsMIMEHeaderParamImpl::GetParameterInternal(const char *aHeaderValue,
|
||||||
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsMIMEHeaderParamImpl::DoParameterInternal(const char *aHeaderValue,
|
nsMIMEHeaderParamImpl::DoParameterInternal(const nsACString& aHeaderValue,
|
||||||
const char* aParamName,
|
const char* aParamName,
|
||||||
ParamDecoding aDecoding,
|
ParamDecoding aDecoding,
|
||||||
char** aCharset,
|
char** aCharset,
|
||||||
|
|
@ -366,8 +387,21 @@ nsMIMEHeaderParamImpl::DoParameterInternal(const char *aHeaderValue,
|
||||||
char** aResult)
|
char** aResult)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!aHeaderValue || !*aHeaderValue || !aResult)
|
if (aHeaderValue.IsEmpty() || !aResult) {
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ContainsTrailingCharPastNull(aHeaderValue)) {
|
||||||
|
// See Bug 1784348
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
const nsCString& flat = PromiseFlatCString(aHeaderValue);
|
||||||
|
const char* str = flat.get();
|
||||||
|
|
||||||
|
if (!*str) {
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
|
||||||
*aResult = nullptr;
|
*aResult = nullptr;
|
||||||
|
|
||||||
|
|
@ -380,8 +414,6 @@ nsMIMEHeaderParamImpl::DoParameterInternal(const char *aHeaderValue,
|
||||||
// them for HTTP header fields later on, see bug 776324
|
// them for HTTP header fields later on, see bug 776324
|
||||||
bool acceptContinuations = true;
|
bool acceptContinuations = true;
|
||||||
|
|
||||||
const char *str = aHeaderValue;
|
|
||||||
|
|
||||||
// skip leading white space.
|
// skip leading white space.
|
||||||
for (; *str && nsCRT::IsAsciiSpace(*str); ++str)
|
for (; *str && nsCRT::IsAsciiSpace(*str); ++str)
|
||||||
;
|
;
|
||||||
|
|
|
||||||
|
|
@ -29,13 +29,14 @@ private:
|
||||||
char **aLang,
|
char **aLang,
|
||||||
nsAString& aResult);
|
nsAString& aResult);
|
||||||
|
|
||||||
nsresult DoParameterInternal(const char *aHeaderValue,
|
nsresult DoParameterInternal(const nsACString& aHeaderValue,
|
||||||
const char* aParamName,
|
const char* aParamName,
|
||||||
ParamDecoding aDecoding,
|
ParamDecoding aDecoding,
|
||||||
char** aCharset,
|
char** aCharset,
|
||||||
char** aLang,
|
char** aLang,
|
||||||
char** aResult);
|
char** aResult);
|
||||||
|
|
||||||
|
static bool ContainsTrailingCharPastNull(const nsACString& aVal);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -432,6 +432,16 @@ var tests = [
|
||||||
// Bug 783502 - xpcshell test netwerk/test/unit/test_MIME_params.js fails on AddressSanitizer
|
// Bug 783502 - xpcshell test netwerk/test/unit/test_MIME_params.js fails on AddressSanitizer
|
||||||
['attachment; filename="\\b\\a\\',
|
['attachment; filename="\\b\\a\\',
|
||||||
"attachment", "ba\\"],
|
"attachment", "ba\\"],
|
||||||
|
|
||||||
|
// Bug 1784348
|
||||||
|
["attachment; filename=foo.exe\0.pdf",
|
||||||
|
Cr.NS_ERROR_ILLEGAL_VALUE,
|
||||||
|
Cr.NS_ERROR_INVALID_ARG],
|
||||||
|
["attachment; filename=\0\0foo\0",
|
||||||
|
Cr.NS_ERROR_ILLEGAL_VALUE,
|
||||||
|
Cr.NS_ERROR_INVALID_ARG],
|
||||||
|
["attachment; filename=foo\0\0\0", "attachment", "foo"],
|
||||||
|
["attachment; filename=\0\0\0", "attachment", ""],
|
||||||
];
|
];
|
||||||
|
|
||||||
var rfc5987paramtests = [
|
var rfc5987paramtests = [
|
||||||
|
|
|
||||||
|
|
@ -150,12 +150,6 @@ interface nsITransferable : nsISupports
|
||||||
void getAnyTransferData ( out ACString aFlavor, out nsISupports aData,
|
void getAnyTransferData ( out ACString aFlavor, out nsISupports aData,
|
||||||
out unsigned long aDataLen ) ;
|
out unsigned long aDataLen ) ;
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the data is large.
|
|
||||||
*/
|
|
||||||
boolean isLargeDataSet ( ) ;
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
// Setter part of interface
|
// Setter part of interface
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ Notes to self:
|
||||||
|
|
||||||
|
|
||||||
#include "nsTransferable.h"
|
#include "nsTransferable.h"
|
||||||
|
#include "nsAnonymousTemporaryFile.h"
|
||||||
#include "nsArray.h"
|
#include "nsArray.h"
|
||||||
#include "nsArrayUtils.h"
|
#include "nsArrayUtils.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
|
|
@ -27,7 +28,6 @@ Notes to self:
|
||||||
#include "nsISupportsPrimitives.h"
|
#include "nsISupportsPrimitives.h"
|
||||||
#include "nsMemory.h"
|
#include "nsMemory.h"
|
||||||
#include "nsPrimitiveHelpers.h"
|
#include "nsPrimitiveHelpers.h"
|
||||||
#include "nsXPIDLString.h"
|
|
||||||
#include "nsDirectoryServiceDefs.h"
|
#include "nsDirectoryServiceDefs.h"
|
||||||
#include "nsDirectoryService.h"
|
#include "nsDirectoryService.h"
|
||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
|
|
@ -36,7 +36,6 @@ Notes to self:
|
||||||
#include "nsIOutputStream.h"
|
#include "nsIOutputStream.h"
|
||||||
#include "nsIInputStream.h"
|
#include "nsIInputStream.h"
|
||||||
#include "nsIWeakReferenceUtils.h"
|
#include "nsIWeakReferenceUtils.h"
|
||||||
#include "nsIFile.h"
|
|
||||||
#include "nsILoadContext.h"
|
#include "nsILoadContext.h"
|
||||||
#include "mozilla/UniquePtr.h"
|
#include "mozilla/UniquePtr.h"
|
||||||
|
|
||||||
|
|
@ -56,7 +55,9 @@ size_t GetDataForFlavor (const nsTArray<DataStruct>& aArray,
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
DataStruct::~DataStruct()
|
DataStruct::~DataStruct()
|
||||||
{
|
{
|
||||||
if (mCacheFileName) free(mCacheFileName);
|
if (mCacheFD) {
|
||||||
|
PR_Close(mCacheFD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
@ -67,23 +68,31 @@ DataStruct::SetData ( nsISupports* aData, uint32_t aDataLen, bool aIsPrivateData
|
||||||
// as well as ensuring that private browsing mode is disabled
|
// as well as ensuring that private browsing mode is disabled
|
||||||
if (aDataLen > kLargeDatasetSize && !aIsPrivateData) {
|
if (aDataLen > kLargeDatasetSize && !aIsPrivateData) {
|
||||||
// if so, cache it to disk instead of memory
|
// if so, cache it to disk instead of memory
|
||||||
if ( NS_SUCCEEDED(WriteCache(aData, aDataLen)) )
|
if (NS_SUCCEEDED(WriteCache(aData, aDataLen))) {
|
||||||
|
// Clear previously set small data.
|
||||||
|
mData = nullptr;
|
||||||
|
mDataLen = 0;
|
||||||
return;
|
return;
|
||||||
else
|
}
|
||||||
NS_WARNING("Oh no, couldn't write data to the cache file");
|
NS_WARNING("Oh no, couldn't write data to the cache file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mCacheFD) {
|
||||||
|
// Clear previously set big data.
|
||||||
|
PR_Close(mCacheFD);
|
||||||
|
mCacheFD = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
mData = aData;
|
mData = aData;
|
||||||
mDataLen = aDataLen;
|
mDataLen = aDataLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
void
|
void
|
||||||
DataStruct::GetData(nsISupports** aData, uint32_t* aDataLen)
|
DataStruct::GetData(nsISupports** aData, uint32_t* aDataLen)
|
||||||
{
|
{
|
||||||
// check here to see if the data is cached on disk
|
// check here to see if the data is cached on disk
|
||||||
if ( !mData && mCacheFileName ) {
|
if (mCacheFD) {
|
||||||
// if so, read it in and pass it back
|
// if so, read it in and pass it back
|
||||||
// ReadCache creates memory and copies the data into it.
|
// ReadCache creates memory and copies the data into it.
|
||||||
if (NS_SUCCEEDED(ReadCache(aData, aDataLen)))
|
if (NS_SUCCEEDED(ReadCache(aData, aDataLen)))
|
||||||
|
|
@ -93,6 +102,8 @@ DataStruct::GetData ( nsISupports** aData, uint32_t *aDataLen )
|
||||||
NS_WARNING("Oh no, couldn't read data in from the cache file");
|
NS_WARNING("Oh no, couldn't read data in from the cache file");
|
||||||
*aData = nullptr;
|
*aData = nullptr;
|
||||||
*aDataLen = 0;
|
*aDataLen = 0;
|
||||||
|
PR_Close(mCacheFD);
|
||||||
|
mCacheFD = nullptr;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -104,118 +115,68 @@ DataStruct::GetData ( nsISupports** aData, uint32_t *aDataLen )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
already_AddRefed<nsIFile>
|
|
||||||
DataStruct::GetFileSpec(const char* aFileName)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIFile> cacheFile;
|
|
||||||
NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(cacheFile));
|
|
||||||
|
|
||||||
if (!cacheFile)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
// if the param aFileName contains a name we should use that
|
|
||||||
// because the file probably already exists
|
|
||||||
// otherwise create a unique name
|
|
||||||
if (!aFileName) {
|
|
||||||
cacheFile->AppendNative(NS_LITERAL_CSTRING("clipboardcache"));
|
|
||||||
nsresult rv = cacheFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return nullptr;
|
|
||||||
} else {
|
|
||||||
cacheFile->AppendNative(nsDependentCString(aFileName));
|
|
||||||
}
|
|
||||||
|
|
||||||
return cacheFile.forget();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
nsresult
|
nsresult
|
||||||
DataStruct::WriteCache(nsISupports* aData, uint32_t aDataLen)
|
DataStruct::WriteCache(nsISupports* aData, uint32_t aDataLen)
|
||||||
{
|
{
|
||||||
// Get a new path and file to the temp directory
|
nsresult rv;
|
||||||
nsCOMPtr<nsIFile> cacheFile = GetFileSpec(mCacheFileName);
|
if (!mCacheFD) {
|
||||||
if (cacheFile) {
|
rv = NS_OpenAnonymousTemporaryFile(&mCacheFD);
|
||||||
// remember the file name
|
if (NS_FAILED(rv)) {
|
||||||
if (!mCacheFileName) {
|
return NS_ERROR_FAILURE;
|
||||||
nsXPIDLCString fName;
|
|
||||||
cacheFile->GetNativeLeafName(fName);
|
|
||||||
mCacheFileName = strdup(fName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// write out the contents of the clipboard
|
|
||||||
// to the file
|
|
||||||
//uint32_t bytes;
|
|
||||||
nsCOMPtr<nsIOutputStream> outStr;
|
|
||||||
|
|
||||||
NS_NewLocalFileOutputStream(getter_AddRefs(outStr),
|
|
||||||
cacheFile);
|
|
||||||
|
|
||||||
if (!outStr) return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
void* buff = nullptr;
|
|
||||||
nsPrimitiveHelpers::CreateDataFromPrimitive ( mFlavor.get(), aData, &buff, aDataLen );
|
|
||||||
if ( buff ) {
|
|
||||||
uint32_t ignored;
|
|
||||||
outStr->Write(reinterpret_cast<char*>(buff), aDataLen, &ignored);
|
|
||||||
free(buff);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else if (PR_Seek64(mCacheFD, 0, PR_SEEK_SET) == -1) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// write out the contents of the clipboard to the file
|
||||||
|
void* buff = nullptr;
|
||||||
|
nsPrimitiveHelpers::CreateDataFromPrimitive(mFlavor.get(), aData, &buff, aDataLen);
|
||||||
|
if ( buff ) {
|
||||||
|
int32_t written = PR_Write(mCacheFD, buff, aDataLen);
|
||||||
|
free(buff);
|
||||||
|
if (written) {
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PR_Close(mCacheFD);
|
||||||
|
mCacheFD = nullptr;
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
nsresult
|
nsresult
|
||||||
DataStruct::ReadCache(nsISupports** aData, uint32_t* aDataLen)
|
DataStruct::ReadCache(nsISupports** aData, uint32_t* aDataLen)
|
||||||
{
|
{
|
||||||
// if we don't have a cache filename we are out of luck
|
// if we don't have a cache filename we are out of luck
|
||||||
if (!mCacheFileName)
|
if (!mCacheFD) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// get the path and file name
|
|
||||||
nsCOMPtr<nsIFile> cacheFile = GetFileSpec(mCacheFileName);
|
|
||||||
bool exists;
|
|
||||||
if ( cacheFile && NS_SUCCEEDED(cacheFile->Exists(&exists)) && exists ) {
|
|
||||||
// get the size of the file
|
|
||||||
int64_t fileSize;
|
|
||||||
int64_t max32 = 0xFFFFFFFF;
|
|
||||||
cacheFile->GetFileSize(&fileSize);
|
|
||||||
if (fileSize > max32)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
uint32_t size = uint32_t(fileSize);
|
|
||||||
// create new memory for the large clipboard data
|
|
||||||
auto data = mozilla::MakeUnique<char[]>(size);
|
|
||||||
if ( !data )
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
// now read it all in
|
|
||||||
nsCOMPtr<nsIInputStream> inStr;
|
|
||||||
NS_NewLocalFileInputStream( getter_AddRefs(inStr),
|
|
||||||
cacheFile);
|
|
||||||
|
|
||||||
if (!cacheFile) return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
nsresult rv = inStr->Read(data.get(), fileSize, aDataLen);
|
|
||||||
|
|
||||||
// make sure we got all the data ok
|
|
||||||
if (NS_SUCCEEDED(rv) && *aDataLen == size) {
|
|
||||||
nsPrimitiveHelpers::CreatePrimitiveForData(mFlavor.get(), data.get(),
|
|
||||||
fileSize, aData);
|
|
||||||
return *aData ? NS_OK : NS_ERROR_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// zero the return params
|
PRFileInfo fileInfo;
|
||||||
*aData = nullptr;
|
if (PR_GetOpenFileInfo(mCacheFD, &fileInfo) != PR_SUCCESS) {
|
||||||
*aDataLen = 0;
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
if (PR_Seek64(mCacheFD, 0, PR_SEEK_SET) == -1) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
uint32_t fileSize = fileInfo.size;
|
||||||
|
|
||||||
|
auto data = mozilla::MakeUnique<char[]>(fileSize);
|
||||||
|
if (!data) {
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t actual = PR_Read(mCacheFD, data.get(), fileSize);
|
||||||
|
if (actual != fileSize) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsPrimitiveHelpers::CreatePrimitiveForData(mFlavor.get(), data.get(), fileSize, aData);
|
||||||
|
*aDataLen = fileSize;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|
@ -484,22 +445,9 @@ nsTransferable::RemoveDataFlavor(const char *aDataFlavor)
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransferable::IsLargeDataSet(bool *_retval)
|
nsTransferable::SetConverter(nsIFormatConverter * aConverter)
|
||||||
{
|
|
||||||
MOZ_ASSERT(mInitialized);
|
|
||||||
|
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
|
||||||
*_retval = false;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
NS_IMETHODIMP nsTransferable::SetConverter(nsIFormatConverter * aConverter)
|
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mInitialized);
|
MOZ_ASSERT(mInitialized);
|
||||||
|
|
||||||
|
|
@ -512,7 +460,8 @@ NS_IMETHODIMP nsTransferable::SetConverter(nsIFormatConverter * aConverter)
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
NS_IMETHODIMP nsTransferable::GetConverter(nsIFormatConverter * *aConverter)
|
NS_IMETHODIMP
|
||||||
|
nsTransferable::GetConverter(nsIFormatConverter * *aConverter)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mInitialized);
|
MOZ_ASSERT(mInitialized);
|
||||||
|
|
||||||
|
|
@ -522,7 +471,6 @@ NS_IMETHODIMP nsTransferable::GetConverter(nsIFormatConverter * *aConverter)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// FlavorsTransferableCanImport
|
// FlavorsTransferableCanImport
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,15 @@
|
||||||
#ifndef nsTransferable_h__
|
#ifndef nsTransferable_h__
|
||||||
#define nsTransferable_h__
|
#define nsTransferable_h__
|
||||||
|
|
||||||
#include "nsIContentPolicyBase.h"
|
|
||||||
#include "nsIFormatConverter.h"
|
#include "nsIFormatConverter.h"
|
||||||
#include "nsITransferable.h"
|
#include "nsITransferable.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
#include "nsIPrincipal.h"
|
#include "nsIPrincipal.h"
|
||||||
|
#include "prio.h"
|
||||||
|
|
||||||
class nsIMutableArray;
|
class nsIMutableArray;
|
||||||
class nsString;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// DataStruct
|
// DataStruct
|
||||||
|
|
@ -25,21 +24,20 @@ class nsString;
|
||||||
struct DataStruct
|
struct DataStruct
|
||||||
{
|
{
|
||||||
explicit DataStruct ( const char* aFlavor )
|
explicit DataStruct ( const char* aFlavor )
|
||||||
: mDataLen(0), mFlavor(aFlavor), mCacheFileName(nullptr) { }
|
: mDataLen(0), mFlavor(aFlavor), mCacheFD(nullptr) { }
|
||||||
~DataStruct();
|
~DataStruct();
|
||||||
|
|
||||||
const nsCString& GetFlavor() const { return mFlavor; }
|
const nsCString& GetFlavor() const { return mFlavor; }
|
||||||
void SetData( nsISupports* inData, uint32_t inDataLen, bool aIsPrivateData );
|
void SetData( nsISupports* inData, uint32_t inDataLen, bool aIsPrivateData );
|
||||||
void GetData( nsISupports** outData, uint32_t *outDataLen );
|
void GetData( nsISupports** outData, uint32_t *outDataLen );
|
||||||
already_AddRefed<nsIFile> GetFileSpec(const char* aFileName);
|
bool IsDataAvailable() const { return mData ? mDataLen > 0 : mCacheFD != nullptr; }
|
||||||
bool IsDataAvailable() const { return (mData && mDataLen > 0) || (!mData && mCacheFileName); }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
// The size of data over which we write the data to disk rather than
|
// The size of data over which we write the data to disk rather than
|
||||||
// keep it around in memory.
|
// keep it around in memory.
|
||||||
kLargeDatasetSize = 1000000 // 1 million bytes
|
kLargeDatasetSize = 4194304 // 4 Megabytes
|
||||||
};
|
};
|
||||||
|
|
||||||
nsresult WriteCache(nsISupports* aData, uint32_t aDataLen );
|
nsresult WriteCache(nsISupports* aData, uint32_t aDataLen );
|
||||||
|
|
@ -47,8 +45,8 @@ protected:
|
||||||
|
|
||||||
nsCOMPtr<nsISupports> mData; // OWNER - some varient of primitive wrapper
|
nsCOMPtr<nsISupports> mData; // OWNER - some varient of primitive wrapper
|
||||||
uint32_t mDataLen;
|
uint32_t mDataLen;
|
||||||
|
PRFileDesc* mCacheFD;
|
||||||
const nsCString mFlavor;
|
const nsCString mFlavor;
|
||||||
char * mCacheFileName;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue