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
|
||||
// grab a file before we're finished writing to it.)
|
||||
nsCOMPtr<nsIFile> gcLogFile = CreateTempFile("incomplete-gc-edges");
|
||||
NS_ENSURE_STATE(gcLogFile);
|
||||
if (NS_WARN_IF(!gcLogFile))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
// Dump the JS heap.
|
||||
FILE* gcLogANSIFile = nullptr;
|
||||
gcLogFile->OpenANSIFileDesc("w", &gcLogANSIFile);
|
||||
NS_ENSURE_STATE(gcLogANSIFile);
|
||||
if (NS_WARN_IF(!gcLogANSIFile))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
MozillaRegisterDebugFILE(gcLogANSIFile);
|
||||
CollectorData *data = sCollectorData.get();
|
||||
if (data && data->mRuntime)
|
||||
@ -1237,11 +1239,13 @@ public:
|
||||
// Strip off "incomplete-".
|
||||
nsCOMPtr<nsIFile> gcLogFileFinalDestination =
|
||||
CreateTempFile("gc-edges");
|
||||
NS_ENSURE_STATE(gcLogFileFinalDestination);
|
||||
if (NS_WARN_IF(!gcLogFileFinalDestination))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsAutoString gcLogFileFinalDestinationName;
|
||||
gcLogFileFinalDestination->GetLeafName(gcLogFileFinalDestinationName);
|
||||
NS_ENSURE_STATE(!gcLogFileFinalDestinationName.IsEmpty());
|
||||
if (NS_WARN_IF(gcLogFileFinalDestinationName.IsEmpty()))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
gcLogFile->MoveTo(/* directory */ nullptr, gcLogFileFinalDestinationName);
|
||||
|
||||
@ -1260,10 +1264,12 @@ public:
|
||||
// Open a file for dumping the CC graph. We again prefix with
|
||||
// "incomplete-".
|
||||
mOutFile = CreateTempFile("incomplete-cc-edges");
|
||||
NS_ENSURE_STATE(mOutFile);
|
||||
if (NS_WARN_IF(!mOutFile))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
MOZ_ASSERT(!mStream);
|
||||
mOutFile->OpenANSIFileDesc("w", &mStream);
|
||||
NS_ENSURE_STATE(mStream);
|
||||
if (NS_WARN_IF(!mStream))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
MozillaRegisterDebugFILE(mStream);
|
||||
|
||||
fprintf(mStream, "# WantAllTraces=%s\n", mWantAllTraces ? "true" : "false");
|
||||
@ -1388,11 +1394,13 @@ public:
|
||||
// Strip off "incomplete-" from the log file's name.
|
||||
nsCOMPtr<nsIFile> logFileFinalDestination =
|
||||
CreateTempFile("cc-edges");
|
||||
NS_ENSURE_STATE(logFileFinalDestination);
|
||||
if (NS_WARN_IF(!logFileFinalDestination))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsAutoString logFileFinalDestinationName;
|
||||
logFileFinalDestination->GetLeafName(logFileFinalDestinationName);
|
||||
NS_ENSURE_STATE(!logFileFinalDestinationName.IsEmpty());
|
||||
if (NS_WARN_IF(logFileFinalDestinationName.IsEmpty()))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
mOutFile->MoveTo(/* directory = */ nullptr,
|
||||
logFileFinalDestinationName);
|
||||
@ -1415,7 +1423,8 @@ public:
|
||||
NS_IMETHOD ProcessNext(nsICycleCollectorHandler* aHandler,
|
||||
bool* aCanContinue)
|
||||
{
|
||||
NS_ENSURE_STATE(aHandler && mWantAfterProcessing);
|
||||
if (NS_WARN_IF(!aHandler) || NS_WARN_IF(!mWantAfterProcessing))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
CCGraphDescriber* d = mDescribers.popFirst();
|
||||
if (d) {
|
||||
switch (d->mType) {
|
||||
@ -1515,7 +1524,8 @@ nsCycleCollectorLoggerConstructor(nsISupports* aOuter,
|
||||
const nsIID& aIID,
|
||||
void* *aInstancePtr)
|
||||
{
|
||||
NS_ENSURE_TRUE(!aOuter, NS_ERROR_NO_AGGREGATION);
|
||||
if (NS_WARN_IF(aOuter))
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsISupports *logger = new nsCycleCollectorLogger();
|
||||
|
||||
@ -2438,7 +2448,8 @@ class CycleCollectorReporter MOZ_FINAL : public MemoryMultiReporter
|
||||
nsIMemoryReporter::KIND_HEAP, \
|
||||
nsIMemoryReporter::UNITS_BYTES, _amount, \
|
||||
NS_LITERAL_CSTRING(_desc), aClosure); \
|
||||
NS_ENSURE_SUCCESS(rv, rv); \
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) \
|
||||
return rv; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
@ -565,7 +565,8 @@ static const nsDebugImpl kImpl;
|
||||
nsresult
|
||||
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)->
|
||||
QueryInterface(aIID, aInstancePtr);
|
||||
|
@ -65,7 +65,8 @@ NS_IMPL_ISUPPORTS1(nsErrorService, nsIErrorService)
|
||||
nsresult
|
||||
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();
|
||||
return serv->QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
@ -33,21 +33,25 @@ nsGZFileWriter::~nsGZFileWriter()
|
||||
NS_IMETHODIMP
|
||||
nsGZFileWriter::Init(nsIFile* aFile)
|
||||
{
|
||||
NS_ENSURE_FALSE(mInitialized, NS_ERROR_FAILURE);
|
||||
NS_ENSURE_FALSE(mFinished, NS_ERROR_FAILURE);
|
||||
if (NS_WARN_IF(mInitialized) ||
|
||||
NS_WARN_IF(mFinished))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// 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.
|
||||
|
||||
FILE* 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");
|
||||
fclose(file);
|
||||
|
||||
// gzdopen returns nullptr on error.
|
||||
NS_ENSURE_TRUE(mGZFile, NS_ERROR_FAILURE);
|
||||
if (NS_WARN_IF(!mGZFile))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mInitialized = true;
|
||||
|
||||
return NS_OK;
|
||||
@ -56,8 +60,9 @@ nsGZFileWriter::Init(nsIFile* aFile)
|
||||
NS_IMETHODIMP
|
||||
nsGZFileWriter::Write(const nsACString& aStr)
|
||||
{
|
||||
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
||||
NS_ENSURE_FALSE(mFinished, NS_ERROR_FAILURE);
|
||||
if (NS_WARN_IF(!mInitialized) ||
|
||||
NS_WARN_IF(mFinished))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// gzwrite uses a return value of 0 to indicate failure. Otherwise, it
|
||||
// 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
|
||||
// multiple times in order to get it to read the whole buffer.
|
||||
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;
|
||||
}
|
||||
@ -79,8 +85,9 @@ nsGZFileWriter::Write(const nsACString& aStr)
|
||||
NS_IMETHODIMP
|
||||
nsGZFileWriter::Finish()
|
||||
{
|
||||
NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
|
||||
NS_ENSURE_FALSE(mFinished, NS_ERROR_FAILURE);
|
||||
if (NS_WARN_IF(!mInitialized) ||
|
||||
NS_WARN_IF(mFinished))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mFinished = true;
|
||||
gzclose(mGZFile);
|
||||
|
@ -535,7 +535,8 @@ public:
|
||||
{
|
||||
int64_t 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,
|
||||
amount, mDescription, aData);
|
||||
|
@ -89,7 +89,8 @@ nsresult nsMacUtilsImpl::GetArchString(nsAString& archString)
|
||||
|
||||
NS_IMETHODIMP nsMacUtilsImpl::GetIsUniversalBinary(bool *aIsUniversalBinary)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aIsUniversalBinary);
|
||||
if (NS_WARN_IF(!aIsUniversalBinary))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
*aIsUniversalBinary = false;
|
||||
|
||||
nsAutoString archString;
|
||||
|
@ -93,7 +93,8 @@ nsMemoryImpl::IsLowMemoryPlatform(bool *result)
|
||||
/*static*/ nsresult
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -416,15 +416,18 @@ public:
|
||||
}
|
||||
} else {
|
||||
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"));
|
||||
NS_ENSURE_SUCCESS(rv, -1);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return -1;
|
||||
|
||||
nsAutoCString 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.
|
||||
// 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) \
|
||||
do { \
|
||||
nsresult rv = (o)->Write(s); \
|
||||
NS_ENSURE_SUCCESS(rv, rv); \
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) \
|
||||
return rv; \
|
||||
} while (0)
|
||||
|
||||
static nsresult
|
||||
@ -680,7 +684,8 @@ public:
|
||||
nsISupports *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,
|
||||
aAmount, aDescription);
|
||||
@ -722,7 +727,8 @@ nsMemoryInfoDumper::OpenTempFile(const nsACString &aFilename, nsIFile* *aFile)
|
||||
nsresult rv;
|
||||
if (!*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
|
||||
@ -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
|
||||
// subdirectory of the temp directory and chmod 777 that directory.
|
||||
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
|
||||
// exists.
|
||||
@ -739,7 +746,8 @@ nsMemoryInfoDumper::OpenTempFile(const nsACString &aFilename, nsIFile* *aFile)
|
||||
|
||||
nsAutoCString 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) {}
|
||||
#endif
|
||||
@ -747,10 +755,12 @@ nsMemoryInfoDumper::OpenTempFile(const nsACString &aFilename, nsIFile* *aFile)
|
||||
nsCOMPtr<nsIFile> file(*aFile);
|
||||
|
||||
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);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
#ifdef ANDROID
|
||||
// Make this file world-read/writable; the permissions passed to the
|
||||
@ -758,7 +768,8 @@ nsMemoryInfoDumper::OpenTempFile(const nsACString &aFilename, nsIFile* *aFile)
|
||||
// umask.
|
||||
nsAutoCString 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) {}
|
||||
#endif
|
||||
@ -801,7 +812,8 @@ DumpHeader(nsIGZFileWriter* aWriter)
|
||||
|
||||
nsCOMPtr<nsIMemoryReporterManager> mgr =
|
||||
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, ",\n");
|
||||
@ -872,11 +884,12 @@ DumpProcessMemoryInfoToTempDir(const nsAString& aIdentifier)
|
||||
rv = nsMemoryInfoDumper::OpenTempFile(NS_LITERAL_CSTRING("incomplete-") +
|
||||
mrFilename,
|
||||
getter_AddRefs(mrTmpFile));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
return rv;
|
||||
|
||||
nsRefPtr<nsGZFileWriter> mrWriter = new nsGZFileWriter();
|
||||
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.
|
||||
DumpProcessMemoryReportsToGZFileWriter(mrWriter);
|
||||
@ -894,11 +907,13 @@ DumpProcessMemoryInfoToTempDir(const nsAString& aIdentifier)
|
||||
|
||||
nsCOMPtr<nsIFile> 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();
|
||||
rv = dmdWriter->Init(dmdFile);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
// Dump DMD output to the file.
|
||||
|
||||
@ -907,7 +922,8 @@ DumpProcessMemoryInfoToTempDir(const nsAString& aIdentifier)
|
||||
dmd::Dump(w);
|
||||
|
||||
rv = dmdWriter->Finish();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
#endif // MOZ_DMD
|
||||
|
||||
// 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
|
||||
// well. So we deliberately don't call Finish() until after DMD finishes.
|
||||
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.
|
||||
// Its final name is "memory-report<-identifier>-<pid>.json.gz".
|
||||
|
||||
nsCOMPtr<nsIFile> 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
|
||||
rv = mrFinalFile->AppendNative(NS_LITERAL_CSTRING("memory-reports"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
#endif
|
||||
|
||||
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);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
nsAutoString 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);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
// Write a message to the console.
|
||||
|
||||
nsCOMPtr<nsIConsoleService> cs =
|
||||
do_GetService(NS_CONSOLESERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
nsString path;
|
||||
mrTmpFile->GetPath(path);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
nsString msg = NS_LITERAL_STRING(
|
||||
"nsIMemoryInfoDumper dumped reports to ");
|
||||
@ -988,7 +1013,8 @@ nsMemoryInfoDumper::DumpMemoryInfoToTempDir(const nsAString& aIdentifier,
|
||||
/* dumpChildProcesses = */ false);
|
||||
nsCOMPtr<nsIMemoryReporterManager> mgr =
|
||||
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;
|
||||
mgr->MinimizeMemoryUsage(callback, getter_AddRefs(runnable));
|
||||
return NS_OK;
|
||||
@ -1043,28 +1069,34 @@ nsMemoryInfoDumper::DumpMemoryReportsToNamedFile(
|
||||
|
||||
nsCOMPtr<nsIFile> 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);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
bool exists;
|
||||
rv = mrFile->Exists(&exists);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
if (!exists) {
|
||||
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.
|
||||
|
||||
nsRefPtr<nsGZFileWriter> mrWriter = new nsGZFileWriter();
|
||||
rv = mrWriter->Init(mrFile);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
rv = DumpHeader(mrWriter);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
// Process reports and finish up.
|
||||
nsRefPtr<DumpReportCallback> dumpReport = new DumpReportCallback();
|
||||
|
@ -102,7 +102,8 @@ private:
|
||||
*aAmount = 0;
|
||||
|
||||
FILE *f = fopen("/proc/self/smaps", "r");
|
||||
NS_ENSURE_STATE(f);
|
||||
if (NS_WARN_IF(!f))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
int64_t total = 0;
|
||||
char line[256];
|
||||
@ -752,7 +753,8 @@ public:
|
||||
nsIMemoryReporter::KIND_HEAP, \
|
||||
nsIMemoryReporter::UNITS_BYTES, _amount, \
|
||||
NS_LITERAL_CSTRING(_desc), aData); \
|
||||
NS_ENSURE_SUCCESS(rv, rv); \
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) \
|
||||
return rv; \
|
||||
} while (0)
|
||||
|
||||
REPORT("explicit/dmd/stack-traces/used",
|
||||
@ -1284,7 +1286,8 @@ NS_IMPL_ISUPPORTS1(ExplicitCallback, nsIHandleReportCallback)
|
||||
NS_IMETHODIMP
|
||||
nsMemoryReporterManager::GetExplicit(int64_t* aAmount)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAmount);
|
||||
if (NS_WARN_IF(!aAmount))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
*aAmount = 0;
|
||||
#ifndef HAVE_JEMALLOC_STATS
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
@ -1550,7 +1553,8 @@ NS_IMETHODIMP
|
||||
nsMemoryReporterManager::MinimizeMemoryUsage(nsIRunnable* aCallback,
|
||||
nsICancelableRunnable** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
if (NS_WARN_IF(!aResult))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsRefPtr<nsICancelableRunnable> runnable =
|
||||
new MinimizeMemoryUsageRunnable(aCallback);
|
||||
@ -1573,7 +1577,8 @@ nsMemoryReporterManager::SizeOfTab(nsIDOMWindow* aTopWindow,
|
||||
{
|
||||
nsCOMPtr<nsIGlobalObject> global = 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();
|
||||
|
||||
@ -1583,7 +1588,8 @@ nsMemoryReporterManager::SizeOfTab(nsIDOMWindow* aTopWindow,
|
||||
nsresult rv = mSizeOfTabFns.mJS(global->GetGlobalJSObject(),
|
||||
&jsObjectsSize, &jsStringsSize,
|
||||
&jsPrivateSize, &jsOtherSize);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
TimeStamp t2 = TimeStamp::Now();
|
||||
|
||||
|
@ -87,7 +87,8 @@ nsresult
|
||||
MessageLoopIdleTask::Init(uint32_t aEnsureRunsAfterMS)
|
||||
{
|
||||
mTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
NS_ENSURE_STATE(mTimer);
|
||||
if (NS_WARN_IF(!mTimer))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsRefPtr<MessageLoopTimerCallback> callback =
|
||||
new MessageLoopTimerCallback(this);
|
||||
@ -153,7 +154,8 @@ nsMessageLoopConstructor(nsISupports* aOuter,
|
||||
const nsIID& aIID,
|
||||
void** aInstancePtr)
|
||||
{
|
||||
NS_ENSURE_FALSE(aOuter, NS_ERROR_NO_AGGREGATION);
|
||||
if (NS_WARN_IF(aOuter))
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
nsISupports* messageLoop = new nsMessageLoop();
|
||||
return messageLoop->QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
@ -165,7 +165,8 @@ nsSystemInfo::Init()
|
||||
if (PR_GetSystemInfo(items[i].cmd, buf, sizeof(buf)) == PR_SUCCESS) {
|
||||
rv = SetPropertyAsACString(NS_ConvertASCIItoUTF16(items[i].name),
|
||||
nsDependentCString(buf));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
NS_WARNING("PR_GetSystemInfo failed");
|
||||
@ -182,7 +183,8 @@ nsSystemInfo::Init()
|
||||
for (uint32_t i = 0; i < ArrayLength(cpuPropItems); i++) {
|
||||
rv = SetPropertyAsBool(NS_ConvertASCIItoUTF16(cpuPropItems[i].name),
|
||||
cpuPropItems[i].propfun());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
@ -191,7 +193,8 @@ nsSystemInfo::Init()
|
||||
NS_WARN_IF_FALSE(gotWow64Value, "IsWow64Process failed");
|
||||
if (gotWow64Value) {
|
||||
rv = SetPropertyAsBool(NS_LITERAL_STRING("isWow64"), !!isWow64);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
}
|
||||
nsAutoCString hddModel, hddRevision;
|
||||
if (NS_SUCCEEDED(GetProfileHDDInfo(hddModel, hddRevision))) {
|
||||
@ -210,7 +213,8 @@ nsSystemInfo::Init()
|
||||
rv = SetPropertyAsACString(NS_LITERAL_STRING("secondaryLibrary"),
|
||||
nsDependentCString(gtkver));
|
||||
PR_smprintf_free(gtkver);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -145,7 +145,8 @@ Omnijar::GetURIString(Type aType, nsACString &result)
|
||||
nsAutoCString omniJarSpec;
|
||||
if (sPath[aType]) {
|
||||
nsresult rv = NS_GetURLSpecFromActualFile(sPath[aType], omniJarSpec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
result = "jar:";
|
||||
if (sIsNested[aType])
|
||||
@ -158,7 +159,8 @@ Omnijar::GetURIString(Type aType, nsACString &result)
|
||||
nsCOMPtr<nsIFile> dir;
|
||||
nsDirectoryService::gService->Get(SPROP(aType), NS_GET_IID(nsIFile), getter_AddRefs(dir));
|
||||
nsresult rv = NS_GetURLSpecFromActualFile(dir, result);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
}
|
||||
result += "/";
|
||||
return NS_OK;
|
||||
|
@ -40,7 +40,8 @@ NS_StringContainerInit2(nsStringContainer &aContainer,
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@ -200,7 +201,8 @@ NS_CStringContainerInit2(nsCStringContainer &aContainer,
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,8 @@ nsThreadManagerGetSingleton(nsISupports* outer,
|
||||
void* *aInstancePtr)
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -232,7 +233,8 @@ nsXPTIInterfaceInfoManagerGetSingleton(nsISupports* outer,
|
||||
void* *aInstancePtr)
|
||||
{
|
||||
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
|
||||
(XPTInterfaceInfoManager::GetSingleton());
|
||||
@ -411,34 +413,34 @@ NS_InitXPCOM2(nsIServiceManager* *result,
|
||||
|
||||
if (!AtExitManager::AlreadyRegistered()) {
|
||||
sExitManager = new AtExitManager();
|
||||
NS_ENSURE_STATE(sExitManager);
|
||||
}
|
||||
|
||||
if (!MessageLoop::current()) {
|
||||
sMessageLoop = new MessageLoopForUI(MessageLoop::TYPE_MOZILLA_UI);
|
||||
NS_ENSURE_STATE(sMessageLoop);
|
||||
}
|
||||
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Default &&
|
||||
!BrowserProcessSubThread::GetMessageLoop(BrowserProcessSubThread::IO)) {
|
||||
scoped_ptr<BrowserProcessSubThread> ioThread(
|
||||
new BrowserProcessSubThread(BrowserProcessSubThread::IO));
|
||||
NS_ENSURE_TRUE(ioThread.get(), NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
base::Thread::Options options;
|
||||
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();
|
||||
}
|
||||
|
||||
// Establish the main thread here.
|
||||
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
|
||||
rv = nsTimerImpl::Startup();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
#ifndef ANDROID
|
||||
// If the locale hasn't already been setup by our embedder,
|
||||
@ -496,14 +498,17 @@ NS_InitXPCOM2(nsIServiceManager* *result,
|
||||
nsDirectoryService::gService->Get(NS_XPCOM_CURRENT_PROCESS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(binaryFile));
|
||||
NS_ENSURE_STATE(binaryFile);
|
||||
if (NS_WARN_IF(!binaryFile))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = binaryFile->AppendNative(NS_LITERAL_CSTRING("nonexistent-executable"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
nsCString 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()) };
|
||||
CommandLine::Init(1, &argv);
|
||||
@ -626,7 +631,9 @@ ShutdownXPCOM(nsIServiceManager* servMgr)
|
||||
// Make sure the hang monitor is enabled for shutdown.
|
||||
HangMonitor::NotifyActivity();
|
||||
|
||||
NS_ENSURE_STATE(NS_IsMainThread());
|
||||
if (!NS_IsMainThread()) {
|
||||
NS_RUNTIMEABORT("Shutdown on wrong thread");
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISimpleEnumerator> moduleLoaders;
|
||||
@ -637,7 +644,8 @@ ShutdownXPCOM(nsIServiceManager* servMgr)
|
||||
// servicemanager shutdown
|
||||
|
||||
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
||||
NS_ENSURE_STATE(thread);
|
||||
if (NS_WARN_IF(!thread))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsRefPtr<nsObserverService> observerService;
|
||||
CallGetService("@mozilla.org/observer-service;1",
|
||||
|
@ -213,7 +213,8 @@ nsresult ProbeManager::StartSession(nsTArray<nsRefPtr<Probe>> &aProbes)
|
||||
used only for unregistration*/
|
||||
);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,8 @@ CategoryNode::DeleteLeaf(const char* aEntryName)
|
||||
NS_METHOD
|
||||
CategoryNode::Enumerate(nsISimpleEnumerator **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
MutexAutoLock lock(mLock);
|
||||
EntryEnumerator* enumObj = EntryEnumerator::Create(mTable);
|
||||
@ -593,9 +594,10 @@ nsCategoryManager::GetCategoryEntry( const char *aCategoryName,
|
||||
const char *aEntryName,
|
||||
char **_retval )
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCategoryName);
|
||||
NS_ENSURE_ARG_POINTER(aEntryName);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!aCategoryName) ||
|
||||
NS_WARN_IF(!aEntryName) ||
|
||||
NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;;
|
||||
|
||||
nsresult status = NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
@ -687,8 +689,9 @@ nsCategoryManager::DeleteCategoryEntry( const char *aCategoryName,
|
||||
const char *aEntryName,
|
||||
bool aDontPersist)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCategoryName);
|
||||
NS_ENSURE_ARG_POINTER(aEntryName);
|
||||
if (NS_WARN_IF(!aCategoryName) ||
|
||||
NS_WARN_IF(!aEntryName))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
/*
|
||||
Note: no errors are reported since failure to delete
|
||||
@ -715,7 +718,8 @@ nsCategoryManager::DeleteCategoryEntry( const char *aCategoryName,
|
||||
NS_IMETHODIMP
|
||||
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
|
||||
// actually delete them. We just remove all of the
|
||||
@ -740,8 +744,9 @@ NS_IMETHODIMP
|
||||
nsCategoryManager::EnumerateCategory( const char *aCategoryName,
|
||||
nsISimpleEnumerator **_retval )
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCategoryName);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!aCategoryName) ||
|
||||
NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
CategoryNode* category;
|
||||
{
|
||||
@ -759,7 +764,8 @@ nsCategoryManager::EnumerateCategory( const char *aCategoryName,
|
||||
NS_IMETHODIMP
|
||||
nsCategoryManager::EnumerateCategories(nsISimpleEnumerator **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
MutexAutoLock lock(mLock);
|
||||
CategoryEnumerator* enumObj = CategoryEnumerator::Create(mTable);
|
||||
|
@ -932,8 +932,9 @@ nsComponentManagerImpl::GetClassObjectByContractID(const char *contractID,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_ENSURE_ARG_POINTER(contractID);
|
||||
if (NS_WARN_IF(!aResult) ||
|
||||
NS_WARN_IF(!contractID))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
@ -1052,7 +1053,8 @@ nsComponentManagerImpl::CreateInstanceByContractID(const char *aContractID,
|
||||
const nsIID &aIID,
|
||||
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
|
||||
// shutdown -- whether it's available or not would depend on the order it
|
||||
@ -1607,7 +1609,9 @@ NS_IMETHODIMP
|
||||
nsComponentManagerImpl::IsContractIDRegistered(const char *aClass,
|
||||
bool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aClass);
|
||||
if (NS_WARN_IF(!aClass))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsFactoryEntry *entry = GetFactoryEntry(aClass, strlen(aClass));
|
||||
|
||||
if (entry)
|
||||
|
@ -64,7 +64,8 @@ nsHashPropertyBag::GetProperty(const nsAString& name, nsIVariant* *_retval)
|
||||
NS_IMETHODIMP
|
||||
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);
|
||||
|
||||
|
@ -51,7 +51,8 @@ nsINIParserFactory::CreateInstance(nsISupports* aOuter,
|
||||
REFNSIID aIID,
|
||||
void **aResult)
|
||||
{
|
||||
NS_ENSURE_NO_AGGREGATION(aOuter);
|
||||
if (NS_WARN_IF(aOuter))
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
// We are our own singleton.
|
||||
return QueryInterface(aIID, aResult);
|
||||
|
@ -150,7 +150,8 @@ ObserverServiceReporter::CollectReports(nsIMemoryReporterCallback* cb,
|
||||
"respect to the number of windows."),
|
||||
aClosure);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = cb->Callback(/* process */ EmptyCString(),
|
||||
@ -162,7 +163,8 @@ ObserverServiceReporter::CollectReports(nsIMemoryReporterCallback* cb,
|
||||
"observer service."),
|
||||
aClosure);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
rv = cb->Callback(/* process */ EmptyCString(),
|
||||
NS_LITERAL_CSTRING("observer-service/referent/weak/alive"),
|
||||
@ -173,7 +175,8 @@ ObserverServiceReporter::CollectReports(nsIMemoryReporterCallback* cb,
|
||||
"observer service that are still alive."),
|
||||
aClosure);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
rv = cb->Callback(/* process */ EmptyCString(),
|
||||
NS_LITERAL_CSTRING("observer-service/referent/weak/dead"),
|
||||
@ -184,7 +187,8 @@ ObserverServiceReporter::CollectReports(nsIMemoryReporterCallback* cb,
|
||||
"observer service that are dead."),
|
||||
aClosure);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -266,7 +270,8 @@ nsObserverService::AddObserver(nsIObserver* anObserver, const char* aTopic,
|
||||
(void*) anObserver, aTopic));
|
||||
|
||||
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)) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
@ -285,7 +290,8 @@ nsObserverService::RemoveObserver(nsIObserver* anObserver, const char* aTopic)
|
||||
LOG(("nsObserverService::RemoveObserver(%p: %s)",
|
||||
(void*) anObserver, aTopic));
|
||||
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);
|
||||
if (!observerList)
|
||||
@ -302,7 +308,8 @@ nsObserverService::EnumerateObservers(const char* aTopic,
|
||||
nsISimpleEnumerator** anEnumerator)
|
||||
{
|
||||
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);
|
||||
if (!observerList)
|
||||
@ -319,7 +326,8 @@ NS_IMETHODIMP nsObserverService::NotifyObservers(nsISupports *aSubject,
|
||||
LOG(("nsObserverService::NotifyObservers(%s)", aTopic));
|
||||
|
||||
NS_ENSURE_VALIDCALL
|
||||
NS_ENSURE_ARG(aTopic);
|
||||
if (NS_WARN_IF(!aTopic))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsObserverList *observerList = mObserverTopicTable.GetEntry(aTopic);
|
||||
if (observerList)
|
||||
|
@ -15,7 +15,8 @@ NS_INTERFACE_MAP_END
|
||||
NS_IMETHODIMP
|
||||
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;
|
||||
if (!nsProperties_HashBase::Get(prop, getter_AddRefs(value))) {
|
||||
@ -27,7 +28,8 @@ nsProperties::Get(const char* prop, const nsIID & uuid, void* *result)
|
||||
NS_IMETHODIMP
|
||||
nsProperties::Set(const char* prop, nsISupports* value)
|
||||
{
|
||||
NS_ENSURE_ARG(prop);
|
||||
if (NS_WARN_IF(!prop))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
Put(prop, value);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -35,7 +37,8 @@ nsProperties::Set(const char* prop, nsISupports* value)
|
||||
NS_IMETHODIMP
|
||||
nsProperties::Undefine(const char* prop)
|
||||
{
|
||||
NS_ENSURE_ARG(prop);
|
||||
if (NS_WARN_IF(!prop))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsCOMPtr<nsISupports> value;
|
||||
if (!nsProperties_HashBase::Get(prop, getter_AddRefs(value)))
|
||||
@ -48,7 +51,8 @@ nsProperties::Undefine(const char* prop)
|
||||
NS_IMETHODIMP
|
||||
nsProperties::Has(const char* prop, bool *result)
|
||||
{
|
||||
NS_ENSURE_ARG(prop);
|
||||
if (NS_WARN_IF(!prop))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsCOMPtr<nsISupports> value;
|
||||
*result = nsProperties_HashBase::Get(prop,
|
||||
@ -82,12 +86,11 @@ GetKeysEnumerate(const char *key, nsISupports* data,
|
||||
NS_IMETHODIMP
|
||||
nsProperties::GetKeys(uint32_t *count, char ***keys)
|
||||
{
|
||||
NS_ENSURE_ARG(count);
|
||||
NS_ENSURE_ARG(keys);
|
||||
if (NS_WARN_IF(!count) || NS_WARN_IF(!keys))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
uint32_t n = Count();
|
||||
char ** k = (char **) nsMemory::Alloc(n * sizeof(char *));
|
||||
NS_ENSURE_TRUE(k, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
GetKeysEnumData gked;
|
||||
gked.keys = k;
|
||||
|
@ -84,7 +84,6 @@ NS_IMPL_ISUPPORTS3(nsStringEnumerator,
|
||||
NS_IMETHODIMP
|
||||
nsStringEnumerator::HasMore(bool* aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = mIndex < Count();
|
||||
return NS_OK;
|
||||
}
|
||||
@ -119,7 +118,8 @@ nsStringEnumerator::GetNext(nsISupports** aResult)
|
||||
NS_IMETHODIMP
|
||||
nsStringEnumerator::GetNext(nsAString& aResult)
|
||||
{
|
||||
NS_ENSURE_TRUE(mIndex < Count(), NS_ERROR_UNEXPECTED);
|
||||
if (NS_WARN_IF(mIndex >= Count()))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
if (mIsUnicode)
|
||||
aResult = mArray->ElementAt(mIndex++);
|
||||
@ -132,7 +132,8 @@ nsStringEnumerator::GetNext(nsAString& aResult)
|
||||
NS_IMETHODIMP
|
||||
nsStringEnumerator::GetNext(nsACString& aResult)
|
||||
{
|
||||
NS_ENSURE_TRUE(mIndex < Count(), NS_ERROR_UNEXPECTED);
|
||||
if (NS_WARN_IF(mIndex >= Count()))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
if (mIsUnicode)
|
||||
CopyUTF16toUTF8(mArray->ElementAt(mIndex++), aResult);
|
||||
@ -160,8 +161,8 @@ nsresult
|
||||
NS_NewStringEnumerator(nsIStringEnumerator** aResult,
|
||||
const nsTArray<nsString>* aArray, nsISupports* aOwner)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_ENSURE_ARG_POINTER(aArray);
|
||||
if (NS_WARN_IF(!aResult) || NS_WARN_IF(!aArray))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
*aResult = new nsStringEnumerator(aArray, aOwner);
|
||||
return StringEnumeratorTail(aResult);
|
||||
@ -172,8 +173,8 @@ nsresult
|
||||
NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
|
||||
const nsTArray<nsCString>* aArray, nsISupports* aOwner)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_ENSURE_ARG_POINTER(aArray);
|
||||
if (NS_WARN_IF(!aResult) || NS_WARN_IF(!aArray))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
*aResult = new nsStringEnumerator(aArray, aOwner);
|
||||
return StringEnumeratorTail(aResult);
|
||||
@ -183,8 +184,8 @@ nsresult
|
||||
NS_NewAdoptingStringEnumerator(nsIStringEnumerator** aResult,
|
||||
nsTArray<nsString>* aArray)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_ENSURE_ARG_POINTER(aArray);
|
||||
if (NS_WARN_IF(!aResult) || NS_WARN_IF(!aArray))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
*aResult = new nsStringEnumerator(aArray, true);
|
||||
return StringEnumeratorTail(aResult);
|
||||
@ -194,8 +195,8 @@ nsresult
|
||||
NS_NewAdoptingUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
|
||||
nsTArray<nsCString>* aArray)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_ENSURE_ARG_POINTER(aArray);
|
||||
if (NS_WARN_IF(!aResult) || NS_WARN_IF(!aArray))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
*aResult = new nsStringEnumerator(aArray, true);
|
||||
return StringEnumeratorTail(aResult);
|
||||
@ -206,8 +207,8 @@ nsresult
|
||||
NS_NewStringEnumerator(nsIStringEnumerator** aResult,
|
||||
const nsTArray<nsString>* aArray)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_ENSURE_ARG_POINTER(aArray);
|
||||
if (NS_WARN_IF(!aResult) || NS_WARN_IF(!aArray))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
*aResult = new nsStringEnumerator(aArray, false);
|
||||
return StringEnumeratorTail(aResult);
|
||||
@ -217,8 +218,8 @@ nsresult
|
||||
NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
|
||||
const nsTArray<nsCString>* aArray)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_ENSURE_ARG_POINTER(aArray);
|
||||
if (NS_WARN_IF(!aResult) || NS_WARN_IF(!aArray))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
*aResult = new nsStringEnumerator(aArray, false);
|
||||
return StringEnumeratorTail(aResult);
|
||||
|
@ -585,7 +585,8 @@ nsSupportsArray::Clone(nsISupportsArray** aResult)
|
||||
{
|
||||
nsCOMPtr<nsISupportsArray> 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;
|
||||
Count(&count);
|
||||
|
@ -810,7 +810,8 @@ nsSupportsDependentCString::nsSupportsDependentCString(const char* aStr)
|
||||
NS_IMETHODIMP
|
||||
nsSupportsDependentCString::GetType(uint16_t *aType)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aType);
|
||||
if (NS_WARN_IF(!aType))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
*aType = TYPE_CSTRING;
|
||||
return NS_OK;
|
||||
@ -826,7 +827,8 @@ nsSupportsDependentCString::GetData(nsACString& aData)
|
||||
NS_IMETHODIMP
|
||||
nsSupportsDependentCString::ToString(char **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
*_retval = ToNewCString(mData);
|
||||
if (!*_retval)
|
||||
|
@ -103,7 +103,8 @@ NS_IMETHODIMP
|
||||
nsWindowsRegKey::OpenChild(const nsAString &path, uint32_t mode,
|
||||
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();
|
||||
|
||||
@ -119,7 +120,8 @@ NS_IMETHODIMP
|
||||
nsWindowsRegKey::CreateChild(const nsAString &path, uint32_t mode,
|
||||
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();
|
||||
|
||||
@ -134,13 +136,15 @@ nsWindowsRegKey::CreateChild(const nsAString &path, uint32_t mode,
|
||||
NS_IMETHODIMP
|
||||
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;
|
||||
LONG rv = RegQueryInfoKeyW(mKey, nullptr, nullptr, nullptr, &numSubKeys,
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr,
|
||||
nullptr, nullptr);
|
||||
NS_ENSURE_STATE(rv == ERROR_SUCCESS);
|
||||
if (rv != ERROR_SUCCESS)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*result = numSubKeys;
|
||||
return NS_OK;
|
||||
@ -149,7 +153,8 @@ nsWindowsRegKey::GetChildCount(uint32_t *result)
|
||||
NS_IMETHODIMP
|
||||
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;
|
||||
|
||||
@ -169,7 +174,8 @@ nsWindowsRegKey::GetChildName(uint32_t index, nsAString &result)
|
||||
NS_IMETHODIMP
|
||||
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
|
||||
// rights. Perhaps there is a more efficient way to do this?
|
||||
@ -187,13 +193,15 @@ nsWindowsRegKey::HasChild(const nsAString &name, bool *result)
|
||||
NS_IMETHODIMP
|
||||
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;
|
||||
LONG rv = RegQueryInfoKeyW(mKey, nullptr, nullptr, nullptr, nullptr,
|
||||
nullptr, nullptr, &numValues, nullptr, nullptr,
|
||||
nullptr, nullptr);
|
||||
NS_ENSURE_STATE(rv == ERROR_SUCCESS);
|
||||
if (rv != ERROR_SUCCESS)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*result = numValues;
|
||||
return NS_OK;
|
||||
@ -202,7 +210,8 @@ nsWindowsRegKey::GetValueCount(uint32_t *result)
|
||||
NS_IMETHODIMP
|
||||
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];
|
||||
DWORD nameLen = sizeof(nameBuf) / sizeof(nameBuf[0]);
|
||||
@ -220,7 +229,8 @@ nsWindowsRegKey::GetValueName(uint32_t index, nsAString &result)
|
||||
NS_IMETHODIMP
|
||||
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,
|
||||
nullptr, nullptr);
|
||||
@ -232,7 +242,8 @@ nsWindowsRegKey::HasValue(const nsAString &name, bool *result)
|
||||
NS_IMETHODIMP
|
||||
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());
|
||||
|
||||
@ -242,7 +253,8 @@ nsWindowsRegKey::RemoveChild(const nsAString &name)
|
||||
NS_IMETHODIMP
|
||||
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());
|
||||
|
||||
@ -252,7 +264,8 @@ nsWindowsRegKey::RemoveValue(const nsAString &name)
|
||||
NS_IMETHODIMP
|
||||
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,
|
||||
(LPDWORD) result, nullptr, nullptr);
|
||||
@ -263,7 +276,8 @@ nsWindowsRegKey::GetValueType(const nsAString &name, uint32_t *result)
|
||||
NS_IMETHODIMP
|
||||
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;
|
||||
|
||||
@ -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.
|
||||
// We're being a bit forgiving here by allowing types other than REG_SZ.
|
||||
NS_ENSURE_STATE(type == REG_SZ ||
|
||||
type == REG_EXPAND_SZ ||
|
||||
type == REG_MULTI_SZ);
|
||||
if (type != REG_SZ && type == REG_EXPAND_SZ && type == REG_MULTI_SZ)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// 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) {
|
||||
result.Truncate();
|
||||
@ -337,7 +351,8 @@ nsWindowsRegKey::ReadStringValue(const nsAString &name, nsAString &result)
|
||||
NS_IMETHODIMP
|
||||
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);
|
||||
LONG rv = RegQueryValueExW(mKey, PromiseFlatString(name).get(), 0, nullptr,
|
||||
@ -349,7 +364,8 @@ nsWindowsRegKey::ReadIntValue(const nsAString &name, uint32_t *result)
|
||||
NS_IMETHODIMP
|
||||
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);
|
||||
LONG rv = RegQueryValueExW(mKey, PromiseFlatString(name).get(), 0, nullptr,
|
||||
@ -361,7 +377,8 @@ nsWindowsRegKey::ReadInt64Value(const nsAString &name, uint64_t *result)
|
||||
NS_IMETHODIMP
|
||||
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;
|
||||
LONG rv = RegQueryValueExW(mKey, PromiseFlatString(name).get(), 0,
|
||||
@ -385,7 +402,8 @@ nsWindowsRegKey::ReadBinaryValue(const nsAString &name, nsACString &result)
|
||||
NS_IMETHODIMP
|
||||
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.
|
||||
const nsString &flatValue = PromiseFlatString(value);
|
||||
@ -400,7 +418,8 @@ nsWindowsRegKey::WriteStringValue(const nsAString &name, const nsAString &value)
|
||||
NS_IMETHODIMP
|
||||
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,
|
||||
(const BYTE *) &value, sizeof(value));
|
||||
@ -411,7 +430,8 @@ nsWindowsRegKey::WriteIntValue(const nsAString &name, uint32_t value)
|
||||
NS_IMETHODIMP
|
||||
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,
|
||||
(const BYTE *) &value, sizeof(value));
|
||||
@ -422,7 +442,8 @@ nsWindowsRegKey::WriteInt64Value(const nsAString &name, uint64_t value)
|
||||
NS_IMETHODIMP
|
||||
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);
|
||||
LONG rv = RegSetValueExW(mKey, PromiseFlatString(name).get(), 0, REG_BINARY,
|
||||
@ -434,7 +455,8 @@ nsWindowsRegKey::WriteBinaryValue(const nsAString &name, const nsACString &value
|
||||
NS_IMETHODIMP
|
||||
nsWindowsRegKey::StartWatching(bool recurse)
|
||||
{
|
||||
NS_ENSURE_TRUE(mKey, NS_ERROR_NOT_INITIALIZED);
|
||||
if (NS_WARN_IF(!mKey))
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
if (mWatchEvent)
|
||||
return NS_OK;
|
||||
|
@ -180,7 +180,6 @@ nsCOMArrayEnumerator::operator new (size_t size, const nsCOMArray_base& aArray)
|
||||
// do the actual allocation
|
||||
nsCOMArrayEnumerator * result =
|
||||
static_cast<nsCOMArrayEnumerator*>(::operator new(size));
|
||||
NS_ENSURE_TRUE(result, nullptr);
|
||||
|
||||
// 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
|
||||
|
@ -57,7 +57,8 @@ int32_t
|
||||
nsCOMArray_base::IndexOfObject(nsISupports* aObject) const
|
||||
{
|
||||
nsCOMPtr<nsISupports> supports = do_QueryInterface(aObject);
|
||||
NS_ENSURE_TRUE(supports, -1);
|
||||
if (NS_WARN_IF(!supports))
|
||||
return -1;
|
||||
|
||||
uint32_t i, count;
|
||||
int32_t retval = -1;
|
||||
|
@ -46,7 +46,8 @@ nsresult
|
||||
CallGetService(const nsCID &aCID, const nsIID &aIID, void **aResult)
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -55,7 +56,8 @@ nsresult
|
||||
CallGetService(const char *aContractID, const nsIID &aIID, void **aResult)
|
||||
{
|
||||
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::GetServiceByContractID(aContractID,
|
||||
@ -119,7 +121,8 @@ CallCreateInstance(const nsCID &aCID, nsISupports *aDelegate,
|
||||
const nsIID &aIID, void **aResult)
|
||||
{
|
||||
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::CreateInstance(aCID, aDelegate, aIID, aResult);
|
||||
@ -130,7 +133,8 @@ CallCreateInstance(const char *aContractID, nsISupports *aDelegate,
|
||||
const nsIID &aIID, void **aResult)
|
||||
{
|
||||
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::CreateInstanceByContractID(aContractID,
|
||||
@ -142,7 +146,8 @@ nsresult
|
||||
CallGetClassObject(const nsCID &aCID, const nsIID &aIID, void **aResult)
|
||||
{
|
||||
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::GetClassObject(aCID, aIID, aResult);
|
||||
@ -152,7 +157,8 @@ nsresult
|
||||
CallGetClassObject(const char *aContractID, const nsIID &aIID, void **aResult)
|
||||
{
|
||||
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::GetClassObjectByContractID(aContractID, aIID,
|
||||
|
@ -65,7 +65,8 @@ nsINIParser::Init(nsIFile* aFile)
|
||||
#ifdef XP_WIN
|
||||
nsAutoString 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);
|
||||
#else
|
||||
|
@ -19,7 +19,8 @@ nsMemory::HeapMinimize(bool aImmediate)
|
||||
{
|
||||
nsCOMPtr<nsIMemory> 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);
|
||||
}
|
||||
|
@ -70,15 +70,18 @@ NS_NewThread(nsIThread **result, nsIRunnable *event, uint32_t stackSize)
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIThreadManager> mgr =
|
||||
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));
|
||||
#endif
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
if (event) {
|
||||
rv = thread->Dispatch(event, NS_DISPATCH_NORMAL);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
}
|
||||
|
||||
*result = nullptr;
|
||||
@ -95,7 +98,8 @@ NS_GetCurrentThread(nsIThread **result)
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIThreadManager> mgr =
|
||||
do_GetService(NS_THREADMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
return mgr->GetCurrentThread(result);
|
||||
#endif
|
||||
}
|
||||
@ -109,7 +113,8 @@ NS_GetMainThread(nsIThread **result)
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIThreadManager> mgr =
|
||||
do_GetService(NS_THREADMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
return mgr->GetMainThread(result);
|
||||
#endif
|
||||
}
|
||||
@ -161,7 +166,8 @@ NS_DispatchToCurrentThread(nsIRunnable *event)
|
||||
#else
|
||||
nsCOMPtr<nsIThread> thread;
|
||||
nsresult rv = NS_GetCurrentThread(getter_AddRefs(thread));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
#endif
|
||||
return thread->Dispatch(event, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
@ -171,7 +177,8 @@ NS_DispatchToMainThread(nsIRunnable *event, uint32_t dispatchFlags)
|
||||
{
|
||||
nsCOMPtr<nsIThread> 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);
|
||||
}
|
||||
|
||||
@ -184,13 +191,15 @@ NS_ProcessPendingEvents(nsIThread *thread, PRIntervalTime timeout)
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
if (!thread) {
|
||||
thread = NS_GetCurrentThread();
|
||||
NS_ENSURE_STATE(thread);
|
||||
if (NS_WARN_IF(!thread))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
#else
|
||||
nsCOMPtr<nsIThread> current;
|
||||
if (!thread) {
|
||||
rv = NS_GetCurrentThread(getter_AddRefs(current));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
thread = current.get();
|
||||
}
|
||||
#endif
|
||||
@ -225,7 +234,8 @@ NS_HasPendingEvents(nsIThread *thread)
|
||||
return hasPendingEvents(current);
|
||||
#else
|
||||
thread = NS_GetCurrentThread();
|
||||
NS_ENSURE_TRUE(thread, false);
|
||||
if (NS_WARN_IF(!thread))
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
return hasPendingEvents(thread);
|
||||
@ -237,13 +247,15 @@ NS_ProcessNextEvent(nsIThread *thread, bool mayWait)
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
if (!thread) {
|
||||
thread = NS_GetCurrentThread();
|
||||
NS_ENSURE_TRUE(thread, false);
|
||||
if (NS_WARN_IF(!thread))
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
nsCOMPtr<nsIThread> current;
|
||||
if (!thread) {
|
||||
NS_GetCurrentThread(getter_AddRefs(current));
|
||||
NS_ENSURE_TRUE(current, false);
|
||||
if (NS_WARN_IF(!current))
|
||||
return false;
|
||||
thread = current.get();
|
||||
}
|
||||
#endif
|
||||
|
@ -71,7 +71,8 @@ NS_NewNamedThread(const char (&name)[LEN],
|
||||
uint32_t stackSize = nsIThreadManager::DEFAULT_STACK_SIZE)
|
||||
{
|
||||
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);
|
||||
if (initialEvent) {
|
||||
rv = (*result)->Dispatch(initialEvent, NS_DISPATCH_NORMAL);
|
||||
|
@ -163,7 +163,8 @@ EncodeInputStream(nsIInputStream *aInputStream,
|
||||
|
||||
if (!aCount) {
|
||||
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,
|
||||
// then will return NS_ERROR_OUT_OF_MEMORY
|
||||
aCount = (uint32_t)count64;
|
||||
|
@ -16,7 +16,8 @@ nsresult RevealFileInFinder(CFURLRef url)
|
||||
{
|
||||
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];
|
||||
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_ENSURE_ARG_POINTER(url);
|
||||
if (NS_WARN_IF(!url))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
NSAutoreleasePool* ap = [[NSAutoreleasePool alloc] init];
|
||||
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_ENSURE_ARG_POINTER(url);
|
||||
NS_ENSURE_ARG_POINTER(creatorCode);
|
||||
if (NS_WARN_IF(!url) || NS_WARN_IF(!creatorCode))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsAutoreleasePool localPool;
|
||||
|
||||
@ -76,7 +78,8 @@ nsresult SetFileCreatorCode(CFURLRef url, OSType creatorCode)
|
||||
{
|
||||
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];
|
||||
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_ENSURE_ARG_POINTER(url);
|
||||
NS_ENSURE_ARG_POINTER(typeCode);
|
||||
if (NS_WARN_IF(!url) || NS_WARN_IF(!typeCode))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsAutoreleasePool localPool;
|
||||
|
||||
@ -121,7 +124,8 @@ nsresult SetFileTypeCode(CFURLRef url, OSType typeCode)
|
||||
{
|
||||
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];
|
||||
NSDictionary* dict = [NSDictionary dictionaryWithObject:[NSNumber numberWithUnsignedLong:typeCode] forKey:NSFileHFSTypeCode];
|
||||
|
@ -50,19 +50,23 @@ using namespace mozilla;
|
||||
static nsresult
|
||||
GetTempDir(nsIFile** aTempDir)
|
||||
{
|
||||
NS_ENSURE_ARG(aTempDir);
|
||||
if (NS_WARN_IF(!aTempDir))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
nsCOMPtr<nsIFile> 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
|
||||
// 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
|
||||
// to ensure it's been cleared.
|
||||
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);
|
||||
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
|
||||
|
||||
tmpFile.forget(aTempDir);
|
||||
@ -73,12 +77,14 @@ GetTempDir(nsIFile** aTempDir)
|
||||
nsresult
|
||||
NS_OpenAnonymousTemporaryFile(PRFileDesc** aOutFileDesc)
|
||||
{
|
||||
NS_ENSURE_ARG(aOutFileDesc);
|
||||
if (NS_WARN_IF(!aOutFileDesc))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIFile> 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
|
||||
// append a counter to the name if it encounters a name collision. Adding
|
||||
@ -90,10 +96,12 @@ NS_OpenAnonymousTemporaryFile(PRFileDesc** aOutFileDesc)
|
||||
name.AppendInt(rand());
|
||||
|
||||
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);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
rv = tmpFile->OpenNSPRFileDesc(PR_RDWR | nsIFile::DELETE_ON_CLOSE,
|
||||
PR_IRWXU, aOutFileDesc);
|
||||
@ -146,16 +154,19 @@ public:
|
||||
// service is installed when running in xpcshell, and this interferes with
|
||||
// the fake idle service, causing xpcshell-test failures.
|
||||
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,
|
||||
SCHEDULE_TIMEOUT_MS,
|
||||
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
|
||||
// the timer runs.
|
||||
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);
|
||||
}
|
||||
|
||||
@ -211,7 +222,8 @@ public:
|
||||
void RemoveAnonTempFileFiles() {
|
||||
nsCOMPtr<nsIFile> tmpDir;
|
||||
nsresult rv = GetTempDir(getter_AddRefs(tmpDir));
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return;
|
||||
|
||||
// Remove the directory recursively.
|
||||
tmpDir->Remove(true);
|
||||
|
@ -87,10 +87,12 @@ NS_IMPL_ISUPPORTS2(nsAppFileLocationProvider, nsIDirectoryServiceProvider, nsIDi
|
||||
NS_IMETHODIMP
|
||||
nsAppFileLocationProvider::GetFile(const char *prop, bool *persistent, nsIFile **_retval)
|
||||
{
|
||||
if (NS_WARN_IF(!prop))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsCOMPtr<nsIFile> localFile;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
NS_ENSURE_ARG(prop);
|
||||
*_retval = nullptr;
|
||||
*persistent = true;
|
||||
|
||||
@ -250,7 +252,8 @@ nsAppFileLocationProvider::GetFile(const char *prop, bool *persistent, nsIFile *
|
||||
|
||||
NS_METHOD nsAppFileLocationProvider::CloneMozBinDirectory(nsIFile **aLocalFile)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLocalFile);
|
||||
if (NS_WARN_IF(!aLocalFile))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
nsresult rv;
|
||||
|
||||
if (!mMozBinDirectory)
|
||||
@ -291,7 +294,8 @@ NS_METHOD nsAppFileLocationProvider::CloneMozBinDirectory(nsIFile **aLocalFile)
|
||||
//----------------------------------------------------------------------------------------
|
||||
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;
|
||||
bool exists;
|
||||
@ -352,7 +356,8 @@ NS_METHOD nsAppFileLocationProvider::GetProductDirectory(nsIFile **aLocalFile, b
|
||||
//----------------------------------------------------------------------------------------
|
||||
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;
|
||||
nsCOMPtr<nsIFile> localDir;
|
||||
@ -416,7 +421,8 @@ class nsAppDirectoryEnumerator : public nsISimpleEnumerator
|
||||
|
||||
NS_IMETHOD GetNext(nsISupports **result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
if (NS_WARN_IF(!result))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
*result = nullptr;
|
||||
|
||||
bool hasMore;
|
||||
@ -511,7 +517,8 @@ class nsPathsDirectoryEnumerator : public nsAppDirectoryEnumerator
|
||||
NS_IMETHODIMP
|
||||
nsAppFileLocationProvider::GetFiles(const char *prop, nsISimpleEnumerator **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
*_retval = nullptr;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -34,21 +34,24 @@ NS_IMPL_ISUPPORTS3(nsBinaryOutputStream, nsIObjectOutputStream, nsIBinaryOutputS
|
||||
NS_IMETHODIMP
|
||||
nsBinaryOutputStream::Flush()
|
||||
{
|
||||
NS_ENSURE_STATE(mOutputStream);
|
||||
if (NS_WARN_IF(!mOutputStream))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
return mOutputStream->Flush();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBinaryOutputStream::Close()
|
||||
{
|
||||
NS_ENSURE_STATE(mOutputStream);
|
||||
if (NS_WARN_IF(!mOutputStream))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
return mOutputStream->Close();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
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);
|
||||
}
|
||||
|
||||
@ -69,14 +72,16 @@ nsBinaryOutputStream::WriteSegments(nsReadSegmentFun reader, void * closure, uin
|
||||
NS_IMETHODIMP
|
||||
nsBinaryOutputStream::IsNonBlocking(bool *aNonBlocking)
|
||||
{
|
||||
NS_ENSURE_STATE(mOutputStream);
|
||||
if (NS_WARN_IF(!mOutputStream))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
return mOutputStream->IsNonBlocking(aNonBlocking);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsBinaryOutputStream::WriteFully(const char *aBuf, uint32_t aCount)
|
||||
{
|
||||
NS_ENSURE_STATE(mOutputStream);
|
||||
if (NS_WARN_IF(!mOutputStream))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsresult rv;
|
||||
uint32_t bytesWritten;
|
||||
@ -91,7 +96,8 @@ nsBinaryOutputStream::WriteFully(const char *aBuf, uint32_t aCount)
|
||||
NS_IMETHODIMP
|
||||
nsBinaryOutputStream::SetOutputStream(nsIOutputStream *aOutputStream)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOutputStream);
|
||||
if (NS_WARN_IF(!aOutputStream))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
mOutputStream = aOutputStream;
|
||||
mBufferAccess = do_QueryInterface(aOutputStream);
|
||||
return NS_OK;
|
||||
@ -245,23 +251,25 @@ nsBinaryOutputStream::WriteCompoundObject(nsISupports* aObject,
|
||||
const nsIID& aIID,
|
||||
bool aIsStrongRef)
|
||||
{
|
||||
// Can't deal with weak refs
|
||||
NS_ENSURE_TRUE(aIsStrongRef, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIClassInfo> classInfo = do_QueryInterface(aObject);
|
||||
NS_ENSURE_TRUE(classInfo, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
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;
|
||||
classInfo->GetClassIDNoAlloc(&cid);
|
||||
|
||||
nsresult rv = WriteID(cid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
rv = WriteID(aIID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
return serializable->Write(this);
|
||||
}
|
||||
@ -270,17 +278,21 @@ NS_IMETHODIMP
|
||||
nsBinaryOutputStream::WriteID(const nsIID& aIID)
|
||||
{
|
||||
nsresult rv = Write32(aIID.m0);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
rv = Write16(aIID.m1);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
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) {
|
||||
rv = Write8(aIID.m3[i]);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -306,14 +318,16 @@ NS_IMPL_ISUPPORTS3(nsBinaryInputStream, nsIObjectInputStream, nsIBinaryInputStre
|
||||
NS_IMETHODIMP
|
||||
nsBinaryInputStream::Available(uint64_t* aResult)
|
||||
{
|
||||
NS_ENSURE_STATE(mInputStream);
|
||||
if (NS_WARN_IF(!mInputStream))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
return mInputStream->Available(aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
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.
|
||||
uint32_t totalRead = 0;
|
||||
@ -383,7 +397,8 @@ ReadSegmentForwardingThunk(nsIInputStream* aStream,
|
||||
NS_IMETHODIMP
|
||||
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 };
|
||||
|
||||
@ -416,21 +431,24 @@ nsBinaryInputStream::ReadSegments(nsWriteSegmentFun writer, void * closure, uint
|
||||
NS_IMETHODIMP
|
||||
nsBinaryInputStream::IsNonBlocking(bool *aNonBlocking)
|
||||
{
|
||||
NS_ENSURE_STATE(mInputStream);
|
||||
if (NS_WARN_IF(!mInputStream))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
return mInputStream->IsNonBlocking(aNonBlocking);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBinaryInputStream::Close()
|
||||
{
|
||||
NS_ENSURE_STATE(mInputStream);
|
||||
if (NS_WARN_IF(!mInputStream))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
return mInputStream->Close();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBinaryInputStream::SetInputStream(nsIInputStream *aInputStream)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInputStream);
|
||||
if (NS_WARN_IF(!aInputStream))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
mInputStream = aInputStream;
|
||||
mBufferAccess = do_QueryInterface(aInputStream);
|
||||
return NS_OK;
|
||||
@ -729,7 +747,8 @@ nsBinaryInputStream::ReadArrayBuffer(uint32_t aLength, const JS::Value& aBuffer,
|
||||
|
||||
uint32_t 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) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -742,10 +761,12 @@ nsBinaryInputStream::ReadObject(bool aIsStrongRef, nsISupports* *aObject)
|
||||
nsCID cid;
|
||||
nsIID iid;
|
||||
nsresult rv = ReadID(&cid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
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
|
||||
// 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
|
||||
|
||||
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);
|
||||
NS_ENSURE_TRUE(serializable, NS_ERROR_UNEXPECTED);
|
||||
if (NS_WARN_IF(!serializable))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
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));
|
||||
}
|
||||
@ -789,17 +813,21 @@ NS_IMETHODIMP
|
||||
nsBinaryInputStream::ReadID(nsID *aResult)
|
||||
{
|
||||
nsresult rv = Read32(&aResult->m0);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
rv = Read16(&aResult->m1);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
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) {
|
||||
rv = Read8(&aResult->m3[i]);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -59,7 +59,8 @@ nsresult
|
||||
nsDirectoryService::GetCurrentProcessDirectory(nsIFile** aFile)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFile);
|
||||
if (NS_WARN_IF(!aFile))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
*aFile = nullptr;
|
||||
|
||||
// Set the component registry location:
|
||||
@ -225,8 +226,10 @@ nsDirectoryService::nsDirectoryService()
|
||||
nsresult
|
||||
nsDirectoryService::Create(nsISupports *outer, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_ENSURE_NO_AGGREGATION(outer);
|
||||
if (NS_WARN_IF(!aResult))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (NS_WARN_IF(outer))
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
if (!gService)
|
||||
{
|
||||
@ -284,7 +287,8 @@ NS_IMPL_ISUPPORTS4(nsDirectoryService, nsIProperties, nsIDirectoryService, nsIDi
|
||||
NS_IMETHODIMP
|
||||
nsDirectoryService::Undefine(const char* prop)
|
||||
{
|
||||
NS_ENSURE_ARG(prop);
|
||||
if (NS_WARN_IF(!prop))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsDependentCString key(prop);
|
||||
if (!mHashtable.Get(key, nullptr))
|
||||
@ -360,7 +364,8 @@ static bool FindProviderFile(nsIDirectoryServiceProvider* aElement,
|
||||
NS_IMETHODIMP
|
||||
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);
|
||||
|
||||
@ -409,7 +414,8 @@ nsDirectoryService::Get(const char* prop, const nsIID & uuid, void* *result)
|
||||
NS_IMETHODIMP
|
||||
nsDirectoryService::Set(const char* prop, nsISupports* value)
|
||||
{
|
||||
NS_ENSURE_ARG(prop);
|
||||
if (NS_WARN_IF(!prop))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsDependentCString key(prop);
|
||||
if (mHashtable.Get(key, nullptr) || !value) {
|
||||
@ -431,7 +437,8 @@ nsDirectoryService::Set(const char* prop, nsISupports* value)
|
||||
NS_IMETHODIMP
|
||||
nsDirectoryService::Has(const char *prop, bool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG(prop);
|
||||
if (NS_WARN_IF(!prop))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
*_retval = false;
|
||||
nsCOMPtr<nsIFile> value;
|
||||
@ -910,7 +917,8 @@ nsDirectoryService::GetFile(const char *prop, bool *persistent, nsIFile **_retva
|
||||
NS_IMETHODIMP
|
||||
nsDirectoryService::GetFiles(const char *prop, nsISimpleEnumerator **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
*_retval = nullptr;
|
||||
|
||||
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
|
||||
* 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/. */
|
||||
@ -13,7 +13,8 @@ NS_IMPL_ISUPPORTS1(nsIOUtil, nsIIOUtil)
|
||||
NS_IMETHODIMP
|
||||
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);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -21,7 +22,8 @@ nsIOUtil::InputStreamIsBuffered(nsIInputStream* aStream, bool* _retval)
|
||||
NS_IMETHODIMP
|
||||
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);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -164,7 +164,6 @@ nsInputStreamTee::TeeSegment(const char *buf, uint32_t count)
|
||||
}
|
||||
nsRefPtr<nsIRunnable> event =
|
||||
new nsInputStreamTeeWriteEvent(buf, count, mSink, this);
|
||||
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
|
||||
LOG(("nsInputStreamTee::TeeSegment [%p] dispatching write %u bytes\n",
|
||||
this, count));
|
||||
return mEventTarget->Dispatch(event, NS_DISPATCH_NORMAL);
|
||||
@ -214,7 +213,8 @@ NS_IMPL_ISUPPORTS2(nsInputStreamTee,
|
||||
NS_IMETHODIMP
|
||||
nsInputStreamTee::Close()
|
||||
{
|
||||
NS_ENSURE_TRUE(mSource, NS_ERROR_NOT_INITIALIZED);
|
||||
if (NS_WARN_IF(!mSource))
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
nsresult rv = mSource->Close();
|
||||
mSource = 0;
|
||||
mSink = 0;
|
||||
@ -224,14 +224,16 @@ nsInputStreamTee::Close()
|
||||
NS_IMETHODIMP
|
||||
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);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
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);
|
||||
if (NS_FAILED(rv) || (*bytesRead == 0))
|
||||
@ -246,7 +248,8 @@ nsInputStreamTee::ReadSegments(nsWriteSegmentFun writer,
|
||||
uint32_t count,
|
||||
uint32_t *bytesRead)
|
||||
{
|
||||
NS_ENSURE_TRUE(mSource, NS_ERROR_NOT_INITIALIZED);
|
||||
if (NS_WARN_IF(!mSource))
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
mWriter = writer;
|
||||
mClosure = closure;
|
||||
@ -257,7 +260,8 @@ nsInputStreamTee::ReadSegments(nsWriteSegmentFun writer,
|
||||
NS_IMETHODIMP
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,8 @@ void NS_ShutdownLocalFile()
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::InitWithFile(nsIFile *aFile)
|
||||
{
|
||||
NS_ENSURE_ARG(aFile);
|
||||
if (NS_WARN_IF(!aFile))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsAutoCString path;
|
||||
aFile->GetNativePath(path);
|
||||
@ -189,7 +190,8 @@ static int32_t SplitPath(PRUnichar *path, PRUnichar **nodeArray, int32_t arrayLe
|
||||
NS_IMETHODIMP
|
||||
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;
|
||||
|
||||
//
|
||||
|
@ -243,8 +243,10 @@ nsLocalFile::nsLocalFileConstructor(nsISupports *outer,
|
||||
const nsIID &aIID,
|
||||
void **aInstancePtr)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
||||
NS_ENSURE_NO_AGGREGATION(outer);
|
||||
if (NS_WARN_IF(!aInstancePtr))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (NS_WARN_IF(outer))
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
*aInstancePtr = nullptr;
|
||||
|
||||
@ -1005,7 +1007,8 @@ NS_IMETHODIMP
|
||||
nsLocalFile::GetLastModifiedTime(PRTime *aLastModTime)
|
||||
{
|
||||
CHECK_mPath();
|
||||
NS_ENSURE_ARG(aLastModTime);
|
||||
if (NS_WARN_IF(!aLastModTime))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
PRFileInfo64 info;
|
||||
if (PR_GetFileInfo64(mPath.get(), &info) != PR_SUCCESS)
|
||||
@ -1043,7 +1046,8 @@ NS_IMETHODIMP
|
||||
nsLocalFile::GetLastModifiedTimeOfLink(PRTime *aLastModTimeOfLink)
|
||||
{
|
||||
CHECK_mPath();
|
||||
NS_ENSURE_ARG(aLastModTimeOfLink);
|
||||
if (NS_WARN_IF(!aLastModTimeOfLink))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
struct STAT sbuf;
|
||||
if (LSTAT(mPath.get(), &sbuf) == -1)
|
||||
@ -1072,7 +1076,8 @@ nsLocalFile::SetLastModifiedTimeOfLink(PRTime aLastModTimeOfLink)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::GetPermissions(uint32_t *aPermissions)
|
||||
{
|
||||
NS_ENSURE_ARG(aPermissions);
|
||||
if (NS_WARN_IF(!aPermissions))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
ENSURE_STAT_CACHE();
|
||||
*aPermissions = NORMALIZE_PERMS(mCachedStat.st_mode);
|
||||
return NS_OK;
|
||||
@ -1082,7 +1087,8 @@ NS_IMETHODIMP
|
||||
nsLocalFile::GetPermissionsOfLink(uint32_t *aPermissionsOfLink)
|
||||
{
|
||||
CHECK_mPath();
|
||||
NS_ENSURE_ARG(aPermissionsOfLink);
|
||||
if (NS_WARN_IF(!aPermissionsOfLink))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
struct STAT sbuf;
|
||||
if (LSTAT(mPath.get(), &sbuf) == -1)
|
||||
@ -1127,7 +1133,8 @@ nsLocalFile::SetPermissionsOfLink(uint32_t aPermissions)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::GetFileSize(int64_t *aFileSize)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFileSize);
|
||||
if (NS_WARN_IF(!aFileSize))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
*aFileSize = 0;
|
||||
ENSURE_STAT_CACHE();
|
||||
|
||||
@ -1176,7 +1183,8 @@ NS_IMETHODIMP
|
||||
nsLocalFile::GetFileSizeOfLink(int64_t *aFileSize)
|
||||
{
|
||||
CHECK_mPath();
|
||||
NS_ENSURE_ARG(aFileSize);
|
||||
if (NS_WARN_IF(!aFileSize))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
struct STAT sbuf;
|
||||
if (LSTAT(mPath.get(), &sbuf) == -1)
|
||||
@ -1241,7 +1249,8 @@ GetDeviceName(int deviceMajor, int deviceMinor, nsACString &deviceName)
|
||||
NS_IMETHODIMP
|
||||
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.
|
||||
|
||||
@ -1326,7 +1335,8 @@ NS_IMETHODIMP
|
||||
nsLocalFile::GetParent(nsIFile **aParent)
|
||||
{
|
||||
CHECK_mPath();
|
||||
NS_ENSURE_ARG_POINTER(aParent);
|
||||
if (NS_WARN_IF(!aParent))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
*aParent = nullptr;
|
||||
|
||||
// if '/' we are at the top of the volume, return null
|
||||
@ -1372,7 +1382,8 @@ NS_IMETHODIMP
|
||||
nsLocalFile::Exists(bool *_retval)
|
||||
{
|
||||
CHECK_mPath();
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
*_retval = (access(mPath.get(), F_OK) == 0);
|
||||
return NS_OK;
|
||||
@ -1383,7 +1394,8 @@ NS_IMETHODIMP
|
||||
nsLocalFile::IsWritable(bool *_retval)
|
||||
{
|
||||
CHECK_mPath();
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
*_retval = (access(mPath.get(), W_OK) == 0);
|
||||
if (*_retval || errno == EACCES)
|
||||
@ -1395,7 +1407,8 @@ NS_IMETHODIMP
|
||||
nsLocalFile::IsReadable(bool *_retval)
|
||||
{
|
||||
CHECK_mPath();
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
*_retval = (access(mPath.get(), R_OK) == 0);
|
||||
if (*_retval || errno == EACCES)
|
||||
@ -1407,7 +1420,8 @@ NS_IMETHODIMP
|
||||
nsLocalFile::IsExecutable(bool *_retval)
|
||||
{
|
||||
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
|
||||
// extension may cause the OS to treat it as executable regardless of
|
||||
@ -1496,7 +1510,8 @@ nsLocalFile::IsExecutable(bool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::IsDirectory(bool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
*_retval = false;
|
||||
ENSURE_STAT_CACHE();
|
||||
*_retval = S_ISDIR(mCachedStat.st_mode);
|
||||
@ -1506,7 +1521,8 @@ nsLocalFile::IsDirectory(bool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::IsFile(bool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
*_retval = false;
|
||||
ENSURE_STAT_CACHE();
|
||||
*_retval = S_ISREG(mCachedStat.st_mode);
|
||||
@ -1516,7 +1532,8 @@ nsLocalFile::IsFile(bool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::IsHidden(bool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
nsACString::const_iterator begin, end;
|
||||
LocateNativeLeafName(begin, end);
|
||||
*_retval = (*begin == '.');
|
||||
@ -1526,7 +1543,8 @@ nsLocalFile::IsHidden(bool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::IsSymlink(bool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
CHECK_mPath();
|
||||
|
||||
struct STAT symStat;
|
||||
@ -1539,7 +1557,8 @@ nsLocalFile::IsSymlink(bool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::IsSpecial(bool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
ENSURE_STAT_CACHE();
|
||||
*_retval = S_ISCHR(mCachedStat.st_mode) ||
|
||||
S_ISBLK(mCachedStat.st_mode) ||
|
||||
@ -1554,8 +1573,10 @@ nsLocalFile::IsSpecial(bool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::Equals(nsIFile *inFile, bool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG(inFile);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!inFile))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
*_retval = false;
|
||||
|
||||
nsAutoCString inPath;
|
||||
@ -1573,8 +1594,10 @@ NS_IMETHODIMP
|
||||
nsLocalFile::Contains(nsIFile *inFile, bool recur, bool *_retval)
|
||||
{
|
||||
CHECK_mPath();
|
||||
NS_ENSURE_ARG(inFile);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!inFile))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsAutoCString inPath;
|
||||
nsresult rv;
|
||||
@ -1710,7 +1733,8 @@ NS_IMETHODIMP
|
||||
nsLocalFile::Load(PRLibrary **_retval)
|
||||
{
|
||||
CHECK_mPath();
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
#ifdef NS_BUILD_REFCNT_LOGGING
|
||||
nsTraceRefcntImpl::SetActivityIsLegal(false);
|
||||
@ -2121,7 +2145,8 @@ nsLocalFile::InitWithCFURL(CFURLRef aCFURL)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::InitWithFSRef(const FSRef *aFSRef)
|
||||
{
|
||||
NS_ENSURE_ARG(aFSRef);
|
||||
if (NS_WARN_IF(!aFSRef))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
CFURLRef newURLRef = ::CFURLCreateFromFSRef(kCFAllocatorDefault, aFSRef);
|
||||
if (newURLRef) {
|
||||
@ -2151,7 +2176,8 @@ nsLocalFile::GetCFURL(CFURLRef *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::GetFSRef(FSRef *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
@ -2169,7 +2195,8 @@ nsLocalFile::GetFSRef(FSRef *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::GetFSSpec(FSSpec *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
FSRef fsRef;
|
||||
nsresult rv = GetFSRef(&fsRef);
|
||||
@ -2184,7 +2211,8 @@ nsLocalFile::GetFSSpec(FSSpec *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::GetFileSizeWithResFork(int64_t *aFileSizeWithResFork)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFileSizeWithResFork);
|
||||
if (NS_WARN_IF(!aFileSizeWithResFork))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
FSRef fsRef;
|
||||
nsresult rv = GetFSRef(&fsRef);
|
||||
@ -2343,7 +2371,8 @@ nsLocalFile::OpenDocWithApp(nsIFile *aAppToOpenWith, bool aLaunchInBackground)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::IsPackage(bool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
*_retval = false;
|
||||
|
||||
CFURLRef url;
|
||||
@ -2414,7 +2443,8 @@ NS_IMETHODIMP
|
||||
nsLocalFile::GetBundleContentsLastModifiedTime(int64_t *aLastModTime)
|
||||
{
|
||||
CHECK_mPath();
|
||||
NS_ENSURE_ARG_POINTER(aLastModTime);
|
||||
if (NS_WARN_IF(!aLastModTime))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
bool isPackage = false;
|
||||
nsresult rv = IsPackage(&isPackage);
|
||||
@ -2440,7 +2470,8 @@ nsLocalFile::GetBundleContentsLastModifiedTime(int64_t *aLastModTime)
|
||||
|
||||
NS_IMETHODIMP nsLocalFile::InitWithFile(nsIFile *aFile)
|
||||
{
|
||||
NS_ENSURE_ARG(aFile);
|
||||
if (NS_WARN_IF(!aFile))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsAutoCString nativePath;
|
||||
nsresult rv = aFile->GetNativePath(nativePath);
|
||||
|
@ -725,7 +725,8 @@ struct nsDir
|
||||
static nsresult
|
||||
OpenDir(const nsAFlatString &name, nsDir * *dir)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(dir);
|
||||
if (NS_WARN_IF(!dir))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
*dir = nullptr;
|
||||
if (name.Length() + 3 >= MAX_PATH)
|
||||
@ -765,7 +766,8 @@ static nsresult
|
||||
ReadDir(nsDir *dir, PRDirFlags flags, nsString& name)
|
||||
{
|
||||
name.Truncate();
|
||||
NS_ENSURE_ARG(dir);
|
||||
if (NS_WARN_IF(!dir))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
while (1) {
|
||||
BOOL rv;
|
||||
@ -809,7 +811,8 @@ ReadDir(nsDir *dir, PRDirFlags flags, nsString& name)
|
||||
static nsresult
|
||||
CloseDir(nsDir *&d)
|
||||
{
|
||||
NS_ENSURE_ARG(d);
|
||||
if (NS_WARN_IF(!d))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
BOOL isOk = FindClose(d->handle);
|
||||
// PR_DELETE also nulls out the passed in pointer.
|
||||
@ -962,8 +965,10 @@ nsLocalFile::nsLocalFile()
|
||||
nsresult
|
||||
nsLocalFile::nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
||||
NS_ENSURE_NO_AGGREGATION(outer);
|
||||
if (NS_WARN_IF(!aInstancePtr))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (NS_WARN_IF(outer))
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsLocalFile* inst = new nsLocalFile();
|
||||
if (inst == nullptr)
|
||||
@ -1149,7 +1154,8 @@ nsLocalFile::Clone(nsIFile **file)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::InitWithFile(nsIFile *aFile)
|
||||
{
|
||||
NS_ENSURE_ARG(aFile);
|
||||
if (NS_WARN_IF(!aFile))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsAutoString path;
|
||||
aFile->GetPath(path);
|
||||
@ -2072,7 +2078,8 @@ nsLocalFile::CopyMove(nsIFile *aParentDir, const nsAString &newName, bool follow
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = file->MoveTo(target, EmptyString());
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2080,7 +2087,8 @@ nsLocalFile::CopyMove(nsIFile *aParentDir, const nsAString &newName, bool follow
|
||||
rv = file->CopyToFollowingLinks(target, EmptyString());
|
||||
else
|
||||
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)
|
||||
{
|
||||
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_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
|
||||
// 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_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(aLastModifiedTime);
|
||||
if (NS_WARN_IF(!aLastModifiedTime))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
// The caller is assumed to have already called IsSymlink
|
||||
// and to have found that this file is a link.
|
||||
@ -2381,7 +2392,8 @@ nsLocalFile::SetModDate(PRTime aLastModifiedTime, const PRUnichar *filePath)
|
||||
NS_IMETHODIMP
|
||||
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
|
||||
// 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_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(aPermissions);
|
||||
if (NS_WARN_IF(!aPermissions))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
// The caller is assumed to have already called IsSymlink
|
||||
// and to have found that this file is a link. It is not
|
||||
@ -2479,7 +2492,8 @@ nsLocalFile::SetPermissionsOfLink(uint32_t aPermissions)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::GetFileSize(int64_t *aFileSize)
|
||||
{
|
||||
NS_ENSURE_ARG(aFileSize);
|
||||
if (NS_WARN_IF(!aFileSize))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsresult rv = ResolveAndStat();
|
||||
if (NS_FAILED(rv))
|
||||
@ -2496,7 +2510,8 @@ nsLocalFile::GetFileSizeOfLink(int64_t *aFileSize)
|
||||
// Check we are correctly initialized.
|
||||
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
|
||||
// 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_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(aDiskSpaceAvailable);
|
||||
if (NS_WARN_IF(!aDiskSpaceAvailable))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
ResolveAndStat();
|
||||
|
||||
@ -2580,7 +2596,8 @@ nsLocalFile::GetParent(nsIFile * *aParent)
|
||||
// Check we are correctly initialized.
|
||||
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
|
||||
if (mWorkingPath.Length() == 2) {
|
||||
@ -2624,7 +2641,8 @@ nsLocalFile::Exists(bool *_retval)
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
*_retval = false;
|
||||
|
||||
MakeDirty();
|
||||
@ -2694,7 +2712,8 @@ nsLocalFile::IsReadable(bool *_retval)
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
*_retval = false;
|
||||
|
||||
nsresult rv = ResolveAndStat();
|
||||
@ -2712,7 +2731,8 @@ nsLocalFile::IsExecutable(bool *_retval)
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
*_retval = false;
|
||||
|
||||
nsresult rv;
|
||||
@ -2867,7 +2887,8 @@ nsLocalFile::IsHidden(bool *_retval)
|
||||
nsresult
|
||||
nsLocalFile::HasFileAttribute(DWORD fileAttrib, bool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG(_retval);
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsresult rv = Resolve();
|
||||
if (NS_FAILED(rv)) {
|
||||
@ -2889,7 +2910,8 @@ nsLocalFile::IsSymlink(bool *_retval)
|
||||
// Check we are correctly initialized.
|
||||
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
|
||||
if (!IsShortcutPath(mWorkingPath)) {
|
||||
@ -2920,8 +2942,10 @@ nsLocalFile::IsSpecial(bool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::Equals(nsIFile *inFile, bool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG(inFile);
|
||||
NS_ENSURE_ARG(_retval);
|
||||
if (NS_WARN_IF(!inFile))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (NS_WARN_IF(!_retval))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
EnsureShortPath();
|
||||
|
||||
|
@ -118,7 +118,6 @@ nsMultiplexInputStream::InsertStream(nsIInputStream *aStream, uint32_t aIndex)
|
||||
{
|
||||
NS_ASSERTION(SeekableStreamAtBeginning(aStream), "Inserted stream not at beginning.");
|
||||
bool result = mStreams.InsertElementAt(aIndex, aStream);
|
||||
NS_ENSURE_TRUE(result, NS_ERROR_OUT_OF_MEMORY);
|
||||
if (mCurrentStream > aIndex ||
|
||||
(mCurrentStream == aIndex && mStartedReadingCurrent))
|
||||
++mCurrentStream;
|
||||
@ -143,7 +142,8 @@ NS_IMETHODIMP
|
||||
nsMultiplexInputStream::GetStream(uint32_t aIndex, nsIInputStream **_retval)
|
||||
{
|
||||
*_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);
|
||||
return NS_OK;
|
||||
@ -181,7 +181,8 @@ nsMultiplexInputStream::Available(uint64_t *_retval)
|
||||
for (uint32_t i = mCurrentStream; i < len; i++) {
|
||||
uint64_t streamAvail;
|
||||
rv = mStreams[i]->Available(&streamAvail);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
avail += streamAvail;
|
||||
}
|
||||
*_retval = avail;
|
||||
@ -328,7 +329,8 @@ nsMultiplexInputStream::IsNonBlocking(bool *aNonBlocking)
|
||||
}
|
||||
for (uint32_t i = 0; i < len; ++i) {
|
||||
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
|
||||
// (except that we don't implement nsIAsyncInputStream, so there's
|
||||
// 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 ||
|
||||
(i == oldCurrentStream && oldStartedReadingCurrent)) {
|
||||
rv = stream->Seek(NS_SEEK_SET, 0);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
@ -383,13 +386,15 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
|
||||
}
|
||||
else {
|
||||
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
|
||||
if (remaining < streamPos) {
|
||||
rv = stream->Seek(NS_SEEK_SET, remaining);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
mCurrentStream = i;
|
||||
mStartedReadingCurrent = remaining != 0;
|
||||
@ -405,12 +410,14 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
|
||||
else {
|
||||
uint64_t 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);
|
||||
|
||||
rv = stream->Seek(NS_SEEK_SET, newPos);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
mCurrentStream = i;
|
||||
mStartedReadingCurrent = true;
|
||||
@ -436,12 +443,14 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
|
||||
|
||||
uint64_t 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);
|
||||
|
||||
rv = stream->Seek(NS_SEEK_CUR, seek);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
mCurrentStream = i;
|
||||
mStartedReadingCurrent = true;
|
||||
@ -460,12 +469,14 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
|
||||
|
||||
int64_t 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);
|
||||
|
||||
rv = stream->Seek(NS_SEEK_CUR, -seek);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
mCurrentStream = i;
|
||||
mStartedReadingCurrent = seek != -pos;
|
||||
@ -495,7 +506,8 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
|
||||
if (remaining == 0) {
|
||||
if (i >= oldCurrentStream) {
|
||||
rv = stream->Seek(NS_SEEK_END, 0);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
@ -509,7 +521,8 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
|
||||
} else {
|
||||
uint64_t avail;
|
||||
rv = mStreams[i]->Available(&avail);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
streamPos = avail;
|
||||
}
|
||||
@ -517,7 +530,8 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
|
||||
// See if we have enough data in the current stream.
|
||||
if (DeprecatedAbs(remaining) < streamPos) {
|
||||
rv = stream->Seek(NS_SEEK_END, remaining);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
mCurrentStream = i;
|
||||
mStartedReadingCurrent = true;
|
||||
@ -531,12 +545,14 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
|
||||
} else {
|
||||
int64_t 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));
|
||||
|
||||
rv = stream->Seek(NS_SEEK_END, -newPos);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
mCurrentStream = i;
|
||||
mStartedReadingCurrent = true;
|
||||
@ -570,11 +586,13 @@ nsMultiplexInputStream::Tell(int64_t *_retval)
|
||||
last = mStartedReadingCurrent ? mCurrentStream+1 : mCurrentStream;
|
||||
for (i = 0; i < last; ++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;
|
||||
rv = stream->Tell(&pos);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
ret64 += pos;
|
||||
}
|
||||
*_retval = ret64;
|
||||
|
@ -356,7 +356,8 @@ nsPipe::GetInputStream(nsIAsyncInputStream **aInputStream)
|
||||
NS_IMETHODIMP
|
||||
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);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -88,8 +88,10 @@ NS_IMETHODIMP
|
||||
nsStorageStream::GetOutputStream(int32_t aStartingOffset,
|
||||
nsIOutputStream * *aOutputStream)
|
||||
{
|
||||
NS_ENSURE_ARG(aOutputStream);
|
||||
NS_ENSURE_TRUE(mSegmentedBuffer, NS_ERROR_NOT_INITIALIZED);
|
||||
if (NS_WARN_IF(!aOutputStream))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
if (NS_WARN_IF(!mSegmentedBuffer))
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
if (mWriteInProgress)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
@ -116,7 +118,8 @@ nsStorageStream::GetOutputStream(int32_t aStartingOffset,
|
||||
NS_IMETHODIMP
|
||||
nsStorageStream::Close()
|
||||
{
|
||||
NS_ENSURE_TRUE(mSegmentedBuffer, NS_ERROR_NOT_INITIALIZED);
|
||||
if (NS_WARN_IF(!mSegmentedBuffer))
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
mWriteInProgress = false;
|
||||
|
||||
@ -145,15 +148,15 @@ nsStorageStream::Flush()
|
||||
NS_IMETHODIMP
|
||||
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;
|
||||
uint32_t count, availableInSegment, remaining;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aNumWritten);
|
||||
NS_ENSURE_ARG(aBuffer);
|
||||
|
||||
LOG(("nsStorageStream [%p] Write mWriteCursor=%x mSegmentEnd=%x aCount=%d\n",
|
||||
this, mWriteCursor, mSegmentEnd, aCount));
|
||||
|
||||
@ -223,7 +226,6 @@ nsStorageStream::IsNonBlocking(bool *aNonBlocking)
|
||||
NS_IMETHODIMP
|
||||
nsStorageStream::GetLength(uint32_t *aLength)
|
||||
{
|
||||
NS_ENSURE_ARG(aLength);
|
||||
*aLength = mLogicalLength;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -232,7 +234,8 @@ nsStorageStream::GetLength(uint32_t *aLength)
|
||||
NS_IMETHODIMP
|
||||
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)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
@ -257,8 +260,6 @@ nsStorageStream::SetLength(uint32_t aLength)
|
||||
NS_IMETHODIMP
|
||||
nsStorageStream::GetWriteInProgress(bool *aWriteInProgress)
|
||||
{
|
||||
NS_ENSURE_ARG(aWriteInProgress);
|
||||
|
||||
*aWriteInProgress = mWriteInProgress;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -266,7 +267,8 @@ nsStorageStream::GetWriteInProgress(bool *aWriteInProgress)
|
||||
NS_METHOD
|
||||
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"
|
||||
if (aPosition == -1)
|
||||
@ -358,7 +360,8 @@ NS_IMPL_ISUPPORTS2(nsStorageInputStream,
|
||||
NS_IMETHODIMP
|
||||
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);
|
||||
if (!inputStream)
|
||||
@ -524,8 +527,6 @@ nsStorageInputStream::Seek(uint32_t aPosition)
|
||||
nsresult
|
||||
NS_NewStorageStream(uint32_t segmentSize, uint32_t maxSize, nsIStorageStream **result)
|
||||
{
|
||||
NS_ENSURE_ARG(result);
|
||||
|
||||
nsStorageStream* storageStream = new nsStorageStream();
|
||||
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
|
||||
// and return an empty string here, but it seems better to keep this return
|
||||
// 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);
|
||||
return NS_OK;
|
||||
@ -140,7 +141,8 @@ nsStringInputStream::ToString(char **result)
|
||||
NS_IMETHODIMP
|
||||
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);
|
||||
mOffset = 0;
|
||||
return NS_OK;
|
||||
@ -149,7 +151,8 @@ nsStringInputStream::SetData(const char *data, int32_t dataLen)
|
||||
NS_IMETHODIMP
|
||||
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);
|
||||
mOffset = 0;
|
||||
return NS_OK;
|
||||
@ -158,7 +161,8 @@ nsStringInputStream::AdoptData(char *data, int32_t dataLen)
|
||||
NS_IMETHODIMP
|
||||
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)
|
||||
dataLen = strlen(data);
|
||||
@ -262,8 +266,8 @@ nsStringInputStream::Seek(int32_t whence, int64_t offset)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
NS_ENSURE_ARG(newPos >= 0);
|
||||
NS_ENSURE_ARG(newPos <= Length());
|
||||
if (NS_WARN_IF(newPos < 0) || NS_WARN_IF(newPos > Length()))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
mOffset = (uint32_t)newPos;
|
||||
return NS_OK;
|
||||
@ -386,7 +390,8 @@ nsStringInputStreamConstructor(nsISupports *outer, REFNSIID iid, void **result)
|
||||
{
|
||||
*result = nullptr;
|
||||
|
||||
NS_ENSURE_TRUE(!outer, NS_ERROR_NO_AGGREGATION);
|
||||
if (NS_WARN_IF(outer))
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsStringInputStream *inst = new nsStringInputStream();
|
||||
if (!inst)
|
||||
|
@ -40,11 +40,13 @@ EXPORT_XPCOM_API(nsresult)
|
||||
NS_GetXPTCallStub(REFNSIID aIID, nsIXPTCProxy* aOuter,
|
||||
nsISomeInterface* *aResult)
|
||||
{
|
||||
NS_ENSURE_ARG(aOuter && aResult);
|
||||
if (NS_WARN_IF(!aOuter) || NS_WARN_IF(!aResult))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
XPTInterfaceInfoManager *iim =
|
||||
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);
|
||||
if (!iie || !iie->EnsureResolved() || iie->GetBuiltinClassFlag())
|
||||
|
@ -147,21 +147,26 @@ LazyIdleThread::EnsureThread()
|
||||
if (mShutdownMethod == AutomaticShutdown && NS_IsMainThread()) {
|
||||
nsCOMPtr<nsIObserverService> obs =
|
||||
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);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return 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 =
|
||||
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);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -268,12 +273,14 @@ LazyIdleThread::ShutdownThread()
|
||||
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
NS_NewRunnableMethod(this, &LazyIdleThread::CleanupThread);
|
||||
NS_ENSURE_TRUE(runnable, NS_ERROR_FAILURE);
|
||||
if (NS_WARN_IF(!runnable))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
PreDispatch();
|
||||
|
||||
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().
|
||||
mQueuedRunnables = &queuedRunnables;
|
||||
@ -299,7 +306,8 @@ LazyIdleThread::ShutdownThread()
|
||||
|
||||
if (mIdleTimer) {
|
||||
rv = mIdleTimer->Cancel();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
mIdleTimer = nullptr;
|
||||
}
|
||||
@ -376,7 +384,8 @@ LazyIdleThread::Dispatch(nsIRunnable* aEvent,
|
||||
ASSERT_OWNING_THREAD();
|
||||
|
||||
// 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.
|
||||
// Queue this runnable for later.
|
||||
@ -386,7 +395,8 @@ LazyIdleThread::Dispatch(nsIRunnable* aEvent,
|
||||
}
|
||||
|
||||
nsresult rv = EnsureThread();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
PreDispatch();
|
||||
|
||||
@ -427,7 +437,8 @@ LazyIdleThread::Shutdown()
|
||||
|
||||
mIdleObserver = nullptr;
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -467,7 +478,8 @@ LazyIdleThread::Notify(nsITimer* aTimer)
|
||||
}
|
||||
|
||||
nsresult rv = ShutdownThread();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -513,10 +525,12 @@ LazyIdleThread::AfterProcessNextEvent(nsIThreadInternal* /* aThread */,
|
||||
if (shouldNotifyIdle) {
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
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);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -48,7 +48,8 @@ nsEnvironment::Exists(const nsAString& aName, bool *aOutValue)
|
||||
{
|
||||
nsAutoCString nativeName;
|
||||
nsresult rv = NS_CopyUnicodeToNative(aName, nativeName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
nsAutoCString nativeVal;
|
||||
#if defined(XP_UNIX)
|
||||
@ -78,7 +79,8 @@ nsEnvironment::Get(const nsAString& aName, nsAString& aOutValue)
|
||||
{
|
||||
nsAutoCString nativeName;
|
||||
nsresult rv = NS_CopyUnicodeToNative(aName, nativeName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
nsAutoCString nativeVal;
|
||||
const char *value = PR_GetEnv(nativeName.get());
|
||||
@ -122,10 +124,12 @@ nsEnvironment::Set(const nsAString& aName, const nsAString& aValue)
|
||||
nsAutoCString nativeVal;
|
||||
|
||||
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);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv)))
|
||||
return rv;
|
||||
|
||||
MutexAutoLock lock(mLock);
|
||||
|
||||
|
@ -49,6 +49,5 @@ NS_DispatchMemoryPressure(MemoryPressureState state)
|
||||
{
|
||||
NS_DispatchEventualMemoryPressure(state);
|
||||
nsCOMPtr<nsIRunnable> event = new nsRunnable;
|
||||
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
|
||||
return NS_DispatchToMainThread(event);
|
||||
}
|
||||
|
@ -88,7 +88,8 @@ nsProcess::Init(nsIFile* executable)
|
||||
if (mExecutable)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(executable);
|
||||
if (NS_WARN_IF(!executable))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
bool isFile;
|
||||
|
||||
//First make sure the file exists
|
||||
@ -408,8 +409,10 @@ nsresult
|
||||
nsProcess::RunProcess(bool blocking, char **my_argv, nsIObserver* observer,
|
||||
bool holdWeak, bool argsUTF8)
|
||||
{
|
||||
NS_ENSURE_TRUE(mExecutable, NS_ERROR_NOT_INITIALIZED);
|
||||
NS_ENSURE_FALSE(mThread, NS_ERROR_ALREADY_INITIALIZED);
|
||||
if (NS_WARN_IF(!mExecutable))
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
if (NS_WARN_IF(mThread))
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
if (observer) {
|
||||
if (holdWeak) {
|
||||
|
@ -152,9 +152,9 @@ NS_IMPL_CI_INTERFACE_GETTER4(nsThread, nsIThread, nsIThreadInternal,
|
||||
|
||||
class nsThreadStartupEvent : public nsRunnable {
|
||||
public:
|
||||
// Create a new thread startup object.
|
||||
static nsThreadStartupEvent *Create() {
|
||||
return new nsThreadStartupEvent();
|
||||
nsThreadStartupEvent()
|
||||
: mMon("nsThreadStartupEvent.mMon")
|
||||
, mInitialized(false) {
|
||||
}
|
||||
|
||||
// This method does not return until the thread startup object is in the
|
||||
@ -180,11 +180,6 @@ private:
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsThreadStartupEvent()
|
||||
: mMon("nsThreadStartupEvent.mMon")
|
||||
, mInitialized(false) {
|
||||
}
|
||||
|
||||
ReentrantMonitor mMon;
|
||||
bool mInitialized;
|
||||
};
|
||||
@ -310,8 +305,7 @@ nsresult
|
||||
nsThread::Init()
|
||||
{
|
||||
// spawn thread and wait until it is fully setup
|
||||
nsRefPtr<nsThreadStartupEvent> startup = nsThreadStartupEvent::Create();
|
||||
NS_ENSURE_TRUE(startup, NS_ERROR_OUT_OF_MEMORY);
|
||||
nsRefPtr<nsThreadStartupEvent> startup = new nsThreadStartupEvent();
|
||||
|
||||
NS_ADDREF_THIS();
|
||||
|
||||
@ -377,7 +371,8 @@ nsThread::Dispatch(nsIRunnable *event, uint32_t 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) {
|
||||
return NS_ERROR_ILLEGAL_DURING_SHUTDOWN;
|
||||
@ -385,7 +380,8 @@ nsThread::Dispatch(nsIRunnable *event, uint32_t flags)
|
||||
|
||||
if (flags & DISPATCH_SYNC) {
|
||||
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
|
||||
// be able to monitor the slot occupied by this event and use
|
||||
@ -437,7 +433,8 @@ nsThread::Shutdown()
|
||||
if (!mThread)
|
||||
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
|
||||
{
|
||||
@ -490,7 +487,8 @@ nsThread::Shutdown()
|
||||
NS_IMETHODIMP
|
||||
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);
|
||||
return NS_OK;
|
||||
@ -548,7 +546,8 @@ nsThread::ProcessNextEvent(bool mayWait, bool *result)
|
||||
{
|
||||
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())
|
||||
HangMonitor::Suspend();
|
||||
@ -644,7 +643,8 @@ nsThread::GetPriority(int32_t *priority)
|
||||
NS_IMETHODIMP
|
||||
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:
|
||||
// PR_PRIORITY_LOW
|
||||
@ -690,7 +690,8 @@ nsThread::GetObserver(nsIThreadObserver **obs)
|
||||
NS_IMETHODIMP
|
||||
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);
|
||||
mObserver = obs;
|
||||
@ -700,8 +701,8 @@ nsThread::SetObserver(nsIThreadObserver *obs)
|
||||
NS_IMETHODIMP
|
||||
nsThread::GetRecursionDepth(uint32_t *depth)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(depth);
|
||||
NS_ENSURE_STATE(PR_GetCurrentThread() == mThread);
|
||||
if (NS_WARN_IF(PR_GetCurrentThread() != mThread))
|
||||
return NS_ERROR_NOT_SAME_THREAD;
|
||||
|
||||
*depth = mRunningEvent;
|
||||
return NS_OK;
|
||||
@ -710,8 +711,10 @@ nsThread::GetRecursionDepth(uint32_t *depth)
|
||||
NS_IMETHODIMP
|
||||
nsThread::AddObserver(nsIThreadObserver *observer)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(observer);
|
||||
NS_ENSURE_STATE(PR_GetCurrentThread() == mThread);
|
||||
if (NS_WARN_IF(!observer))
|
||||
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),
|
||||
"Adding an observer twice!");
|
||||
@ -727,7 +730,8 @@ nsThread::AddObserver(nsIThreadObserver *observer)
|
||||
NS_IMETHODIMP
|
||||
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)) {
|
||||
NS_WARNING("Removing an observer that was never added!");
|
||||
|
@ -217,7 +217,8 @@ nsThreadManager::NewThread(uint32_t creationFlags,
|
||||
nsIThread **result)
|
||||
{
|
||||
// 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);
|
||||
if (!thr)
|
||||
@ -242,8 +243,10 @@ NS_IMETHODIMP
|
||||
nsThreadManager::GetThreadFromPRThread(PRThread *thread, nsIThread **result)
|
||||
{
|
||||
// Keep this functioning during Shutdown
|
||||
NS_ENSURE_TRUE(mMainThread, NS_ERROR_NOT_INITIALIZED);
|
||||
NS_ENSURE_ARG_POINTER(thread);
|
||||
if (NS_WARN_IF(!mMainThread))
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
if (NS_WARN_IF(!thread))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsRefPtr<nsThread> temp;
|
||||
{
|
||||
@ -259,7 +262,8 @@ NS_IMETHODIMP
|
||||
nsThreadManager::GetMainThread(nsIThread **result)
|
||||
{
|
||||
// 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);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -268,7 +272,8 @@ NS_IMETHODIMP
|
||||
nsThreadManager::GetCurrentThread(nsIThread **result)
|
||||
{
|
||||
// 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();
|
||||
if (!*result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -92,7 +92,8 @@ nsThreadPool::PutEvent(nsIRunnable *event)
|
||||
nsThreadManager::get()->NewThread(0,
|
||||
nsIThreadManager::DEFAULT_STACK_SIZE,
|
||||
getter_AddRefs(thread));
|
||||
NS_ENSURE_STATE(thread);
|
||||
if (NS_WARN_IF(!thread))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
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));
|
||||
|
||||
NS_ENSURE_STATE(!mShutdown);
|
||||
if (NS_WARN_IF(mShutdown))
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
if (flags & DISPATCH_SYNC) {
|
||||
nsCOMPtr<nsIThread> thread;
|
||||
nsThreadManager::get()->GetCurrentThread(getter_AddRefs(thread));
|
||||
NS_ENSURE_STATE(thread);
|
||||
if (NS_WARN_IF(!thread))
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
nsRefPtr<nsThreadSyncDispatch> wrapper =
|
||||
new nsThreadSyncDispatch(thread, event);
|
||||
|
@ -317,14 +317,16 @@ nsresult nsTimerImpl::InitCommon(uint32_t aType, uint32_t aDelay)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_ENSURE_TRUE(gThread, NS_ERROR_NOT_INITIALIZED);
|
||||
if (NS_WARN_IF(!gThread))
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
if (!mEventTarget) {
|
||||
NS_ERROR("mEventTarget is NULL");
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
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
|
||||
@ -357,7 +359,8 @@ NS_IMETHODIMP nsTimerImpl::InitWithFuncCallback(nsTimerCallbackFunc aFunc,
|
||||
uint32_t aDelay,
|
||||
uint32_t aType)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFunc);
|
||||
if (NS_WARN_IF(!aFunc))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
ReleaseCallback();
|
||||
mCallbackType = CALLBACK_TYPE_FUNC;
|
||||
@ -371,7 +374,8 @@ NS_IMETHODIMP nsTimerImpl::InitWithCallback(nsITimerCallback *aCallback,
|
||||
uint32_t aDelay,
|
||||
uint32_t aType)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCallback);
|
||||
if (NS_WARN_IF(!aCallback))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
ReleaseCallback();
|
||||
mCallbackType = CALLBACK_TYPE_INTERFACE;
|
||||
@ -385,7 +389,8 @@ NS_IMETHODIMP nsTimerImpl::Init(nsIObserver *aObserver,
|
||||
uint32_t aDelay,
|
||||
uint32_t aType)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aObserver);
|
||||
if (NS_WARN_IF(!aObserver))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
ReleaseCallback();
|
||||
mCallbackType = CALLBACK_TYPE_OBSERVER;
|
||||
@ -481,8 +486,8 @@ NS_IMETHODIMP nsTimerImpl::GetTarget(nsIEventTarget** aTarget)
|
||||
|
||||
NS_IMETHODIMP nsTimerImpl::SetTarget(nsIEventTarget* aTarget)
|
||||
{
|
||||
NS_ENSURE_TRUE(mCallbackType == CALLBACK_TYPE_UNKNOWN,
|
||||
NS_ERROR_ALREADY_INITIALIZED);
|
||||
if (NS_WARN_IF(mCallbackType != CALLBACK_TYPE_UNKNOWN))
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
if (aTarget)
|
||||
mEventTarget = aTarget;
|
||||
|
Loading…
Reference in New Issue
Block a user