mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 672843 part C - convert most of XPCOM except for xpcom/tests, r=vdjeric
This commit is contained in:
parent
f72af0bb16
commit
9bfc4e98e3
@ -1221,12 +1221,14 @@ public:
|
|||||||
// want scripts which poll the filesystem looking for gc/cc dumps to
|
// want scripts which poll the filesystem looking for gc/cc dumps to
|
||||||
// grab a file before we're finished writing to it.)
|
// grab a file before we're finished writing to it.)
|
||||||
nsCOMPtr<nsIFile> gcLogFile = CreateTempFile("incomplete-gc-edges");
|
nsCOMPtr<nsIFile> gcLogFile = CreateTempFile("incomplete-gc-edges");
|
||||||
NS_ENSURE_STATE(gcLogFile);
|
if (NS_WARN_IF(!gcLogFile))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
// Dump the JS heap.
|
// Dump the JS heap.
|
||||||
FILE* gcLogANSIFile = nullptr;
|
FILE* gcLogANSIFile = nullptr;
|
||||||
gcLogFile->OpenANSIFileDesc("w", &gcLogANSIFile);
|
gcLogFile->OpenANSIFileDesc("w", &gcLogANSIFile);
|
||||||
NS_ENSURE_STATE(gcLogANSIFile);
|
if (NS_WARN_IF(!gcLogANSIFile))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
MozillaRegisterDebugFILE(gcLogANSIFile);
|
MozillaRegisterDebugFILE(gcLogANSIFile);
|
||||||
CollectorData *data = sCollectorData.get();
|
CollectorData *data = sCollectorData.get();
|
||||||
if (data && data->mRuntime)
|
if (data && data->mRuntime)
|
||||||
@ -1237,11 +1239,13 @@ public:
|
|||||||
// Strip off "incomplete-".
|
// Strip off "incomplete-".
|
||||||
nsCOMPtr<nsIFile> gcLogFileFinalDestination =
|
nsCOMPtr<nsIFile> gcLogFileFinalDestination =
|
||||||
CreateTempFile("gc-edges");
|
CreateTempFile("gc-edges");
|
||||||
NS_ENSURE_STATE(gcLogFileFinalDestination);
|
if (NS_WARN_IF(!gcLogFileFinalDestination))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
nsAutoString gcLogFileFinalDestinationName;
|
nsAutoString gcLogFileFinalDestinationName;
|
||||||
gcLogFileFinalDestination->GetLeafName(gcLogFileFinalDestinationName);
|
gcLogFileFinalDestination->GetLeafName(gcLogFileFinalDestinationName);
|
||||||
NS_ENSURE_STATE(!gcLogFileFinalDestinationName.IsEmpty());
|
if (NS_WARN_IF(gcLogFileFinalDestinationName.IsEmpty()))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
gcLogFile->MoveTo(/* directory */ nullptr, gcLogFileFinalDestinationName);
|
gcLogFile->MoveTo(/* directory */ nullptr, gcLogFileFinalDestinationName);
|
||||||
|
|
||||||
@ -1260,10 +1264,12 @@ public:
|
|||||||
// Open a file for dumping the CC graph. We again prefix with
|
// Open a file for dumping the CC graph. We again prefix with
|
||||||
// "incomplete-".
|
// "incomplete-".
|
||||||
mOutFile = CreateTempFile("incomplete-cc-edges");
|
mOutFile = CreateTempFile("incomplete-cc-edges");
|
||||||
NS_ENSURE_STATE(mOutFile);
|
if (NS_WARN_IF(!mOutFile))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
MOZ_ASSERT(!mStream);
|
MOZ_ASSERT(!mStream);
|
||||||
mOutFile->OpenANSIFileDesc("w", &mStream);
|
mOutFile->OpenANSIFileDesc("w", &mStream);
|
||||||
NS_ENSURE_STATE(mStream);
|
if (NS_WARN_IF(!mStream))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
MozillaRegisterDebugFILE(mStream);
|
MozillaRegisterDebugFILE(mStream);
|
||||||
|
|
||||||
fprintf(mStream, "# WantAllTraces=%s\n", mWantAllTraces ? "true" : "false");
|
fprintf(mStream, "# WantAllTraces=%s\n", mWantAllTraces ? "true" : "false");
|
||||||
@ -1388,11 +1394,13 @@ public:
|
|||||||
// Strip off "incomplete-" from the log file's name.
|
// Strip off "incomplete-" from the log file's name.
|
||||||
nsCOMPtr<nsIFile> logFileFinalDestination =
|
nsCOMPtr<nsIFile> logFileFinalDestination =
|
||||||
CreateTempFile("cc-edges");
|
CreateTempFile("cc-edges");
|
||||||
NS_ENSURE_STATE(logFileFinalDestination);
|
if (NS_WARN_IF(!logFileFinalDestination))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
nsAutoString logFileFinalDestinationName;
|
nsAutoString logFileFinalDestinationName;
|
||||||
logFileFinalDestination->GetLeafName(logFileFinalDestinationName);
|
logFileFinalDestination->GetLeafName(logFileFinalDestinationName);
|
||||||
NS_ENSURE_STATE(!logFileFinalDestinationName.IsEmpty());
|
if (NS_WARN_IF(logFileFinalDestinationName.IsEmpty()))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
mOutFile->MoveTo(/* directory = */ nullptr,
|
mOutFile->MoveTo(/* directory = */ nullptr,
|
||||||
logFileFinalDestinationName);
|
logFileFinalDestinationName);
|
||||||
@ -1415,7 +1423,8 @@ public:
|
|||||||
NS_IMETHOD ProcessNext(nsICycleCollectorHandler* aHandler,
|
NS_IMETHOD ProcessNext(nsICycleCollectorHandler* aHandler,
|
||||||
bool* aCanContinue)
|
bool* aCanContinue)
|
||||||
{
|
{
|
||||||
NS_ENSURE_STATE(aHandler && mWantAfterProcessing);
|
if (NS_WARN_IF(!aHandler) || NS_WARN_IF(!mWantAfterProcessing))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
CCGraphDescriber* d = mDescribers.popFirst();
|
CCGraphDescriber* d = mDescribers.popFirst();
|
||||||
if (d) {
|
if (d) {
|
||||||
switch (d->mType) {
|
switch (d->mType) {
|
||||||
@ -1515,7 +1524,8 @@ nsCycleCollectorLoggerConstructor(nsISupports* aOuter,
|
|||||||
const nsIID& aIID,
|
const nsIID& aIID,
|
||||||
void* *aInstancePtr)
|
void* *aInstancePtr)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(!aOuter, NS_ERROR_NO_AGGREGATION);
|
if (NS_WARN_IF(aOuter))
|
||||||
|
return NS_ERROR_NO_AGGREGATION;
|
||||||
|
|
||||||
nsISupports *logger = new nsCycleCollectorLogger();
|
nsISupports *logger = new nsCycleCollectorLogger();
|
||||||
|
|
||||||
@ -2438,7 +2448,8 @@ class CycleCollectorReporter MOZ_FINAL : public MemoryMultiReporter
|
|||||||
nsIMemoryReporter::KIND_HEAP, \
|
nsIMemoryReporter::KIND_HEAP, \
|
||||||
nsIMemoryReporter::UNITS_BYTES, _amount, \
|
nsIMemoryReporter::UNITS_BYTES, _amount, \
|
||||||
NS_LITERAL_CSTRING(_desc), aClosure); \
|
NS_LITERAL_CSTRING(_desc), aClosure); \
|
||||||
NS_ENSURE_SUCCESS(rv, rv); \
|
if (NS_WARN_IF(NS_FAILED(rv))) \
|
||||||
|
return rv; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
@ -565,7 +565,8 @@ static const nsDebugImpl kImpl;
|
|||||||
nsresult
|
nsresult
|
||||||
nsDebugImpl::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
|
nsDebugImpl::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
|
||||||
{
|
{
|
||||||
NS_ENSURE_NO_AGGREGATION(outer);
|
if (NS_WARN_IF(outer))
|
||||||
|
return NS_ERROR_NO_AGGREGATION;
|
||||||
|
|
||||||
return const_cast<nsDebugImpl*>(&kImpl)->
|
return const_cast<nsDebugImpl*>(&kImpl)->
|
||||||
QueryInterface(aIID, aInstancePtr);
|
QueryInterface(aIID, aInstancePtr);
|
||||||
|
@ -65,7 +65,8 @@ NS_IMPL_ISUPPORTS1(nsErrorService, nsIErrorService)
|
|||||||
nsresult
|
nsresult
|
||||||
nsErrorService::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
|
nsErrorService::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
|
||||||
{
|
{
|
||||||
NS_ENSURE_NO_AGGREGATION(outer);
|
if (NS_WARN_IF(outer))
|
||||||
|
return NS_ERROR_NO_AGGREGATION;
|
||||||
nsRefPtr<nsErrorService> serv = new nsErrorService();
|
nsRefPtr<nsErrorService> serv = new nsErrorService();
|
||||||
return serv->QueryInterface(aIID, aInstancePtr);
|
return serv->QueryInterface(aIID, aInstancePtr);
|
||||||
}
|
}
|
||||||
|
@ -33,21 +33,25 @@ nsGZFileWriter::~nsGZFileWriter()
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsGZFileWriter::Init(nsIFile* aFile)
|
nsGZFileWriter::Init(nsIFile* aFile)
|
||||||
{
|
{
|
||||||
NS_ENSURE_FALSE(mInitialized, NS_ERROR_FAILURE);
|
if (NS_WARN_IF(mInitialized) ||
|
||||||
NS_ENSURE_FALSE(mFinished, NS_ERROR_FAILURE);
|
NS_WARN_IF(mFinished))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// Get a FILE out of our nsIFile. Convert that into a file descriptor which
|
// Get a FILE out of our nsIFile. Convert that into a file descriptor which
|
||||||
// gzip can own. Then close our FILE, leaving only gzip's fd open.
|
// gzip can own. Then close our FILE, leaving only gzip's fd open.
|
||||||
|
|
||||||
FILE* file;
|
FILE* file;
|
||||||
nsresult rv = aFile->OpenANSIFileDesc("wb", &file);
|
nsresult rv = aFile->OpenANSIFileDesc("wb", &file);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
mGZFile = gzdopen(dup(fileno(file)), "wb");
|
mGZFile = gzdopen(dup(fileno(file)), "wb");
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
// gzdopen returns nullptr on error.
|
// gzdopen returns nullptr on error.
|
||||||
NS_ENSURE_TRUE(mGZFile, NS_ERROR_FAILURE);
|
if (NS_WARN_IF(!mGZFile))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
mInitialized = true;
|
mInitialized = true;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -56,8 +60,9 @@ nsGZFileWriter::Init(nsIFile* aFile)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsGZFileWriter::Write(const nsACString& aStr)
|
nsGZFileWriter::Write(const nsACString& aStr)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mInitialized) ||
|
||||||
NS_ENSURE_FALSE(mFinished, NS_ERROR_FAILURE);
|
NS_WARN_IF(mFinished))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// gzwrite uses a return value of 0 to indicate failure. Otherwise, it
|
// gzwrite uses a return value of 0 to indicate failure. Otherwise, it
|
||||||
// returns the number of uncompressed bytes written. To ensure we can
|
// returns the number of uncompressed bytes written. To ensure we can
|
||||||
@ -71,7 +76,8 @@ nsGZFileWriter::Write(const nsACString& aStr)
|
|||||||
// always be either 0 or aStr.Length(), and we shouldn't have to call it
|
// always be either 0 or aStr.Length(), and we shouldn't have to call it
|
||||||
// multiple times in order to get it to read the whole buffer.
|
// multiple times in order to get it to read the whole buffer.
|
||||||
int rv = gzwrite(mGZFile, aStr.BeginReading(), aStr.Length());
|
int rv = gzwrite(mGZFile, aStr.BeginReading(), aStr.Length());
|
||||||
NS_ENSURE_TRUE(rv == static_cast<int>(aStr.Length()), NS_ERROR_FAILURE);
|
if (NS_WARN_IF(rv != static_cast<int>(aStr.Length())))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -79,8 +85,9 @@ nsGZFileWriter::Write(const nsACString& aStr)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsGZFileWriter::Finish()
|
nsGZFileWriter::Finish()
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mInitialized) ||
|
||||||
NS_ENSURE_FALSE(mFinished, NS_ERROR_FAILURE);
|
NS_WARN_IF(mFinished))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
mFinished = true;
|
mFinished = true;
|
||||||
gzclose(mGZFile);
|
gzclose(mGZFile);
|
||||||
|
@ -535,7 +535,8 @@ public:
|
|||||||
{
|
{
|
||||||
int64_t amount;
|
int64_t amount;
|
||||||
nsresult rv = GetAmount(&amount);
|
nsresult rv = GetAmount(&amount);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
return aCallback->Callback(EmptyCString(), mNameAndPath, mKind, mUnits,
|
return aCallback->Callback(EmptyCString(), mNameAndPath, mKind, mUnits,
|
||||||
amount, mDescription, aData);
|
amount, mDescription, aData);
|
||||||
|
@ -89,7 +89,8 @@ nsresult nsMacUtilsImpl::GetArchString(nsAString& archString)
|
|||||||
|
|
||||||
NS_IMETHODIMP nsMacUtilsImpl::GetIsUniversalBinary(bool *aIsUniversalBinary)
|
NS_IMETHODIMP nsMacUtilsImpl::GetIsUniversalBinary(bool *aIsUniversalBinary)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aIsUniversalBinary);
|
if (NS_WARN_IF(!aIsUniversalBinary))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
*aIsUniversalBinary = false;
|
*aIsUniversalBinary = false;
|
||||||
|
|
||||||
nsAutoString archString;
|
nsAutoString archString;
|
||||||
|
@ -93,7 +93,8 @@ nsMemoryImpl::IsLowMemoryPlatform(bool *result)
|
|||||||
/*static*/ nsresult
|
/*static*/ nsresult
|
||||||
nsMemoryImpl::Create(nsISupports* outer, const nsIID& aIID, void **aResult)
|
nsMemoryImpl::Create(nsISupports* outer, const nsIID& aIID, void **aResult)
|
||||||
{
|
{
|
||||||
NS_ENSURE_NO_AGGREGATION(outer);
|
if (NS_WARN_IF(outer))
|
||||||
|
return NS_ERROR_NO_AGGREGATION;
|
||||||
return sGlobalMemory.QueryInterface(aIID, aResult);
|
return sGlobalMemory.QueryInterface(aIID, aResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,15 +416,18 @@ public:
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(file));
|
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(file));
|
||||||
NS_ENSURE_SUCCESS(rv, -1);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = file->AppendNative(NS_LITERAL_CSTRING("debug_info_trigger"));
|
rv = file->AppendNative(NS_LITERAL_CSTRING("debug_info_trigger"));
|
||||||
NS_ENSURE_SUCCESS(rv, -1);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
nsAutoCString path;
|
nsAutoCString path;
|
||||||
rv = file->GetNativePath(path);
|
rv = file->GetNativePath(path);
|
||||||
NS_ENSURE_SUCCESS(rv, -1);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
// unlink might fail because the file doesn't exist, or for other reasons.
|
// unlink might fail because the file doesn't exist, or for other reasons.
|
||||||
// But we don't care it fails; any problems will be detected later, when we
|
// But we don't care it fails; any problems will be detected later, when we
|
||||||
@ -606,7 +609,8 @@ namespace mozilla {
|
|||||||
#define DUMP(o, s) \
|
#define DUMP(o, s) \
|
||||||
do { \
|
do { \
|
||||||
nsresult rv = (o)->Write(s); \
|
nsresult rv = (o)->Write(s); \
|
||||||
NS_ENSURE_SUCCESS(rv, rv); \
|
if (NS_WARN_IF(NS_FAILED(rv))) \
|
||||||
|
return rv; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static nsresult
|
static nsresult
|
||||||
@ -680,7 +684,8 @@ public:
|
|||||||
nsISupports *aData)
|
nsISupports *aData)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIGZFileWriter> writer = do_QueryInterface(aData);
|
nsCOMPtr<nsIGZFileWriter> writer = do_QueryInterface(aData);
|
||||||
NS_ENSURE_TRUE(writer, NS_ERROR_FAILURE);
|
if (NS_WARN_IF(!writer))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
nsresult rv = DumpReport(writer, mIsFirst, aProcess, aPath, aKind, aUnits,
|
nsresult rv = DumpReport(writer, mIsFirst, aProcess, aPath, aKind, aUnits,
|
||||||
aAmount, aDescription);
|
aAmount, aDescription);
|
||||||
@ -722,7 +727,8 @@ nsMemoryInfoDumper::OpenTempFile(const nsACString &aFilename, nsIFile* *aFile)
|
|||||||
nsresult rv;
|
nsresult rv;
|
||||||
if (!*aFile) {
|
if (!*aFile) {
|
||||||
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, aFile);
|
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, aFile);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
@ -731,7 +737,8 @@ nsMemoryInfoDumper::OpenTempFile(const nsACString &aFilename, nsIFile* *aFile)
|
|||||||
// users to be able to remove these files, so we write them into a
|
// users to be able to remove these files, so we write them into a
|
||||||
// subdirectory of the temp directory and chmod 777 that directory.
|
// subdirectory of the temp directory and chmod 777 that directory.
|
||||||
rv = (*aFile)->AppendNative(NS_LITERAL_CSTRING("memory-reports"));
|
rv = (*aFile)->AppendNative(NS_LITERAL_CSTRING("memory-reports"));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
// It's OK if this fails; that probably just means that the directory already
|
// It's OK if this fails; that probably just means that the directory already
|
||||||
// exists.
|
// exists.
|
||||||
@ -739,7 +746,8 @@ nsMemoryInfoDumper::OpenTempFile(const nsACString &aFilename, nsIFile* *aFile)
|
|||||||
|
|
||||||
nsAutoCString dirPath;
|
nsAutoCString dirPath;
|
||||||
rv = (*aFile)->GetNativePath(dirPath);
|
rv = (*aFile)->GetNativePath(dirPath);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
while (chmod(dirPath.get(), 0777) == -1 && errno == EINTR) {}
|
while (chmod(dirPath.get(), 0777) == -1 && errno == EINTR) {}
|
||||||
#endif
|
#endif
|
||||||
@ -747,10 +755,12 @@ nsMemoryInfoDumper::OpenTempFile(const nsACString &aFilename, nsIFile* *aFile)
|
|||||||
nsCOMPtr<nsIFile> file(*aFile);
|
nsCOMPtr<nsIFile> file(*aFile);
|
||||||
|
|
||||||
rv = file->AppendNative(aFilename);
|
rv = file->AppendNative(aFilename);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
rv = file->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0666);
|
rv = file->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0666);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
// Make this file world-read/writable; the permissions passed to the
|
// Make this file world-read/writable; the permissions passed to the
|
||||||
@ -758,7 +768,8 @@ nsMemoryInfoDumper::OpenTempFile(const nsACString &aFilename, nsIFile* *aFile)
|
|||||||
// umask.
|
// umask.
|
||||||
nsAutoCString path;
|
nsAutoCString path;
|
||||||
rv = file->GetNativePath(path);
|
rv = file->GetNativePath(path);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
while (chmod(path.get(), 0666) == -1 && errno == EINTR) {}
|
while (chmod(path.get(), 0666) == -1 && errno == EINTR) {}
|
||||||
#endif
|
#endif
|
||||||
@ -801,7 +812,8 @@ DumpHeader(nsIGZFileWriter* aWriter)
|
|||||||
|
|
||||||
nsCOMPtr<nsIMemoryReporterManager> mgr =
|
nsCOMPtr<nsIMemoryReporterManager> mgr =
|
||||||
do_GetService("@mozilla.org/memory-reporter-manager;1");
|
do_GetService("@mozilla.org/memory-reporter-manager;1");
|
||||||
NS_ENSURE_STATE(mgr);
|
if (NS_WARN_IF(!mgr))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
DUMP(aWriter, mgr->GetHasMozMallocUsableSize() ? "true" : "false");
|
DUMP(aWriter, mgr->GetHasMozMallocUsableSize() ? "true" : "false");
|
||||||
DUMP(aWriter, ",\n");
|
DUMP(aWriter, ",\n");
|
||||||
@ -872,11 +884,12 @@ DumpProcessMemoryInfoToTempDir(const nsAString& aIdentifier)
|
|||||||
rv = nsMemoryInfoDumper::OpenTempFile(NS_LITERAL_CSTRING("incomplete-") +
|
rv = nsMemoryInfoDumper::OpenTempFile(NS_LITERAL_CSTRING("incomplete-") +
|
||||||
mrFilename,
|
mrFilename,
|
||||||
getter_AddRefs(mrTmpFile));
|
getter_AddRefs(mrTmpFile));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
return rv;
|
||||||
|
|
||||||
nsRefPtr<nsGZFileWriter> mrWriter = new nsGZFileWriter();
|
nsRefPtr<nsGZFileWriter> mrWriter = new nsGZFileWriter();
|
||||||
rv = mrWriter->Init(mrTmpFile);
|
rv = mrWriter->Init(mrTmpFile);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
// Dump the memory reports to the file.
|
// Dump the memory reports to the file.
|
||||||
DumpProcessMemoryReportsToGZFileWriter(mrWriter);
|
DumpProcessMemoryReportsToGZFileWriter(mrWriter);
|
||||||
@ -894,11 +907,13 @@ DumpProcessMemoryInfoToTempDir(const nsAString& aIdentifier)
|
|||||||
|
|
||||||
nsCOMPtr<nsIFile> dmdFile;
|
nsCOMPtr<nsIFile> dmdFile;
|
||||||
rv = nsMemoryInfoDumper::OpenTempFile(dmdFilename, getter_AddRefs(dmdFile));
|
rv = nsMemoryInfoDumper::OpenTempFile(dmdFilename, getter_AddRefs(dmdFile));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
nsRefPtr<nsGZFileWriter> dmdWriter = new nsGZFileWriter();
|
nsRefPtr<nsGZFileWriter> dmdWriter = new nsGZFileWriter();
|
||||||
rv = dmdWriter->Init(dmdFile);
|
rv = dmdWriter->Init(dmdFile);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
// Dump DMD output to the file.
|
// Dump DMD output to the file.
|
||||||
|
|
||||||
@ -907,7 +922,8 @@ DumpProcessMemoryInfoToTempDir(const nsAString& aIdentifier)
|
|||||||
dmd::Dump(w);
|
dmd::Dump(w);
|
||||||
|
|
||||||
rv = dmdWriter->Finish();
|
rv = dmdWriter->Finish();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
#endif // MOZ_DMD
|
#endif // MOZ_DMD
|
||||||
|
|
||||||
// The call to Finish() deallocates the memory allocated by mrWriter's first
|
// The call to Finish() deallocates the memory allocated by mrWriter's first
|
||||||
@ -916,42 +932,51 @@ DumpProcessMemoryInfoToTempDir(const nsAString& aIdentifier)
|
|||||||
// them -- by "heap-allocated" if nothing else -- we want DMD to see it as
|
// them -- by "heap-allocated" if nothing else -- we want DMD to see it as
|
||||||
// well. So we deliberately don't call Finish() until after DMD finishes.
|
// well. So we deliberately don't call Finish() until after DMD finishes.
|
||||||
rv = mrWriter->Finish();
|
rv = mrWriter->Finish();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
// Rename the memory reports file, now that we're done writing all the files.
|
// Rename the memory reports file, now that we're done writing all the files.
|
||||||
// Its final name is "memory-report<-identifier>-<pid>.json.gz".
|
// Its final name is "memory-report<-identifier>-<pid>.json.gz".
|
||||||
|
|
||||||
nsCOMPtr<nsIFile> mrFinalFile;
|
nsCOMPtr<nsIFile> mrFinalFile;
|
||||||
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(mrFinalFile));
|
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(mrFinalFile));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
rv = mrFinalFile->AppendNative(NS_LITERAL_CSTRING("memory-reports"));
|
rv = mrFinalFile->AppendNative(NS_LITERAL_CSTRING("memory-reports"));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rv = mrFinalFile->AppendNative(mrFilename);
|
rv = mrFinalFile->AppendNative(mrFilename);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
rv = mrFinalFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
|
rv = mrFinalFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
nsAutoString mrActualFinalFilename;
|
nsAutoString mrActualFinalFilename;
|
||||||
rv = mrFinalFile->GetLeafName(mrActualFinalFilename);
|
rv = mrFinalFile->GetLeafName(mrActualFinalFilename);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
rv = mrTmpFile->MoveTo(/* directory */ nullptr, mrActualFinalFilename);
|
rv = mrTmpFile->MoveTo(/* directory */ nullptr, mrActualFinalFilename);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
// Write a message to the console.
|
// Write a message to the console.
|
||||||
|
|
||||||
nsCOMPtr<nsIConsoleService> cs =
|
nsCOMPtr<nsIConsoleService> cs =
|
||||||
do_GetService(NS_CONSOLESERVICE_CONTRACTID, &rv);
|
do_GetService(NS_CONSOLESERVICE_CONTRACTID, &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
nsString path;
|
nsString path;
|
||||||
mrTmpFile->GetPath(path);
|
mrTmpFile->GetPath(path);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
nsString msg = NS_LITERAL_STRING(
|
nsString msg = NS_LITERAL_STRING(
|
||||||
"nsIMemoryInfoDumper dumped reports to ");
|
"nsIMemoryInfoDumper dumped reports to ");
|
||||||
@ -988,7 +1013,8 @@ nsMemoryInfoDumper::DumpMemoryInfoToTempDir(const nsAString& aIdentifier,
|
|||||||
/* dumpChildProcesses = */ false);
|
/* dumpChildProcesses = */ false);
|
||||||
nsCOMPtr<nsIMemoryReporterManager> mgr =
|
nsCOMPtr<nsIMemoryReporterManager> mgr =
|
||||||
do_GetService("@mozilla.org/memory-reporter-manager;1");
|
do_GetService("@mozilla.org/memory-reporter-manager;1");
|
||||||
NS_ENSURE_TRUE(mgr, NS_ERROR_FAILURE);
|
if (NS_WARN_IF(!mgr))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
nsCOMPtr<nsICancelableRunnable> runnable;
|
nsCOMPtr<nsICancelableRunnable> runnable;
|
||||||
mgr->MinimizeMemoryUsage(callback, getter_AddRefs(runnable));
|
mgr->MinimizeMemoryUsage(callback, getter_AddRefs(runnable));
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -1043,28 +1069,34 @@ nsMemoryInfoDumper::DumpMemoryReportsToNamedFile(
|
|||||||
|
|
||||||
nsCOMPtr<nsIFile> mrFile;
|
nsCOMPtr<nsIFile> mrFile;
|
||||||
nsresult rv = NS_NewLocalFile(aFilename, false, getter_AddRefs(mrFile));
|
nsresult rv = NS_NewLocalFile(aFilename, false, getter_AddRefs(mrFile));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
mrFile->InitWithPath(aFilename);
|
mrFile->InitWithPath(aFilename);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
bool exists;
|
bool exists;
|
||||||
rv = mrFile->Exists(&exists);
|
rv = mrFile->Exists(&exists);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
rv = mrFile->Create(nsIFile::NORMAL_FILE_TYPE, 0644);
|
rv = mrFile->Create(nsIFile::NORMAL_FILE_TYPE, 0644);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the memory reports to the file.
|
// Write the memory reports to the file.
|
||||||
|
|
||||||
nsRefPtr<nsGZFileWriter> mrWriter = new nsGZFileWriter();
|
nsRefPtr<nsGZFileWriter> mrWriter = new nsGZFileWriter();
|
||||||
rv = mrWriter->Init(mrFile);
|
rv = mrWriter->Init(mrFile);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
rv = DumpHeader(mrWriter);
|
rv = DumpHeader(mrWriter);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
// Process reports and finish up.
|
// Process reports and finish up.
|
||||||
nsRefPtr<DumpReportCallback> dumpReport = new DumpReportCallback();
|
nsRefPtr<DumpReportCallback> dumpReport = new DumpReportCallback();
|
||||||
|
@ -102,7 +102,8 @@ private:
|
|||||||
*aAmount = 0;
|
*aAmount = 0;
|
||||||
|
|
||||||
FILE *f = fopen("/proc/self/smaps", "r");
|
FILE *f = fopen("/proc/self/smaps", "r");
|
||||||
NS_ENSURE_STATE(f);
|
if (NS_WARN_IF(!f))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
int64_t total = 0;
|
int64_t total = 0;
|
||||||
char line[256];
|
char line[256];
|
||||||
@ -752,7 +753,8 @@ public:
|
|||||||
nsIMemoryReporter::KIND_HEAP, \
|
nsIMemoryReporter::KIND_HEAP, \
|
||||||
nsIMemoryReporter::UNITS_BYTES, _amount, \
|
nsIMemoryReporter::UNITS_BYTES, _amount, \
|
||||||
NS_LITERAL_CSTRING(_desc), aData); \
|
NS_LITERAL_CSTRING(_desc), aData); \
|
||||||
NS_ENSURE_SUCCESS(rv, rv); \
|
if (NS_WARN_IF(NS_FAILED(rv))) \
|
||||||
|
return rv; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
REPORT("explicit/dmd/stack-traces/used",
|
REPORT("explicit/dmd/stack-traces/used",
|
||||||
@ -1284,7 +1286,8 @@ NS_IMPL_ISUPPORTS1(ExplicitCallback, nsIHandleReportCallback)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsMemoryReporterManager::GetExplicit(int64_t* aAmount)
|
nsMemoryReporterManager::GetExplicit(int64_t* aAmount)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aAmount);
|
if (NS_WARN_IF(!aAmount))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
*aAmount = 0;
|
*aAmount = 0;
|
||||||
#ifndef HAVE_JEMALLOC_STATS
|
#ifndef HAVE_JEMALLOC_STATS
|
||||||
return NS_ERROR_NOT_AVAILABLE;
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
@ -1550,7 +1553,8 @@ NS_IMETHODIMP
|
|||||||
nsMemoryReporterManager::MinimizeMemoryUsage(nsIRunnable* aCallback,
|
nsMemoryReporterManager::MinimizeMemoryUsage(nsIRunnable* aCallback,
|
||||||
nsICancelableRunnable** aResult)
|
nsICancelableRunnable** aResult)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aResult);
|
if (NS_WARN_IF(!aResult))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsRefPtr<nsICancelableRunnable> runnable =
|
nsRefPtr<nsICancelableRunnable> runnable =
|
||||||
new MinimizeMemoryUsageRunnable(aCallback);
|
new MinimizeMemoryUsageRunnable(aCallback);
|
||||||
@ -1573,7 +1577,8 @@ nsMemoryReporterManager::SizeOfTab(nsIDOMWindow* aTopWindow,
|
|||||||
{
|
{
|
||||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aTopWindow);
|
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aTopWindow);
|
||||||
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(aTopWindow);
|
nsCOMPtr<nsPIDOMWindow> piWindow = do_QueryInterface(aTopWindow);
|
||||||
NS_ENSURE_TRUE(!!global && !!piWindow, NS_ERROR_FAILURE);
|
if (NS_WARN_IF(!global) || NS_WARN_IF(!piWindow))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
TimeStamp t1 = TimeStamp::Now();
|
TimeStamp t1 = TimeStamp::Now();
|
||||||
|
|
||||||
@ -1583,7 +1588,8 @@ nsMemoryReporterManager::SizeOfTab(nsIDOMWindow* aTopWindow,
|
|||||||
nsresult rv = mSizeOfTabFns.mJS(global->GetGlobalJSObject(),
|
nsresult rv = mSizeOfTabFns.mJS(global->GetGlobalJSObject(),
|
||||||
&jsObjectsSize, &jsStringsSize,
|
&jsObjectsSize, &jsStringsSize,
|
||||||
&jsPrivateSize, &jsOtherSize);
|
&jsPrivateSize, &jsOtherSize);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
TimeStamp t2 = TimeStamp::Now();
|
TimeStamp t2 = TimeStamp::Now();
|
||||||
|
|
||||||
|
@ -87,7 +87,8 @@ nsresult
|
|||||||
MessageLoopIdleTask::Init(uint32_t aEnsureRunsAfterMS)
|
MessageLoopIdleTask::Init(uint32_t aEnsureRunsAfterMS)
|
||||||
{
|
{
|
||||||
mTimer = do_CreateInstance("@mozilla.org/timer;1");
|
mTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||||
NS_ENSURE_STATE(mTimer);
|
if (NS_WARN_IF(!mTimer))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
nsRefPtr<MessageLoopTimerCallback> callback =
|
nsRefPtr<MessageLoopTimerCallback> callback =
|
||||||
new MessageLoopTimerCallback(this);
|
new MessageLoopTimerCallback(this);
|
||||||
@ -153,7 +154,8 @@ nsMessageLoopConstructor(nsISupports* aOuter,
|
|||||||
const nsIID& aIID,
|
const nsIID& aIID,
|
||||||
void** aInstancePtr)
|
void** aInstancePtr)
|
||||||
{
|
{
|
||||||
NS_ENSURE_FALSE(aOuter, NS_ERROR_NO_AGGREGATION);
|
if (NS_WARN_IF(aOuter))
|
||||||
|
return NS_ERROR_NO_AGGREGATION;
|
||||||
nsISupports* messageLoop = new nsMessageLoop();
|
nsISupports* messageLoop = new nsMessageLoop();
|
||||||
return messageLoop->QueryInterface(aIID, aInstancePtr);
|
return messageLoop->QueryInterface(aIID, aInstancePtr);
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,8 @@ nsSystemInfo::Init()
|
|||||||
if (PR_GetSystemInfo(items[i].cmd, buf, sizeof(buf)) == PR_SUCCESS) {
|
if (PR_GetSystemInfo(items[i].cmd, buf, sizeof(buf)) == PR_SUCCESS) {
|
||||||
rv = SetPropertyAsACString(NS_ConvertASCIItoUTF16(items[i].name),
|
rv = SetPropertyAsACString(NS_ConvertASCIItoUTF16(items[i].name),
|
||||||
nsDependentCString(buf));
|
nsDependentCString(buf));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NS_WARNING("PR_GetSystemInfo failed");
|
NS_WARNING("PR_GetSystemInfo failed");
|
||||||
@ -182,7 +183,8 @@ nsSystemInfo::Init()
|
|||||||
for (uint32_t i = 0; i < ArrayLength(cpuPropItems); i++) {
|
for (uint32_t i = 0; i < ArrayLength(cpuPropItems); i++) {
|
||||||
rv = SetPropertyAsBool(NS_ConvertASCIItoUTF16(cpuPropItems[i].name),
|
rv = SetPropertyAsBool(NS_ConvertASCIItoUTF16(cpuPropItems[i].name),
|
||||||
cpuPropItems[i].propfun());
|
cpuPropItems[i].propfun());
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
@ -191,7 +193,8 @@ nsSystemInfo::Init()
|
|||||||
NS_WARN_IF_FALSE(gotWow64Value, "IsWow64Process failed");
|
NS_WARN_IF_FALSE(gotWow64Value, "IsWow64Process failed");
|
||||||
if (gotWow64Value) {
|
if (gotWow64Value) {
|
||||||
rv = SetPropertyAsBool(NS_LITERAL_STRING("isWow64"), !!isWow64);
|
rv = SetPropertyAsBool(NS_LITERAL_STRING("isWow64"), !!isWow64);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
nsAutoCString hddModel, hddRevision;
|
nsAutoCString hddModel, hddRevision;
|
||||||
if (NS_SUCCEEDED(GetProfileHDDInfo(hddModel, hddRevision))) {
|
if (NS_SUCCEEDED(GetProfileHDDInfo(hddModel, hddRevision))) {
|
||||||
@ -210,7 +213,8 @@ nsSystemInfo::Init()
|
|||||||
rv = SetPropertyAsACString(NS_LITERAL_STRING("secondaryLibrary"),
|
rv = SetPropertyAsACString(NS_LITERAL_STRING("secondaryLibrary"),
|
||||||
nsDependentCString(gtkver));
|
nsDependentCString(gtkver));
|
||||||
PR_smprintf_free(gtkver);
|
PR_smprintf_free(gtkver);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -145,7 +145,8 @@ Omnijar::GetURIString(Type aType, nsACString &result)
|
|||||||
nsAutoCString omniJarSpec;
|
nsAutoCString omniJarSpec;
|
||||||
if (sPath[aType]) {
|
if (sPath[aType]) {
|
||||||
nsresult rv = NS_GetURLSpecFromActualFile(sPath[aType], omniJarSpec);
|
nsresult rv = NS_GetURLSpecFromActualFile(sPath[aType], omniJarSpec);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
result = "jar:";
|
result = "jar:";
|
||||||
if (sIsNested[aType])
|
if (sIsNested[aType])
|
||||||
@ -158,7 +159,8 @@ Omnijar::GetURIString(Type aType, nsACString &result)
|
|||||||
nsCOMPtr<nsIFile> dir;
|
nsCOMPtr<nsIFile> dir;
|
||||||
nsDirectoryService::gService->Get(SPROP(aType), NS_GET_IID(nsIFile), getter_AddRefs(dir));
|
nsDirectoryService::gService->Get(SPROP(aType), NS_GET_IID(nsIFile), getter_AddRefs(dir));
|
||||||
nsresult rv = NS_GetURLSpecFromActualFile(dir, result);
|
nsresult rv = NS_GetURLSpecFromActualFile(dir, result);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
result += "/";
|
result += "/";
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -40,7 +40,8 @@ NS_StringContainerInit2(nsStringContainer &aContainer,
|
|||||||
{
|
{
|
||||||
if (aDataLength == UINT32_MAX)
|
if (aDataLength == UINT32_MAX)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(!(aFlags & NS_STRING_CONTAINER_INIT_SUBSTRING));
|
if (NS_WARN_IF(aFlags & NS_STRING_CONTAINER_INIT_SUBSTRING))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
aDataLength = nsCharTraits<PRUnichar>::length(aData);
|
aDataLength = nsCharTraits<PRUnichar>::length(aData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +201,8 @@ NS_CStringContainerInit2(nsCStringContainer &aContainer,
|
|||||||
{
|
{
|
||||||
if (aDataLength == UINT32_MAX)
|
if (aDataLength == UINT32_MAX)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(!(aFlags & NS_CSTRING_CONTAINER_INIT_SUBSTRING));
|
if (NS_WARN_IF(aFlags & NS_CSTRING_CONTAINER_INIT_SUBSTRING))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
aDataLength = nsCharTraits<char>::length(aData);
|
aDataLength = nsCharTraits<char>::length(aData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +219,8 @@ nsThreadManagerGetSingleton(nsISupports* outer,
|
|||||||
void* *aInstancePtr)
|
void* *aInstancePtr)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(aInstancePtr, "null outptr");
|
NS_ASSERTION(aInstancePtr, "null outptr");
|
||||||
NS_ENSURE_TRUE(!outer, NS_ERROR_NO_AGGREGATION);
|
if (NS_WARN_IF(outer))
|
||||||
|
return NS_ERROR_NO_AGGREGATION;
|
||||||
|
|
||||||
return nsThreadManager::get()->QueryInterface(aIID, aInstancePtr);
|
return nsThreadManager::get()->QueryInterface(aIID, aInstancePtr);
|
||||||
}
|
}
|
||||||
@ -232,7 +233,8 @@ nsXPTIInterfaceInfoManagerGetSingleton(nsISupports* outer,
|
|||||||
void* *aInstancePtr)
|
void* *aInstancePtr)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(aInstancePtr, "null outptr");
|
NS_ASSERTION(aInstancePtr, "null outptr");
|
||||||
NS_ENSURE_TRUE(!outer, NS_ERROR_NO_AGGREGATION);
|
if (NS_WARN_IF(outer))
|
||||||
|
return NS_ERROR_NO_AGGREGATION;
|
||||||
|
|
||||||
nsCOMPtr<nsIInterfaceInfoManager> iim
|
nsCOMPtr<nsIInterfaceInfoManager> iim
|
||||||
(XPTInterfaceInfoManager::GetSingleton());
|
(XPTInterfaceInfoManager::GetSingleton());
|
||||||
@ -313,16 +315,16 @@ static nsIDebug* gDebug = nullptr;
|
|||||||
EXPORT_XPCOM_API(nsresult)
|
EXPORT_XPCOM_API(nsresult)
|
||||||
NS_GetDebug(nsIDebug** result)
|
NS_GetDebug(nsIDebug** result)
|
||||||
{
|
{
|
||||||
return nsDebugImpl::Create(nullptr,
|
return nsDebugImpl::Create(nullptr,
|
||||||
NS_GET_IID(nsIDebug),
|
NS_GET_IID(nsIDebug),
|
||||||
(void**) result);
|
(void**) result);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_XPCOM_API(nsresult)
|
EXPORT_XPCOM_API(nsresult)
|
||||||
NS_GetTraceRefcnt(nsITraceRefcnt** result)
|
NS_GetTraceRefcnt(nsITraceRefcnt** result)
|
||||||
{
|
{
|
||||||
return nsTraceRefcntImpl::Create(nullptr,
|
return nsTraceRefcntImpl::Create(nullptr,
|
||||||
NS_GET_IID(nsITraceRefcnt),
|
NS_GET_IID(nsITraceRefcnt),
|
||||||
(void**) result);
|
(void**) result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,38 +413,38 @@ NS_InitXPCOM2(nsIServiceManager* *result,
|
|||||||
|
|
||||||
if (!AtExitManager::AlreadyRegistered()) {
|
if (!AtExitManager::AlreadyRegistered()) {
|
||||||
sExitManager = new AtExitManager();
|
sExitManager = new AtExitManager();
|
||||||
NS_ENSURE_STATE(sExitManager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MessageLoop::current()) {
|
if (!MessageLoop::current()) {
|
||||||
sMessageLoop = new MessageLoopForUI(MessageLoop::TYPE_MOZILLA_UI);
|
sMessageLoop = new MessageLoopForUI(MessageLoop::TYPE_MOZILLA_UI);
|
||||||
NS_ENSURE_STATE(sMessageLoop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (XRE_GetProcessType() == GeckoProcessType_Default &&
|
if (XRE_GetProcessType() == GeckoProcessType_Default &&
|
||||||
!BrowserProcessSubThread::GetMessageLoop(BrowserProcessSubThread::IO)) {
|
!BrowserProcessSubThread::GetMessageLoop(BrowserProcessSubThread::IO)) {
|
||||||
scoped_ptr<BrowserProcessSubThread> ioThread(
|
scoped_ptr<BrowserProcessSubThread> ioThread(
|
||||||
new BrowserProcessSubThread(BrowserProcessSubThread::IO));
|
new BrowserProcessSubThread(BrowserProcessSubThread::IO));
|
||||||
NS_ENSURE_TRUE(ioThread.get(), NS_ERROR_OUT_OF_MEMORY);
|
|
||||||
|
|
||||||
base::Thread::Options options;
|
base::Thread::Options options;
|
||||||
options.message_loop_type = MessageLoop::TYPE_IO;
|
options.message_loop_type = MessageLoop::TYPE_IO;
|
||||||
NS_ENSURE_TRUE(ioThread->StartWithOptions(options), NS_ERROR_FAILURE);
|
if (NS_WARN_IF(!ioThread->StartWithOptions(options)))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
sIOThread = ioThread.release();
|
sIOThread = ioThread.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establish the main thread here.
|
// Establish the main thread here.
|
||||||
rv = nsThreadManager::get()->Init();
|
rv = nsThreadManager::get()->Init();
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
// Set up the timer globals/timer thread
|
// Set up the timer globals/timer thread
|
||||||
rv = nsTimerImpl::Startup();
|
rv = nsTimerImpl::Startup();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
#ifndef ANDROID
|
#ifndef ANDROID
|
||||||
// If the locale hasn't already been setup by our embedder,
|
// If the locale hasn't already been setup by our embedder,
|
||||||
// get us out of the "C" locale and into the system
|
// get us out of the "C" locale and into the system
|
||||||
if (strcmp(setlocale(LC_ALL, nullptr), "C") == 0)
|
if (strcmp(setlocale(LC_ALL, nullptr), "C") == 0)
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
#endif
|
#endif
|
||||||
@ -493,18 +495,21 @@ NS_InitXPCOM2(nsIServiceManager* *result,
|
|||||||
CommandLine::Init(0, nullptr);
|
CommandLine::Init(0, nullptr);
|
||||||
#else
|
#else
|
||||||
nsCOMPtr<nsIFile> binaryFile;
|
nsCOMPtr<nsIFile> binaryFile;
|
||||||
nsDirectoryService::gService->Get(NS_XPCOM_CURRENT_PROCESS_DIR,
|
nsDirectoryService::gService->Get(NS_XPCOM_CURRENT_PROCESS_DIR,
|
||||||
NS_GET_IID(nsIFile),
|
NS_GET_IID(nsIFile),
|
||||||
getter_AddRefs(binaryFile));
|
getter_AddRefs(binaryFile));
|
||||||
NS_ENSURE_STATE(binaryFile);
|
if (NS_WARN_IF(!binaryFile))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
rv = binaryFile->AppendNative(NS_LITERAL_CSTRING("nonexistent-executable"));
|
rv = binaryFile->AppendNative(NS_LITERAL_CSTRING("nonexistent-executable"));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
nsCString binaryPath;
|
nsCString binaryPath;
|
||||||
rv = binaryFile->GetNativePath(binaryPath);
|
rv = binaryFile->GetNativePath(binaryPath);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
static char const *const argv = { strdup(binaryPath.get()) };
|
static char const *const argv = { strdup(binaryPath.get()) };
|
||||||
CommandLine::Init(1, &argv);
|
CommandLine::Init(1, &argv);
|
||||||
#endif
|
#endif
|
||||||
@ -568,7 +573,7 @@ NS_InitXPCOM2(nsIServiceManager* *result,
|
|||||||
mozilla::AvailableMemoryTracker::Activate();
|
mozilla::AvailableMemoryTracker::Activate();
|
||||||
|
|
||||||
// Notify observers of xpcom autoregistration start
|
// Notify observers of xpcom autoregistration start
|
||||||
NS_CreateServicesFromCategory(NS_XPCOM_STARTUP_CATEGORY,
|
NS_CreateServicesFromCategory(NS_XPCOM_STARTUP_CATEGORY,
|
||||||
nullptr,
|
nullptr,
|
||||||
NS_XPCOM_STARTUP_OBSERVER_ID);
|
NS_XPCOM_STARTUP_OBSERVER_ID);
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
@ -626,7 +631,9 @@ ShutdownXPCOM(nsIServiceManager* servMgr)
|
|||||||
// Make sure the hang monitor is enabled for shutdown.
|
// Make sure the hang monitor is enabled for shutdown.
|
||||||
HangMonitor::NotifyActivity();
|
HangMonitor::NotifyActivity();
|
||||||
|
|
||||||
NS_ENSURE_STATE(NS_IsMainThread());
|
if (!NS_IsMainThread()) {
|
||||||
|
NS_RUNTIMEABORT("Shutdown on wrong thread");
|
||||||
|
}
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsISimpleEnumerator> moduleLoaders;
|
nsCOMPtr<nsISimpleEnumerator> moduleLoaders;
|
||||||
@ -637,7 +644,8 @@ ShutdownXPCOM(nsIServiceManager* servMgr)
|
|||||||
// servicemanager shutdown
|
// servicemanager shutdown
|
||||||
|
|
||||||
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
||||||
NS_ENSURE_STATE(thread);
|
if (NS_WARN_IF(!thread))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
nsRefPtr<nsObserverService> observerService;
|
nsRefPtr<nsObserverService> observerService;
|
||||||
CallGetService("@mozilla.org/observer-service;1",
|
CallGetService("@mozilla.org/observer-service;1",
|
||||||
|
@ -213,7 +213,8 @@ nsresult ProbeManager::StartSession(nsTArray<nsRefPtr<Probe>> &aProbes)
|
|||||||
used only for unregistration*/
|
used only for unregistration*/
|
||||||
);
|
);
|
||||||
delete[] probes;
|
delete[] probes;
|
||||||
NS_ENSURE_TRUE(result == ERROR_SUCCESS, NS_ERROR_UNEXPECTED);
|
if (NS_WARN_IF(result != ERROR_SUCCESS))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +299,8 @@ CategoryNode::DeleteLeaf(const char* aEntryName)
|
|||||||
NS_METHOD
|
NS_METHOD
|
||||||
CategoryNode::Enumerate(nsISimpleEnumerator **_retval)
|
CategoryNode::Enumerate(nsISimpleEnumerator **_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
MutexAutoLock lock(mLock);
|
MutexAutoLock lock(mLock);
|
||||||
EntryEnumerator* enumObj = EntryEnumerator::Create(mTable);
|
EntryEnumerator* enumObj = EntryEnumerator::Create(mTable);
|
||||||
@ -593,9 +594,10 @@ nsCategoryManager::GetCategoryEntry( const char *aCategoryName,
|
|||||||
const char *aEntryName,
|
const char *aEntryName,
|
||||||
char **_retval )
|
char **_retval )
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aCategoryName);
|
if (NS_WARN_IF(!aCategoryName) ||
|
||||||
NS_ENSURE_ARG_POINTER(aEntryName);
|
NS_WARN_IF(!aEntryName) ||
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;;
|
||||||
|
|
||||||
nsresult status = NS_ERROR_NOT_AVAILABLE;
|
nsresult status = NS_ERROR_NOT_AVAILABLE;
|
||||||
|
|
||||||
@ -687,8 +689,9 @@ nsCategoryManager::DeleteCategoryEntry( const char *aCategoryName,
|
|||||||
const char *aEntryName,
|
const char *aEntryName,
|
||||||
bool aDontPersist)
|
bool aDontPersist)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aCategoryName);
|
if (NS_WARN_IF(!aCategoryName) ||
|
||||||
NS_ENSURE_ARG_POINTER(aEntryName);
|
NS_WARN_IF(!aEntryName))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Note: no errors are reported since failure to delete
|
Note: no errors are reported since failure to delete
|
||||||
@ -715,7 +718,8 @@ nsCategoryManager::DeleteCategoryEntry( const char *aCategoryName,
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsCategoryManager::DeleteCategory( const char *aCategoryName )
|
nsCategoryManager::DeleteCategory( const char *aCategoryName )
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aCategoryName);
|
if (NS_WARN_IF(!aCategoryName))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
// the categories are arena-allocated, so we don't
|
// the categories are arena-allocated, so we don't
|
||||||
// actually delete them. We just remove all of the
|
// actually delete them. We just remove all of the
|
||||||
@ -740,8 +744,9 @@ NS_IMETHODIMP
|
|||||||
nsCategoryManager::EnumerateCategory( const char *aCategoryName,
|
nsCategoryManager::EnumerateCategory( const char *aCategoryName,
|
||||||
nsISimpleEnumerator **_retval )
|
nsISimpleEnumerator **_retval )
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aCategoryName);
|
if (NS_WARN_IF(!aCategoryName) ||
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
CategoryNode* category;
|
CategoryNode* category;
|
||||||
{
|
{
|
||||||
@ -759,7 +764,8 @@ nsCategoryManager::EnumerateCategory( const char *aCategoryName,
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsCategoryManager::EnumerateCategories(nsISimpleEnumerator **_retval)
|
nsCategoryManager::EnumerateCategories(nsISimpleEnumerator **_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
MutexAutoLock lock(mLock);
|
MutexAutoLock lock(mLock);
|
||||||
CategoryEnumerator* enumObj = CategoryEnumerator::Create(mTable);
|
CategoryEnumerator* enumObj = CategoryEnumerator::Create(mTable);
|
||||||
|
@ -932,8 +932,9 @@ nsComponentManagerImpl::GetClassObjectByContractID(const char *contractID,
|
|||||||
const nsIID &aIID,
|
const nsIID &aIID,
|
||||||
void **aResult)
|
void **aResult)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aResult);
|
if (NS_WARN_IF(!aResult) ||
|
||||||
NS_ENSURE_ARG_POINTER(contractID);
|
NS_WARN_IF(!contractID))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
@ -1052,7 +1053,8 @@ nsComponentManagerImpl::CreateInstanceByContractID(const char *aContractID,
|
|||||||
const nsIID &aIID,
|
const nsIID &aIID,
|
||||||
void **aResult)
|
void **aResult)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aContractID);
|
if (NS_WARN_IF(!aContractID))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
// test this first, since there's no point in creating a component during
|
// test this first, since there's no point in creating a component during
|
||||||
// shutdown -- whether it's available or not would depend on the order it
|
// shutdown -- whether it's available or not would depend on the order it
|
||||||
@ -1607,7 +1609,9 @@ NS_IMETHODIMP
|
|||||||
nsComponentManagerImpl::IsContractIDRegistered(const char *aClass,
|
nsComponentManagerImpl::IsContractIDRegistered(const char *aClass,
|
||||||
bool *_retval)
|
bool *_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aClass);
|
if (NS_WARN_IF(!aClass))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsFactoryEntry *entry = GetFactoryEntry(aClass, strlen(aClass));
|
nsFactoryEntry *entry = GetFactoryEntry(aClass, strlen(aClass));
|
||||||
|
|
||||||
if (entry)
|
if (entry)
|
||||||
|
@ -64,7 +64,8 @@ nsHashPropertyBag::GetProperty(const nsAString& name, nsIVariant* *_retval)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHashPropertyBag::SetProperty(const nsAString& name, nsIVariant *value)
|
nsHashPropertyBag::SetProperty(const nsAString& name, nsIVariant *value)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(value);
|
if (NS_WARN_IF(!value))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
mPropertyHash.Put(name, value);
|
mPropertyHash.Put(name, value);
|
||||||
|
|
||||||
|
@ -51,7 +51,8 @@ nsINIParserFactory::CreateInstance(nsISupports* aOuter,
|
|||||||
REFNSIID aIID,
|
REFNSIID aIID,
|
||||||
void **aResult)
|
void **aResult)
|
||||||
{
|
{
|
||||||
NS_ENSURE_NO_AGGREGATION(aOuter);
|
if (NS_WARN_IF(aOuter))
|
||||||
|
return NS_ERROR_NO_AGGREGATION;
|
||||||
|
|
||||||
// We are our own singleton.
|
// We are our own singleton.
|
||||||
return QueryInterface(aIID, aResult);
|
return QueryInterface(aIID, aResult);
|
||||||
|
@ -150,7 +150,8 @@ ObserverServiceReporter::CollectReports(nsIMemoryReporterCallback* cb,
|
|||||||
"respect to the number of windows."),
|
"respect to the number of windows."),
|
||||||
aClosure);
|
aClosure);
|
||||||
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = cb->Callback(/* process */ EmptyCString(),
|
rv = cb->Callback(/* process */ EmptyCString(),
|
||||||
@ -162,7 +163,8 @@ ObserverServiceReporter::CollectReports(nsIMemoryReporterCallback* cb,
|
|||||||
"observer service."),
|
"observer service."),
|
||||||
aClosure);
|
aClosure);
|
||||||
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
rv = cb->Callback(/* process */ EmptyCString(),
|
rv = cb->Callback(/* process */ EmptyCString(),
|
||||||
NS_LITERAL_CSTRING("observer-service/referent/weak/alive"),
|
NS_LITERAL_CSTRING("observer-service/referent/weak/alive"),
|
||||||
@ -173,7 +175,8 @@ ObserverServiceReporter::CollectReports(nsIMemoryReporterCallback* cb,
|
|||||||
"observer service that are still alive."),
|
"observer service that are still alive."),
|
||||||
aClosure);
|
aClosure);
|
||||||
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
rv = cb->Callback(/* process */ EmptyCString(),
|
rv = cb->Callback(/* process */ EmptyCString(),
|
||||||
NS_LITERAL_CSTRING("observer-service/referent/weak/dead"),
|
NS_LITERAL_CSTRING("observer-service/referent/weak/dead"),
|
||||||
@ -184,7 +187,8 @@ ObserverServiceReporter::CollectReports(nsIMemoryReporterCallback* cb,
|
|||||||
"observer service that are dead."),
|
"observer service that are dead."),
|
||||||
aClosure);
|
aClosure);
|
||||||
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -266,7 +270,8 @@ nsObserverService::AddObserver(nsIObserver* anObserver, const char* aTopic,
|
|||||||
(void*) anObserver, aTopic));
|
(void*) anObserver, aTopic));
|
||||||
|
|
||||||
NS_ENSURE_VALIDCALL
|
NS_ENSURE_VALIDCALL
|
||||||
NS_ENSURE_ARG(anObserver && aTopic);
|
if (NS_WARN_IF(!anObserver) || NS_WARN_IF(!aTopic))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
if (mozilla::net::IsNeckoChild() && !strncmp(aTopic, "http-on-", 8)) {
|
if (mozilla::net::IsNeckoChild() && !strncmp(aTopic, "http-on-", 8)) {
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
@ -285,7 +290,8 @@ nsObserverService::RemoveObserver(nsIObserver* anObserver, const char* aTopic)
|
|||||||
LOG(("nsObserverService::RemoveObserver(%p: %s)",
|
LOG(("nsObserverService::RemoveObserver(%p: %s)",
|
||||||
(void*) anObserver, aTopic));
|
(void*) anObserver, aTopic));
|
||||||
NS_ENSURE_VALIDCALL
|
NS_ENSURE_VALIDCALL
|
||||||
NS_ENSURE_ARG(anObserver && aTopic);
|
if (NS_WARN_IF(!anObserver) || NS_WARN_IF(!aTopic))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsObserverList *observerList = mObserverTopicTable.GetEntry(aTopic);
|
nsObserverList *observerList = mObserverTopicTable.GetEntry(aTopic);
|
||||||
if (!observerList)
|
if (!observerList)
|
||||||
@ -302,7 +308,8 @@ nsObserverService::EnumerateObservers(const char* aTopic,
|
|||||||
nsISimpleEnumerator** anEnumerator)
|
nsISimpleEnumerator** anEnumerator)
|
||||||
{
|
{
|
||||||
NS_ENSURE_VALIDCALL
|
NS_ENSURE_VALIDCALL
|
||||||
NS_ENSURE_ARG(aTopic && anEnumerator);
|
if (NS_WARN_IF(!anEnumerator) || NS_WARN_IF(!aTopic))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsObserverList *observerList = mObserverTopicTable.GetEntry(aTopic);
|
nsObserverList *observerList = mObserverTopicTable.GetEntry(aTopic);
|
||||||
if (!observerList)
|
if (!observerList)
|
||||||
@ -319,7 +326,8 @@ NS_IMETHODIMP nsObserverService::NotifyObservers(nsISupports *aSubject,
|
|||||||
LOG(("nsObserverService::NotifyObservers(%s)", aTopic));
|
LOG(("nsObserverService::NotifyObservers(%s)", aTopic));
|
||||||
|
|
||||||
NS_ENSURE_VALIDCALL
|
NS_ENSURE_VALIDCALL
|
||||||
NS_ENSURE_ARG(aTopic);
|
if (NS_WARN_IF(!aTopic))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsObserverList *observerList = mObserverTopicTable.GetEntry(aTopic);
|
nsObserverList *observerList = mObserverTopicTable.GetEntry(aTopic);
|
||||||
if (observerList)
|
if (observerList)
|
||||||
|
@ -15,7 +15,8 @@ NS_INTERFACE_MAP_END
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsProperties::Get(const char* prop, const nsIID & uuid, void* *result)
|
nsProperties::Get(const char* prop, const nsIID & uuid, void* *result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(prop);
|
if (NS_WARN_IF(!prop))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsCOMPtr<nsISupports> value;
|
nsCOMPtr<nsISupports> value;
|
||||||
if (!nsProperties_HashBase::Get(prop, getter_AddRefs(value))) {
|
if (!nsProperties_HashBase::Get(prop, getter_AddRefs(value))) {
|
||||||
@ -27,7 +28,8 @@ nsProperties::Get(const char* prop, const nsIID & uuid, void* *result)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsProperties::Set(const char* prop, nsISupports* value)
|
nsProperties::Set(const char* prop, nsISupports* value)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(prop);
|
if (NS_WARN_IF(!prop))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
Put(prop, value);
|
Put(prop, value);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -35,7 +37,8 @@ nsProperties::Set(const char* prop, nsISupports* value)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsProperties::Undefine(const char* prop)
|
nsProperties::Undefine(const char* prop)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(prop);
|
if (NS_WARN_IF(!prop))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsCOMPtr<nsISupports> value;
|
nsCOMPtr<nsISupports> value;
|
||||||
if (!nsProperties_HashBase::Get(prop, getter_AddRefs(value)))
|
if (!nsProperties_HashBase::Get(prop, getter_AddRefs(value)))
|
||||||
@ -48,7 +51,8 @@ nsProperties::Undefine(const char* prop)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsProperties::Has(const char* prop, bool *result)
|
nsProperties::Has(const char* prop, bool *result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(prop);
|
if (NS_WARN_IF(!prop))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsCOMPtr<nsISupports> value;
|
nsCOMPtr<nsISupports> value;
|
||||||
*result = nsProperties_HashBase::Get(prop,
|
*result = nsProperties_HashBase::Get(prop,
|
||||||
@ -82,12 +86,11 @@ GetKeysEnumerate(const char *key, nsISupports* data,
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsProperties::GetKeys(uint32_t *count, char ***keys)
|
nsProperties::GetKeys(uint32_t *count, char ***keys)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(count);
|
if (NS_WARN_IF(!count) || NS_WARN_IF(!keys))
|
||||||
NS_ENSURE_ARG(keys);
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
uint32_t n = Count();
|
uint32_t n = Count();
|
||||||
char ** k = (char **) nsMemory::Alloc(n * sizeof(char *));
|
char ** k = (char **) nsMemory::Alloc(n * sizeof(char *));
|
||||||
NS_ENSURE_TRUE(k, NS_ERROR_OUT_OF_MEMORY);
|
|
||||||
|
|
||||||
GetKeysEnumData gked;
|
GetKeysEnumData gked;
|
||||||
gked.keys = k;
|
gked.keys = k;
|
||||||
|
@ -84,7 +84,6 @@ NS_IMPL_ISUPPORTS3(nsStringEnumerator,
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsStringEnumerator::HasMore(bool* aResult)
|
nsStringEnumerator::HasMore(bool* aResult)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aResult);
|
|
||||||
*aResult = mIndex < Count();
|
*aResult = mIndex < Count();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -119,7 +118,8 @@ nsStringEnumerator::GetNext(nsISupports** aResult)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsStringEnumerator::GetNext(nsAString& aResult)
|
nsStringEnumerator::GetNext(nsAString& aResult)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mIndex < Count(), NS_ERROR_UNEXPECTED);
|
if (NS_WARN_IF(mIndex >= Count()))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
if (mIsUnicode)
|
if (mIsUnicode)
|
||||||
aResult = mArray->ElementAt(mIndex++);
|
aResult = mArray->ElementAt(mIndex++);
|
||||||
@ -132,7 +132,8 @@ nsStringEnumerator::GetNext(nsAString& aResult)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsStringEnumerator::GetNext(nsACString& aResult)
|
nsStringEnumerator::GetNext(nsACString& aResult)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mIndex < Count(), NS_ERROR_UNEXPECTED);
|
if (NS_WARN_IF(mIndex >= Count()))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
if (mIsUnicode)
|
if (mIsUnicode)
|
||||||
CopyUTF16toUTF8(mArray->ElementAt(mIndex++), aResult);
|
CopyUTF16toUTF8(mArray->ElementAt(mIndex++), aResult);
|
||||||
@ -160,8 +161,8 @@ nsresult
|
|||||||
NS_NewStringEnumerator(nsIStringEnumerator** aResult,
|
NS_NewStringEnumerator(nsIStringEnumerator** aResult,
|
||||||
const nsTArray<nsString>* aArray, nsISupports* aOwner)
|
const nsTArray<nsString>* aArray, nsISupports* aOwner)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aResult);
|
if (NS_WARN_IF(!aResult) || NS_WARN_IF(!aArray))
|
||||||
NS_ENSURE_ARG_POINTER(aArray);
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
*aResult = new nsStringEnumerator(aArray, aOwner);
|
*aResult = new nsStringEnumerator(aArray, aOwner);
|
||||||
return StringEnumeratorTail(aResult);
|
return StringEnumeratorTail(aResult);
|
||||||
@ -172,8 +173,8 @@ nsresult
|
|||||||
NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
|
NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
|
||||||
const nsTArray<nsCString>* aArray, nsISupports* aOwner)
|
const nsTArray<nsCString>* aArray, nsISupports* aOwner)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aResult);
|
if (NS_WARN_IF(!aResult) || NS_WARN_IF(!aArray))
|
||||||
NS_ENSURE_ARG_POINTER(aArray);
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
*aResult = new nsStringEnumerator(aArray, aOwner);
|
*aResult = new nsStringEnumerator(aArray, aOwner);
|
||||||
return StringEnumeratorTail(aResult);
|
return StringEnumeratorTail(aResult);
|
||||||
@ -183,8 +184,8 @@ nsresult
|
|||||||
NS_NewAdoptingStringEnumerator(nsIStringEnumerator** aResult,
|
NS_NewAdoptingStringEnumerator(nsIStringEnumerator** aResult,
|
||||||
nsTArray<nsString>* aArray)
|
nsTArray<nsString>* aArray)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aResult);
|
if (NS_WARN_IF(!aResult) || NS_WARN_IF(!aArray))
|
||||||
NS_ENSURE_ARG_POINTER(aArray);
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
*aResult = new nsStringEnumerator(aArray, true);
|
*aResult = new nsStringEnumerator(aArray, true);
|
||||||
return StringEnumeratorTail(aResult);
|
return StringEnumeratorTail(aResult);
|
||||||
@ -194,8 +195,8 @@ nsresult
|
|||||||
NS_NewAdoptingUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
|
NS_NewAdoptingUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
|
||||||
nsTArray<nsCString>* aArray)
|
nsTArray<nsCString>* aArray)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aResult);
|
if (NS_WARN_IF(!aResult) || NS_WARN_IF(!aArray))
|
||||||
NS_ENSURE_ARG_POINTER(aArray);
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
*aResult = new nsStringEnumerator(aArray, true);
|
*aResult = new nsStringEnumerator(aArray, true);
|
||||||
return StringEnumeratorTail(aResult);
|
return StringEnumeratorTail(aResult);
|
||||||
@ -206,8 +207,8 @@ nsresult
|
|||||||
NS_NewStringEnumerator(nsIStringEnumerator** aResult,
|
NS_NewStringEnumerator(nsIStringEnumerator** aResult,
|
||||||
const nsTArray<nsString>* aArray)
|
const nsTArray<nsString>* aArray)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aResult);
|
if (NS_WARN_IF(!aResult) || NS_WARN_IF(!aArray))
|
||||||
NS_ENSURE_ARG_POINTER(aArray);
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
*aResult = new nsStringEnumerator(aArray, false);
|
*aResult = new nsStringEnumerator(aArray, false);
|
||||||
return StringEnumeratorTail(aResult);
|
return StringEnumeratorTail(aResult);
|
||||||
@ -217,8 +218,8 @@ nsresult
|
|||||||
NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
|
NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
|
||||||
const nsTArray<nsCString>* aArray)
|
const nsTArray<nsCString>* aArray)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aResult);
|
if (NS_WARN_IF(!aResult) || NS_WARN_IF(!aArray))
|
||||||
NS_ENSURE_ARG_POINTER(aArray);
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
*aResult = new nsStringEnumerator(aArray, false);
|
*aResult = new nsStringEnumerator(aArray, false);
|
||||||
return StringEnumeratorTail(aResult);
|
return StringEnumeratorTail(aResult);
|
||||||
|
@ -585,7 +585,8 @@ nsSupportsArray::Clone(nsISupportsArray** aResult)
|
|||||||
{
|
{
|
||||||
nsCOMPtr<nsISupportsArray> newArray;
|
nsCOMPtr<nsISupportsArray> newArray;
|
||||||
nsresult rv = NS_NewISupportsArray(getter_AddRefs(newArray));
|
nsresult rv = NS_NewISupportsArray(getter_AddRefs(newArray));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
Count(&count);
|
Count(&count);
|
||||||
|
@ -810,7 +810,8 @@ nsSupportsDependentCString::nsSupportsDependentCString(const char* aStr)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsSupportsDependentCString::GetType(uint16_t *aType)
|
nsSupportsDependentCString::GetType(uint16_t *aType)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aType);
|
if (NS_WARN_IF(!aType))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
*aType = TYPE_CSTRING;
|
*aType = TYPE_CSTRING;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -826,7 +827,8 @@ nsSupportsDependentCString::GetData(nsACString& aData)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsSupportsDependentCString::ToString(char **_retval)
|
nsSupportsDependentCString::ToString(char **_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
*_retval = ToNewCString(mData);
|
*_retval = ToNewCString(mData);
|
||||||
if (!*_retval)
|
if (!*_retval)
|
||||||
|
@ -103,7 +103,8 @@ NS_IMETHODIMP
|
|||||||
nsWindowsRegKey::OpenChild(const nsAString &path, uint32_t mode,
|
nsWindowsRegKey::OpenChild(const nsAString &path, uint32_t mode,
|
||||||
nsIWindowsRegKey **result)
|
nsIWindowsRegKey **result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
nsCOMPtr<nsIWindowsRegKey> child = new nsWindowsRegKey();
|
nsCOMPtr<nsIWindowsRegKey> child = new nsWindowsRegKey();
|
||||||
|
|
||||||
@ -119,7 +120,8 @@ NS_IMETHODIMP
|
|||||||
nsWindowsRegKey::CreateChild(const nsAString &path, uint32_t mode,
|
nsWindowsRegKey::CreateChild(const nsAString &path, uint32_t mode,
|
||||||
nsIWindowsRegKey **result)
|
nsIWindowsRegKey **result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
nsCOMPtr<nsIWindowsRegKey> child = new nsWindowsRegKey();
|
nsCOMPtr<nsIWindowsRegKey> child = new nsWindowsRegKey();
|
||||||
|
|
||||||
@ -134,13 +136,15 @@ nsWindowsRegKey::CreateChild(const nsAString &path, uint32_t mode,
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsRegKey::GetChildCount(uint32_t *result)
|
nsWindowsRegKey::GetChildCount(uint32_t *result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
DWORD numSubKeys;
|
DWORD numSubKeys;
|
||||||
LONG rv = RegQueryInfoKeyW(mKey, nullptr, nullptr, nullptr, &numSubKeys,
|
LONG rv = RegQueryInfoKeyW(mKey, nullptr, nullptr, nullptr, &numSubKeys,
|
||||||
nullptr, nullptr, nullptr, nullptr, nullptr,
|
nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||||
nullptr, nullptr);
|
nullptr, nullptr);
|
||||||
NS_ENSURE_STATE(rv == ERROR_SUCCESS);
|
if (rv != ERROR_SUCCESS)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
*result = numSubKeys;
|
*result = numSubKeys;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -149,7 +153,8 @@ nsWindowsRegKey::GetChildCount(uint32_t *result)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsRegKey::GetChildName(uint32_t index, nsAString &result)
|
nsWindowsRegKey::GetChildName(uint32_t index, nsAString &result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
FILETIME lastWritten;
|
FILETIME lastWritten;
|
||||||
|
|
||||||
@ -169,7 +174,8 @@ nsWindowsRegKey::GetChildName(uint32_t index, nsAString &result)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsRegKey::HasChild(const nsAString &name, bool *result)
|
nsWindowsRegKey::HasChild(const nsAString &name, bool *result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
// Check for the existence of a child key by opening the key with minimal
|
// Check for the existence of a child key by opening the key with minimal
|
||||||
// rights. Perhaps there is a more efficient way to do this?
|
// rights. Perhaps there is a more efficient way to do this?
|
||||||
@ -187,13 +193,15 @@ nsWindowsRegKey::HasChild(const nsAString &name, bool *result)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsRegKey::GetValueCount(uint32_t *result)
|
nsWindowsRegKey::GetValueCount(uint32_t *result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
DWORD numValues;
|
DWORD numValues;
|
||||||
LONG rv = RegQueryInfoKeyW(mKey, nullptr, nullptr, nullptr, nullptr,
|
LONG rv = RegQueryInfoKeyW(mKey, nullptr, nullptr, nullptr, nullptr,
|
||||||
nullptr, nullptr, &numValues, nullptr, nullptr,
|
nullptr, nullptr, &numValues, nullptr, nullptr,
|
||||||
nullptr, nullptr);
|
nullptr, nullptr);
|
||||||
NS_ENSURE_STATE(rv == ERROR_SUCCESS);
|
if (rv != ERROR_SUCCESS)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
*result = numValues;
|
*result = numValues;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -202,7 +210,8 @@ nsWindowsRegKey::GetValueCount(uint32_t *result)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsRegKey::GetValueName(uint32_t index, nsAString &result)
|
nsWindowsRegKey::GetValueName(uint32_t index, nsAString &result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
PRUnichar nameBuf[MAX_VALUE_NAME_LEN];
|
PRUnichar nameBuf[MAX_VALUE_NAME_LEN];
|
||||||
DWORD nameLen = sizeof(nameBuf) / sizeof(nameBuf[0]);
|
DWORD nameLen = sizeof(nameBuf) / sizeof(nameBuf[0]);
|
||||||
@ -220,7 +229,8 @@ nsWindowsRegKey::GetValueName(uint32_t index, nsAString &result)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsRegKey::HasValue(const nsAString &name, bool *result)
|
nsWindowsRegKey::HasValue(const nsAString &name, bool *result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
LONG rv = RegQueryValueExW(mKey, PromiseFlatString(name).get(), 0, nullptr,
|
LONG rv = RegQueryValueExW(mKey, PromiseFlatString(name).get(), 0, nullptr,
|
||||||
nullptr, nullptr);
|
nullptr, nullptr);
|
||||||
@ -232,7 +242,8 @@ nsWindowsRegKey::HasValue(const nsAString &name, bool *result)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsRegKey::RemoveChild(const nsAString &name)
|
nsWindowsRegKey::RemoveChild(const nsAString &name)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
LONG rv = RegDeleteKeyW(mKey, PromiseFlatString(name).get());
|
LONG rv = RegDeleteKeyW(mKey, PromiseFlatString(name).get());
|
||||||
|
|
||||||
@ -242,7 +253,8 @@ nsWindowsRegKey::RemoveChild(const nsAString &name)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsRegKey::RemoveValue(const nsAString &name)
|
nsWindowsRegKey::RemoveValue(const nsAString &name)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
LONG rv = RegDeleteValueW(mKey, PromiseFlatString(name).get());
|
LONG rv = RegDeleteValueW(mKey, PromiseFlatString(name).get());
|
||||||
|
|
||||||
@ -252,7 +264,8 @@ nsWindowsRegKey::RemoveValue(const nsAString &name)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsRegKey::GetValueType(const nsAString &name, uint32_t *result)
|
nsWindowsRegKey::GetValueType(const nsAString &name, uint32_t *result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
LONG rv = RegQueryValueExW(mKey, PromiseFlatString(name).get(), 0,
|
LONG rv = RegQueryValueExW(mKey, PromiseFlatString(name).get(), 0,
|
||||||
(LPDWORD) result, nullptr, nullptr);
|
(LPDWORD) result, nullptr, nullptr);
|
||||||
@ -263,7 +276,8 @@ nsWindowsRegKey::GetValueType(const nsAString &name, uint32_t *result)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsRegKey::ReadStringValue(const nsAString &name, nsAString &result)
|
nsWindowsRegKey::ReadStringValue(const nsAString &name, nsAString &result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
DWORD type, size;
|
DWORD type, size;
|
||||||
|
|
||||||
@ -275,12 +289,12 @@ nsWindowsRegKey::ReadStringValue(const nsAString &name, nsAString &result)
|
|||||||
|
|
||||||
// This must be a string type in order to fetch the value as a string.
|
// This must be a string type in order to fetch the value as a string.
|
||||||
// We're being a bit forgiving here by allowing types other than REG_SZ.
|
// We're being a bit forgiving here by allowing types other than REG_SZ.
|
||||||
NS_ENSURE_STATE(type == REG_SZ ||
|
if (type != REG_SZ && type == REG_EXPAND_SZ && type == REG_MULTI_SZ)
|
||||||
type == REG_EXPAND_SZ ||
|
return NS_ERROR_FAILURE;
|
||||||
type == REG_MULTI_SZ);
|
|
||||||
|
|
||||||
// The buffer size must be a multiple of 2.
|
// The buffer size must be a multiple of 2.
|
||||||
NS_ENSURE_STATE(size % 2 == 0);
|
if (size % 2 != 0)
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
result.Truncate();
|
result.Truncate();
|
||||||
@ -337,7 +351,8 @@ nsWindowsRegKey::ReadStringValue(const nsAString &name, nsAString &result)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsRegKey::ReadIntValue(const nsAString &name, uint32_t *result)
|
nsWindowsRegKey::ReadIntValue(const nsAString &name, uint32_t *result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
DWORD size = sizeof(*result);
|
DWORD size = sizeof(*result);
|
||||||
LONG rv = RegQueryValueExW(mKey, PromiseFlatString(name).get(), 0, nullptr,
|
LONG rv = RegQueryValueExW(mKey, PromiseFlatString(name).get(), 0, nullptr,
|
||||||
@ -349,7 +364,8 @@ nsWindowsRegKey::ReadIntValue(const nsAString &name, uint32_t *result)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsRegKey::ReadInt64Value(const nsAString &name, uint64_t *result)
|
nsWindowsRegKey::ReadInt64Value(const nsAString &name, uint64_t *result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
DWORD size = sizeof(*result);
|
DWORD size = sizeof(*result);
|
||||||
LONG rv = RegQueryValueExW(mKey, PromiseFlatString(name).get(), 0, nullptr,
|
LONG rv = RegQueryValueExW(mKey, PromiseFlatString(name).get(), 0, nullptr,
|
||||||
@ -361,7 +377,8 @@ nsWindowsRegKey::ReadInt64Value(const nsAString &name, uint64_t *result)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsRegKey::ReadBinaryValue(const nsAString &name, nsACString &result)
|
nsWindowsRegKey::ReadBinaryValue(const nsAString &name, nsACString &result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
DWORD size;
|
DWORD size;
|
||||||
LONG rv = RegQueryValueExW(mKey, PromiseFlatString(name).get(), 0,
|
LONG rv = RegQueryValueExW(mKey, PromiseFlatString(name).get(), 0,
|
||||||
@ -385,7 +402,8 @@ nsWindowsRegKey::ReadBinaryValue(const nsAString &name, nsACString &result)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsRegKey::WriteStringValue(const nsAString &name, const nsAString &value)
|
nsWindowsRegKey::WriteStringValue(const nsAString &name, const nsAString &value)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
// Need to indicate complete size of buffer including null terminator.
|
// Need to indicate complete size of buffer including null terminator.
|
||||||
const nsString &flatValue = PromiseFlatString(value);
|
const nsString &flatValue = PromiseFlatString(value);
|
||||||
@ -400,7 +418,8 @@ nsWindowsRegKey::WriteStringValue(const nsAString &name, const nsAString &value)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsRegKey::WriteIntValue(const nsAString &name, uint32_t value)
|
nsWindowsRegKey::WriteIntValue(const nsAString &name, uint32_t value)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
LONG rv = RegSetValueExW(mKey, PromiseFlatString(name).get(), 0, REG_DWORD,
|
LONG rv = RegSetValueExW(mKey, PromiseFlatString(name).get(), 0, REG_DWORD,
|
||||||
(const BYTE *) &value, sizeof(value));
|
(const BYTE *) &value, sizeof(value));
|
||||||
@ -411,7 +430,8 @@ nsWindowsRegKey::WriteIntValue(const nsAString &name, uint32_t value)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsRegKey::WriteInt64Value(const nsAString &name, uint64_t value)
|
nsWindowsRegKey::WriteInt64Value(const nsAString &name, uint64_t value)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
LONG rv = RegSetValueExW(mKey, PromiseFlatString(name).get(), 0, REG_QWORD,
|
LONG rv = RegSetValueExW(mKey, PromiseFlatString(name).get(), 0, REG_QWORD,
|
||||||
(const BYTE *) &value, sizeof(value));
|
(const BYTE *) &value, sizeof(value));
|
||||||
@ -422,7 +442,8 @@ nsWindowsRegKey::WriteInt64Value(const nsAString &name, uint64_t value)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsRegKey::WriteBinaryValue(const nsAString &name, const nsACString &value)
|
nsWindowsRegKey::WriteBinaryValue(const nsAString &name, const nsACString &value)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
const nsCString &flatValue = PromiseFlatCString(value);
|
const nsCString &flatValue = PromiseFlatCString(value);
|
||||||
LONG rv = RegSetValueExW(mKey, PromiseFlatString(name).get(), 0, REG_BINARY,
|
LONG rv = RegSetValueExW(mKey, PromiseFlatString(name).get(), 0, REG_BINARY,
|
||||||
@ -434,7 +455,8 @@ nsWindowsRegKey::WriteBinaryValue(const nsAString &name, const nsACString &value
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsRegKey::StartWatching(bool recurse)
|
nsWindowsRegKey::StartWatching(bool recurse)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mKey))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
if (mWatchEvent)
|
if (mWatchEvent)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -180,7 +180,6 @@ nsCOMArrayEnumerator::operator new (size_t size, const nsCOMArray_base& aArray)
|
|||||||
// do the actual allocation
|
// do the actual allocation
|
||||||
nsCOMArrayEnumerator * result =
|
nsCOMArrayEnumerator * result =
|
||||||
static_cast<nsCOMArrayEnumerator*>(::operator new(size));
|
static_cast<nsCOMArrayEnumerator*>(::operator new(size));
|
||||||
NS_ENSURE_TRUE(result, nullptr);
|
|
||||||
|
|
||||||
// now need to copy over the values, and addref each one
|
// now need to copy over the values, and addref each one
|
||||||
// now this might seem like a lot of work, but we're actually just
|
// now this might seem like a lot of work, but we're actually just
|
||||||
|
@ -57,7 +57,8 @@ int32_t
|
|||||||
nsCOMArray_base::IndexOfObject(nsISupports* aObject) const
|
nsCOMArray_base::IndexOfObject(nsISupports* aObject) const
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsISupports> supports = do_QueryInterface(aObject);
|
nsCOMPtr<nsISupports> supports = do_QueryInterface(aObject);
|
||||||
NS_ENSURE_TRUE(supports, -1);
|
if (NS_WARN_IF(!supports))
|
||||||
|
return -1;
|
||||||
|
|
||||||
uint32_t i, count;
|
uint32_t i, count;
|
||||||
int32_t retval = -1;
|
int32_t retval = -1;
|
||||||
|
@ -46,7 +46,8 @@ nsresult
|
|||||||
CallGetService(const nsCID &aCID, const nsIID &aIID, void **aResult)
|
CallGetService(const nsCID &aCID, const nsIID &aIID, void **aResult)
|
||||||
{
|
{
|
||||||
nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
|
nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
|
||||||
NS_ENSURE_TRUE(compMgr, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!compMgr))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
return compMgr->nsComponentManagerImpl::GetService(aCID, aIID, aResult);
|
return compMgr->nsComponentManagerImpl::GetService(aCID, aIID, aResult);
|
||||||
}
|
}
|
||||||
@ -55,7 +56,8 @@ nsresult
|
|||||||
CallGetService(const char *aContractID, const nsIID &aIID, void **aResult)
|
CallGetService(const char *aContractID, const nsIID &aIID, void **aResult)
|
||||||
{
|
{
|
||||||
nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
|
nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
|
||||||
NS_ENSURE_TRUE(compMgr, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!compMgr))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
return compMgr->
|
return compMgr->
|
||||||
nsComponentManagerImpl::GetServiceByContractID(aContractID,
|
nsComponentManagerImpl::GetServiceByContractID(aContractID,
|
||||||
@ -119,7 +121,8 @@ CallCreateInstance(const nsCID &aCID, nsISupports *aDelegate,
|
|||||||
const nsIID &aIID, void **aResult)
|
const nsIID &aIID, void **aResult)
|
||||||
{
|
{
|
||||||
nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
|
nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
|
||||||
NS_ENSURE_TRUE(compMgr, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!compMgr))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
return compMgr->
|
return compMgr->
|
||||||
nsComponentManagerImpl::CreateInstance(aCID, aDelegate, aIID, aResult);
|
nsComponentManagerImpl::CreateInstance(aCID, aDelegate, aIID, aResult);
|
||||||
@ -130,7 +133,8 @@ CallCreateInstance(const char *aContractID, nsISupports *aDelegate,
|
|||||||
const nsIID &aIID, void **aResult)
|
const nsIID &aIID, void **aResult)
|
||||||
{
|
{
|
||||||
nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
|
nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
|
||||||
NS_ENSURE_TRUE(compMgr, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!compMgr))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
return compMgr->
|
return compMgr->
|
||||||
nsComponentManagerImpl::CreateInstanceByContractID(aContractID,
|
nsComponentManagerImpl::CreateInstanceByContractID(aContractID,
|
||||||
@ -142,7 +146,8 @@ nsresult
|
|||||||
CallGetClassObject(const nsCID &aCID, const nsIID &aIID, void **aResult)
|
CallGetClassObject(const nsCID &aCID, const nsIID &aIID, void **aResult)
|
||||||
{
|
{
|
||||||
nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
|
nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
|
||||||
NS_ENSURE_TRUE(compMgr, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!compMgr))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
return compMgr->
|
return compMgr->
|
||||||
nsComponentManagerImpl::GetClassObject(aCID, aIID, aResult);
|
nsComponentManagerImpl::GetClassObject(aCID, aIID, aResult);
|
||||||
@ -152,7 +157,8 @@ nsresult
|
|||||||
CallGetClassObject(const char *aContractID, const nsIID &aIID, void **aResult)
|
CallGetClassObject(const char *aContractID, const nsIID &aIID, void **aResult)
|
||||||
{
|
{
|
||||||
nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
|
nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
|
||||||
NS_ENSURE_TRUE(compMgr, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!compMgr))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
return compMgr->
|
return compMgr->
|
||||||
nsComponentManagerImpl::GetClassObjectByContractID(aContractID, aIID,
|
nsComponentManagerImpl::GetClassObjectByContractID(aContractID, aIID,
|
||||||
|
@ -65,7 +65,8 @@ nsINIParser::Init(nsIFile* aFile)
|
|||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
nsAutoString path;
|
nsAutoString path;
|
||||||
nsresult rv = aFile->GetPath(path);
|
nsresult rv = aFile->GetPath(path);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
fd = _wfopen(path.get(), READ_BINARYMODE);
|
fd = _wfopen(path.get(), READ_BINARYMODE);
|
||||||
#else
|
#else
|
||||||
|
@ -19,7 +19,8 @@ nsMemory::HeapMinimize(bool aImmediate)
|
|||||||
{
|
{
|
||||||
nsCOMPtr<nsIMemory> mem;
|
nsCOMPtr<nsIMemory> mem;
|
||||||
nsresult rv = NS_GetMemoryManager(getter_AddRefs(mem));
|
nsresult rv = NS_GetMemoryManager(getter_AddRefs(mem));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
return mem->HeapMinimize(aImmediate);
|
return mem->HeapMinimize(aImmediate);
|
||||||
}
|
}
|
||||||
|
@ -70,15 +70,18 @@ NS_NewThread(nsIThread **result, nsIRunnable *event, uint32_t stackSize)
|
|||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIThreadManager> mgr =
|
nsCOMPtr<nsIThreadManager> mgr =
|
||||||
do_GetService(NS_THREADMANAGER_CONTRACTID, &rv);
|
do_GetService(NS_THREADMANAGER_CONTRACTID, &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
rv = mgr->NewThread(0, stackSize, getter_AddRefs(thread));
|
rv = mgr->NewThread(0, stackSize, getter_AddRefs(thread));
|
||||||
#endif
|
#endif
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
if (event) {
|
if (event) {
|
||||||
rv = thread->Dispatch(event, NS_DISPATCH_NORMAL);
|
rv = thread->Dispatch(event, NS_DISPATCH_NORMAL);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
*result = nullptr;
|
*result = nullptr;
|
||||||
@ -95,7 +98,8 @@ NS_GetCurrentThread(nsIThread **result)
|
|||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIThreadManager> mgr =
|
nsCOMPtr<nsIThreadManager> mgr =
|
||||||
do_GetService(NS_THREADMANAGER_CONTRACTID, &rv);
|
do_GetService(NS_THREADMANAGER_CONTRACTID, &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
return mgr->GetCurrentThread(result);
|
return mgr->GetCurrentThread(result);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -109,7 +113,8 @@ NS_GetMainThread(nsIThread **result)
|
|||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIThreadManager> mgr =
|
nsCOMPtr<nsIThreadManager> mgr =
|
||||||
do_GetService(NS_THREADMANAGER_CONTRACTID, &rv);
|
do_GetService(NS_THREADMANAGER_CONTRACTID, &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
return mgr->GetMainThread(result);
|
return mgr->GetMainThread(result);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -161,7 +166,8 @@ NS_DispatchToCurrentThread(nsIRunnable *event)
|
|||||||
#else
|
#else
|
||||||
nsCOMPtr<nsIThread> thread;
|
nsCOMPtr<nsIThread> thread;
|
||||||
nsresult rv = NS_GetCurrentThread(getter_AddRefs(thread));
|
nsresult rv = NS_GetCurrentThread(getter_AddRefs(thread));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
#endif
|
#endif
|
||||||
return thread->Dispatch(event, NS_DISPATCH_NORMAL);
|
return thread->Dispatch(event, NS_DISPATCH_NORMAL);
|
||||||
}
|
}
|
||||||
@ -171,7 +177,8 @@ NS_DispatchToMainThread(nsIRunnable *event, uint32_t dispatchFlags)
|
|||||||
{
|
{
|
||||||
nsCOMPtr<nsIThread> thread;
|
nsCOMPtr<nsIThread> thread;
|
||||||
nsresult rv = NS_GetMainThread(getter_AddRefs(thread));
|
nsresult rv = NS_GetMainThread(getter_AddRefs(thread));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
return thread->Dispatch(event, dispatchFlags);
|
return thread->Dispatch(event, dispatchFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,13 +191,15 @@ NS_ProcessPendingEvents(nsIThread *thread, PRIntervalTime timeout)
|
|||||||
#ifdef MOZILLA_INTERNAL_API
|
#ifdef MOZILLA_INTERNAL_API
|
||||||
if (!thread) {
|
if (!thread) {
|
||||||
thread = NS_GetCurrentThread();
|
thread = NS_GetCurrentThread();
|
||||||
NS_ENSURE_STATE(thread);
|
if (NS_WARN_IF(!thread))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
nsCOMPtr<nsIThread> current;
|
nsCOMPtr<nsIThread> current;
|
||||||
if (!thread) {
|
if (!thread) {
|
||||||
rv = NS_GetCurrentThread(getter_AddRefs(current));
|
rv = NS_GetCurrentThread(getter_AddRefs(current));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
thread = current.get();
|
thread = current.get();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -225,7 +234,8 @@ NS_HasPendingEvents(nsIThread *thread)
|
|||||||
return hasPendingEvents(current);
|
return hasPendingEvents(current);
|
||||||
#else
|
#else
|
||||||
thread = NS_GetCurrentThread();
|
thread = NS_GetCurrentThread();
|
||||||
NS_ENSURE_TRUE(thread, false);
|
if (NS_WARN_IF(!thread))
|
||||||
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return hasPendingEvents(thread);
|
return hasPendingEvents(thread);
|
||||||
@ -237,13 +247,15 @@ NS_ProcessNextEvent(nsIThread *thread, bool mayWait)
|
|||||||
#ifdef MOZILLA_INTERNAL_API
|
#ifdef MOZILLA_INTERNAL_API
|
||||||
if (!thread) {
|
if (!thread) {
|
||||||
thread = NS_GetCurrentThread();
|
thread = NS_GetCurrentThread();
|
||||||
NS_ENSURE_TRUE(thread, false);
|
if (NS_WARN_IF(!thread))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
nsCOMPtr<nsIThread> current;
|
nsCOMPtr<nsIThread> current;
|
||||||
if (!thread) {
|
if (!thread) {
|
||||||
NS_GetCurrentThread(getter_AddRefs(current));
|
NS_GetCurrentThread(getter_AddRefs(current));
|
||||||
NS_ENSURE_TRUE(current, false);
|
if (NS_WARN_IF(!current))
|
||||||
|
return false;
|
||||||
thread = current.get();
|
thread = current.get();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -71,7 +71,8 @@ NS_NewNamedThread(const char (&name)[LEN],
|
|||||||
uint32_t stackSize = nsIThreadManager::DEFAULT_STACK_SIZE)
|
uint32_t stackSize = nsIThreadManager::DEFAULT_STACK_SIZE)
|
||||||
{
|
{
|
||||||
nsresult rv = NS_NewThread(result, nullptr, stackSize);
|
nsresult rv = NS_NewThread(result, nullptr, stackSize);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
NS_SetThreadName<LEN>(*result, name);
|
NS_SetThreadName<LEN>(*result, name);
|
||||||
if (initialEvent) {
|
if (initialEvent) {
|
||||||
rv = (*result)->Dispatch(initialEvent, NS_DISPATCH_NORMAL);
|
rv = (*result)->Dispatch(initialEvent, NS_DISPATCH_NORMAL);
|
||||||
|
@ -163,7 +163,8 @@ EncodeInputStream(nsIInputStream *aInputStream,
|
|||||||
|
|
||||||
if (!aCount) {
|
if (!aCount) {
|
||||||
rv = aInputStream->Available(&count64);
|
rv = aInputStream->Available(&count64);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
// if count64 is over 4GB, it will be failed at the below condition,
|
// if count64 is over 4GB, it will be failed at the below condition,
|
||||||
// then will return NS_ERROR_OUT_OF_MEMORY
|
// then will return NS_ERROR_OUT_OF_MEMORY
|
||||||
aCount = (uint32_t)count64;
|
aCount = (uint32_t)count64;
|
||||||
|
@ -16,7 +16,8 @@ nsresult RevealFileInFinder(CFURLRef url)
|
|||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||||
|
|
||||||
NS_ENSURE_ARG_POINTER(url);
|
if (NS_WARN_IF(!url))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
|
||||||
BOOL success = [[NSWorkspace sharedWorkspace] selectFile:[(NSURL*)url path] inFileViewerRootedAtPath:@""];
|
BOOL success = [[NSWorkspace sharedWorkspace] selectFile:[(NSURL*)url path] inFileViewerRootedAtPath:@""];
|
||||||
@ -31,7 +32,8 @@ nsresult OpenURL(CFURLRef url)
|
|||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||||
|
|
||||||
NS_ENSURE_ARG_POINTER(url);
|
if (NS_WARN_IF(!url))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
|
||||||
BOOL success = [[NSWorkspace sharedWorkspace] openURL:(NSURL*)url];
|
BOOL success = [[NSWorkspace sharedWorkspace] openURL:(NSURL*)url];
|
||||||
@ -46,8 +48,8 @@ nsresult GetFileCreatorCode(CFURLRef url, OSType *creatorCode)
|
|||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||||
|
|
||||||
NS_ENSURE_ARG_POINTER(url);
|
if (NS_WARN_IF(!url) || NS_WARN_IF(!creatorCode))
|
||||||
NS_ENSURE_ARG_POINTER(creatorCode);
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsAutoreleasePool localPool;
|
nsAutoreleasePool localPool;
|
||||||
|
|
||||||
@ -76,7 +78,8 @@ nsresult SetFileCreatorCode(CFURLRef url, OSType creatorCode)
|
|||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||||
|
|
||||||
NS_ENSURE_ARG_POINTER(url);
|
if (NS_WARN_IF(!url))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
|
||||||
NSDictionary* dict = [NSDictionary dictionaryWithObject:[NSNumber numberWithUnsignedLong:creatorCode] forKey:NSFileHFSCreatorCode];
|
NSDictionary* dict = [NSDictionary dictionaryWithObject:[NSNumber numberWithUnsignedLong:creatorCode] forKey:NSFileHFSCreatorCode];
|
||||||
@ -91,8 +94,8 @@ nsresult GetFileTypeCode(CFURLRef url, OSType *typeCode)
|
|||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||||
|
|
||||||
NS_ENSURE_ARG_POINTER(url);
|
if (NS_WARN_IF(!url) || NS_WARN_IF(!typeCode))
|
||||||
NS_ENSURE_ARG_POINTER(typeCode);
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsAutoreleasePool localPool;
|
nsAutoreleasePool localPool;
|
||||||
|
|
||||||
@ -121,7 +124,8 @@ nsresult SetFileTypeCode(CFURLRef url, OSType typeCode)
|
|||||||
{
|
{
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||||
|
|
||||||
NS_ENSURE_ARG_POINTER(url);
|
if (NS_WARN_IF(!url))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
|
||||||
NSDictionary* dict = [NSDictionary dictionaryWithObject:[NSNumber numberWithUnsignedLong:typeCode] forKey:NSFileHFSTypeCode];
|
NSDictionary* dict = [NSDictionary dictionaryWithObject:[NSNumber numberWithUnsignedLong:typeCode] forKey:NSFileHFSTypeCode];
|
||||||
|
@ -50,19 +50,23 @@ using namespace mozilla;
|
|||||||
static nsresult
|
static nsresult
|
||||||
GetTempDir(nsIFile** aTempDir)
|
GetTempDir(nsIFile** aTempDir)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(aTempDir);
|
if (NS_WARN_IF(!aTempDir))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
nsCOMPtr<nsIFile> tmpFile;
|
nsCOMPtr<nsIFile> tmpFile;
|
||||||
nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tmpFile));
|
nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tmpFile));
|
||||||
NS_ENSURE_SUCCESS(rv,rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
// On windows DELETE_ON_CLOSE is unreliable, so we store temporary files
|
// On windows DELETE_ON_CLOSE is unreliable, so we store temporary files
|
||||||
// in a subdir of the temp dir and delete that in an idle service observer
|
// in a subdir of the temp dir and delete that in an idle service observer
|
||||||
// to ensure it's been cleared.
|
// to ensure it's been cleared.
|
||||||
rv = tmpFile->AppendNative(nsDependentCString("mozilla-temp-files"));
|
rv = tmpFile->AppendNative(nsDependentCString("mozilla-temp-files"));
|
||||||
NS_ENSURE_SUCCESS(rv,rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
rv = tmpFile->Create(nsIFile::DIRECTORY_TYPE, 0700);
|
rv = tmpFile->Create(nsIFile::DIRECTORY_TYPE, 0700);
|
||||||
NS_ENSURE_TRUE(rv == NS_ERROR_FILE_ALREADY_EXISTS || NS_SUCCEEDED(rv), rv);
|
if (rv != NS_ERROR_FILE_ALREADY_EXISTS && NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tmpFile.forget(aTempDir);
|
tmpFile.forget(aTempDir);
|
||||||
@ -73,12 +77,14 @@ GetTempDir(nsIFile** aTempDir)
|
|||||||
nsresult
|
nsresult
|
||||||
NS_OpenAnonymousTemporaryFile(PRFileDesc** aOutFileDesc)
|
NS_OpenAnonymousTemporaryFile(PRFileDesc** aOutFileDesc)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(aOutFileDesc);
|
if (NS_WARN_IF(!aOutFileDesc))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
nsCOMPtr<nsIFile> tmpFile;
|
nsCOMPtr<nsIFile> tmpFile;
|
||||||
rv = GetTempDir(getter_AddRefs(tmpFile));
|
rv = GetTempDir(getter_AddRefs(tmpFile));
|
||||||
NS_ENSURE_SUCCESS(rv,rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
// Give the temp file a name with a random element. CreateUnique will also
|
// Give the temp file a name with a random element. CreateUnique will also
|
||||||
// append a counter to the name if it encounters a name collision. Adding
|
// append a counter to the name if it encounters a name collision. Adding
|
||||||
@ -90,10 +96,12 @@ NS_OpenAnonymousTemporaryFile(PRFileDesc** aOutFileDesc)
|
|||||||
name.AppendInt(rand());
|
name.AppendInt(rand());
|
||||||
|
|
||||||
rv = tmpFile->AppendNative(name);
|
rv = tmpFile->AppendNative(name);
|
||||||
NS_ENSURE_SUCCESS(rv,rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
rv = tmpFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0700);
|
rv = tmpFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0700);
|
||||||
NS_ENSURE_SUCCESS(rv,rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
rv = tmpFile->OpenNSPRFileDesc(PR_RDWR | nsIFile::DELETE_ON_CLOSE,
|
rv = tmpFile->OpenNSPRFileDesc(PR_RDWR | nsIFile::DELETE_ON_CLOSE,
|
||||||
PR_IRWXU, aOutFileDesc);
|
PR_IRWXU, aOutFileDesc);
|
||||||
@ -146,16 +154,19 @@ public:
|
|||||||
// service is installed when running in xpcshell, and this interferes with
|
// service is installed when running in xpcshell, and this interferes with
|
||||||
// the fake idle service, causing xpcshell-test failures.
|
// the fake idle service, causing xpcshell-test failures.
|
||||||
mTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
|
mTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
|
||||||
NS_ENSURE_TRUE(mTimer != nullptr, NS_ERROR_FAILURE);
|
if (NS_WARN_IF(!mTimer))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
nsresult rv = mTimer->Init(this,
|
nsresult rv = mTimer->Init(this,
|
||||||
SCHEDULE_TIMEOUT_MS,
|
SCHEDULE_TIMEOUT_MS,
|
||||||
nsITimer::TYPE_ONE_SHOT);
|
nsITimer::TYPE_ONE_SHOT);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
// Register shutdown observer so we can cancel the timer if we shutdown before
|
// Register shutdown observer so we can cancel the timer if we shutdown before
|
||||||
// the timer runs.
|
// the timer runs.
|
||||||
nsCOMPtr<nsIObserverService> obsSrv = services::GetObserverService();
|
nsCOMPtr<nsIObserverService> obsSrv = services::GetObserverService();
|
||||||
NS_ENSURE_TRUE(obsSrv != nullptr, NS_ERROR_FAILURE);
|
if (NS_WARN_IF(!obsSrv))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
return obsSrv->AddObserver(this, XPCOM_SHUTDOWN_TOPIC, false);
|
return obsSrv->AddObserver(this, XPCOM_SHUTDOWN_TOPIC, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +222,8 @@ public:
|
|||||||
void RemoveAnonTempFileFiles() {
|
void RemoveAnonTempFileFiles() {
|
||||||
nsCOMPtr<nsIFile> tmpDir;
|
nsCOMPtr<nsIFile> tmpDir;
|
||||||
nsresult rv = GetTempDir(getter_AddRefs(tmpDir));
|
nsresult rv = GetTempDir(getter_AddRefs(tmpDir));
|
||||||
NS_ENSURE_SUCCESS_VOID(rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return;
|
||||||
|
|
||||||
// Remove the directory recursively.
|
// Remove the directory recursively.
|
||||||
tmpDir->Remove(true);
|
tmpDir->Remove(true);
|
||||||
|
@ -87,10 +87,12 @@ NS_IMPL_ISUPPORTS2(nsAppFileLocationProvider, nsIDirectoryServiceProvider, nsIDi
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsAppFileLocationProvider::GetFile(const char *prop, bool *persistent, nsIFile **_retval)
|
nsAppFileLocationProvider::GetFile(const char *prop, bool *persistent, nsIFile **_retval)
|
||||||
{
|
{
|
||||||
|
if (NS_WARN_IF(!prop))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsCOMPtr<nsIFile> localFile;
|
nsCOMPtr<nsIFile> localFile;
|
||||||
nsresult rv = NS_ERROR_FAILURE;
|
nsresult rv = NS_ERROR_FAILURE;
|
||||||
|
|
||||||
NS_ENSURE_ARG(prop);
|
|
||||||
*_retval = nullptr;
|
*_retval = nullptr;
|
||||||
*persistent = true;
|
*persistent = true;
|
||||||
|
|
||||||
@ -250,7 +252,8 @@ nsAppFileLocationProvider::GetFile(const char *prop, bool *persistent, nsIFile *
|
|||||||
|
|
||||||
NS_METHOD nsAppFileLocationProvider::CloneMozBinDirectory(nsIFile **aLocalFile)
|
NS_METHOD nsAppFileLocationProvider::CloneMozBinDirectory(nsIFile **aLocalFile)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aLocalFile);
|
if (NS_WARN_IF(!aLocalFile))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
if (!mMozBinDirectory)
|
if (!mMozBinDirectory)
|
||||||
@ -291,7 +294,8 @@ NS_METHOD nsAppFileLocationProvider::CloneMozBinDirectory(nsIFile **aLocalFile)
|
|||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
NS_METHOD nsAppFileLocationProvider::GetProductDirectory(nsIFile **aLocalFile, bool aLocal)
|
NS_METHOD nsAppFileLocationProvider::GetProductDirectory(nsIFile **aLocalFile, bool aLocal)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aLocalFile);
|
if (NS_WARN_IF(!aLocalFile))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
bool exists;
|
bool exists;
|
||||||
@ -352,7 +356,8 @@ NS_METHOD nsAppFileLocationProvider::GetProductDirectory(nsIFile **aLocalFile, b
|
|||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
NS_METHOD nsAppFileLocationProvider::GetDefaultUserProfileRoot(nsIFile **aLocalFile, bool aLocal)
|
NS_METHOD nsAppFileLocationProvider::GetDefaultUserProfileRoot(nsIFile **aLocalFile, bool aLocal)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aLocalFile);
|
if (NS_WARN_IF(!aLocalFile))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIFile> localDir;
|
nsCOMPtr<nsIFile> localDir;
|
||||||
@ -416,7 +421,8 @@ class nsAppDirectoryEnumerator : public nsISimpleEnumerator
|
|||||||
|
|
||||||
NS_IMETHOD GetNext(nsISupports **result)
|
NS_IMETHOD GetNext(nsISupports **result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(result);
|
if (NS_WARN_IF(!result))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
*result = nullptr;
|
*result = nullptr;
|
||||||
|
|
||||||
bool hasMore;
|
bool hasMore;
|
||||||
@ -511,7 +517,8 @@ class nsPathsDirectoryEnumerator : public nsAppDirectoryEnumerator
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsAppFileLocationProvider::GetFiles(const char *prop, nsISimpleEnumerator **_retval)
|
nsAppFileLocationProvider::GetFiles(const char *prop, nsISimpleEnumerator **_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
*_retval = nullptr;
|
*_retval = nullptr;
|
||||||
nsresult rv = NS_ERROR_FAILURE;
|
nsresult rv = NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
@ -34,21 +34,24 @@ NS_IMPL_ISUPPORTS3(nsBinaryOutputStream, nsIObjectOutputStream, nsIBinaryOutputS
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsBinaryOutputStream::Flush()
|
nsBinaryOutputStream::Flush()
|
||||||
{
|
{
|
||||||
NS_ENSURE_STATE(mOutputStream);
|
if (NS_WARN_IF(!mOutputStream))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
return mOutputStream->Flush();
|
return mOutputStream->Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsBinaryOutputStream::Close()
|
nsBinaryOutputStream::Close()
|
||||||
{
|
{
|
||||||
NS_ENSURE_STATE(mOutputStream);
|
if (NS_WARN_IF(!mOutputStream))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
return mOutputStream->Close();
|
return mOutputStream->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsBinaryOutputStream::Write(const char *aBuf, uint32_t aCount, uint32_t *aActualBytes)
|
nsBinaryOutputStream::Write(const char *aBuf, uint32_t aCount, uint32_t *aActualBytes)
|
||||||
{
|
{
|
||||||
NS_ENSURE_STATE(mOutputStream);
|
if (NS_WARN_IF(!mOutputStream))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
return mOutputStream->Write(aBuf, aCount, aActualBytes);
|
return mOutputStream->Write(aBuf, aCount, aActualBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,14 +72,16 @@ nsBinaryOutputStream::WriteSegments(nsReadSegmentFun reader, void * closure, uin
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsBinaryOutputStream::IsNonBlocking(bool *aNonBlocking)
|
nsBinaryOutputStream::IsNonBlocking(bool *aNonBlocking)
|
||||||
{
|
{
|
||||||
NS_ENSURE_STATE(mOutputStream);
|
if (NS_WARN_IF(!mOutputStream))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
return mOutputStream->IsNonBlocking(aNonBlocking);
|
return mOutputStream->IsNonBlocking(aNonBlocking);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsBinaryOutputStream::WriteFully(const char *aBuf, uint32_t aCount)
|
nsBinaryOutputStream::WriteFully(const char *aBuf, uint32_t aCount)
|
||||||
{
|
{
|
||||||
NS_ENSURE_STATE(mOutputStream);
|
if (NS_WARN_IF(!mOutputStream))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
uint32_t bytesWritten;
|
uint32_t bytesWritten;
|
||||||
@ -91,7 +96,8 @@ nsBinaryOutputStream::WriteFully(const char *aBuf, uint32_t aCount)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsBinaryOutputStream::SetOutputStream(nsIOutputStream *aOutputStream)
|
nsBinaryOutputStream::SetOutputStream(nsIOutputStream *aOutputStream)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aOutputStream);
|
if (NS_WARN_IF(!aOutputStream))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
mOutputStream = aOutputStream;
|
mOutputStream = aOutputStream;
|
||||||
mBufferAccess = do_QueryInterface(aOutputStream);
|
mBufferAccess = do_QueryInterface(aOutputStream);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -245,23 +251,25 @@ nsBinaryOutputStream::WriteCompoundObject(nsISupports* aObject,
|
|||||||
const nsIID& aIID,
|
const nsIID& aIID,
|
||||||
bool aIsStrongRef)
|
bool aIsStrongRef)
|
||||||
{
|
{
|
||||||
// Can't deal with weak refs
|
|
||||||
NS_ENSURE_TRUE(aIsStrongRef, NS_ERROR_UNEXPECTED);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIClassInfo> classInfo = do_QueryInterface(aObject);
|
nsCOMPtr<nsIClassInfo> classInfo = do_QueryInterface(aObject);
|
||||||
NS_ENSURE_TRUE(classInfo, NS_ERROR_NOT_AVAILABLE);
|
|
||||||
|
|
||||||
nsCOMPtr<nsISerializable> serializable = do_QueryInterface(aObject);
|
nsCOMPtr<nsISerializable> serializable = do_QueryInterface(aObject);
|
||||||
NS_ENSURE_TRUE(serializable, NS_ERROR_NOT_AVAILABLE);
|
|
||||||
|
// Can't deal with weak refs
|
||||||
|
if (NS_WARN_IF(!aIsStrongRef))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
if (NS_WARN_IF(!classInfo) || NS_WARN_IF(!serializable))
|
||||||
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
|
|
||||||
nsCID cid;
|
nsCID cid;
|
||||||
classInfo->GetClassIDNoAlloc(&cid);
|
classInfo->GetClassIDNoAlloc(&cid);
|
||||||
|
|
||||||
nsresult rv = WriteID(cid);
|
nsresult rv = WriteID(cid);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
rv = WriteID(aIID);
|
rv = WriteID(aIID);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
return serializable->Write(this);
|
return serializable->Write(this);
|
||||||
}
|
}
|
||||||
@ -270,17 +278,21 @@ NS_IMETHODIMP
|
|||||||
nsBinaryOutputStream::WriteID(const nsIID& aIID)
|
nsBinaryOutputStream::WriteID(const nsIID& aIID)
|
||||||
{
|
{
|
||||||
nsresult rv = Write32(aIID.m0);
|
nsresult rv = Write32(aIID.m0);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
rv = Write16(aIID.m1);
|
rv = Write16(aIID.m1);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
rv = Write16(aIID.m2);
|
rv = Write16(aIID.m2);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
rv = Write8(aIID.m3[i]);
|
rv = Write8(aIID.m3[i]);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -306,14 +318,16 @@ NS_IMPL_ISUPPORTS3(nsBinaryInputStream, nsIObjectInputStream, nsIBinaryInputStre
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsBinaryInputStream::Available(uint64_t* aResult)
|
nsBinaryInputStream::Available(uint64_t* aResult)
|
||||||
{
|
{
|
||||||
NS_ENSURE_STATE(mInputStream);
|
if (NS_WARN_IF(!mInputStream))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
return mInputStream->Available(aResult);
|
return mInputStream->Available(aResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsBinaryInputStream::Read(char* aBuffer, uint32_t aCount, uint32_t *aNumRead)
|
nsBinaryInputStream::Read(char* aBuffer, uint32_t aCount, uint32_t *aNumRead)
|
||||||
{
|
{
|
||||||
NS_ENSURE_STATE(mInputStream);
|
if (NS_WARN_IF(!mInputStream))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
// mInputStream might give us short reads, so deal with that.
|
// mInputStream might give us short reads, so deal with that.
|
||||||
uint32_t totalRead = 0;
|
uint32_t totalRead = 0;
|
||||||
@ -383,7 +397,8 @@ ReadSegmentForwardingThunk(nsIInputStream* aStream,
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsBinaryInputStream::ReadSegments(nsWriteSegmentFun writer, void * closure, uint32_t count, uint32_t *_retval)
|
nsBinaryInputStream::ReadSegments(nsWriteSegmentFun writer, void * closure, uint32_t count, uint32_t *_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_STATE(mInputStream);
|
if (NS_WARN_IF(!mInputStream))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
ReadSegmentsClosure thunkClosure = { this, closure, writer, NS_OK, 0 };
|
ReadSegmentsClosure thunkClosure = { this, closure, writer, NS_OK, 0 };
|
||||||
|
|
||||||
@ -416,21 +431,24 @@ nsBinaryInputStream::ReadSegments(nsWriteSegmentFun writer, void * closure, uint
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsBinaryInputStream::IsNonBlocking(bool *aNonBlocking)
|
nsBinaryInputStream::IsNonBlocking(bool *aNonBlocking)
|
||||||
{
|
{
|
||||||
NS_ENSURE_STATE(mInputStream);
|
if (NS_WARN_IF(!mInputStream))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
return mInputStream->IsNonBlocking(aNonBlocking);
|
return mInputStream->IsNonBlocking(aNonBlocking);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsBinaryInputStream::Close()
|
nsBinaryInputStream::Close()
|
||||||
{
|
{
|
||||||
NS_ENSURE_STATE(mInputStream);
|
if (NS_WARN_IF(!mInputStream))
|
||||||
return mInputStream->Close();
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
return mInputStream->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsBinaryInputStream::SetInputStream(nsIInputStream *aInputStream)
|
nsBinaryInputStream::SetInputStream(nsIInputStream *aInputStream)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aInputStream);
|
if (NS_WARN_IF(!aInputStream))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
mInputStream = aInputStream;
|
mInputStream = aInputStream;
|
||||||
mBufferAccess = do_QueryInterface(aInputStream);
|
mBufferAccess = do_QueryInterface(aInputStream);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -729,7 +747,8 @@ nsBinaryInputStream::ReadArrayBuffer(uint32_t aLength, const JS::Value& aBuffer,
|
|||||||
|
|
||||||
uint32_t bytesRead;
|
uint32_t bytesRead;
|
||||||
nsresult rv = Read(reinterpret_cast<char*>(data), aLength, &bytesRead);
|
nsresult rv = Read(reinterpret_cast<char*>(data), aLength, &bytesRead);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
if (bytesRead != aLength) {
|
if (bytesRead != aLength) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
@ -742,10 +761,12 @@ nsBinaryInputStream::ReadObject(bool aIsStrongRef, nsISupports* *aObject)
|
|||||||
nsCID cid;
|
nsCID cid;
|
||||||
nsIID iid;
|
nsIID iid;
|
||||||
nsresult rv = ReadID(&cid);
|
nsresult rv = ReadID(&cid);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
rv = ReadID(&iid);
|
rv = ReadID(&iid);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
// HACK: Intercept old (pre-gecko6) nsIURI IID, and replace with
|
// HACK: Intercept old (pre-gecko6) nsIURI IID, and replace with
|
||||||
// the updated IID, so that we're QI'ing to an actual interface.
|
// the updated IID, so that we're QI'ing to an actual interface.
|
||||||
@ -774,13 +795,16 @@ nsBinaryInputStream::ReadObject(bool aIsStrongRef, nsISupports* *aObject)
|
|||||||
// END HACK
|
// END HACK
|
||||||
|
|
||||||
nsCOMPtr<nsISupports> object = do_CreateInstance(cid, &rv);
|
nsCOMPtr<nsISupports> object = do_CreateInstance(cid, &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
nsCOMPtr<nsISerializable> serializable = do_QueryInterface(object);
|
nsCOMPtr<nsISerializable> serializable = do_QueryInterface(object);
|
||||||
NS_ENSURE_TRUE(serializable, NS_ERROR_UNEXPECTED);
|
if (NS_WARN_IF(!serializable))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
rv = serializable->Read(this);
|
rv = serializable->Read(this);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
return object->QueryInterface(iid, reinterpret_cast<void**>(aObject));
|
return object->QueryInterface(iid, reinterpret_cast<void**>(aObject));
|
||||||
}
|
}
|
||||||
@ -789,17 +813,21 @@ NS_IMETHODIMP
|
|||||||
nsBinaryInputStream::ReadID(nsID *aResult)
|
nsBinaryInputStream::ReadID(nsID *aResult)
|
||||||
{
|
{
|
||||||
nsresult rv = Read32(&aResult->m0);
|
nsresult rv = Read32(&aResult->m0);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
rv = Read16(&aResult->m1);
|
rv = Read16(&aResult->m1);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
rv = Read16(&aResult->m2);
|
rv = Read16(&aResult->m2);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
for (int i = 0; i < 8; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
rv = Read8(&aResult->m3[i]);
|
rv = Read8(&aResult->m3[i]);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -59,7 +59,8 @@ nsresult
|
|||||||
nsDirectoryService::GetCurrentProcessDirectory(nsIFile** aFile)
|
nsDirectoryService::GetCurrentProcessDirectory(nsIFile** aFile)
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aFile);
|
if (NS_WARN_IF(!aFile))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
*aFile = nullptr;
|
*aFile = nullptr;
|
||||||
|
|
||||||
// Set the component registry location:
|
// Set the component registry location:
|
||||||
@ -225,8 +226,10 @@ nsDirectoryService::nsDirectoryService()
|
|||||||
nsresult
|
nsresult
|
||||||
nsDirectoryService::Create(nsISupports *outer, REFNSIID aIID, void **aResult)
|
nsDirectoryService::Create(nsISupports *outer, REFNSIID aIID, void **aResult)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aResult);
|
if (NS_WARN_IF(!aResult))
|
||||||
NS_ENSURE_NO_AGGREGATION(outer);
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
if (NS_WARN_IF(outer))
|
||||||
|
return NS_ERROR_NO_AGGREGATION;
|
||||||
|
|
||||||
if (!gService)
|
if (!gService)
|
||||||
{
|
{
|
||||||
@ -284,7 +287,8 @@ NS_IMPL_ISUPPORTS4(nsDirectoryService, nsIProperties, nsIDirectoryService, nsIDi
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDirectoryService::Undefine(const char* prop)
|
nsDirectoryService::Undefine(const char* prop)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(prop);
|
if (NS_WARN_IF(!prop))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsDependentCString key(prop);
|
nsDependentCString key(prop);
|
||||||
if (!mHashtable.Get(key, nullptr))
|
if (!mHashtable.Get(key, nullptr))
|
||||||
@ -360,7 +364,8 @@ static bool FindProviderFile(nsIDirectoryServiceProvider* aElement,
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDirectoryService::Get(const char* prop, const nsIID & uuid, void* *result)
|
nsDirectoryService::Get(const char* prop, const nsIID & uuid, void* *result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(prop);
|
if (NS_WARN_IF(!prop))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsDependentCString key(prop);
|
nsDependentCString key(prop);
|
||||||
|
|
||||||
@ -409,7 +414,8 @@ nsDirectoryService::Get(const char* prop, const nsIID & uuid, void* *result)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDirectoryService::Set(const char* prop, nsISupports* value)
|
nsDirectoryService::Set(const char* prop, nsISupports* value)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(prop);
|
if (NS_WARN_IF(!prop))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsDependentCString key(prop);
|
nsDependentCString key(prop);
|
||||||
if (mHashtable.Get(key, nullptr) || !value) {
|
if (mHashtable.Get(key, nullptr) || !value) {
|
||||||
@ -431,7 +437,8 @@ nsDirectoryService::Set(const char* prop, nsISupports* value)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDirectoryService::Has(const char *prop, bool *_retval)
|
nsDirectoryService::Has(const char *prop, bool *_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(prop);
|
if (NS_WARN_IF(!prop))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
*_retval = false;
|
*_retval = false;
|
||||||
nsCOMPtr<nsIFile> value;
|
nsCOMPtr<nsIFile> value;
|
||||||
@ -910,7 +917,8 @@ nsDirectoryService::GetFile(const char *prop, bool *persistent, nsIFile **_retva
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDirectoryService::GetFiles(const char *prop, nsISimpleEnumerator **_retval)
|
nsDirectoryService::GetFiles(const char *prop, nsISimpleEnumerator **_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
*_retval = nullptr;
|
*_retval = nullptr;
|
||||||
|
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
@ -13,7 +13,8 @@ NS_IMPL_ISUPPORTS1(nsIOUtil, nsIIOUtil)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsIOUtil::InputStreamIsBuffered(nsIInputStream* aStream, bool* _retval)
|
nsIOUtil::InputStreamIsBuffered(nsIInputStream* aStream, bool* _retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aStream);
|
if (NS_WARN_IF(!aStream))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
*_retval = NS_InputStreamIsBuffered(aStream);
|
*_retval = NS_InputStreamIsBuffered(aStream);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -21,7 +22,8 @@ nsIOUtil::InputStreamIsBuffered(nsIInputStream* aStream, bool* _retval)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsIOUtil::OutputStreamIsBuffered(nsIOutputStream* aStream, bool* _retval)
|
nsIOUtil::OutputStreamIsBuffered(nsIOutputStream* aStream, bool* _retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aStream);
|
if (NS_WARN_IF(!aStream))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
*_retval = NS_OutputStreamIsBuffered(aStream);
|
*_retval = NS_OutputStreamIsBuffered(aStream);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,6 @@ nsInputStreamTee::TeeSegment(const char *buf, uint32_t count)
|
|||||||
}
|
}
|
||||||
nsRefPtr<nsIRunnable> event =
|
nsRefPtr<nsIRunnable> event =
|
||||||
new nsInputStreamTeeWriteEvent(buf, count, mSink, this);
|
new nsInputStreamTeeWriteEvent(buf, count, mSink, this);
|
||||||
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
|
|
||||||
LOG(("nsInputStreamTee::TeeSegment [%p] dispatching write %u bytes\n",
|
LOG(("nsInputStreamTee::TeeSegment [%p] dispatching write %u bytes\n",
|
||||||
this, count));
|
this, count));
|
||||||
return mEventTarget->Dispatch(event, NS_DISPATCH_NORMAL);
|
return mEventTarget->Dispatch(event, NS_DISPATCH_NORMAL);
|
||||||
@ -214,7 +213,8 @@ NS_IMPL_ISUPPORTS2(nsInputStreamTee,
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsInputStreamTee::Close()
|
nsInputStreamTee::Close()
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mSource, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mSource))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
nsresult rv = mSource->Close();
|
nsresult rv = mSource->Close();
|
||||||
mSource = 0;
|
mSource = 0;
|
||||||
mSink = 0;
|
mSink = 0;
|
||||||
@ -224,14 +224,16 @@ nsInputStreamTee::Close()
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsInputStreamTee::Available(uint64_t *avail)
|
nsInputStreamTee::Available(uint64_t *avail)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mSource, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mSource))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
return mSource->Available(avail);
|
return mSource->Available(avail);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsInputStreamTee::Read(char *buf, uint32_t count, uint32_t *bytesRead)
|
nsInputStreamTee::Read(char *buf, uint32_t count, uint32_t *bytesRead)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mSource, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mSource))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
nsresult rv = mSource->Read(buf, count, bytesRead);
|
nsresult rv = mSource->Read(buf, count, bytesRead);
|
||||||
if (NS_FAILED(rv) || (*bytesRead == 0))
|
if (NS_FAILED(rv) || (*bytesRead == 0))
|
||||||
@ -246,7 +248,8 @@ nsInputStreamTee::ReadSegments(nsWriteSegmentFun writer,
|
|||||||
uint32_t count,
|
uint32_t count,
|
||||||
uint32_t *bytesRead)
|
uint32_t *bytesRead)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mSource, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mSource))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
mWriter = writer;
|
mWriter = writer;
|
||||||
mClosure = closure;
|
mClosure = closure;
|
||||||
@ -257,7 +260,8 @@ nsInputStreamTee::ReadSegments(nsWriteSegmentFun writer,
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsInputStreamTee::IsNonBlocking(bool *result)
|
nsInputStreamTee::IsNonBlocking(bool *result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mSource, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mSource))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
return mSource->IsNonBlocking(result);
|
return mSource->IsNonBlocking(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,8 @@ void NS_ShutdownLocalFile()
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::InitWithFile(nsIFile *aFile)
|
nsLocalFile::InitWithFile(nsIFile *aFile)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(aFile);
|
if (NS_WARN_IF(!aFile))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsAutoCString path;
|
nsAutoCString path;
|
||||||
aFile->GetNativePath(path);
|
aFile->GetNativePath(path);
|
||||||
@ -189,7 +190,8 @@ static int32_t SplitPath(PRUnichar *path, PRUnichar **nodeArray, int32_t arrayLe
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::GetRelativeDescriptor(nsIFile *fromFile, nsACString& _retval)
|
nsLocalFile::GetRelativeDescriptor(nsIFile *fromFile, nsACString& _retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(fromFile);
|
if (NS_WARN_IF(!fromFile))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
const int32_t kMaxNodesInPath = 32;
|
const int32_t kMaxNodesInPath = 32;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -243,8 +243,10 @@ nsLocalFile::nsLocalFileConstructor(nsISupports *outer,
|
|||||||
const nsIID &aIID,
|
const nsIID &aIID,
|
||||||
void **aInstancePtr)
|
void **aInstancePtr)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
if (NS_WARN_IF(!aInstancePtr))
|
||||||
NS_ENSURE_NO_AGGREGATION(outer);
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
if (NS_WARN_IF(outer))
|
||||||
|
return NS_ERROR_NO_AGGREGATION;
|
||||||
|
|
||||||
*aInstancePtr = nullptr;
|
*aInstancePtr = nullptr;
|
||||||
|
|
||||||
@ -1005,7 +1007,8 @@ NS_IMETHODIMP
|
|||||||
nsLocalFile::GetLastModifiedTime(PRTime *aLastModTime)
|
nsLocalFile::GetLastModifiedTime(PRTime *aLastModTime)
|
||||||
{
|
{
|
||||||
CHECK_mPath();
|
CHECK_mPath();
|
||||||
NS_ENSURE_ARG(aLastModTime);
|
if (NS_WARN_IF(!aLastModTime))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
PRFileInfo64 info;
|
PRFileInfo64 info;
|
||||||
if (PR_GetFileInfo64(mPath.get(), &info) != PR_SUCCESS)
|
if (PR_GetFileInfo64(mPath.get(), &info) != PR_SUCCESS)
|
||||||
@ -1043,7 +1046,8 @@ NS_IMETHODIMP
|
|||||||
nsLocalFile::GetLastModifiedTimeOfLink(PRTime *aLastModTimeOfLink)
|
nsLocalFile::GetLastModifiedTimeOfLink(PRTime *aLastModTimeOfLink)
|
||||||
{
|
{
|
||||||
CHECK_mPath();
|
CHECK_mPath();
|
||||||
NS_ENSURE_ARG(aLastModTimeOfLink);
|
if (NS_WARN_IF(!aLastModTimeOfLink))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
struct STAT sbuf;
|
struct STAT sbuf;
|
||||||
if (LSTAT(mPath.get(), &sbuf) == -1)
|
if (LSTAT(mPath.get(), &sbuf) == -1)
|
||||||
@ -1072,7 +1076,8 @@ nsLocalFile::SetLastModifiedTimeOfLink(PRTime aLastModTimeOfLink)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::GetPermissions(uint32_t *aPermissions)
|
nsLocalFile::GetPermissions(uint32_t *aPermissions)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(aPermissions);
|
if (NS_WARN_IF(!aPermissions))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
ENSURE_STAT_CACHE();
|
ENSURE_STAT_CACHE();
|
||||||
*aPermissions = NORMALIZE_PERMS(mCachedStat.st_mode);
|
*aPermissions = NORMALIZE_PERMS(mCachedStat.st_mode);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -1082,7 +1087,8 @@ NS_IMETHODIMP
|
|||||||
nsLocalFile::GetPermissionsOfLink(uint32_t *aPermissionsOfLink)
|
nsLocalFile::GetPermissionsOfLink(uint32_t *aPermissionsOfLink)
|
||||||
{
|
{
|
||||||
CHECK_mPath();
|
CHECK_mPath();
|
||||||
NS_ENSURE_ARG(aPermissionsOfLink);
|
if (NS_WARN_IF(!aPermissionsOfLink))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
struct STAT sbuf;
|
struct STAT sbuf;
|
||||||
if (LSTAT(mPath.get(), &sbuf) == -1)
|
if (LSTAT(mPath.get(), &sbuf) == -1)
|
||||||
@ -1127,7 +1133,8 @@ nsLocalFile::SetPermissionsOfLink(uint32_t aPermissions)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::GetFileSize(int64_t *aFileSize)
|
nsLocalFile::GetFileSize(int64_t *aFileSize)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aFileSize);
|
if (NS_WARN_IF(!aFileSize))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
*aFileSize = 0;
|
*aFileSize = 0;
|
||||||
ENSURE_STAT_CACHE();
|
ENSURE_STAT_CACHE();
|
||||||
|
|
||||||
@ -1176,7 +1183,8 @@ NS_IMETHODIMP
|
|||||||
nsLocalFile::GetFileSizeOfLink(int64_t *aFileSize)
|
nsLocalFile::GetFileSizeOfLink(int64_t *aFileSize)
|
||||||
{
|
{
|
||||||
CHECK_mPath();
|
CHECK_mPath();
|
||||||
NS_ENSURE_ARG(aFileSize);
|
if (NS_WARN_IF(!aFileSize))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
struct STAT sbuf;
|
struct STAT sbuf;
|
||||||
if (LSTAT(mPath.get(), &sbuf) == -1)
|
if (LSTAT(mPath.get(), &sbuf) == -1)
|
||||||
@ -1241,7 +1249,8 @@ GetDeviceName(int deviceMajor, int deviceMinor, nsACString &deviceName)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::GetDiskSpaceAvailable(int64_t *aDiskSpaceAvailable)
|
nsLocalFile::GetDiskSpaceAvailable(int64_t *aDiskSpaceAvailable)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aDiskSpaceAvailable);
|
if (NS_WARN_IF(!aDiskSpaceAvailable))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
// These systems have the operations necessary to check disk space.
|
// These systems have the operations necessary to check disk space.
|
||||||
|
|
||||||
@ -1326,7 +1335,8 @@ NS_IMETHODIMP
|
|||||||
nsLocalFile::GetParent(nsIFile **aParent)
|
nsLocalFile::GetParent(nsIFile **aParent)
|
||||||
{
|
{
|
||||||
CHECK_mPath();
|
CHECK_mPath();
|
||||||
NS_ENSURE_ARG_POINTER(aParent);
|
if (NS_WARN_IF(!aParent))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
*aParent = nullptr;
|
*aParent = nullptr;
|
||||||
|
|
||||||
// if '/' we are at the top of the volume, return null
|
// if '/' we are at the top of the volume, return null
|
||||||
@ -1372,7 +1382,8 @@ NS_IMETHODIMP
|
|||||||
nsLocalFile::Exists(bool *_retval)
|
nsLocalFile::Exists(bool *_retval)
|
||||||
{
|
{
|
||||||
CHECK_mPath();
|
CHECK_mPath();
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
*_retval = (access(mPath.get(), F_OK) == 0);
|
*_retval = (access(mPath.get(), F_OK) == 0);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -1383,7 +1394,8 @@ NS_IMETHODIMP
|
|||||||
nsLocalFile::IsWritable(bool *_retval)
|
nsLocalFile::IsWritable(bool *_retval)
|
||||||
{
|
{
|
||||||
CHECK_mPath();
|
CHECK_mPath();
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
*_retval = (access(mPath.get(), W_OK) == 0);
|
*_retval = (access(mPath.get(), W_OK) == 0);
|
||||||
if (*_retval || errno == EACCES)
|
if (*_retval || errno == EACCES)
|
||||||
@ -1395,7 +1407,8 @@ NS_IMETHODIMP
|
|||||||
nsLocalFile::IsReadable(bool *_retval)
|
nsLocalFile::IsReadable(bool *_retval)
|
||||||
{
|
{
|
||||||
CHECK_mPath();
|
CHECK_mPath();
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
*_retval = (access(mPath.get(), R_OK) == 0);
|
*_retval = (access(mPath.get(), R_OK) == 0);
|
||||||
if (*_retval || errno == EACCES)
|
if (*_retval || errno == EACCES)
|
||||||
@ -1407,7 +1420,8 @@ NS_IMETHODIMP
|
|||||||
nsLocalFile::IsExecutable(bool *_retval)
|
nsLocalFile::IsExecutable(bool *_retval)
|
||||||
{
|
{
|
||||||
CHECK_mPath();
|
CHECK_mPath();
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
// Check extension (bug 663899). On certain platforms, the file
|
// Check extension (bug 663899). On certain platforms, the file
|
||||||
// extension may cause the OS to treat it as executable regardless of
|
// extension may cause the OS to treat it as executable regardless of
|
||||||
@ -1496,7 +1510,8 @@ nsLocalFile::IsExecutable(bool *_retval)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::IsDirectory(bool *_retval)
|
nsLocalFile::IsDirectory(bool *_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
*_retval = false;
|
*_retval = false;
|
||||||
ENSURE_STAT_CACHE();
|
ENSURE_STAT_CACHE();
|
||||||
*_retval = S_ISDIR(mCachedStat.st_mode);
|
*_retval = S_ISDIR(mCachedStat.st_mode);
|
||||||
@ -1506,7 +1521,8 @@ nsLocalFile::IsDirectory(bool *_retval)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::IsFile(bool *_retval)
|
nsLocalFile::IsFile(bool *_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
*_retval = false;
|
*_retval = false;
|
||||||
ENSURE_STAT_CACHE();
|
ENSURE_STAT_CACHE();
|
||||||
*_retval = S_ISREG(mCachedStat.st_mode);
|
*_retval = S_ISREG(mCachedStat.st_mode);
|
||||||
@ -1516,7 +1532,8 @@ nsLocalFile::IsFile(bool *_retval)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::IsHidden(bool *_retval)
|
nsLocalFile::IsHidden(bool *_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
nsACString::const_iterator begin, end;
|
nsACString::const_iterator begin, end;
|
||||||
LocateNativeLeafName(begin, end);
|
LocateNativeLeafName(begin, end);
|
||||||
*_retval = (*begin == '.');
|
*_retval = (*begin == '.');
|
||||||
@ -1526,7 +1543,8 @@ nsLocalFile::IsHidden(bool *_retval)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::IsSymlink(bool *_retval)
|
nsLocalFile::IsSymlink(bool *_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
CHECK_mPath();
|
CHECK_mPath();
|
||||||
|
|
||||||
struct STAT symStat;
|
struct STAT symStat;
|
||||||
@ -1539,7 +1557,8 @@ nsLocalFile::IsSymlink(bool *_retval)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::IsSpecial(bool *_retval)
|
nsLocalFile::IsSpecial(bool *_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
ENSURE_STAT_CACHE();
|
ENSURE_STAT_CACHE();
|
||||||
*_retval = S_ISCHR(mCachedStat.st_mode) ||
|
*_retval = S_ISCHR(mCachedStat.st_mode) ||
|
||||||
S_ISBLK(mCachedStat.st_mode) ||
|
S_ISBLK(mCachedStat.st_mode) ||
|
||||||
@ -1554,8 +1573,10 @@ nsLocalFile::IsSpecial(bool *_retval)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::Equals(nsIFile *inFile, bool *_retval)
|
nsLocalFile::Equals(nsIFile *inFile, bool *_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(inFile);
|
if (NS_WARN_IF(!inFile))
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
*_retval = false;
|
*_retval = false;
|
||||||
|
|
||||||
nsAutoCString inPath;
|
nsAutoCString inPath;
|
||||||
@ -1573,8 +1594,10 @@ NS_IMETHODIMP
|
|||||||
nsLocalFile::Contains(nsIFile *inFile, bool recur, bool *_retval)
|
nsLocalFile::Contains(nsIFile *inFile, bool recur, bool *_retval)
|
||||||
{
|
{
|
||||||
CHECK_mPath();
|
CHECK_mPath();
|
||||||
NS_ENSURE_ARG(inFile);
|
if (NS_WARN_IF(!inFile))
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsAutoCString inPath;
|
nsAutoCString inPath;
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
@ -1710,7 +1733,8 @@ NS_IMETHODIMP
|
|||||||
nsLocalFile::Load(PRLibrary **_retval)
|
nsLocalFile::Load(PRLibrary **_retval)
|
||||||
{
|
{
|
||||||
CHECK_mPath();
|
CHECK_mPath();
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
#ifdef NS_BUILD_REFCNT_LOGGING
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
||||||
nsTraceRefcntImpl::SetActivityIsLegal(false);
|
nsTraceRefcntImpl::SetActivityIsLegal(false);
|
||||||
@ -2121,7 +2145,8 @@ nsLocalFile::InitWithCFURL(CFURLRef aCFURL)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::InitWithFSRef(const FSRef *aFSRef)
|
nsLocalFile::InitWithFSRef(const FSRef *aFSRef)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(aFSRef);
|
if (NS_WARN_IF(!aFSRef))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
CFURLRef newURLRef = ::CFURLCreateFromFSRef(kCFAllocatorDefault, aFSRef);
|
CFURLRef newURLRef = ::CFURLCreateFromFSRef(kCFAllocatorDefault, aFSRef);
|
||||||
if (newURLRef) {
|
if (newURLRef) {
|
||||||
@ -2151,7 +2176,8 @@ nsLocalFile::GetCFURL(CFURLRef *_retval)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::GetFSRef(FSRef *_retval)
|
nsLocalFile::GetFSRef(FSRef *_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsresult rv = NS_ERROR_FAILURE;
|
nsresult rv = NS_ERROR_FAILURE;
|
||||||
|
|
||||||
@ -2169,7 +2195,8 @@ nsLocalFile::GetFSRef(FSRef *_retval)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::GetFSSpec(FSSpec *_retval)
|
nsLocalFile::GetFSSpec(FSSpec *_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
FSRef fsRef;
|
FSRef fsRef;
|
||||||
nsresult rv = GetFSRef(&fsRef);
|
nsresult rv = GetFSRef(&fsRef);
|
||||||
@ -2184,7 +2211,8 @@ nsLocalFile::GetFSSpec(FSSpec *_retval)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::GetFileSizeWithResFork(int64_t *aFileSizeWithResFork)
|
nsLocalFile::GetFileSizeWithResFork(int64_t *aFileSizeWithResFork)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aFileSizeWithResFork);
|
if (NS_WARN_IF(!aFileSizeWithResFork))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
FSRef fsRef;
|
FSRef fsRef;
|
||||||
nsresult rv = GetFSRef(&fsRef);
|
nsresult rv = GetFSRef(&fsRef);
|
||||||
@ -2343,7 +2371,8 @@ nsLocalFile::OpenDocWithApp(nsIFile *aAppToOpenWith, bool aLaunchInBackground)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::IsPackage(bool *_retval)
|
nsLocalFile::IsPackage(bool *_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
*_retval = false;
|
*_retval = false;
|
||||||
|
|
||||||
CFURLRef url;
|
CFURLRef url;
|
||||||
@ -2414,7 +2443,8 @@ NS_IMETHODIMP
|
|||||||
nsLocalFile::GetBundleContentsLastModifiedTime(int64_t *aLastModTime)
|
nsLocalFile::GetBundleContentsLastModifiedTime(int64_t *aLastModTime)
|
||||||
{
|
{
|
||||||
CHECK_mPath();
|
CHECK_mPath();
|
||||||
NS_ENSURE_ARG_POINTER(aLastModTime);
|
if (NS_WARN_IF(!aLastModTime))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
bool isPackage = false;
|
bool isPackage = false;
|
||||||
nsresult rv = IsPackage(&isPackage);
|
nsresult rv = IsPackage(&isPackage);
|
||||||
@ -2440,7 +2470,8 @@ nsLocalFile::GetBundleContentsLastModifiedTime(int64_t *aLastModTime)
|
|||||||
|
|
||||||
NS_IMETHODIMP nsLocalFile::InitWithFile(nsIFile *aFile)
|
NS_IMETHODIMP nsLocalFile::InitWithFile(nsIFile *aFile)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(aFile);
|
if (NS_WARN_IF(!aFile))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsAutoCString nativePath;
|
nsAutoCString nativePath;
|
||||||
nsresult rv = aFile->GetNativePath(nativePath);
|
nsresult rv = aFile->GetNativePath(nativePath);
|
||||||
|
@ -725,7 +725,8 @@ struct nsDir
|
|||||||
static nsresult
|
static nsresult
|
||||||
OpenDir(const nsAFlatString &name, nsDir * *dir)
|
OpenDir(const nsAFlatString &name, nsDir * *dir)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(dir);
|
if (NS_WARN_IF(!dir))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
*dir = nullptr;
|
*dir = nullptr;
|
||||||
if (name.Length() + 3 >= MAX_PATH)
|
if (name.Length() + 3 >= MAX_PATH)
|
||||||
@ -765,7 +766,8 @@ static nsresult
|
|||||||
ReadDir(nsDir *dir, PRDirFlags flags, nsString& name)
|
ReadDir(nsDir *dir, PRDirFlags flags, nsString& name)
|
||||||
{
|
{
|
||||||
name.Truncate();
|
name.Truncate();
|
||||||
NS_ENSURE_ARG(dir);
|
if (NS_WARN_IF(!dir))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
BOOL rv;
|
BOOL rv;
|
||||||
@ -809,7 +811,8 @@ ReadDir(nsDir *dir, PRDirFlags flags, nsString& name)
|
|||||||
static nsresult
|
static nsresult
|
||||||
CloseDir(nsDir *&d)
|
CloseDir(nsDir *&d)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(d);
|
if (NS_WARN_IF(!d))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
BOOL isOk = FindClose(d->handle);
|
BOOL isOk = FindClose(d->handle);
|
||||||
// PR_DELETE also nulls out the passed in pointer.
|
// PR_DELETE also nulls out the passed in pointer.
|
||||||
@ -962,8 +965,10 @@ nsLocalFile::nsLocalFile()
|
|||||||
nsresult
|
nsresult
|
||||||
nsLocalFile::nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
|
nsLocalFile::nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
if (NS_WARN_IF(!aInstancePtr))
|
||||||
NS_ENSURE_NO_AGGREGATION(outer);
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
if (NS_WARN_IF(outer))
|
||||||
|
return NS_ERROR_NO_AGGREGATION;
|
||||||
|
|
||||||
nsLocalFile* inst = new nsLocalFile();
|
nsLocalFile* inst = new nsLocalFile();
|
||||||
if (inst == nullptr)
|
if (inst == nullptr)
|
||||||
@ -1149,7 +1154,8 @@ nsLocalFile::Clone(nsIFile **file)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::InitWithFile(nsIFile *aFile)
|
nsLocalFile::InitWithFile(nsIFile *aFile)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(aFile);
|
if (NS_WARN_IF(!aFile))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsAutoString path;
|
nsAutoString path;
|
||||||
aFile->GetPath(path);
|
aFile->GetPath(path);
|
||||||
@ -2072,7 +2078,8 @@ nsLocalFile::CopyMove(nsIFile *aParentDir, const nsAString &newName, bool follow
|
|||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
rv = file->MoveTo(target, EmptyString());
|
rv = file->MoveTo(target, EmptyString());
|
||||||
NS_ENSURE_SUCCESS(rv,rv);
|
if (NS_FAILED(rv))
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2080,7 +2087,8 @@ nsLocalFile::CopyMove(nsIFile *aParentDir, const nsAString &newName, bool follow
|
|||||||
rv = file->CopyToFollowingLinks(target, EmptyString());
|
rv = file->CopyToFollowingLinks(target, EmptyString());
|
||||||
else
|
else
|
||||||
rv = file->CopyTo(target, EmptyString());
|
rv = file->CopyTo(target, EmptyString());
|
||||||
NS_ENSURE_SUCCESS(rv,rv);
|
if (NS_FAILED(rv))
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2093,7 +2101,8 @@ nsLocalFile::CopyMove(nsIFile *aParentDir, const nsAString &newName, bool follow
|
|||||||
if (move)
|
if (move)
|
||||||
{
|
{
|
||||||
rv = Remove(false /* recursive */);
|
rv = Remove(false /* recursive */);
|
||||||
NS_ENSURE_SUCCESS(rv,rv);
|
if (NS_FAILED(rv))
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2258,7 +2267,8 @@ nsLocalFile::GetLastModifiedTime(PRTime *aLastModifiedTime)
|
|||||||
// Check we are correctly initialized.
|
// Check we are correctly initialized.
|
||||||
CHECK_mWorkingPath();
|
CHECK_mWorkingPath();
|
||||||
|
|
||||||
NS_ENSURE_ARG(aLastModifiedTime);
|
if (NS_WARN_IF(!aLastModifiedTime))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
// get the modified time of the target as determined by mFollowSymlinks
|
// get the modified time of the target as determined by mFollowSymlinks
|
||||||
// If true, then this will be for the target of the shortcut file,
|
// If true, then this will be for the target of the shortcut file,
|
||||||
@ -2281,7 +2291,8 @@ nsLocalFile::GetLastModifiedTimeOfLink(PRTime *aLastModifiedTime)
|
|||||||
// Check we are correctly initialized.
|
// Check we are correctly initialized.
|
||||||
CHECK_mWorkingPath();
|
CHECK_mWorkingPath();
|
||||||
|
|
||||||
NS_ENSURE_ARG(aLastModifiedTime);
|
if (NS_WARN_IF(!aLastModifiedTime))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
// The caller is assumed to have already called IsSymlink
|
// The caller is assumed to have already called IsSymlink
|
||||||
// and to have found that this file is a link.
|
// and to have found that this file is a link.
|
||||||
@ -2381,7 +2392,8 @@ nsLocalFile::SetModDate(PRTime aLastModifiedTime, const PRUnichar *filePath)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::GetPermissions(uint32_t *aPermissions)
|
nsLocalFile::GetPermissions(uint32_t *aPermissions)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(aPermissions);
|
if (NS_WARN_IF(!aPermissions))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
// get the permissions of the target as determined by mFollowSymlinks
|
// get the permissions of the target as determined by mFollowSymlinks
|
||||||
// If true, then this will be for the target of the shortcut file,
|
// If true, then this will be for the target of the shortcut file,
|
||||||
@ -2410,7 +2422,8 @@ nsLocalFile::GetPermissionsOfLink(uint32_t *aPermissions)
|
|||||||
// Check we are correctly initialized.
|
// Check we are correctly initialized.
|
||||||
CHECK_mWorkingPath();
|
CHECK_mWorkingPath();
|
||||||
|
|
||||||
NS_ENSURE_ARG(aPermissions);
|
if (NS_WARN_IF(!aPermissions))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
// The caller is assumed to have already called IsSymlink
|
// The caller is assumed to have already called IsSymlink
|
||||||
// and to have found that this file is a link. It is not
|
// and to have found that this file is a link. It is not
|
||||||
@ -2479,7 +2492,8 @@ nsLocalFile::SetPermissionsOfLink(uint32_t aPermissions)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::GetFileSize(int64_t *aFileSize)
|
nsLocalFile::GetFileSize(int64_t *aFileSize)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(aFileSize);
|
if (NS_WARN_IF(!aFileSize))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsresult rv = ResolveAndStat();
|
nsresult rv = ResolveAndStat();
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
@ -2496,7 +2510,8 @@ nsLocalFile::GetFileSizeOfLink(int64_t *aFileSize)
|
|||||||
// Check we are correctly initialized.
|
// Check we are correctly initialized.
|
||||||
CHECK_mWorkingPath();
|
CHECK_mWorkingPath();
|
||||||
|
|
||||||
NS_ENSURE_ARG(aFileSize);
|
if (NS_WARN_IF(!aFileSize))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
// The caller is assumed to have already called IsSymlink
|
// The caller is assumed to have already called IsSymlink
|
||||||
// and to have found that this file is a link.
|
// and to have found that this file is a link.
|
||||||
@ -2551,7 +2566,8 @@ nsLocalFile::GetDiskSpaceAvailable(int64_t *aDiskSpaceAvailable)
|
|||||||
// Check we are correctly initialized.
|
// Check we are correctly initialized.
|
||||||
CHECK_mWorkingPath();
|
CHECK_mWorkingPath();
|
||||||
|
|
||||||
NS_ENSURE_ARG(aDiskSpaceAvailable);
|
if (NS_WARN_IF(!aDiskSpaceAvailable))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
ResolveAndStat();
|
ResolveAndStat();
|
||||||
|
|
||||||
@ -2580,7 +2596,8 @@ nsLocalFile::GetParent(nsIFile * *aParent)
|
|||||||
// Check we are correctly initialized.
|
// Check we are correctly initialized.
|
||||||
CHECK_mWorkingPath();
|
CHECK_mWorkingPath();
|
||||||
|
|
||||||
NS_ENSURE_ARG_POINTER(aParent);
|
if (NS_WARN_IF(!aParent))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
// A two-character path must be a drive such as C:, so it has no parent
|
// A two-character path must be a drive such as C:, so it has no parent
|
||||||
if (mWorkingPath.Length() == 2) {
|
if (mWorkingPath.Length() == 2) {
|
||||||
@ -2624,7 +2641,8 @@ nsLocalFile::Exists(bool *_retval)
|
|||||||
// Check we are correctly initialized.
|
// Check we are correctly initialized.
|
||||||
CHECK_mWorkingPath();
|
CHECK_mWorkingPath();
|
||||||
|
|
||||||
NS_ENSURE_ARG(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
*_retval = false;
|
*_retval = false;
|
||||||
|
|
||||||
MakeDirty();
|
MakeDirty();
|
||||||
@ -2694,7 +2712,8 @@ nsLocalFile::IsReadable(bool *_retval)
|
|||||||
// Check we are correctly initialized.
|
// Check we are correctly initialized.
|
||||||
CHECK_mWorkingPath();
|
CHECK_mWorkingPath();
|
||||||
|
|
||||||
NS_ENSURE_ARG(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
*_retval = false;
|
*_retval = false;
|
||||||
|
|
||||||
nsresult rv = ResolveAndStat();
|
nsresult rv = ResolveAndStat();
|
||||||
@ -2712,7 +2731,8 @@ nsLocalFile::IsExecutable(bool *_retval)
|
|||||||
// Check we are correctly initialized.
|
// Check we are correctly initialized.
|
||||||
CHECK_mWorkingPath();
|
CHECK_mWorkingPath();
|
||||||
|
|
||||||
NS_ENSURE_ARG(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
*_retval = false;
|
*_retval = false;
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
@ -2867,7 +2887,8 @@ nsLocalFile::IsHidden(bool *_retval)
|
|||||||
nsresult
|
nsresult
|
||||||
nsLocalFile::HasFileAttribute(DWORD fileAttrib, bool *_retval)
|
nsLocalFile::HasFileAttribute(DWORD fileAttrib, bool *_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsresult rv = Resolve();
|
nsresult rv = Resolve();
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
@ -2889,7 +2910,8 @@ nsLocalFile::IsSymlink(bool *_retval)
|
|||||||
// Check we are correctly initialized.
|
// Check we are correctly initialized.
|
||||||
CHECK_mWorkingPath();
|
CHECK_mWorkingPath();
|
||||||
|
|
||||||
NS_ENSURE_ARG(_retval);
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
// unless it is a valid shortcut path it's not a symlink
|
// unless it is a valid shortcut path it's not a symlink
|
||||||
if (!IsShortcutPath(mWorkingPath)) {
|
if (!IsShortcutPath(mWorkingPath)) {
|
||||||
@ -2920,8 +2942,10 @@ nsLocalFile::IsSpecial(bool *_retval)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::Equals(nsIFile *inFile, bool *_retval)
|
nsLocalFile::Equals(nsIFile *inFile, bool *_retval)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(inFile);
|
if (NS_WARN_IF(!inFile))
|
||||||
NS_ENSURE_ARG(_retval);
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
if (NS_WARN_IF(!_retval))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
EnsureShortPath();
|
EnsureShortPath();
|
||||||
|
|
||||||
|
@ -118,7 +118,6 @@ nsMultiplexInputStream::InsertStream(nsIInputStream *aStream, uint32_t aIndex)
|
|||||||
{
|
{
|
||||||
NS_ASSERTION(SeekableStreamAtBeginning(aStream), "Inserted stream not at beginning.");
|
NS_ASSERTION(SeekableStreamAtBeginning(aStream), "Inserted stream not at beginning.");
|
||||||
bool result = mStreams.InsertElementAt(aIndex, aStream);
|
bool result = mStreams.InsertElementAt(aIndex, aStream);
|
||||||
NS_ENSURE_TRUE(result, NS_ERROR_OUT_OF_MEMORY);
|
|
||||||
if (mCurrentStream > aIndex ||
|
if (mCurrentStream > aIndex ||
|
||||||
(mCurrentStream == aIndex && mStartedReadingCurrent))
|
(mCurrentStream == aIndex && mStartedReadingCurrent))
|
||||||
++mCurrentStream;
|
++mCurrentStream;
|
||||||
@ -143,7 +142,8 @@ NS_IMETHODIMP
|
|||||||
nsMultiplexInputStream::GetStream(uint32_t aIndex, nsIInputStream **_retval)
|
nsMultiplexInputStream::GetStream(uint32_t aIndex, nsIInputStream **_retval)
|
||||||
{
|
{
|
||||||
*_retval = mStreams.SafeElementAt(aIndex, nullptr);
|
*_retval = mStreams.SafeElementAt(aIndex, nullptr);
|
||||||
NS_ENSURE_TRUE(*_retval, NS_ERROR_NOT_AVAILABLE);
|
if (NS_WARN_IF(!*_retval))
|
||||||
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
|
|
||||||
NS_ADDREF(*_retval);
|
NS_ADDREF(*_retval);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -181,7 +181,8 @@ nsMultiplexInputStream::Available(uint64_t *_retval)
|
|||||||
for (uint32_t i = mCurrentStream; i < len; i++) {
|
for (uint32_t i = mCurrentStream; i < len; i++) {
|
||||||
uint64_t streamAvail;
|
uint64_t streamAvail;
|
||||||
rv = mStreams[i]->Available(&streamAvail);
|
rv = mStreams[i]->Available(&streamAvail);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
avail += streamAvail;
|
avail += streamAvail;
|
||||||
}
|
}
|
||||||
*_retval = avail;
|
*_retval = avail;
|
||||||
@ -328,7 +329,8 @@ nsMultiplexInputStream::IsNonBlocking(bool *aNonBlocking)
|
|||||||
}
|
}
|
||||||
for (uint32_t i = 0; i < len; ++i) {
|
for (uint32_t i = 0; i < len; ++i) {
|
||||||
nsresult rv = mStreams[i]->IsNonBlocking(aNonBlocking);
|
nsresult rv = mStreams[i]->IsNonBlocking(aNonBlocking);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
// If one is non-blocking the entire stream becomes non-blocking
|
// If one is non-blocking the entire stream becomes non-blocking
|
||||||
// (except that we don't implement nsIAsyncInputStream, so there's
|
// (except that we don't implement nsIAsyncInputStream, so there's
|
||||||
// not much for the caller to do if Read returns "would block")
|
// not much for the caller to do if Read returns "would block")
|
||||||
@ -367,7 +369,8 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
|
|||||||
if (i < oldCurrentStream ||
|
if (i < oldCurrentStream ||
|
||||||
(i == oldCurrentStream && oldStartedReadingCurrent)) {
|
(i == oldCurrentStream && oldStartedReadingCurrent)) {
|
||||||
rv = stream->Seek(NS_SEEK_SET, 0);
|
rv = stream->Seek(NS_SEEK_SET, 0);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -383,13 +386,15 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rv = stream->Tell(&streamPos);
|
rv = stream->Tell(&streamPos);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if we need to seek current stream forward or backward
|
// See if we need to seek current stream forward or backward
|
||||||
if (remaining < streamPos) {
|
if (remaining < streamPos) {
|
||||||
rv = stream->Seek(NS_SEEK_SET, remaining);
|
rv = stream->Seek(NS_SEEK_SET, remaining);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
mCurrentStream = i;
|
mCurrentStream = i;
|
||||||
mStartedReadingCurrent = remaining != 0;
|
mStartedReadingCurrent = remaining != 0;
|
||||||
@ -405,12 +410,14 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
|
|||||||
else {
|
else {
|
||||||
uint64_t avail;
|
uint64_t avail;
|
||||||
rv = mStreams[i]->Available(&avail);
|
rv = mStreams[i]->Available(&avail);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
int64_t newPos = XPCOM_MIN(remaining, streamPos + (int64_t)avail);
|
int64_t newPos = XPCOM_MIN(remaining, streamPos + (int64_t)avail);
|
||||||
|
|
||||||
rv = stream->Seek(NS_SEEK_SET, newPos);
|
rv = stream->Seek(NS_SEEK_SET, newPos);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
mCurrentStream = i;
|
mCurrentStream = i;
|
||||||
mStartedReadingCurrent = true;
|
mStartedReadingCurrent = true;
|
||||||
@ -436,12 +443,14 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
|
|||||||
|
|
||||||
uint64_t avail;
|
uint64_t avail;
|
||||||
rv = mStreams[i]->Available(&avail);
|
rv = mStreams[i]->Available(&avail);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
int64_t seek = XPCOM_MIN((int64_t)avail, remaining);
|
int64_t seek = XPCOM_MIN((int64_t)avail, remaining);
|
||||||
|
|
||||||
rv = stream->Seek(NS_SEEK_CUR, seek);
|
rv = stream->Seek(NS_SEEK_CUR, seek);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
mCurrentStream = i;
|
mCurrentStream = i;
|
||||||
mStartedReadingCurrent = true;
|
mStartedReadingCurrent = true;
|
||||||
@ -460,12 +469,14 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
|
|||||||
|
|
||||||
int64_t pos;
|
int64_t pos;
|
||||||
rv = stream->Tell(&pos);
|
rv = stream->Tell(&pos);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
int64_t seek = XPCOM_MIN(pos, remaining);
|
int64_t seek = XPCOM_MIN(pos, remaining);
|
||||||
|
|
||||||
rv = stream->Seek(NS_SEEK_CUR, -seek);
|
rv = stream->Seek(NS_SEEK_CUR, -seek);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
mCurrentStream = i;
|
mCurrentStream = i;
|
||||||
mStartedReadingCurrent = seek != -pos;
|
mStartedReadingCurrent = seek != -pos;
|
||||||
@ -495,7 +506,8 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
|
|||||||
if (remaining == 0) {
|
if (remaining == 0) {
|
||||||
if (i >= oldCurrentStream) {
|
if (i >= oldCurrentStream) {
|
||||||
rv = stream->Seek(NS_SEEK_END, 0);
|
rv = stream->Seek(NS_SEEK_END, 0);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
break;
|
break;
|
||||||
@ -509,7 +521,8 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
|
|||||||
} else {
|
} else {
|
||||||
uint64_t avail;
|
uint64_t avail;
|
||||||
rv = mStreams[i]->Available(&avail);
|
rv = mStreams[i]->Available(&avail);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
streamPos = avail;
|
streamPos = avail;
|
||||||
}
|
}
|
||||||
@ -517,7 +530,8 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
|
|||||||
// See if we have enough data in the current stream.
|
// See if we have enough data in the current stream.
|
||||||
if (DeprecatedAbs(remaining) < streamPos) {
|
if (DeprecatedAbs(remaining) < streamPos) {
|
||||||
rv = stream->Seek(NS_SEEK_END, remaining);
|
rv = stream->Seek(NS_SEEK_END, remaining);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
mCurrentStream = i;
|
mCurrentStream = i;
|
||||||
mStartedReadingCurrent = true;
|
mStartedReadingCurrent = true;
|
||||||
@ -531,12 +545,14 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
|
|||||||
} else {
|
} else {
|
||||||
int64_t avail;
|
int64_t avail;
|
||||||
rv = stream->Tell(&avail);
|
rv = stream->Tell(&avail);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
int64_t newPos = streamPos + XPCOM_MIN(avail, DeprecatedAbs(remaining));
|
int64_t newPos = streamPos + XPCOM_MIN(avail, DeprecatedAbs(remaining));
|
||||||
|
|
||||||
rv = stream->Seek(NS_SEEK_END, -newPos);
|
rv = stream->Seek(NS_SEEK_END, -newPos);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
mCurrentStream = i;
|
mCurrentStream = i;
|
||||||
mStartedReadingCurrent = true;
|
mStartedReadingCurrent = true;
|
||||||
@ -570,11 +586,13 @@ nsMultiplexInputStream::Tell(int64_t *_retval)
|
|||||||
last = mStartedReadingCurrent ? mCurrentStream+1 : mCurrentStream;
|
last = mStartedReadingCurrent ? mCurrentStream+1 : mCurrentStream;
|
||||||
for (i = 0; i < last; ++i) {
|
for (i = 0; i < last; ++i) {
|
||||||
nsCOMPtr<nsISeekableStream> stream = do_QueryInterface(mStreams[i]);
|
nsCOMPtr<nsISeekableStream> stream = do_QueryInterface(mStreams[i]);
|
||||||
NS_ENSURE_TRUE(stream, NS_ERROR_NO_INTERFACE);
|
if (NS_WARN_IF(!stream))
|
||||||
|
return NS_ERROR_NO_INTERFACE;
|
||||||
|
|
||||||
int64_t pos;
|
int64_t pos;
|
||||||
rv = stream->Tell(&pos);
|
rv = stream->Tell(&pos);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
ret64 += pos;
|
ret64 += pos;
|
||||||
}
|
}
|
||||||
*_retval = ret64;
|
*_retval = ret64;
|
||||||
|
@ -356,7 +356,8 @@ nsPipe::GetInputStream(nsIAsyncInputStream **aInputStream)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsPipe::GetOutputStream(nsIAsyncOutputStream **aOutputStream)
|
nsPipe::GetOutputStream(nsIAsyncOutputStream **aOutputStream)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mInited, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mInited))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
NS_ADDREF(*aOutputStream = &mOutput);
|
NS_ADDREF(*aOutputStream = &mOutput);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -88,8 +88,10 @@ NS_IMETHODIMP
|
|||||||
nsStorageStream::GetOutputStream(int32_t aStartingOffset,
|
nsStorageStream::GetOutputStream(int32_t aStartingOffset,
|
||||||
nsIOutputStream * *aOutputStream)
|
nsIOutputStream * *aOutputStream)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(aOutputStream);
|
if (NS_WARN_IF(!aOutputStream))
|
||||||
NS_ENSURE_TRUE(mSegmentedBuffer, NS_ERROR_NOT_INITIALIZED);
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
if (NS_WARN_IF(!mSegmentedBuffer))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
if (mWriteInProgress)
|
if (mWriteInProgress)
|
||||||
return NS_ERROR_NOT_AVAILABLE;
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
@ -116,7 +118,8 @@ nsStorageStream::GetOutputStream(int32_t aStartingOffset,
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsStorageStream::Close()
|
nsStorageStream::Close()
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mSegmentedBuffer, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mSegmentedBuffer))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
mWriteInProgress = false;
|
mWriteInProgress = false;
|
||||||
|
|
||||||
@ -145,15 +148,15 @@ nsStorageStream::Flush()
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsStorageStream::Write(const char *aBuffer, uint32_t aCount, uint32_t *aNumWritten)
|
nsStorageStream::Write(const char *aBuffer, uint32_t aCount, uint32_t *aNumWritten)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mSegmentedBuffer, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!aNumWritten) || NS_WARN_IF(!aBuffer))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
if (NS_WARN_IF(!mSegmentedBuffer))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
const char* readCursor;
|
const char* readCursor;
|
||||||
uint32_t count, availableInSegment, remaining;
|
uint32_t count, availableInSegment, remaining;
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
NS_ENSURE_ARG_POINTER(aNumWritten);
|
|
||||||
NS_ENSURE_ARG(aBuffer);
|
|
||||||
|
|
||||||
LOG(("nsStorageStream [%p] Write mWriteCursor=%x mSegmentEnd=%x aCount=%d\n",
|
LOG(("nsStorageStream [%p] Write mWriteCursor=%x mSegmentEnd=%x aCount=%d\n",
|
||||||
this, mWriteCursor, mSegmentEnd, aCount));
|
this, mWriteCursor, mSegmentEnd, aCount));
|
||||||
|
|
||||||
@ -223,7 +226,6 @@ nsStorageStream::IsNonBlocking(bool *aNonBlocking)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsStorageStream::GetLength(uint32_t *aLength)
|
nsStorageStream::GetLength(uint32_t *aLength)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(aLength);
|
|
||||||
*aLength = mLogicalLength;
|
*aLength = mLogicalLength;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -232,7 +234,8 @@ nsStorageStream::GetLength(uint32_t *aLength)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsStorageStream::SetLength(uint32_t aLength)
|
nsStorageStream::SetLength(uint32_t aLength)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mSegmentedBuffer, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mSegmentedBuffer))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
if (mWriteInProgress)
|
if (mWriteInProgress)
|
||||||
return NS_ERROR_NOT_AVAILABLE;
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
@ -257,8 +260,6 @@ nsStorageStream::SetLength(uint32_t aLength)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsStorageStream::GetWriteInProgress(bool *aWriteInProgress)
|
nsStorageStream::GetWriteInProgress(bool *aWriteInProgress)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(aWriteInProgress);
|
|
||||||
|
|
||||||
*aWriteInProgress = mWriteInProgress;
|
*aWriteInProgress = mWriteInProgress;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -266,7 +267,8 @@ nsStorageStream::GetWriteInProgress(bool *aWriteInProgress)
|
|||||||
NS_METHOD
|
NS_METHOD
|
||||||
nsStorageStream::Seek(int32_t aPosition)
|
nsStorageStream::Seek(int32_t aPosition)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mSegmentedBuffer, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mSegmentedBuffer))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
// An argument of -1 means "seek to end of stream"
|
// An argument of -1 means "seek to end of stream"
|
||||||
if (aPosition == -1)
|
if (aPosition == -1)
|
||||||
@ -358,7 +360,8 @@ NS_IMPL_ISUPPORTS2(nsStorageInputStream,
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsStorageStream::NewInputStream(int32_t aStartingOffset, nsIInputStream* *aInputStream)
|
nsStorageStream::NewInputStream(int32_t aStartingOffset, nsIInputStream* *aInputStream)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mSegmentedBuffer, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mSegmentedBuffer))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
nsStorageInputStream *inputStream = new nsStorageInputStream(this, mSegmentSize);
|
nsStorageInputStream *inputStream = new nsStorageInputStream(this, mSegmentSize);
|
||||||
if (!inputStream)
|
if (!inputStream)
|
||||||
@ -524,8 +527,6 @@ nsStorageInputStream::Seek(uint32_t aPosition)
|
|||||||
nsresult
|
nsresult
|
||||||
NS_NewStorageStream(uint32_t segmentSize, uint32_t maxSize, nsIStorageStream **result)
|
NS_NewStorageStream(uint32_t segmentSize, uint32_t maxSize, nsIStorageStream **result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(result);
|
|
||||||
|
|
||||||
nsStorageStream* storageStream = new nsStorageStream();
|
nsStorageStream* storageStream = new nsStorageStream();
|
||||||
if (!storageStream) return NS_ERROR_OUT_OF_MEMORY;
|
if (!storageStream) return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
@ -112,7 +112,8 @@ nsStringInputStream::GetData(nsACString &data)
|
|||||||
// The stream doesn't have any data when it is closed. We could fake it
|
// The stream doesn't have any data when it is closed. We could fake it
|
||||||
// and return an empty string here, but it seems better to keep this return
|
// and return an empty string here, but it seems better to keep this return
|
||||||
// value consistent with the behavior of the other 'getter' methods.
|
// value consistent with the behavior of the other 'getter' methods.
|
||||||
NS_ENSURE_TRUE(!Closed(), NS_BASE_STREAM_CLOSED);
|
if (NS_WARN_IF(Closed()))
|
||||||
|
return NS_BASE_STREAM_CLOSED;
|
||||||
|
|
||||||
data.Assign(mData);
|
data.Assign(mData);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -140,7 +141,8 @@ nsStringInputStream::ToString(char **result)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsStringInputStream::SetData(const char *data, int32_t dataLen)
|
nsStringInputStream::SetData(const char *data, int32_t dataLen)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(data);
|
if (NS_WARN_IF(!data))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
mData.Assign(data, dataLen);
|
mData.Assign(data, dataLen);
|
||||||
mOffset = 0;
|
mOffset = 0;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -149,7 +151,8 @@ nsStringInputStream::SetData(const char *data, int32_t dataLen)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsStringInputStream::AdoptData(char *data, int32_t dataLen)
|
nsStringInputStream::AdoptData(char *data, int32_t dataLen)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(data);
|
if (NS_WARN_IF(!data))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
mData.Adopt(data, dataLen);
|
mData.Adopt(data, dataLen);
|
||||||
mOffset = 0;
|
mOffset = 0;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -158,7 +161,8 @@ nsStringInputStream::AdoptData(char *data, int32_t dataLen)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsStringInputStream::ShareData(const char *data, int32_t dataLen)
|
nsStringInputStream::ShareData(const char *data, int32_t dataLen)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(data);
|
if (NS_WARN_IF(!data))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
if (dataLen < 0)
|
if (dataLen < 0)
|
||||||
dataLen = strlen(data);
|
dataLen = strlen(data);
|
||||||
@ -262,8 +266,8 @@ nsStringInputStream::Seek(int32_t whence, int64_t offset)
|
|||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_ENSURE_ARG(newPos >= 0);
|
if (NS_WARN_IF(newPos < 0) || NS_WARN_IF(newPos > Length()))
|
||||||
NS_ENSURE_ARG(newPos <= Length());
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
mOffset = (uint32_t)newPos;
|
mOffset = (uint32_t)newPos;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -386,7 +390,8 @@ nsStringInputStreamConstructor(nsISupports *outer, REFNSIID iid, void **result)
|
|||||||
{
|
{
|
||||||
*result = nullptr;
|
*result = nullptr;
|
||||||
|
|
||||||
NS_ENSURE_TRUE(!outer, NS_ERROR_NO_AGGREGATION);
|
if (NS_WARN_IF(outer))
|
||||||
|
return NS_ERROR_NO_AGGREGATION;
|
||||||
|
|
||||||
nsStringInputStream *inst = new nsStringInputStream();
|
nsStringInputStream *inst = new nsStringInputStream();
|
||||||
if (!inst)
|
if (!inst)
|
||||||
|
@ -40,11 +40,13 @@ EXPORT_XPCOM_API(nsresult)
|
|||||||
NS_GetXPTCallStub(REFNSIID aIID, nsIXPTCProxy* aOuter,
|
NS_GetXPTCallStub(REFNSIID aIID, nsIXPTCProxy* aOuter,
|
||||||
nsISomeInterface* *aResult)
|
nsISomeInterface* *aResult)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(aOuter && aResult);
|
if (NS_WARN_IF(!aOuter) || NS_WARN_IF(!aResult))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
XPTInterfaceInfoManager *iim =
|
XPTInterfaceInfoManager *iim =
|
||||||
XPTInterfaceInfoManager::GetSingleton();
|
XPTInterfaceInfoManager::GetSingleton();
|
||||||
NS_ENSURE_TRUE(iim, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!iim))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
xptiInterfaceEntry *iie = iim->GetInterfaceEntryForIID(&aIID);
|
xptiInterfaceEntry *iie = iim->GetInterfaceEntryForIID(&aIID);
|
||||||
if (!iie || !iie->EnsureResolved() || iie->GetBuiltinClassFlag())
|
if (!iie || !iie->EnsureResolved() || iie->GetBuiltinClassFlag())
|
||||||
|
@ -147,21 +147,26 @@ LazyIdleThread::EnsureThread()
|
|||||||
if (mShutdownMethod == AutomaticShutdown && NS_IsMainThread()) {
|
if (mShutdownMethod == AutomaticShutdown && NS_IsMainThread()) {
|
||||||
nsCOMPtr<nsIObserverService> obs =
|
nsCOMPtr<nsIObserverService> obs =
|
||||||
do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
|
do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
rv = obs->AddObserver(this, "xpcom-shutdown-threads", false);
|
rv = obs->AddObserver(this, "xpcom-shutdown-threads", false);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
mIdleTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
|
mIdleTimer = do_CreateInstance(NS_TIMER_CONTRACTID, &rv);
|
||||||
NS_ENSURE_TRUE(mIdleTimer, NS_ERROR_FAILURE);
|
if (NS_WARN_IF(!mIdleTimer))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
nsCOMPtr<nsIRunnable> runnable =
|
nsCOMPtr<nsIRunnable> runnable =
|
||||||
NS_NewRunnableMethod(this, &LazyIdleThread::InitThread);
|
NS_NewRunnableMethod(this, &LazyIdleThread::InitThread);
|
||||||
NS_ENSURE_TRUE(runnable, NS_ERROR_FAILURE);
|
if (NS_WARN_IF(!runnable))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
rv = NS_NewThread(getter_AddRefs(mThread), runnable);
|
rv = NS_NewThread(getter_AddRefs(mThread), runnable);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -268,12 +273,14 @@ LazyIdleThread::ShutdownThread()
|
|||||||
|
|
||||||
nsCOMPtr<nsIRunnable> runnable =
|
nsCOMPtr<nsIRunnable> runnable =
|
||||||
NS_NewRunnableMethod(this, &LazyIdleThread::CleanupThread);
|
NS_NewRunnableMethod(this, &LazyIdleThread::CleanupThread);
|
||||||
NS_ENSURE_TRUE(runnable, NS_ERROR_FAILURE);
|
if (NS_WARN_IF(!runnable))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
PreDispatch();
|
PreDispatch();
|
||||||
|
|
||||||
rv = mThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
|
rv = mThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
// Put the temporary queue in place before calling Shutdown().
|
// Put the temporary queue in place before calling Shutdown().
|
||||||
mQueuedRunnables = &queuedRunnables;
|
mQueuedRunnables = &queuedRunnables;
|
||||||
@ -299,7 +306,8 @@ LazyIdleThread::ShutdownThread()
|
|||||||
|
|
||||||
if (mIdleTimer) {
|
if (mIdleTimer) {
|
||||||
rv = mIdleTimer->Cancel();
|
rv = mIdleTimer->Cancel();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
mIdleTimer = nullptr;
|
mIdleTimer = nullptr;
|
||||||
}
|
}
|
||||||
@ -376,7 +384,8 @@ LazyIdleThread::Dispatch(nsIRunnable* aEvent,
|
|||||||
ASSERT_OWNING_THREAD();
|
ASSERT_OWNING_THREAD();
|
||||||
|
|
||||||
// LazyIdleThread can't always support synchronous dispatch currently.
|
// LazyIdleThread can't always support synchronous dispatch currently.
|
||||||
NS_ENSURE_TRUE(aFlags == NS_DISPATCH_NORMAL, NS_ERROR_NOT_IMPLEMENTED);
|
if (NS_WARN_IF(aFlags != NS_DISPATCH_NORMAL))
|
||||||
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
// If our thread is shutting down then we can't actually dispatch right now.
|
// If our thread is shutting down then we can't actually dispatch right now.
|
||||||
// Queue this runnable for later.
|
// Queue this runnable for later.
|
||||||
@ -386,7 +395,8 @@ LazyIdleThread::Dispatch(nsIRunnable* aEvent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult rv = EnsureThread();
|
nsresult rv = EnsureThread();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
PreDispatch();
|
PreDispatch();
|
||||||
|
|
||||||
@ -427,7 +437,8 @@ LazyIdleThread::Shutdown()
|
|||||||
|
|
||||||
mIdleObserver = nullptr;
|
mIdleObserver = nullptr;
|
||||||
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -467,7 +478,8 @@ LazyIdleThread::Notify(nsITimer* aTimer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult rv = ShutdownThread();
|
nsresult rv = ShutdownThread();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -513,10 +525,12 @@ LazyIdleThread::AfterProcessNextEvent(nsIThreadInternal* /* aThread */,
|
|||||||
if (shouldNotifyIdle) {
|
if (shouldNotifyIdle) {
|
||||||
nsCOMPtr<nsIRunnable> runnable =
|
nsCOMPtr<nsIRunnable> runnable =
|
||||||
NS_NewRunnableMethod(this, &LazyIdleThread::ScheduleTimer);
|
NS_NewRunnableMethod(this, &LazyIdleThread::ScheduleTimer);
|
||||||
NS_ENSURE_TRUE(runnable, NS_ERROR_FAILURE);
|
if (NS_WARN_IF(!runnable))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
nsresult rv = mOwningThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
|
nsresult rv = mOwningThread->Dispatch(runnable, NS_DISPATCH_NORMAL);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -48,7 +48,8 @@ nsEnvironment::Exists(const nsAString& aName, bool *aOutValue)
|
|||||||
{
|
{
|
||||||
nsAutoCString nativeName;
|
nsAutoCString nativeName;
|
||||||
nsresult rv = NS_CopyUnicodeToNative(aName, nativeName);
|
nsresult rv = NS_CopyUnicodeToNative(aName, nativeName);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
nsAutoCString nativeVal;
|
nsAutoCString nativeVal;
|
||||||
#if defined(XP_UNIX)
|
#if defined(XP_UNIX)
|
||||||
@ -78,7 +79,8 @@ nsEnvironment::Get(const nsAString& aName, nsAString& aOutValue)
|
|||||||
{
|
{
|
||||||
nsAutoCString nativeName;
|
nsAutoCString nativeName;
|
||||||
nsresult rv = NS_CopyUnicodeToNative(aName, nativeName);
|
nsresult rv = NS_CopyUnicodeToNative(aName, nativeName);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
nsAutoCString nativeVal;
|
nsAutoCString nativeVal;
|
||||||
const char *value = PR_GetEnv(nativeName.get());
|
const char *value = PR_GetEnv(nativeName.get());
|
||||||
@ -122,10 +124,12 @@ nsEnvironment::Set(const nsAString& aName, const nsAString& aValue)
|
|||||||
nsAutoCString nativeVal;
|
nsAutoCString nativeVal;
|
||||||
|
|
||||||
nsresult rv = NS_CopyUnicodeToNative(aName, nativeName);
|
nsresult rv = NS_CopyUnicodeToNative(aName, nativeName);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
rv = NS_CopyUnicodeToNative(aValue, nativeVal);
|
rv = NS_CopyUnicodeToNative(aValue, nativeVal);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
MutexAutoLock lock(mLock);
|
MutexAutoLock lock(mLock);
|
||||||
|
|
||||||
|
@ -49,6 +49,5 @@ NS_DispatchMemoryPressure(MemoryPressureState state)
|
|||||||
{
|
{
|
||||||
NS_DispatchEventualMemoryPressure(state);
|
NS_DispatchEventualMemoryPressure(state);
|
||||||
nsCOMPtr<nsIRunnable> event = new nsRunnable;
|
nsCOMPtr<nsIRunnable> event = new nsRunnable;
|
||||||
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
|
|
||||||
return NS_DispatchToMainThread(event);
|
return NS_DispatchToMainThread(event);
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,8 @@ nsProcess::Init(nsIFile* executable)
|
|||||||
if (mExecutable)
|
if (mExecutable)
|
||||||
return NS_ERROR_ALREADY_INITIALIZED;
|
return NS_ERROR_ALREADY_INITIALIZED;
|
||||||
|
|
||||||
NS_ENSURE_ARG_POINTER(executable);
|
if (NS_WARN_IF(!executable))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
bool isFile;
|
bool isFile;
|
||||||
|
|
||||||
//First make sure the file exists
|
//First make sure the file exists
|
||||||
@ -408,8 +409,10 @@ nsresult
|
|||||||
nsProcess::RunProcess(bool blocking, char **my_argv, nsIObserver* observer,
|
nsProcess::RunProcess(bool blocking, char **my_argv, nsIObserver* observer,
|
||||||
bool holdWeak, bool argsUTF8)
|
bool holdWeak, bool argsUTF8)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mExecutable, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mExecutable))
|
||||||
NS_ENSURE_FALSE(mThread, NS_ERROR_ALREADY_INITIALIZED);
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
if (NS_WARN_IF(mThread))
|
||||||
|
return NS_ERROR_ALREADY_INITIALIZED;
|
||||||
|
|
||||||
if (observer) {
|
if (observer) {
|
||||||
if (holdWeak) {
|
if (holdWeak) {
|
||||||
|
@ -152,9 +152,9 @@ NS_IMPL_CI_INTERFACE_GETTER4(nsThread, nsIThread, nsIThreadInternal,
|
|||||||
|
|
||||||
class nsThreadStartupEvent : public nsRunnable {
|
class nsThreadStartupEvent : public nsRunnable {
|
||||||
public:
|
public:
|
||||||
// Create a new thread startup object.
|
nsThreadStartupEvent()
|
||||||
static nsThreadStartupEvent *Create() {
|
: mMon("nsThreadStartupEvent.mMon")
|
||||||
return new nsThreadStartupEvent();
|
, mInitialized(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method does not return until the thread startup object is in the
|
// This method does not return until the thread startup object is in the
|
||||||
@ -180,11 +180,6 @@ private:
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsThreadStartupEvent()
|
|
||||||
: mMon("nsThreadStartupEvent.mMon")
|
|
||||||
, mInitialized(false) {
|
|
||||||
}
|
|
||||||
|
|
||||||
ReentrantMonitor mMon;
|
ReentrantMonitor mMon;
|
||||||
bool mInitialized;
|
bool mInitialized;
|
||||||
};
|
};
|
||||||
@ -310,8 +305,7 @@ nsresult
|
|||||||
nsThread::Init()
|
nsThread::Init()
|
||||||
{
|
{
|
||||||
// spawn thread and wait until it is fully setup
|
// spawn thread and wait until it is fully setup
|
||||||
nsRefPtr<nsThreadStartupEvent> startup = nsThreadStartupEvent::Create();
|
nsRefPtr<nsThreadStartupEvent> startup = new nsThreadStartupEvent();
|
||||||
NS_ENSURE_TRUE(startup, NS_ERROR_OUT_OF_MEMORY);
|
|
||||||
|
|
||||||
NS_ADDREF_THIS();
|
NS_ADDREF_THIS();
|
||||||
|
|
||||||
@ -377,7 +371,8 @@ nsThread::Dispatch(nsIRunnable *event, uint32_t flags)
|
|||||||
{
|
{
|
||||||
LOG(("THRD(%p) Dispatch [%p %x]\n", this, event, flags));
|
LOG(("THRD(%p) Dispatch [%p %x]\n", this, event, flags));
|
||||||
|
|
||||||
NS_ENSURE_ARG_POINTER(event);
|
if (NS_WARN_IF(!event))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
if (gXPCOMThreadsShutDown && MAIN_THREAD != mIsMainThread) {
|
if (gXPCOMThreadsShutDown && MAIN_THREAD != mIsMainThread) {
|
||||||
return NS_ERROR_ILLEGAL_DURING_SHUTDOWN;
|
return NS_ERROR_ILLEGAL_DURING_SHUTDOWN;
|
||||||
@ -385,7 +380,8 @@ nsThread::Dispatch(nsIRunnable *event, uint32_t flags)
|
|||||||
|
|
||||||
if (flags & DISPATCH_SYNC) {
|
if (flags & DISPATCH_SYNC) {
|
||||||
nsThread *thread = nsThreadManager::get()->GetCurrentThread();
|
nsThread *thread = nsThreadManager::get()->GetCurrentThread();
|
||||||
NS_ENSURE_STATE(thread);
|
if (NS_WARN_IF(!thread))
|
||||||
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
|
|
||||||
// XXX we should be able to do something better here... we should
|
// XXX we should be able to do something better here... we should
|
||||||
// be able to monitor the slot occupied by this event and use
|
// be able to monitor the slot occupied by this event and use
|
||||||
@ -437,7 +433,8 @@ nsThread::Shutdown()
|
|||||||
if (!mThread)
|
if (!mThread)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
NS_ENSURE_STATE(mThread != PR_GetCurrentThread());
|
if (NS_WARN_IF(mThread == PR_GetCurrentThread()))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
// Prevent multiple calls to this method
|
// Prevent multiple calls to this method
|
||||||
{
|
{
|
||||||
@ -490,7 +487,8 @@ nsThread::Shutdown()
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsThread::HasPendingEvents(bool *result)
|
nsThread::HasPendingEvents(bool *result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_STATE(PR_GetCurrentThread() == mThread);
|
if (NS_WARN_IF(PR_GetCurrentThread() != mThread))
|
||||||
|
return NS_ERROR_NOT_SAME_THREAD;
|
||||||
|
|
||||||
*result = mEvents.GetEvent(false, nullptr);
|
*result = mEvents.GetEvent(false, nullptr);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -548,7 +546,8 @@ nsThread::ProcessNextEvent(bool mayWait, bool *result)
|
|||||||
{
|
{
|
||||||
LOG(("THRD(%p) ProcessNextEvent [%u %u]\n", this, mayWait, mRunningEvent));
|
LOG(("THRD(%p) ProcessNextEvent [%u %u]\n", this, mayWait, mRunningEvent));
|
||||||
|
|
||||||
NS_ENSURE_STATE(PR_GetCurrentThread() == mThread);
|
if (NS_WARN_IF(PR_GetCurrentThread() != mThread))
|
||||||
|
return NS_ERROR_NOT_SAME_THREAD;
|
||||||
|
|
||||||
if (MAIN_THREAD == mIsMainThread && mayWait && !ShuttingDown())
|
if (MAIN_THREAD == mIsMainThread && mayWait && !ShuttingDown())
|
||||||
HangMonitor::Suspend();
|
HangMonitor::Suspend();
|
||||||
@ -644,7 +643,8 @@ nsThread::GetPriority(int32_t *priority)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsThread::SetPriority(int32_t priority)
|
nsThread::SetPriority(int32_t priority)
|
||||||
{
|
{
|
||||||
NS_ENSURE_STATE(mThread);
|
if (NS_WARN_IF(!mThread))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
// NSPR defines the following four thread priorities:
|
// NSPR defines the following four thread priorities:
|
||||||
// PR_PRIORITY_LOW
|
// PR_PRIORITY_LOW
|
||||||
@ -690,7 +690,8 @@ nsThread::GetObserver(nsIThreadObserver **obs)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsThread::SetObserver(nsIThreadObserver *obs)
|
nsThread::SetObserver(nsIThreadObserver *obs)
|
||||||
{
|
{
|
||||||
NS_ENSURE_STATE(PR_GetCurrentThread() == mThread);
|
if (NS_WARN_IF(PR_GetCurrentThread() != mThread))
|
||||||
|
return NS_ERROR_NOT_SAME_THREAD;
|
||||||
|
|
||||||
MutexAutoLock lock(mLock);
|
MutexAutoLock lock(mLock);
|
||||||
mObserver = obs;
|
mObserver = obs;
|
||||||
@ -700,8 +701,8 @@ nsThread::SetObserver(nsIThreadObserver *obs)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsThread::GetRecursionDepth(uint32_t *depth)
|
nsThread::GetRecursionDepth(uint32_t *depth)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(depth);
|
if (NS_WARN_IF(PR_GetCurrentThread() != mThread))
|
||||||
NS_ENSURE_STATE(PR_GetCurrentThread() == mThread);
|
return NS_ERROR_NOT_SAME_THREAD;
|
||||||
|
|
||||||
*depth = mRunningEvent;
|
*depth = mRunningEvent;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@ -710,8 +711,10 @@ nsThread::GetRecursionDepth(uint32_t *depth)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsThread::AddObserver(nsIThreadObserver *observer)
|
nsThread::AddObserver(nsIThreadObserver *observer)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(observer);
|
if (NS_WARN_IF(!observer))
|
||||||
NS_ENSURE_STATE(PR_GetCurrentThread() == mThread);
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
if (NS_WARN_IF(PR_GetCurrentThread() != mThread))
|
||||||
|
return NS_ERROR_NOT_SAME_THREAD;
|
||||||
|
|
||||||
NS_WARN_IF_FALSE(!mEventObservers.Contains(observer),
|
NS_WARN_IF_FALSE(!mEventObservers.Contains(observer),
|
||||||
"Adding an observer twice!");
|
"Adding an observer twice!");
|
||||||
@ -727,7 +730,8 @@ nsThread::AddObserver(nsIThreadObserver *observer)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsThread::RemoveObserver(nsIThreadObserver *observer)
|
nsThread::RemoveObserver(nsIThreadObserver *observer)
|
||||||
{
|
{
|
||||||
NS_ENSURE_STATE(PR_GetCurrentThread() == mThread);
|
if (NS_WARN_IF(PR_GetCurrentThread() != mThread))
|
||||||
|
return NS_ERROR_NOT_SAME_THREAD;
|
||||||
|
|
||||||
if (observer && !mEventObservers.RemoveElement(observer)) {
|
if (observer && !mEventObservers.RemoveElement(observer)) {
|
||||||
NS_WARNING("Removing an observer that was never added!");
|
NS_WARNING("Removing an observer that was never added!");
|
||||||
|
@ -217,7 +217,8 @@ nsThreadManager::NewThread(uint32_t creationFlags,
|
|||||||
nsIThread **result)
|
nsIThread **result)
|
||||||
{
|
{
|
||||||
// No new threads during Shutdown
|
// No new threads during Shutdown
|
||||||
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mInitialized))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
nsThread *thr = new nsThread(nsThread::NOT_MAIN_THREAD, stackSize);
|
nsThread *thr = new nsThread(nsThread::NOT_MAIN_THREAD, stackSize);
|
||||||
if (!thr)
|
if (!thr)
|
||||||
@ -242,8 +243,10 @@ NS_IMETHODIMP
|
|||||||
nsThreadManager::GetThreadFromPRThread(PRThread *thread, nsIThread **result)
|
nsThreadManager::GetThreadFromPRThread(PRThread *thread, nsIThread **result)
|
||||||
{
|
{
|
||||||
// Keep this functioning during Shutdown
|
// Keep this functioning during Shutdown
|
||||||
NS_ENSURE_TRUE(mMainThread, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mMainThread))
|
||||||
NS_ENSURE_ARG_POINTER(thread);
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
if (NS_WARN_IF(!thread))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsRefPtr<nsThread> temp;
|
nsRefPtr<nsThread> temp;
|
||||||
{
|
{
|
||||||
@ -259,7 +262,8 @@ NS_IMETHODIMP
|
|||||||
nsThreadManager::GetMainThread(nsIThread **result)
|
nsThreadManager::GetMainThread(nsIThread **result)
|
||||||
{
|
{
|
||||||
// Keep this functioning during Shutdown
|
// Keep this functioning during Shutdown
|
||||||
NS_ENSURE_TRUE(mMainThread, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mMainThread))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
NS_ADDREF(*result = mMainThread);
|
NS_ADDREF(*result = mMainThread);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -268,7 +272,8 @@ NS_IMETHODIMP
|
|||||||
nsThreadManager::GetCurrentThread(nsIThread **result)
|
nsThreadManager::GetCurrentThread(nsIThread **result)
|
||||||
{
|
{
|
||||||
// Keep this functioning during Shutdown
|
// Keep this functioning during Shutdown
|
||||||
NS_ENSURE_TRUE(mMainThread, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!mMainThread))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
*result = GetCurrentThread();
|
*result = GetCurrentThread();
|
||||||
if (!*result)
|
if (!*result)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
@ -92,7 +92,8 @@ nsThreadPool::PutEvent(nsIRunnable *event)
|
|||||||
nsThreadManager::get()->NewThread(0,
|
nsThreadManager::get()->NewThread(0,
|
||||||
nsIThreadManager::DEFAULT_STACK_SIZE,
|
nsIThreadManager::DEFAULT_STACK_SIZE,
|
||||||
getter_AddRefs(thread));
|
getter_AddRefs(thread));
|
||||||
NS_ENSURE_STATE(thread);
|
if (NS_WARN_IF(!thread))
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
bool killThread = false;
|
bool killThread = false;
|
||||||
{
|
{
|
||||||
@ -225,12 +226,14 @@ nsThreadPool::Dispatch(nsIRunnable *event, uint32_t flags)
|
|||||||
{
|
{
|
||||||
LOG(("THRD-P(%p) dispatch [%p %x]\n", this, event, flags));
|
LOG(("THRD-P(%p) dispatch [%p %x]\n", this, event, flags));
|
||||||
|
|
||||||
NS_ENSURE_STATE(!mShutdown);
|
if (NS_WARN_IF(mShutdown))
|
||||||
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
|
|
||||||
if (flags & DISPATCH_SYNC) {
|
if (flags & DISPATCH_SYNC) {
|
||||||
nsCOMPtr<nsIThread> thread;
|
nsCOMPtr<nsIThread> thread;
|
||||||
nsThreadManager::get()->GetCurrentThread(getter_AddRefs(thread));
|
nsThreadManager::get()->GetCurrentThread(getter_AddRefs(thread));
|
||||||
NS_ENSURE_STATE(thread);
|
if (NS_WARN_IF(!thread))
|
||||||
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
|
|
||||||
nsRefPtr<nsThreadSyncDispatch> wrapper =
|
nsRefPtr<nsThreadSyncDispatch> wrapper =
|
||||||
new nsThreadSyncDispatch(thread, event);
|
new nsThreadSyncDispatch(thread, event);
|
||||||
|
@ -317,14 +317,16 @@ nsresult nsTimerImpl::InitCommon(uint32_t aType, uint32_t aDelay)
|
|||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
NS_ENSURE_TRUE(gThread, NS_ERROR_NOT_INITIALIZED);
|
if (NS_WARN_IF(!gThread))
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
if (!mEventTarget) {
|
if (!mEventTarget) {
|
||||||
NS_ERROR("mEventTarget is NULL");
|
NS_ERROR("mEventTarget is NULL");
|
||||||
return NS_ERROR_NOT_INITIALIZED;
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = gThread->Init();
|
rv = gThread->Init();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||||
|
return rv;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In case of re-Init, both with and without a preceding Cancel, clear the
|
* In case of re-Init, both with and without a preceding Cancel, clear the
|
||||||
@ -357,7 +359,8 @@ NS_IMETHODIMP nsTimerImpl::InitWithFuncCallback(nsTimerCallbackFunc aFunc,
|
|||||||
uint32_t aDelay,
|
uint32_t aDelay,
|
||||||
uint32_t aType)
|
uint32_t aType)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aFunc);
|
if (NS_WARN_IF(!aFunc))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
ReleaseCallback();
|
ReleaseCallback();
|
||||||
mCallbackType = CALLBACK_TYPE_FUNC;
|
mCallbackType = CALLBACK_TYPE_FUNC;
|
||||||
@ -371,7 +374,8 @@ NS_IMETHODIMP nsTimerImpl::InitWithCallback(nsITimerCallback *aCallback,
|
|||||||
uint32_t aDelay,
|
uint32_t aDelay,
|
||||||
uint32_t aType)
|
uint32_t aType)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aCallback);
|
if (NS_WARN_IF(!aCallback))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
ReleaseCallback();
|
ReleaseCallback();
|
||||||
mCallbackType = CALLBACK_TYPE_INTERFACE;
|
mCallbackType = CALLBACK_TYPE_INTERFACE;
|
||||||
@ -385,7 +389,8 @@ NS_IMETHODIMP nsTimerImpl::Init(nsIObserver *aObserver,
|
|||||||
uint32_t aDelay,
|
uint32_t aDelay,
|
||||||
uint32_t aType)
|
uint32_t aType)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aObserver);
|
if (NS_WARN_IF(!aObserver))
|
||||||
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
ReleaseCallback();
|
ReleaseCallback();
|
||||||
mCallbackType = CALLBACK_TYPE_OBSERVER;
|
mCallbackType = CALLBACK_TYPE_OBSERVER;
|
||||||
@ -481,8 +486,8 @@ NS_IMETHODIMP nsTimerImpl::GetTarget(nsIEventTarget** aTarget)
|
|||||||
|
|
||||||
NS_IMETHODIMP nsTimerImpl::SetTarget(nsIEventTarget* aTarget)
|
NS_IMETHODIMP nsTimerImpl::SetTarget(nsIEventTarget* aTarget)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mCallbackType == CALLBACK_TYPE_UNKNOWN,
|
if (NS_WARN_IF(mCallbackType != CALLBACK_TYPE_UNKNOWN))
|
||||||
NS_ERROR_ALREADY_INITIALIZED);
|
return NS_ERROR_ALREADY_INITIALIZED;
|
||||||
|
|
||||||
if (aTarget)
|
if (aTarget)
|
||||||
mEventTarget = aTarget;
|
mEventTarget = aTarget;
|
||||||
|
Loading…
Reference in New Issue
Block a user