Skip to content

Commit

Permalink
Bug 1322979 - Migrating from NS_ASSERTION to MOZ_ASSERT in dom/file, …
Browse files Browse the repository at this point in the history
…r=qdot
  • Loading branch information
bakulf committed Dec 13, 2016
1 parent 1ec1f6a commit e1fcb91
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 27 deletions.
24 changes: 12 additions & 12 deletions dom/file/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class DataOwnerAdapter final : public nsIInputStream,
mSeekableStream(do_QueryInterface(aStream)),
mSerializableInputStream(do_QueryInterface(aStream))
{
NS_ASSERTION(mSeekableStream, "Somebody gave us the wrong stream!");
MOZ_ASSERT(mSeekableStream, "Somebody gave us the wrong stream!");
}

RefPtr<DataOwner> mDataOwner;
Expand All @@ -108,7 +108,7 @@ nsresult DataOwnerAdapter::Create(DataOwner* aDataOwner,
nsIInputStream** _retval)
{
nsresult rv;
NS_ASSERTION(aDataOwner, "Uh ...");
MOZ_ASSERT(aDataOwner, "Uh ...");

nsCOMPtr<nsIInputStream> stream;

Expand Down Expand Up @@ -672,28 +672,28 @@ NS_IMPL_ISUPPORTS_INHERITED0(BlobImplFile, BlobImpl)
void
BlobImplBase::GetName(nsAString& aName) const
{
NS_ASSERTION(mIsFile, "Should only be called on files");
MOZ_ASSERT(mIsFile, "Should only be called on files");
aName = mName;
}

void
BlobImplBase::GetPath(nsAString& aPath) const
{
NS_ASSERTION(mIsFile, "Should only be called on files");
MOZ_ASSERT(mIsFile, "Should only be called on files");
aPath = mPath;
}

void
BlobImplBase::SetPath(const nsAString& aPath)
{
NS_ASSERTION(mIsFile, "Should only be called on files");
MOZ_ASSERT(mIsFile, "Should only be called on files");
mPath = aPath;
}

void
BlobImplBase::GetMozFullPath(nsAString& aFileName, ErrorResult& aRv) const
{
NS_ASSERTION(mIsFile, "Should only be called on files");
MOZ_ASSERT(mIsFile, "Should only be called on files");

aFileName.Truncate();

Expand Down Expand Up @@ -733,7 +733,7 @@ BlobImplBase::GetType(nsAString& aType)
int64_t
BlobImplBase::GetLastModified(ErrorResult& aRv)
{
NS_ASSERTION(mIsFile, "Should only be called on files");
MOZ_ASSERT(mIsFile, "Should only be called on files");
if (IsDateUnknown()) {
mLastModificationDate = PR_Now();
}
Expand Down Expand Up @@ -840,15 +840,15 @@ BlobImplFile::CreateSlice(uint64_t aStart, uint64_t aLength,
void
BlobImplFile::GetMozFullPathInternal(nsAString& aFilename, ErrorResult& aRv) const
{
NS_ASSERTION(mIsFile, "Should only be called on files");
MOZ_ASSERT(mIsFile, "Should only be called on files");
aRv = mFile->GetPath(aFilename);
}

uint64_t
BlobImplFile::GetSize(ErrorResult& aRv)
{
if (BlobImplBase::IsSizeUnknown()) {
NS_ASSERTION(mWholeFile,
MOZ_ASSERT(mWholeFile,
"Should only use lazy size when using the whole file");
int64_t fileSize;
aRv = mFile->GetFileSize(&fileSize);
Expand Down Expand Up @@ -907,8 +907,8 @@ BlobImplFile::GetType(nsAString& aType)
aType.Truncate();

if (mContentType.IsVoid()) {
NS_ASSERTION(mWholeFile,
"Should only use lazy ContentType when using the whole file");
MOZ_ASSERT(mWholeFile,
"Should only use lazy ContentType when using the whole file");

if (!NS_IsMainThread()) {
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
Expand Down Expand Up @@ -952,7 +952,7 @@ BlobImplFile::GetType(nsAString& aType)
int64_t
BlobImplFile::GetLastModified(ErrorResult& aRv)
{
NS_ASSERTION(mIsFile, "Should only be called on files");
MOZ_ASSERT(mIsFile, "Should only be called on files");
if (BlobImplBase::IsDateUnknown()) {
PRTime msecs;
aRv = mFile->GetLastModifiedTime(&msecs);
Expand Down
19 changes: 9 additions & 10 deletions dom/file/File.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,7 @@ class BlobImplBase : public BlobImpl
, mLastModificationDate(INT64_MAX)
, mSerialNumber(NextSerialNumber())
{
NS_ASSERTION(aLength != UINT64_MAX,
"Must know length when creating slice");
MOZ_ASSERT(aLength != UINT64_MAX, "Must know length when creating slice");
// Ensure non-null mContentType by default
mContentType.SetIsVoid(false);
}
Expand Down Expand Up @@ -551,15 +550,15 @@ class BlobImplMemory final : public BlobImplBase
: BlobImplBase(aName, aContentType, aLength, aLastModifiedDate)
, mDataOwner(new DataOwner(aMemoryBuffer, aLength))
{
NS_ASSERTION(mDataOwner && mDataOwner->mData, "must have data");
MOZ_ASSERT(mDataOwner && mDataOwner->mData, "must have data");
}

BlobImplMemory(void* aMemoryBuffer, uint64_t aLength,
const nsAString& aContentType)
: BlobImplBase(aContentType, aLength)
, mDataOwner(new DataOwner(aMemoryBuffer, aLength))
{
NS_ASSERTION(mDataOwner && mDataOwner->mData, "must have data");
MOZ_ASSERT(mDataOwner && mDataOwner->mData, "must have data");
}

virtual void GetInternalStream(nsIInputStream** aStream,
Expand Down Expand Up @@ -626,7 +625,7 @@ class BlobImplMemory final : public BlobImplBase
: BlobImplBase(aContentType, aOther->mStart + aStart, aLength)
, mDataOwner(aOther->mDataOwner)
{
NS_ASSERTION(mDataOwner && mDataOwner->mData, "must have data");
MOZ_ASSERT(mDataOwner && mDataOwner->mData, "must have data");
mImmutable = aOther->mImmutable;
}

Expand Down Expand Up @@ -683,7 +682,7 @@ class BlobImplFile : public BlobImplBase
, mWholeFile(true)
, mIsTemporary(aTemporary)
{
NS_ASSERTION(mFile, "must have file");
MOZ_ASSERT(mFile, "must have file");
// Lazily get the content type and size
mContentType.SetIsVoid(true);
mFile->GetLeafName(mName);
Expand All @@ -697,7 +696,7 @@ class BlobImplFile : public BlobImplBase
, mWholeFile(true)
, mIsTemporary(false)
{
NS_ASSERTION(mFile, "must have file");
MOZ_ASSERT(mFile, "must have file");
}

BlobImplFile(const nsAString& aName, const nsAString& aContentType,
Expand All @@ -708,7 +707,7 @@ class BlobImplFile : public BlobImplBase
, mWholeFile(true)
, mIsTemporary(false)
{
NS_ASSERTION(mFile, "must have file");
MOZ_ASSERT(mFile, "must have file");
}

// Create as a file with custom name
Expand All @@ -719,7 +718,7 @@ class BlobImplFile : public BlobImplBase
, mWholeFile(true)
, mIsTemporary(false)
{
NS_ASSERTION(mFile, "must have file");
MOZ_ASSERT(mFile, "must have file");
if (aContentType.IsEmpty()) {
// Lazily get the content type and size
mContentType.SetIsVoid(true);
Expand Down Expand Up @@ -766,7 +765,7 @@ class BlobImplFile : public BlobImplBase
, mWholeFile(false)
, mIsTemporary(false)
{
NS_ASSERTION(mFile, "must have file");
MOZ_ASSERT(mFile, "must have file");
mImmutable = aOther->mImmutable;
}

Expand Down
6 changes: 3 additions & 3 deletions dom/file/FileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ FileReader::DoReadData(uint64_t aCount)
if (mDataFormat == FILE_AS_BINARY) {
//Continuously update our binary string as data comes in
uint32_t oldLen = mResult.Length();
NS_ASSERTION(mResult.Length() == mDataLen, "unexpected mResult length");
MOZ_ASSERT(mResult.Length() == mDataLen, "unexpected mResult length");
if (uint64_t(oldLen) + aCount > UINT32_MAX)
return NS_ERROR_OUT_OF_MEMORY;
char16_t *buf = nullptr;
Expand All @@ -313,7 +313,7 @@ FileReader::DoReadData(uint64_t aCount)
uint32_t bytesRead = 0;
mAsyncStream->ReadSegments(ReadFuncBinaryString, buf + oldLen, aCount,
&bytesRead);
NS_ASSERTION(bytesRead == aCount, "failed to read data");
MOZ_ASSERT(bytesRead == aCount, "failed to read data");
}
else {
CheckedInt<uint64_t> size = mDataLen;
Expand All @@ -334,7 +334,7 @@ FileReader::DoReadData(uint64_t aCount)

uint32_t bytesRead = 0;
mAsyncStream->Read(mFileData + mDataLen, aCount, &bytesRead);
NS_ASSERTION(bytesRead == aCount, "failed to read data");
MOZ_ASSERT(bytesRead == aCount, "failed to read data");
}

mDataLen += aCount;
Expand Down
4 changes: 2 additions & 2 deletions dom/file/MultipartBlobImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ MultipartBlobImpl::InitializeChromeFile(Blob& aBlob,
const ChromeFilePropertyBag& aBag,
ErrorResult& aRv)
{
NS_ASSERTION(!mImmutable, "Something went wrong ...");
MOZ_ASSERT(!mImmutable, "Something went wrong ...");

if (mImmutable) {
aRv.Throw(NS_ERROR_UNEXPECTED);
Expand Down Expand Up @@ -362,7 +362,7 @@ MultipartBlobImpl::InitializeChromeFile(nsPIDOMWindowInner* aWindow,
bool aIsFromNsIFile,
ErrorResult& aRv)
{
NS_ASSERTION(!mImmutable, "Something went wrong ...");
MOZ_ASSERT(!mImmutable, "Something went wrong ...");
if (mImmutable) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return;
Expand Down

0 comments on commit e1fcb91

Please sign in to comment.