mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1599615 - Make some necko code less nsresult-happy. r=kershaw,valentin
Stuff that's infallible and not virtual has no reason to return an nsresult. Differential Revision: https://phabricator.services.mozilla.com/D54831 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
d0e4d2c6c2
commit
74327c26b4
@ -77,7 +77,7 @@ nsresult nsBufferedStream::Init(nsISupports* aStream, uint32_t bufferSize) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsBufferedStream::Close() {
|
||||
void nsBufferedStream::Close() {
|
||||
// Drop the reference from nsBufferedStream::Init()
|
||||
mStream = nullptr;
|
||||
if (mBuffer) {
|
||||
@ -115,7 +115,6 @@ nsresult nsBufferedStream::Close() {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -131,9 +130,7 @@ nsBufferedStream::Seek(int32_t whence, int64_t offset) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISeekableStream> ras = do_QueryInterface(mStream, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
#ifdef DEBUG
|
||||
NS_WARNING("mStream doesn't QI to nsISeekableStream");
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -374,32 +371,18 @@ already_AddRefed<nsIInputStream> nsBufferedInputStream::GetInputStream() {
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBufferedInputStream::Close() {
|
||||
nsresult rv1 = NS_OK, rv2;
|
||||
nsresult rv = NS_OK;
|
||||
if (mStream) {
|
||||
rv1 = Source()->Close();
|
||||
#ifdef DEBUG
|
||||
if (NS_FAILED(rv1)) {
|
||||
rv = Source()->Close();
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING(
|
||||
"(debug) Error: Source()->Close() returned error (rv1) in "
|
||||
"(debug) Error: Source()->Close() returned error in "
|
||||
"bsBuffedInputStream::Close().");
|
||||
};
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
rv2 = nsBufferedStream::Close();
|
||||
|
||||
#ifdef DEBUG
|
||||
if (NS_FAILED(rv2)) {
|
||||
NS_WARNING(
|
||||
"(debug) Error: nsBufferedStream::Close() returned error (rv2) within "
|
||||
"nsBufferedInputStream::Close().");
|
||||
};
|
||||
#endif
|
||||
|
||||
if (NS_FAILED(rv1)) {
|
||||
return rv1;
|
||||
}
|
||||
return rv2;
|
||||
nsBufferedStream::Close();
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -876,7 +859,7 @@ nsBufferedOutputStream::Init(nsIOutputStream* stream, uint32_t bufferSize) {
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBufferedOutputStream::Close() {
|
||||
nsresult rv1, rv2 = NS_OK, rv3;
|
||||
nsresult rv1, rv2 = NS_OK;
|
||||
|
||||
rv1 = Flush();
|
||||
|
||||
@ -901,15 +884,7 @@ nsBufferedOutputStream::Close() {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
rv3 = nsBufferedStream::Close();
|
||||
|
||||
#ifdef DEBUG
|
||||
if (NS_FAILED(rv3)) {
|
||||
NS_WARNING(
|
||||
"(debug) nsBufferedStream:Close() inside "
|
||||
"nsBufferedOutputStream::Close() returned error (rv3).");
|
||||
}
|
||||
#endif
|
||||
nsBufferedStream::Close();
|
||||
|
||||
if (NS_FAILED(rv1)) {
|
||||
return rv1;
|
||||
@ -917,7 +892,7 @@ nsBufferedOutputStream::Close() {
|
||||
if (NS_FAILED(rv2)) {
|
||||
return rv2;
|
||||
}
|
||||
return rv3;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1002,7 +977,7 @@ NS_IMETHODIMP
|
||||
nsBufferedOutputStream::Finish() {
|
||||
// flush the stream, to write out any buffered data...
|
||||
nsresult rv1 = nsBufferedOutputStream::Flush();
|
||||
nsresult rv2 = NS_OK, rv3;
|
||||
nsresult rv2 = NS_OK;
|
||||
|
||||
if (NS_FAILED(rv1)) {
|
||||
NS_WARNING(
|
||||
@ -1026,7 +1001,7 @@ nsBufferedOutputStream::Finish() {
|
||||
|
||||
// ... and close the buffered stream, so any further attempts to flush/close
|
||||
// the buffered stream won't cause errors.
|
||||
rv3 = nsBufferedStream::Close();
|
||||
nsBufferedStream::Close();
|
||||
|
||||
// We want to return the errors precisely from Finish()
|
||||
// and mimick the existing error handling in
|
||||
@ -1038,7 +1013,7 @@ nsBufferedOutputStream::Finish() {
|
||||
if (NS_FAILED(rv2)) {
|
||||
return rv2;
|
||||
}
|
||||
return rv3;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult nsReadFromInputStream(nsIOutputStream* outStr, void* closure,
|
||||
|
@ -29,7 +29,7 @@ class nsBufferedStream : public nsISeekableStream {
|
||||
|
||||
nsBufferedStream();
|
||||
|
||||
nsresult Close();
|
||||
void Close();
|
||||
|
||||
protected:
|
||||
virtual ~nsBufferedStream();
|
||||
|
@ -437,8 +437,6 @@ nsresult CacheFile::OnChunkUpdated(CacheFileChunk* aChunk) {
|
||||
}
|
||||
|
||||
nsresult CacheFile::OnFileOpened(CacheFileHandle* aHandle, nsresult aResult) {
|
||||
nsresult rv;
|
||||
|
||||
// Using an 'auto' class to perform doom or fail the listener
|
||||
// outside the CacheFile's lock.
|
||||
class AutoFailDoomListener {
|
||||
@ -582,13 +580,7 @@ nsresult CacheFile::OnFileOpened(CacheFileHandle* aHandle, nsresult aResult) {
|
||||
MOZ_ASSERT(mListener);
|
||||
|
||||
mMetadata = new CacheFileMetadata(mHandle, mKey);
|
||||
|
||||
rv = mMetadata->ReadMetadata(this);
|
||||
if (NS_FAILED(rv)) {
|
||||
mListener.swap(listener);
|
||||
listener->OnFileReady(rv, false);
|
||||
}
|
||||
|
||||
mMetadata->ReadMetadata(this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1126,7 +1118,8 @@ nsresult CacheFile::VisitMetaData(nsICacheEntryMetaDataVisitor* aVisitor) {
|
||||
MOZ_ASSERT(mReady);
|
||||
NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
|
||||
|
||||
return mMetadata->Visit(aVisitor);
|
||||
mMetadata->Visit(aVisitor);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFile::ElementsSize(uint32_t* _retval) {
|
||||
@ -1148,8 +1141,8 @@ nsresult CacheFile::SetExpirationTime(uint32_t aExpirationTime) {
|
||||
NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
|
||||
|
||||
PostWriteTimer();
|
||||
|
||||
return mMetadata->SetExpirationTime(aExpirationTime);
|
||||
mMetadata->SetExpirationTime(aExpirationTime);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFile::GetExpirationTime(uint32_t* _retval) {
|
||||
@ -1157,7 +1150,8 @@ nsresult CacheFile::GetExpirationTime(uint32_t* _retval) {
|
||||
MOZ_ASSERT(mMetadata);
|
||||
NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
|
||||
|
||||
return mMetadata->GetExpirationTime(_retval);
|
||||
*_retval = mMetadata->GetExpirationTime();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFile::SetFrecency(uint32_t aFrecency) {
|
||||
@ -1174,15 +1168,16 @@ nsresult CacheFile::SetFrecency(uint32_t aFrecency) {
|
||||
CacheFileIOManager::UpdateIndexEntry(mHandle, &aFrecency, nullptr, nullptr,
|
||||
nullptr, nullptr, nullptr, 0);
|
||||
|
||||
return mMetadata->SetFrecency(aFrecency);
|
||||
mMetadata->SetFrecency(aFrecency);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFile::GetFrecency(uint32_t* _retval) {
|
||||
CacheFileAutoLock lock(this);
|
||||
MOZ_ASSERT(mMetadata);
|
||||
NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
|
||||
|
||||
return mMetadata->GetFrecency(_retval);
|
||||
*_retval = mMetadata->GetFrecency();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFile::SetNetworkTimes(uint64_t aOnStartTime,
|
||||
@ -1341,7 +1336,8 @@ nsresult CacheFile::SetAltMetadata(const char* aAltMetadata) {
|
||||
|
||||
nsresult rv =
|
||||
mMetadata->SetElement(CacheFileUtils::kAltDataKey, aAltMetadata);
|
||||
bool hasAltData = aAltMetadata ? true : false;
|
||||
|
||||
bool hasAltData = !!aAltMetadata;
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// Removing element shouldn't fail because it doesn't allocate memory.
|
||||
@ -1364,7 +1360,8 @@ nsresult CacheFile::GetLastModified(uint32_t* _retval) {
|
||||
MOZ_ASSERT(mMetadata);
|
||||
NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
|
||||
|
||||
return mMetadata->GetLastModified(_retval);
|
||||
*_retval = mMetadata->GetLastModified();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFile::GetLastFetched(uint32_t* _retval) {
|
||||
@ -1372,15 +1369,16 @@ nsresult CacheFile::GetLastFetched(uint32_t* _retval) {
|
||||
MOZ_ASSERT(mMetadata);
|
||||
NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
|
||||
|
||||
return mMetadata->GetLastFetched(_retval);
|
||||
*_retval = mMetadata->GetLastFetched();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFile::GetFetchCount(uint32_t* _retval) {
|
||||
CacheFileAutoLock lock(this);
|
||||
MOZ_ASSERT(mMetadata);
|
||||
NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
|
||||
|
||||
return mMetadata->GetFetchCount(_retval);
|
||||
*_retval = mMetadata->GetFetchCount();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFile::GetDiskStorageSizeInKB(uint32_t* aDiskStorageSize) {
|
||||
@ -1402,7 +1400,8 @@ nsresult CacheFile::OnFetched() {
|
||||
|
||||
PostWriteTimer();
|
||||
|
||||
return mMetadata->OnFetched();
|
||||
mMetadata->OnFetched();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void CacheFile::Lock() { mLock.Lock(); }
|
||||
@ -1467,8 +1466,7 @@ nsresult CacheFile::GetChunkLocked(uint32_t aIndex, ECallerType aCaller,
|
||||
if (chunk->IsReady() || aCaller == WRITER) {
|
||||
chunk.swap(*_retval);
|
||||
} else {
|
||||
rv = QueueChunkListener(aIndex, aCallback);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
QueueChunkListener(aIndex, aCallback);
|
||||
}
|
||||
|
||||
if (preload) {
|
||||
@ -1540,8 +1538,7 @@ nsresult CacheFile::GetChunkLocked(uint32_t aIndex, ECallerType aCaller,
|
||||
if (aCaller == WRITER) {
|
||||
chunk.swap(*_retval);
|
||||
} else if (aCaller != PRELOADER) {
|
||||
rv = QueueChunkListener(aIndex, aCallback);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
QueueChunkListener(aIndex, aCallback);
|
||||
}
|
||||
|
||||
if (preload) {
|
||||
@ -1629,8 +1626,7 @@ nsresult CacheFile::GetChunkLocked(uint32_t aIndex, ECallerType aCaller,
|
||||
|
||||
if (mOutput) {
|
||||
// the chunk doesn't exist but mOutput may create it
|
||||
rv = QueueChunkListener(aIndex, aCallback);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
QueueChunkListener(aIndex, aCallback);
|
||||
} else {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
@ -2067,10 +2063,7 @@ nsresult CacheFile::Truncate(int64_t aOffset) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = chunk->Truncate(bytesInNewLastChunk);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
chunk->Truncate(bytesInNewLastChunk);
|
||||
|
||||
// If the chunk is ready set the new hash now. If it's still being loaded
|
||||
// CacheChunk::Truncate() made the chunk dirty and the hash will be updated
|
||||
@ -2118,8 +2111,7 @@ static uint32_t StatusToTelemetryEnum(nsresult aStatus) {
|
||||
MOZ_ASSERT_UNREACHABLE("We should never get here");
|
||||
}
|
||||
|
||||
nsresult CacheFile::RemoveInput(CacheFileInputStream* aInput,
|
||||
nsresult aStatus) {
|
||||
void CacheFile::RemoveInput(CacheFileInputStream* aInput, nsresult aStatus) {
|
||||
CacheFileAutoLock lock(this);
|
||||
|
||||
LOG(("CacheFile::RemoveInput() [this=%p, input=%p, status=0x%08" PRIx32 "]",
|
||||
@ -2140,12 +2132,9 @@ nsresult CacheFile::RemoveInput(CacheFileInputStream* aInput,
|
||||
|
||||
Telemetry::Accumulate(Telemetry::NETWORK_CACHE_V2_INPUT_STREAM_STATUS,
|
||||
StatusToTelemetryEnum(aStatus));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFile::RemoveOutput(CacheFileOutputStream* aOutput,
|
||||
nsresult aStatus) {
|
||||
void CacheFile::RemoveOutput(CacheFileOutputStream* aOutput, nsresult aStatus) {
|
||||
AssertOwnsLock();
|
||||
|
||||
nsresult rv;
|
||||
@ -2158,7 +2147,7 @@ nsresult CacheFile::RemoveOutput(CacheFileOutputStream* aOutput,
|
||||
("CacheFile::RemoveOutput() - This output was already removed, ignoring"
|
||||
" call [this=%p]",
|
||||
this));
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
mOutput = nullptr;
|
||||
@ -2210,8 +2199,6 @@ nsresult CacheFile::RemoveOutput(CacheFileOutputStream* aOutput,
|
||||
|
||||
Telemetry::Accumulate(Telemetry::NETWORK_CACHE_V2_OUTPUT_STREAM_STATUS,
|
||||
StatusToTelemetryEnum(aStatus));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFile::NotifyChunkListener(CacheFileChunkListener* aCallback,
|
||||
@ -2224,20 +2211,16 @@ nsresult CacheFile::NotifyChunkListener(CacheFileChunkListener* aCallback,
|
||||
this, aCallback, aTarget, static_cast<uint32_t>(aResult), aChunkIdx,
|
||||
aChunk));
|
||||
|
||||
nsresult rv;
|
||||
RefPtr<NotifyChunkListenerEvent> ev;
|
||||
ev = new NotifyChunkListenerEvent(aCallback, aResult, aChunkIdx, aChunk);
|
||||
if (aTarget)
|
||||
rv = aTarget->Dispatch(ev, NS_DISPATCH_NORMAL);
|
||||
else
|
||||
rv = NS_DispatchToCurrentThread(ev);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
if (aTarget) {
|
||||
return aTarget->Dispatch(ev, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
return NS_DispatchToCurrentThread(ev);
|
||||
}
|
||||
|
||||
nsresult CacheFile::QueueChunkListener(uint32_t aIndex,
|
||||
CacheFileChunkListener* aCallback) {
|
||||
void CacheFile::QueueChunkListener(uint32_t aIndex,
|
||||
CacheFileChunkListener* aCallback) {
|
||||
LOG(("CacheFile::QueueChunkListener() [this=%p, idx=%u, listener=%p]", this,
|
||||
aIndex, aCallback));
|
||||
|
||||
@ -2262,7 +2245,6 @@ nsresult CacheFile::QueueChunkListener(uint32_t aIndex,
|
||||
}
|
||||
|
||||
listeners->mItems.AppendElement(item);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFile::NotifyChunkListeners(uint32_t aIndex, nsresult aResult,
|
||||
@ -2567,8 +2549,7 @@ nsresult CacheFile::InitIndexEntry() {
|
||||
mMetadata->IsAnonymous(), mPinned);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
uint32_t frecency;
|
||||
mMetadata->GetFrecency(&frecency);
|
||||
uint32_t frecency = mMetadata->GetFrecency();
|
||||
|
||||
bool hasAltData =
|
||||
mMetadata->GetElement(CacheFileUtils::kAltDataKey) ? true : false;
|
||||
|
@ -162,13 +162,12 @@ class CacheFile final : public CacheFileChunkListener,
|
||||
int64_t BytesFromChunk(uint32_t aIndex, bool aAlternativeData);
|
||||
nsresult Truncate(int64_t aOffset);
|
||||
|
||||
nsresult RemoveInput(CacheFileInputStream* aInput, nsresult aStatus);
|
||||
nsresult RemoveOutput(CacheFileOutputStream* aOutput, nsresult aStatus);
|
||||
void RemoveInput(CacheFileInputStream* aInput, nsresult aStatus);
|
||||
void RemoveOutput(CacheFileOutputStream* aOutput, nsresult aStatus);
|
||||
nsresult NotifyChunkListener(CacheFileChunkListener* aCallback,
|
||||
nsIEventTarget* aTarget, nsresult aResult,
|
||||
uint32_t aChunkIdx, CacheFileChunk* aChunk);
|
||||
nsresult QueueChunkListener(uint32_t aIndex,
|
||||
CacheFileChunkListener* aCallback);
|
||||
void QueueChunkListener(uint32_t aIndex, CacheFileChunkListener* aCallback);
|
||||
nsresult NotifyChunkListeners(uint32_t aIndex, nsresult aResult,
|
||||
CacheFileChunk* aChunk);
|
||||
bool HaveChunkListeners(uint32_t aIndex);
|
||||
|
@ -441,7 +441,7 @@ void CacheFileChunk::WaitForUpdate(CacheFileChunkListener* aCallback) {
|
||||
mUpdateListeners.AppendElement(item);
|
||||
}
|
||||
|
||||
nsresult CacheFileChunk::CancelWait(CacheFileChunkListener* aCallback) {
|
||||
void CacheFileChunk::CancelWait(CacheFileChunkListener* aCallback) {
|
||||
AssertOwnsLock();
|
||||
|
||||
LOG(("CacheFileChunk::CancelWait() [this=%p, listener=%p]", this, aCallback));
|
||||
@ -464,8 +464,6 @@ nsresult CacheFileChunk::CancelWait(CacheFileChunkListener* aCallback) {
|
||||
MOZ_ASSERT(mUpdateListeners[i]->mCallback != aCallback);
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileChunk::NotifyUpdateListeners() {
|
||||
@ -550,7 +548,7 @@ void CacheFileChunk::UpdateDataSize(uint32_t aOffset, uint32_t aLen) {
|
||||
mValidityMap.Log();
|
||||
}
|
||||
|
||||
nsresult CacheFileChunk::Truncate(uint32_t aOffset) {
|
||||
void CacheFileChunk::Truncate(uint32_t aOffset) {
|
||||
MOZ_RELEASE_ASSERT(mState == READY || mState == WRITING || mState == READING);
|
||||
|
||||
if (mState == READING) {
|
||||
@ -558,7 +556,6 @@ nsresult CacheFileChunk::Truncate(uint32_t aOffset) {
|
||||
}
|
||||
|
||||
mBuf->SetDataSize(aOffset);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileChunk::OnFileOpened(CacheFileHandle* aHandle,
|
||||
|
@ -140,7 +140,7 @@ class CacheFileChunk final : public CacheFileIOListener,
|
||||
CacheHash::Hash16_t aHash, CacheFileChunkListener* aCallback);
|
||||
nsresult Write(CacheFileHandle* aHandle, CacheFileChunkListener* aCallback);
|
||||
void WaitForUpdate(CacheFileChunkListener* aCallback);
|
||||
nsresult CancelWait(CacheFileChunkListener* aCallback);
|
||||
void CancelWait(CacheFileChunkListener* aCallback);
|
||||
nsresult NotifyUpdateListeners();
|
||||
|
||||
uint32_t Index() const;
|
||||
@ -182,7 +182,7 @@ class CacheFileChunk final : public CacheFileIOListener,
|
||||
void AssertOwnsLock() const;
|
||||
|
||||
void UpdateDataSize(uint32_t aOffset, uint32_t aLen);
|
||||
nsresult Truncate(uint32_t aOffset);
|
||||
void Truncate(uint32_t aOffset);
|
||||
|
||||
bool CanAllocate(uint32_t aSize) const;
|
||||
void BuffersAllocationChanged(uint32_t aFreed, uint32_t aAllocated);
|
||||
|
@ -158,7 +158,7 @@ nsresult CacheFileContextEvictor::AddContext(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileContextEvictor::CacheIndexStateChanged() {
|
||||
void CacheFileContextEvictor::CacheIndexStateChanged() {
|
||||
LOG(("CacheFileContextEvictor::CacheIndexStateChanged() [this=%p]", this));
|
||||
|
||||
MOZ_ASSERT(CacheFileIOManager::IsOnIOThread());
|
||||
@ -168,18 +168,18 @@ nsresult CacheFileContextEvictor::CacheIndexStateChanged() {
|
||||
if (mEntries.Length() == 0) {
|
||||
// Just save the state and exit, since there is nothing to do
|
||||
mIndexIsUpToDate = isUpToDate;
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isUpToDate && !mIndexIsUpToDate) {
|
||||
// Index is outdated and status has not changed, nothing to do.
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
if (isUpToDate && mIndexIsUpToDate) {
|
||||
// Status has not changed, but make sure the eviction is running.
|
||||
if (mEvicting) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
// We're not evicting, but we should be evicting?!
|
||||
@ -197,19 +197,14 @@ nsresult CacheFileContextEvictor::CacheIndexStateChanged() {
|
||||
} else {
|
||||
CloseIterators();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileContextEvictor::WasEvicted(const nsACString& aKey,
|
||||
nsIFile* aFile,
|
||||
bool* aEvictedAsPinned,
|
||||
bool* aEvictedAsNonPinned) {
|
||||
void CacheFileContextEvictor::WasEvicted(const nsACString& aKey, nsIFile* aFile,
|
||||
bool* aEvictedAsPinned,
|
||||
bool* aEvictedAsNonPinned) {
|
||||
LOG(("CacheFileContextEvictor::WasEvicted() [key=%s]",
|
||||
PromiseFlatCString(aKey).get()));
|
||||
|
||||
nsresult rv;
|
||||
|
||||
*aEvictedAsPinned = false;
|
||||
*aEvictedAsNonPinned = false;
|
||||
|
||||
@ -219,7 +214,7 @@ nsresult CacheFileContextEvictor::WasEvicted(const nsACString& aKey,
|
||||
MOZ_ASSERT(info);
|
||||
if (!info) {
|
||||
LOG(("CacheFileContextEvictor::WasEvicted() - Cannot parse key!"));
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < mEntries.Length(); ++i) {
|
||||
@ -230,13 +225,11 @@ nsresult CacheFileContextEvictor::WasEvicted(const nsACString& aKey,
|
||||
}
|
||||
|
||||
PRTime lastModifiedTime;
|
||||
rv = aFile->GetLastModifiedTime(&lastModifiedTime);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (NS_FAILED(aFile->GetLastModifiedTime(&lastModifiedTime))) {
|
||||
LOG(
|
||||
("CacheFileContextEvictor::WasEvicted() - Cannot get last modified "
|
||||
"time"
|
||||
", returning false."));
|
||||
return NS_OK;
|
||||
"time, returning."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastModifiedTime > entry->mTimeStamp) {
|
||||
@ -255,8 +248,6 @@ nsresult CacheFileContextEvictor::WasEvicted(const nsACString& aKey,
|
||||
*aEvictedAsNonPinned = true;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileContextEvictor::PersistEvictionInfoToDisk(
|
||||
@ -543,9 +534,9 @@ void CacheFileContextEvictor::StartEvicting() {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> ev;
|
||||
ev = NewRunnableMethod("net::CacheFileContextEvictor::EvictEntries", this,
|
||||
&CacheFileContextEvictor::EvictEntries);
|
||||
nsCOMPtr<nsIRunnable> ev =
|
||||
NewRunnableMethod("net::CacheFileContextEvictor::EvictEntries", this,
|
||||
&CacheFileContextEvictor::EvictEntries);
|
||||
|
||||
RefPtr<CacheIOThread> ioThread = CacheFileIOManager::IOThread();
|
||||
|
||||
@ -560,7 +551,7 @@ void CacheFileContextEvictor::StartEvicting() {
|
||||
mEvicting = true;
|
||||
}
|
||||
|
||||
nsresult CacheFileContextEvictor::EvictEntries() {
|
||||
void CacheFileContextEvictor::EvictEntries() {
|
||||
LOG(("CacheFileContextEvictor::EvictEntries()"));
|
||||
|
||||
nsresult rv;
|
||||
@ -573,7 +564,7 @@ nsresult CacheFileContextEvictor::EvictEntries() {
|
||||
LOG(
|
||||
("CacheFileContextEvictor::EvictEntries() - Stopping evicting due to "
|
||||
"outdated index."));
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
@ -584,7 +575,7 @@ nsresult CacheFileContextEvictor::EvictEntries() {
|
||||
mEvicting =
|
||||
true; // We don't want to start eviction again during shutdown
|
||||
// process. Setting this flag to true ensures it.
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
if (CacheIOThread::YieldAndRerun()) {
|
||||
@ -592,7 +583,7 @@ nsresult CacheFileContextEvictor::EvictEntries() {
|
||||
("CacheFileContextEvictor::EvictEntries() - Breaking loop for higher "
|
||||
"level events."));
|
||||
mEvicting = true;
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mEntries.Length() == 0) {
|
||||
@ -603,7 +594,7 @@ nsresult CacheFileContextEvictor::EvictEntries() {
|
||||
// Allow index to notify AsyncGetDiskConsumption callbacks. The size is
|
||||
// actual again.
|
||||
CacheIndex::OnAsyncEviction(false);
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
SHA1Sum::Hash hash;
|
||||
@ -677,13 +668,9 @@ nsresult CacheFileContextEvictor::EvictEntries() {
|
||||
}
|
||||
|
||||
// Now get the context + enhance id + URL from the key.
|
||||
nsAutoCString key;
|
||||
metadata->GetKey(key);
|
||||
|
||||
nsAutoCString uriSpec;
|
||||
|
||||
RefPtr<nsILoadContextInfo> info =
|
||||
CacheFileUtils::ParseKey(key, nullptr, &uriSpec);
|
||||
CacheFileUtils::ParseKey(metadata->GetKey(), nullptr, &uriSpec);
|
||||
MOZ_ASSERT(info);
|
||||
if (!info) {
|
||||
continue;
|
||||
@ -743,7 +730,6 @@ nsresult CacheFileContextEvictor::EvictEntries() {
|
||||
}
|
||||
|
||||
MOZ_ASSERT_UNREACHABLE("We should never get here");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
|
@ -46,14 +46,14 @@ class CacheFileContextEvictor {
|
||||
// CacheFileIOManager calls this method when CacheIndex's state changes. We
|
||||
// check whether the index is up to date and start or stop evicting according
|
||||
// to index's state.
|
||||
nsresult CacheIndexStateChanged();
|
||||
void CacheIndexStateChanged();
|
||||
// CacheFileIOManager calls this method to check whether an entry file should
|
||||
// be considered as evicted. It returns true when there is a matching context
|
||||
// info to the given key and the last modified time of the entry file is
|
||||
// earlier than the time stamp of the time when the context was added to the
|
||||
// evictor.
|
||||
nsresult WasEvicted(const nsACString& aKey, nsIFile* aFile,
|
||||
bool* aEvictedAsPinned, bool* aEvictedAsNonPinned);
|
||||
void WasEvicted(const nsACString& aKey, nsIFile* aFile,
|
||||
bool* aEvictedAsPinned, bool* aEvictedAsNonPinned);
|
||||
|
||||
private:
|
||||
// Writes information about eviction of the given context to the disk. This is
|
||||
@ -75,7 +75,7 @@ class CacheFileContextEvictor {
|
||||
void CreateIterators();
|
||||
void CloseIterators();
|
||||
void StartEvicting();
|
||||
nsresult EvictEntries();
|
||||
void EvictEntries();
|
||||
|
||||
// Whether eviction is in progress
|
||||
bool mEvicting;
|
||||
|
@ -387,9 +387,9 @@ nsresult CacheFileHandles::GetHandle(const SHA1Sum::Hash* aHash,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileHandles::NewHandle(const SHA1Sum::Hash* aHash, bool aPriority,
|
||||
CacheFileHandle::PinningStatus aPinning,
|
||||
CacheFileHandle** _retval) {
|
||||
already_AddRefed<CacheFileHandle> CacheFileHandles::NewHandle(
|
||||
const SHA1Sum::Hash* aHash, bool aPriority,
|
||||
CacheFileHandle::PinningStatus aPinning) {
|
||||
MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased());
|
||||
MOZ_ASSERT(aHash);
|
||||
|
||||
@ -417,9 +417,7 @@ nsresult CacheFileHandles::NewHandle(const SHA1Sum::Hash* aHash, bool aPriority,
|
||||
("CacheFileHandles::NewHandle() hash=%08x%08x%08x%08x%08x "
|
||||
"created new handle %p, entry=%p",
|
||||
LOGSHA1(aHash), handle.get(), entry));
|
||||
|
||||
handle.forget(_retval);
|
||||
return NS_OK;
|
||||
return handle.forget();
|
||||
}
|
||||
|
||||
void CacheFileHandles::RemoveHandle(CacheFileHandle* aHandle) {
|
||||
@ -1207,7 +1205,7 @@ nsresult CacheFileIOManager::Shutdown() {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileIOManager::ShutdownInternal() {
|
||||
void CacheFileIOManager::ShutdownInternal() {
|
||||
LOG(("CacheFileIOManager::ShutdownInternal() [this=%p]", this));
|
||||
|
||||
MOZ_ASSERT(mIOThread->IsCurrentThread());
|
||||
@ -1275,8 +1273,6 @@ nsresult CacheFileIOManager::ShutdownInternal() {
|
||||
mContextEvictor->Shutdown();
|
||||
mContextEvictor = nullptr;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
@ -1459,7 +1455,7 @@ nsresult CacheFileIOManager::UnscheduleMetadataWrite(CacheFile* aFile) {
|
||||
return target->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
nsresult CacheFileIOManager::UnscheduleMetadataWriteInternal(CacheFile* aFile) {
|
||||
void CacheFileIOManager::UnscheduleMetadataWriteInternal(CacheFile* aFile) {
|
||||
MOZ_ASSERT(IsOnIOThreadOrCeased());
|
||||
|
||||
mScheduledMetadataWrites.RemoveElement(aFile);
|
||||
@ -1468,8 +1464,6 @@ nsresult CacheFileIOManager::UnscheduleMetadataWriteInternal(CacheFile* aFile) {
|
||||
mMetadataWritesTimer->Cancel();
|
||||
mMetadataWritesTimer = nullptr;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
@ -1484,7 +1478,7 @@ nsresult CacheFileIOManager::ShutdownMetadataWriteScheduling() {
|
||||
return target->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
nsresult CacheFileIOManager::ShutdownMetadataWriteSchedulingInternal() {
|
||||
void CacheFileIOManager::ShutdownMetadataWriteSchedulingInternal() {
|
||||
MOZ_ASSERT(IsOnIOThreadOrCeased());
|
||||
|
||||
nsTArray<RefPtr<CacheFile> > files;
|
||||
@ -1498,8 +1492,6 @@ nsresult CacheFileIOManager::ShutdownMetadataWriteSchedulingInternal() {
|
||||
mMetadataWritesTimer->Cancel();
|
||||
mMetadataWritesTimer = nullptr;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1590,9 +1582,7 @@ nsresult CacheFileIOManager::OpenFileInternal(const SHA1Sum::Hash* aHash,
|
||||
handle = nullptr;
|
||||
}
|
||||
|
||||
rv = mHandles.NewHandle(aHash, aFlags & PRIORITY, pinning,
|
||||
getter_AddRefs(handle));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
handle = mHandles.NewHandle(aHash, aFlags & PRIORITY, pinning);
|
||||
|
||||
bool exists;
|
||||
rv = file->Exists(&exists);
|
||||
@ -1647,10 +1637,7 @@ nsresult CacheFileIOManager::OpenFileInternal(const SHA1Sum::Hash* aHash,
|
||||
pinning = CacheFileHandle::PinningStatus::UNKNOWN;
|
||||
}
|
||||
|
||||
rv = mHandles.NewHandle(aHash, aFlags & PRIORITY, pinning,
|
||||
getter_AddRefs(handle));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
handle = mHandles.NewHandle(aHash, aFlags & PRIORITY, pinning);
|
||||
if (exists) {
|
||||
// If this file has been found evicted through the context file evictor
|
||||
// above for any of pinned or non-pinned state, these calls ensure we doom
|
||||
@ -1777,9 +1764,8 @@ nsresult CacheFileIOManager::OpenSpecialFileInternal(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileIOManager::CloseHandleInternal(CacheFileHandle* aHandle) {
|
||||
void CacheFileIOManager::CloseHandleInternal(CacheFileHandle* aHandle) {
|
||||
nsresult rv;
|
||||
|
||||
LOG(("CacheFileIOManager::CloseHandleInternal() [handle=%p]", aHandle));
|
||||
|
||||
MOZ_ASSERT(!aHandle->IsClosed());
|
||||
@ -1823,8 +1809,6 @@ nsresult CacheFileIOManager::CloseHandleInternal(CacheFileHandle* aHandle) {
|
||||
mHandles.RemoveHandle(aHandle);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
@ -2475,11 +2459,8 @@ nsresult CacheFileIOManager::GetEntryInfo(
|
||||
}
|
||||
|
||||
// Now get the context + enhance id + URL from the key.
|
||||
nsAutoCString key;
|
||||
metadata->GetKey(key);
|
||||
|
||||
RefPtr<nsILoadContextInfo> info =
|
||||
CacheFileUtils::ParseKey(key, &enhanceId, &uriSpec);
|
||||
CacheFileUtils::ParseKey(metadata->GetKey(), &enhanceId, &uriSpec);
|
||||
MOZ_ASSERT(info);
|
||||
if (!info) {
|
||||
return NS_OK;
|
||||
@ -2487,18 +2468,9 @@ nsresult CacheFileIOManager::GetEntryInfo(
|
||||
|
||||
// Pick all data to pass to the callback.
|
||||
int64_t dataSize = metadata->Offset();
|
||||
uint32_t fetchCount;
|
||||
if (NS_FAILED(metadata->GetFetchCount(&fetchCount))) {
|
||||
fetchCount = 0;
|
||||
}
|
||||
uint32_t expirationTime;
|
||||
if (NS_FAILED(metadata->GetExpirationTime(&expirationTime))) {
|
||||
expirationTime = 0;
|
||||
}
|
||||
uint32_t lastModified;
|
||||
if (NS_FAILED(metadata->GetLastModified(&lastModified))) {
|
||||
lastModified = 0;
|
||||
}
|
||||
uint32_t fetchCount = metadata->GetFetchCount();
|
||||
uint32_t expirationTime = metadata->GetExpirationTime();
|
||||
uint32_t lastModified = metadata->GetLastModified();
|
||||
|
||||
// Call directly on the callback.
|
||||
aCallback->OnEntryInfo(uriSpec, enhanceId, dataSize, fetchCount, lastModified,
|
||||
@ -3195,8 +3167,7 @@ nsresult CacheFileIOManager::CacheIndexStateChanged() {
|
||||
|
||||
// We have to re-distatch even if we are on IO thread to prevent reentering
|
||||
// the lock in CacheIndex
|
||||
nsCOMPtr<nsIRunnable> ev;
|
||||
ev = NewRunnableMethod(
|
||||
nsCOMPtr<nsIRunnable> ev = NewRunnableMethod(
|
||||
"net::CacheFileIOManager::CacheIndexStateChangedInternal",
|
||||
gInstance.get(), &CacheFileIOManager::CacheIndexStateChangedInternal);
|
||||
|
||||
@ -3211,18 +3182,17 @@ nsresult CacheFileIOManager::CacheIndexStateChanged() {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileIOManager::CacheIndexStateChangedInternal() {
|
||||
void CacheFileIOManager::CacheIndexStateChangedInternal() {
|
||||
if (mShuttingDown) {
|
||||
// ignore notification during shutdown
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mContextEvictor) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
mContextEvictor->CacheIndexStateChanged();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileIOManager::TrashDirectory(nsIFile* aFile) {
|
||||
|
@ -133,9 +133,9 @@ class CacheFileHandles {
|
||||
~CacheFileHandles();
|
||||
|
||||
nsresult GetHandle(const SHA1Sum::Hash* aHash, CacheFileHandle** _retval);
|
||||
nsresult NewHandle(const SHA1Sum::Hash* aHash, bool aPriority,
|
||||
CacheFileHandle::PinningStatus aPinning,
|
||||
CacheFileHandle** _retval);
|
||||
already_AddRefed<CacheFileHandle> NewHandle(const SHA1Sum::Hash*,
|
||||
bool aPriority,
|
||||
CacheFileHandle::PinningStatus);
|
||||
void RemoveHandle(CacheFileHandle* aHandlle);
|
||||
void GetAllHandles(nsTArray<RefPtr<CacheFileHandle> >* _retval);
|
||||
void GetActiveHandles(nsTArray<RefPtr<CacheFileHandle> >* _retval);
|
||||
@ -369,13 +369,13 @@ class CacheFileIOManager final : public nsITimerCallback, public nsINamed {
|
||||
virtual ~CacheFileIOManager();
|
||||
|
||||
nsresult InitInternal();
|
||||
nsresult ShutdownInternal();
|
||||
void ShutdownInternal();
|
||||
|
||||
nsresult OpenFileInternal(const SHA1Sum::Hash* aHash, const nsACString& aKey,
|
||||
uint32_t aFlags, CacheFileHandle** _retval);
|
||||
nsresult OpenSpecialFileInternal(const nsACString& aKey, uint32_t aFlags,
|
||||
CacheFileHandle** _retval);
|
||||
nsresult CloseHandleInternal(CacheFileHandle* aHandle);
|
||||
void CloseHandleInternal(CacheFileHandle* aHandle);
|
||||
nsresult ReadInternal(CacheFileHandle* aHandle, int64_t aOffset, char* aBuf,
|
||||
int32_t aCount);
|
||||
nsresult WriteInternal(CacheFileHandle* aHandle, int64_t aOffset,
|
||||
@ -421,11 +421,11 @@ class CacheFileIOManager final : public nsITimerCallback, public nsINamed {
|
||||
void SyncRemoveAllCacheFiles();
|
||||
|
||||
nsresult ScheduleMetadataWriteInternal(CacheFile* aFile);
|
||||
nsresult UnscheduleMetadataWriteInternal(CacheFile* aFile);
|
||||
nsresult ShutdownMetadataWriteSchedulingInternal();
|
||||
void UnscheduleMetadataWriteInternal(CacheFile* aFile);
|
||||
void ShutdownMetadataWriteSchedulingInternal();
|
||||
|
||||
static nsresult CacheIndexStateChanged();
|
||||
nsresult CacheIndexStateChangedInternal();
|
||||
void CacheIndexStateChangedInternal();
|
||||
|
||||
// Smart size calculation. UpdateSmartCacheSize() must be called on IO thread.
|
||||
// It is called in EvictIfOverLimitInternal() just before we decide whether to
|
||||
|
@ -251,10 +251,11 @@ CacheFileInputStream::CloseWithStatus(nsresult aStatus) {
|
||||
"]",
|
||||
this, static_cast<uint32_t>(aStatus)));
|
||||
|
||||
return CloseWithStatusLocked(aStatus);
|
||||
CloseWithStatusLocked(aStatus);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileInputStream::CloseWithStatusLocked(nsresult aStatus) {
|
||||
void CacheFileInputStream::CloseWithStatusLocked(nsresult aStatus) {
|
||||
LOG(
|
||||
("CacheFileInputStream::CloseWithStatusLocked() [this=%p, "
|
||||
"aStatus=0x%08" PRIx32 "]",
|
||||
@ -266,8 +267,7 @@ nsresult CacheFileInputStream::CloseWithStatusLocked(nsresult aStatus) {
|
||||
// step out from ReadSegments. So if the stream is already closed the
|
||||
// following assertion must be true.
|
||||
MOZ_ASSERT(!mCallback || mInReadSegments);
|
||||
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
mClosed = true;
|
||||
@ -276,8 +276,6 @@ nsresult CacheFileInputStream::CloseWithStatusLocked(nsresult aStatus) {
|
||||
if (!mInReadSegments) {
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void CacheFileInputStream::CleanUp() {
|
||||
|
@ -47,7 +47,7 @@ class CacheFileInputStream : public nsIAsyncInputStream,
|
||||
private:
|
||||
virtual ~CacheFileInputStream();
|
||||
|
||||
nsresult CloseWithStatusLocked(nsresult aStatus);
|
||||
void CloseWithStatusLocked(nsresult aStatus);
|
||||
void CleanUp();
|
||||
void ReleaseChunk();
|
||||
void EnsureCorrectChunk(bool aReleaseOnly);
|
||||
|
@ -147,12 +147,7 @@ void CacheFileMetadata::SetHandle(CacheFileHandle* aHandle) {
|
||||
mHandle = aHandle;
|
||||
}
|
||||
|
||||
nsresult CacheFileMetadata::GetKey(nsACString& _retval) {
|
||||
_retval = mKey;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileMetadata::ReadMetadata(CacheFileMetadataListener* aListener) {
|
||||
void CacheFileMetadata::ReadMetadata(CacheFileMetadataListener* aListener) {
|
||||
LOG(("CacheFileMetadata::ReadMetadata() [this=%p, listener=%p]", this,
|
||||
aListener));
|
||||
|
||||
@ -175,7 +170,7 @@ nsresult CacheFileMetadata::ReadMetadata(CacheFileMetadataListener* aListener) {
|
||||
|
||||
InitEmptyMetadata();
|
||||
aListener->OnMetadataRead(NS_OK);
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
if (size < int64_t(sizeof(CacheFileMetadataHeader) + 2 * sizeof(uint32_t))) {
|
||||
@ -187,7 +182,7 @@ nsresult CacheFileMetadata::ReadMetadata(CacheFileMetadataListener* aListener) {
|
||||
|
||||
InitEmptyMetadata();
|
||||
aListener->OnMetadataRead(NS_OK);
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
// Set offset so that we read at least kMinMetadataRead if the file is big
|
||||
@ -225,10 +220,7 @@ nsresult CacheFileMetadata::ReadMetadata(CacheFileMetadataListener* aListener) {
|
||||
mListener = nullptr;
|
||||
InitEmptyMetadata();
|
||||
aListener->OnMetadataRead(NS_OK);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
uint32_t CacheFileMetadata::CalcMetadataSize(uint32_t aElementsSize,
|
||||
@ -478,7 +470,7 @@ nsresult CacheFileMetadata::SetElement(const char* aKey, const char* aValue) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileMetadata::Visit(nsICacheEntryMetaDataVisitor* aVisitor) {
|
||||
void CacheFileMetadata::Visit(nsICacheEntryMetaDataVisitor* aVisitor) {
|
||||
const char* data = mBuf;
|
||||
const char* limit = mBuf + mElementsSize;
|
||||
|
||||
@ -494,8 +486,6 @@ nsresult CacheFileMetadata::Visit(nsICacheEntryMetaDataVisitor* aVisitor) {
|
||||
}
|
||||
|
||||
MOZ_ASSERT(data == limit, "Metadata elements corrupted");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
CacheHash::Hash16_t CacheFileMetadata::GetHash(uint32_t aIndex) {
|
||||
@ -551,72 +541,37 @@ nsresult CacheFileMetadata::RemoveHash(uint32_t aIndex) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileMetadata::AddFlags(uint32_t aFlags) {
|
||||
void CacheFileMetadata::AddFlags(uint32_t aFlags) {
|
||||
MarkDirty(false);
|
||||
mMetaHdr.mFlags |= aFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileMetadata::RemoveFlags(uint32_t aFlags) {
|
||||
void CacheFileMetadata::RemoveFlags(uint32_t aFlags) {
|
||||
MarkDirty(false);
|
||||
mMetaHdr.mFlags &= ~aFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileMetadata::GetFlags(uint32_t* _retval) {
|
||||
*_retval = mMetaHdr.mFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileMetadata::SetExpirationTime(uint32_t aExpirationTime) {
|
||||
void CacheFileMetadata::SetExpirationTime(uint32_t aExpirationTime) {
|
||||
LOG(("CacheFileMetadata::SetExpirationTime() [this=%p, expirationTime=%d]",
|
||||
this, aExpirationTime));
|
||||
|
||||
MarkDirty(false);
|
||||
mMetaHdr.mExpirationTime = aExpirationTime;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileMetadata::GetExpirationTime(uint32_t* _retval) {
|
||||
*_retval = mMetaHdr.mExpirationTime;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileMetadata::SetFrecency(uint32_t aFrecency) {
|
||||
void CacheFileMetadata::SetFrecency(uint32_t aFrecency) {
|
||||
LOG(("CacheFileMetadata::SetFrecency() [this=%p, frecency=%f]", this,
|
||||
(double)aFrecency));
|
||||
|
||||
MarkDirty(false);
|
||||
mMetaHdr.mFrecency = aFrecency;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileMetadata::GetFrecency(uint32_t* _retval) {
|
||||
*_retval = mMetaHdr.mFrecency;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileMetadata::GetLastModified(uint32_t* _retval) {
|
||||
*_retval = mMetaHdr.mLastModified;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileMetadata::GetLastFetched(uint32_t* _retval) {
|
||||
*_retval = mMetaHdr.mLastFetched;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileMetadata::GetFetchCount(uint32_t* _retval) {
|
||||
*_retval = mMetaHdr.mFetchCount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheFileMetadata::OnFetched() {
|
||||
void CacheFileMetadata::OnFetched() {
|
||||
MarkDirty(false);
|
||||
|
||||
mMetaHdr.mLastFetched = NOW_SECONDS();
|
||||
++mMetaHdr.mFetchCount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void CacheFileMetadata::MarkDirty(bool aUpdateLastModified) {
|
||||
|
@ -141,9 +141,9 @@ class CacheFileMetadata final : public CacheFileIOListener,
|
||||
|
||||
void SetHandle(CacheFileHandle* aHandle);
|
||||
|
||||
nsresult GetKey(nsACString& _retval);
|
||||
const nsACString& GetKey() const { return mKey; }
|
||||
|
||||
nsresult ReadMetadata(CacheFileMetadataListener* aListener);
|
||||
void ReadMetadata(CacheFileMetadataListener* aListener);
|
||||
uint32_t CalcMetadataSize(uint32_t aElementsSize, uint32_t aHashCount);
|
||||
nsresult WriteMetadata(uint32_t aOffset,
|
||||
CacheFileMetadataListener* aListener);
|
||||
@ -157,25 +157,25 @@ class CacheFileMetadata final : public CacheFileIOListener,
|
||||
|
||||
const char* GetElement(const char* aKey);
|
||||
nsresult SetElement(const char* aKey, const char* aValue);
|
||||
nsresult Visit(nsICacheEntryMetaDataVisitor* aVisitor);
|
||||
void Visit(nsICacheEntryMetaDataVisitor* aVisitor);
|
||||
|
||||
CacheHash::Hash16_t GetHash(uint32_t aIndex);
|
||||
nsresult SetHash(uint32_t aIndex, CacheHash::Hash16_t aHash);
|
||||
nsresult RemoveHash(uint32_t aIndex);
|
||||
|
||||
nsresult AddFlags(uint32_t aFlags);
|
||||
nsresult RemoveFlags(uint32_t aFlags);
|
||||
nsresult GetFlags(uint32_t* _retval);
|
||||
nsresult SetExpirationTime(uint32_t aExpirationTime);
|
||||
nsresult GetExpirationTime(uint32_t* _retval);
|
||||
nsresult SetFrecency(uint32_t aFrecency);
|
||||
nsresult GetFrecency(uint32_t* _retval);
|
||||
nsresult GetLastModified(uint32_t* _retval);
|
||||
nsresult GetLastFetched(uint32_t* _retval);
|
||||
nsresult GetFetchCount(uint32_t* _retval);
|
||||
void AddFlags(uint32_t aFlags);
|
||||
void RemoveFlags(uint32_t aFlags);
|
||||
uint32_t GetFlags() const { return mMetaHdr.mFlags; }
|
||||
void SetExpirationTime(uint32_t aExpirationTime);
|
||||
uint32_t GetExpirationTime() const { return mMetaHdr.mExpirationTime; }
|
||||
void SetFrecency(uint32_t aFrecency);
|
||||
uint32_t GetFrecency() const { return mMetaHdr.mFrecency; }
|
||||
uint32_t GetLastModified() const { return mMetaHdr.mLastModified; }
|
||||
uint32_t GetLastFetched() const { return mMetaHdr.mLastFetched; }
|
||||
uint32_t GetFetchCount() const { return mMetaHdr.mFetchCount; }
|
||||
// Called by upper layers to indicate the entry this metadata belongs
|
||||
// with has been fetched, i.e. delivered to the consumer.
|
||||
nsresult OnFetched();
|
||||
void OnFetched();
|
||||
|
||||
int64_t Offset() { return mOffset; }
|
||||
uint32_t ElementsSize() { return mElementsSize; }
|
||||
|
@ -2675,9 +2675,7 @@ nsresult CacheIndex::InitEntryFromDiskData(CacheIndexEntry* aEntry,
|
||||
aEntry->Init(GetOriginAttrsHash(aMetaData->OriginAttributes()),
|
||||
aMetaData->IsAnonymous(), aMetaData->Pinned());
|
||||
|
||||
uint32_t frecency;
|
||||
aMetaData->GetFrecency(&frecency);
|
||||
aEntry->SetFrecency(frecency);
|
||||
aEntry->SetFrecency(aMetaData->GetFrecency());
|
||||
|
||||
const char* altData = aMetaData->GetElement(CacheFileUtils::kAltDataKey);
|
||||
bool hasAltData = altData ? true : false;
|
||||
@ -3508,14 +3506,13 @@ nsresult CacheIndex::Run() {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheIndex::OnFileOpenedInternal(FileOpenHelper* aOpener,
|
||||
CacheFileHandle* aHandle,
|
||||
nsresult aResult) {
|
||||
void CacheIndex::OnFileOpenedInternal(FileOpenHelper* aOpener,
|
||||
CacheFileHandle* aHandle,
|
||||
nsresult aResult) {
|
||||
LOG(
|
||||
("CacheIndex::OnFileOpenedInternal() [opener=%p, handle=%p, "
|
||||
"result=0x%08" PRIx32 "]",
|
||||
aOpener, aHandle, static_cast<uint32_t>(aResult)));
|
||||
|
||||
MOZ_ASSERT(CacheFileIOManager::IsOnIOThread());
|
||||
|
||||
nsresult rv;
|
||||
@ -3525,7 +3522,7 @@ nsresult CacheIndex::OnFileOpenedInternal(FileOpenHelper* aOpener,
|
||||
MOZ_RELEASE_ASSERT(IsIndexUsable());
|
||||
|
||||
if (mState == READY && mShuttingDown) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (mState) {
|
||||
@ -3612,8 +3609,6 @@ nsresult CacheIndex::OnFileOpenedInternal(FileOpenHelper* aOpener,
|
||||
default:
|
||||
MOZ_ASSERT(false, "Unexpected state!");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult CacheIndex::OnFileOpened(CacheFileHandle* aHandle, nsresult aResult) {
|
||||
|
@ -793,8 +793,8 @@ class CacheIndex final : public CacheFileIOListener, public nsIRunnable {
|
||||
virtual ~CacheIndex();
|
||||
|
||||
NS_IMETHOD OnFileOpened(CacheFileHandle* aHandle, nsresult aResult) override;
|
||||
nsresult OnFileOpenedInternal(FileOpenHelper* aOpener,
|
||||
CacheFileHandle* aHandle, nsresult aResult);
|
||||
void OnFileOpenedInternal(FileOpenHelper* aOpener, CacheFileHandle* aHandle,
|
||||
nsresult aResult);
|
||||
NS_IMETHOD OnDataWritten(CacheFileHandle* aHandle, const char* aBuf,
|
||||
nsresult aResult) override;
|
||||
NS_IMETHOD OnDataRead(CacheFileHandle* aHandle, char* aBuf,
|
||||
|
@ -477,10 +477,11 @@ NS_IMETHODIMP _OldCacheEntryWrapper::VisitMetaData(
|
||||
|
||||
namespace {
|
||||
|
||||
nsresult GetCacheSessionNameForStoragePolicy(
|
||||
const nsACString& scheme, nsCacheStoragePolicy storagePolicy,
|
||||
bool isPrivate, OriginAttributes const* originAttribs,
|
||||
nsACString& sessionName) {
|
||||
void GetCacheSessionNameForStoragePolicy(const nsACString& scheme,
|
||||
nsCacheStoragePolicy storagePolicy,
|
||||
bool isPrivate,
|
||||
OriginAttributes const* originAttribs,
|
||||
nsACString& sessionName) {
|
||||
MOZ_ASSERT(!isPrivate || storagePolicy == nsICache::STORE_IN_MEMORY);
|
||||
|
||||
// HTTP
|
||||
@ -525,8 +526,6 @@ nsresult GetCacheSessionNameForStoragePolicy(
|
||||
nsAutoCString suffix;
|
||||
originAttribs->CreateSuffix(suffix);
|
||||
sessionName.Append(suffix);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult GetCacheSession(const nsACString& aScheme, bool aWriteToDisk,
|
||||
@ -547,10 +546,9 @@ nsresult GetCacheSession(const nsACString& aScheme, bool aWriteToDisk,
|
||||
if (aAppCache) {
|
||||
aAppCache->GetClientID(clientId);
|
||||
} else {
|
||||
rv = GetCacheSessionNameForStoragePolicy(
|
||||
GetCacheSessionNameForStoragePolicy(
|
||||
aScheme, storagePolicy, aLoadInfo->IsPrivate(),
|
||||
aLoadInfo->OriginAttributesPtr(), clientId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
LOG((" GetCacheSession for client=%s, policy=%d", clientId.get(),
|
||||
|
@ -88,8 +88,7 @@ bool DocumentLoadListener::Open(
|
||||
RefPtr<HttpBaseChannel> httpBaseChannel = do_QueryObject(mChannel, aRv);
|
||||
if (httpBaseChannel) {
|
||||
nsCOMPtr<nsIURI> topWindowURI = DeserializeURI(aTopWindowURI);
|
||||
*aRv = httpBaseChannel->SetTopWindowURI(topWindowURI);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(*aRv));
|
||||
httpBaseChannel->SetTopWindowURI(topWindowURI);
|
||||
|
||||
if (aContentBlockingAllowListPrincipal) {
|
||||
nsCOMPtr<nsIPrincipal> contentBlockingAllowListPrincipal =
|
||||
|
@ -1045,13 +1045,13 @@ HttpBaseChannel::ExplicitSetUploadStream(nsIInputStream* aStream,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult HttpBaseChannel::ExplicitSetUploadStreamLength(
|
||||
uint64_t aContentLength, bool aStreamHasHeaders) {
|
||||
void HttpBaseChannel::ExplicitSetUploadStreamLength(uint64_t aContentLength,
|
||||
bool aStreamHasHeaders) {
|
||||
// We already have the content length. We don't need to determinate it.
|
||||
mReqContentLength = aContentLength;
|
||||
|
||||
if (aStreamHasHeaders) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoCString header;
|
||||
@ -1061,7 +1061,7 @@ nsresult HttpBaseChannel::ExplicitSetUploadStreamLength(
|
||||
nsAutoCString value;
|
||||
nsresult rv = GetRequestHeader(header, value);
|
||||
if (NS_SUCCEEDED(rv) && !value.IsEmpty()) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
// SetRequestHeader propagates headers to chrome if HttpChannelChild
|
||||
@ -1069,8 +1069,6 @@ nsresult HttpBaseChannel::ExplicitSetUploadStreamLength(
|
||||
nsAutoCString contentLengthStr;
|
||||
contentLengthStr.AppendInt(aContentLength);
|
||||
SetRequestHeader(header, contentLengthStr, false);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -3580,8 +3578,7 @@ nsresult HttpBaseChannel::SetupReplacementChannel(nsIURI* newURI,
|
||||
realChannel->SetContentBlockingAllowListPrincipal(
|
||||
mContentBlockingAllowListPrincipal);
|
||||
|
||||
rv = realChannel->SetTopWindowURI(mTopWindowURI);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
realChannel->SetTopWindowURI(mTopWindowURI);
|
||||
}
|
||||
|
||||
// update the DocumentURI indicator since we are being redirected.
|
||||
|
@ -461,10 +461,7 @@ class HttpBaseChannel : public nsHashPropertyBag,
|
||||
return mRequestHead.ClearHeader(nsHttp::Referer);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE nsresult SetTopWindowURI(nsIURI* aTopWindowURI) {
|
||||
mTopWindowURI = aTopWindowURI;
|
||||
return NS_OK;
|
||||
}
|
||||
void SetTopWindowURI(nsIURI* aTopWindowURI) { mTopWindowURI = aTopWindowURI; }
|
||||
|
||||
void SetContentBlockingAllowListPrincipal(nsIPrincipal* aPrincipal) {
|
||||
mContentBlockingAllowListPrincipal = aPrincipal;
|
||||
@ -622,8 +619,8 @@ class HttpBaseChannel : public nsHashPropertyBag,
|
||||
// Proxy release all members above on main thread.
|
||||
void ReleaseMainThreadOnlyReferences();
|
||||
|
||||
nsresult ExplicitSetUploadStreamLength(uint64_t aContentLength,
|
||||
bool aStreamHasHeaders);
|
||||
void ExplicitSetUploadStreamLength(uint64_t aContentLength,
|
||||
bool aStreamHasHeaders);
|
||||
|
||||
void MaybeResumeAsyncOpen();
|
||||
|
||||
|
@ -458,8 +458,7 @@ bool HttpChannelParent::DoAsyncOpen(
|
||||
|
||||
if (apiRedirectToUri) httpChannel->RedirectTo(apiRedirectToUri);
|
||||
if (topWindowUri) {
|
||||
rv = httpChannel->SetTopWindowURI(topWindowUri);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
httpChannel->SetTopWindowURI(topWindowUri);
|
||||
}
|
||||
|
||||
if (aContentBlockingAllowListPrincipal) {
|
||||
@ -2233,8 +2232,7 @@ void HttpChannelParent::StartDiversion() {
|
||||
}
|
||||
|
||||
// Now mParentListener can be diverted to mDivertListener.
|
||||
DebugOnly<nsresult> rvdbg = mParentListener->DivertTo(mDivertListener);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rvdbg));
|
||||
mParentListener->DivertTo(mDivertListener);
|
||||
mDivertListener = nullptr;
|
||||
|
||||
// Either IPC channel is closed or background channel
|
||||
|
@ -176,7 +176,7 @@ HttpTrafficCategory HttpTrafficAnalyzer::CreateTrafficCategory(
|
||||
return HttpTrafficCategory::eInvalid;
|
||||
}
|
||||
|
||||
nsresult HttpTrafficAnalyzer::IncrementHttpTransaction(
|
||||
void HttpTrafficAnalyzer::IncrementHttpTransaction(
|
||||
HttpTrafficCategory aCategory) {
|
||||
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
||||
MOZ_ASSERT(StaticPrefs::network_traffic_analyzer_enabled());
|
||||
@ -187,10 +187,9 @@ nsresult HttpTrafficAnalyzer::IncrementHttpTransaction(
|
||||
|
||||
Telemetry::AccumulateCategoricalKeyed(NS_LITERAL_CSTRING("Transaction"),
|
||||
gTelemetryLabel[aCategory]);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult HttpTrafficAnalyzer::IncrementHttpConnection(
|
||||
void HttpTrafficAnalyzer::IncrementHttpConnection(
|
||||
HttpTrafficCategory aCategory) {
|
||||
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
||||
MOZ_ASSERT(StaticPrefs::network_traffic_analyzer_enabled());
|
||||
@ -201,10 +200,9 @@ nsresult HttpTrafficAnalyzer::IncrementHttpConnection(
|
||||
|
||||
Telemetry::AccumulateCategoricalKeyed(NS_LITERAL_CSTRING("Connection"),
|
||||
gTelemetryLabel[aCategory]);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult HttpTrafficAnalyzer::IncrementHttpConnection(
|
||||
void HttpTrafficAnalyzer::IncrementHttpConnection(
|
||||
nsTArray<HttpTrafficCategory>&& aCategories) {
|
||||
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
||||
MOZ_ASSERT(StaticPrefs::network_traffic_analyzer_enabled());
|
||||
@ -242,14 +240,13 @@ nsresult HttpTrafficAnalyzer::IncrementHttpConnection(
|
||||
break;
|
||||
}
|
||||
|
||||
Unused << IncrementHttpConnection(best);
|
||||
return NS_OK;
|
||||
IncrementHttpConnection(best);
|
||||
}
|
||||
|
||||
#define CLAMP_U32(num) \
|
||||
Clamp<uint32_t>(num, 0, std::numeric_limits<uint32_t>::max())
|
||||
|
||||
nsresult HttpTrafficAnalyzer::AccumulateHttpTransferredSize(
|
||||
void HttpTrafficAnalyzer::AccumulateHttpTransferredSize(
|
||||
HttpTrafficCategory aCategory, uint64_t aBytesRead, uint64_t aBytesSent) {
|
||||
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
||||
MOZ_ASSERT(StaticPrefs::network_traffic_analyzer_enabled());
|
||||
@ -265,7 +262,6 @@ nsresult HttpTrafficAnalyzer::AccumulateHttpTransferredSize(
|
||||
Telemetry::ScalarAdd(Telemetry::ScalarID::NETWORKING_DATA_TRANSFERRED_V3_KB,
|
||||
NS_ConvertUTF8toUTF16(gKeyName[aCategory]), total);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
|
@ -6,6 +6,8 @@
|
||||
#ifndef mozilla_netwerk_protocol_http_HttpTrafficAnalyzer_h
|
||||
#define mozilla_netwerk_protocol_http_HttpTrafficAnalyzer_h
|
||||
|
||||
#include "nsTArrayForwardDeclare.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
@ -35,12 +37,11 @@ class HttpTrafficAnalyzer final {
|
||||
bool aIsPrivateMode, bool aIsSystemPrincipal, bool aIsThirdParty,
|
||||
ClassOfService aClassOfService, TrackingClassification aClassification);
|
||||
|
||||
nsresult IncrementHttpTransaction(HttpTrafficCategory aCategory);
|
||||
nsresult IncrementHttpConnection(HttpTrafficCategory aCategory);
|
||||
nsresult IncrementHttpConnection(nsTArray<HttpTrafficCategory>&& aCategories);
|
||||
nsresult AccumulateHttpTransferredSize(HttpTrafficCategory aCategory,
|
||||
uint64_t aBytesRead,
|
||||
uint64_t aBytesSent);
|
||||
void IncrementHttpTransaction(HttpTrafficCategory aCategory);
|
||||
void IncrementHttpConnection(HttpTrafficCategory aCategory);
|
||||
void IncrementHttpConnection(nsTArray<HttpTrafficCategory>&& aCategories);
|
||||
void AccumulateHttpTransferredSize(HttpTrafficCategory aCategory,
|
||||
uint64_t aBytesRead, uint64_t aBytesSent);
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
@ -72,8 +72,8 @@ void InterceptedChannelBase::DoNotifyController() {
|
||||
mController = nullptr;
|
||||
}
|
||||
|
||||
nsresult InterceptedChannelBase::DoSynthesizeStatus(uint16_t aStatus,
|
||||
const nsACString& aReason) {
|
||||
void InterceptedChannelBase::DoSynthesizeStatus(uint16_t aStatus,
|
||||
const nsACString& aReason) {
|
||||
EnsureSynthesizedResponse();
|
||||
|
||||
// Always assume HTTP 1.1 for synthesized responses.
|
||||
@ -84,7 +84,6 @@ nsresult InterceptedChannelBase::DoSynthesizeStatus(uint16_t aStatus,
|
||||
statusLine.Append(aReason);
|
||||
|
||||
(*mSynthesizedResponseHead)->ParseStatusLine(statusLine);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult InterceptedChannelBase::DoSynthesizeHeader(const nsACString& aName,
|
||||
@ -93,9 +92,7 @@ nsresult InterceptedChannelBase::DoSynthesizeHeader(const nsACString& aName,
|
||||
|
||||
nsAutoCString header = aName + NS_LITERAL_CSTRING(": ") + aValue;
|
||||
// Overwrite any existing header.
|
||||
nsresult rv = (*mSynthesizedResponseHead)->ParseHeaderLine(header);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return NS_OK;
|
||||
return (*mSynthesizedResponseHead)->ParseHeaderLine(header);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -274,7 +271,8 @@ InterceptedChannelContent::SynthesizeStatus(uint16_t aStatus,
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
return DoSynthesizeStatus(aStatus, aReason);
|
||||
DoSynthesizeStatus(aStatus, aReason);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -42,8 +42,7 @@ class InterceptedChannelBase : public nsIInterceptedChannel {
|
||||
|
||||
void EnsureSynthesizedResponse();
|
||||
void DoNotifyController();
|
||||
MOZ_MUST_USE nsresult DoSynthesizeStatus(uint16_t aStatus,
|
||||
const nsACString& aReason);
|
||||
void DoSynthesizeStatus(uint16_t aStatus, const nsACString& aReason);
|
||||
MOZ_MUST_USE nsresult DoSynthesizeHeader(const nsACString& aName,
|
||||
const nsACString& aValue);
|
||||
|
||||
|
@ -300,16 +300,13 @@ nsresult ParentChannelListener::SuspendForDiversion() {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult ParentChannelListener::ResumeForDiversion() {
|
||||
void ParentChannelListener::ResumeForDiversion() {
|
||||
MOZ_RELEASE_ASSERT(mSuspendedForDiversion, "Must already be suspended!");
|
||||
|
||||
// Allow OnStart/OnData/OnStop callbacks to be forwarded to mNextListener.
|
||||
mSuspendedForDiversion = false;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult ParentChannelListener::DivertTo(nsIStreamListener* aListener) {
|
||||
void ParentChannelListener::DivertTo(nsIStreamListener* aListener) {
|
||||
MOZ_ASSERT(aListener);
|
||||
MOZ_RELEASE_ASSERT(mSuspendedForDiversion, "Must already be suspended!");
|
||||
|
||||
@ -319,8 +316,7 @@ nsresult ParentChannelListener::DivertTo(nsIStreamListener* aListener) {
|
||||
mInterceptCanceled = false;
|
||||
|
||||
mNextListener = aListener;
|
||||
|
||||
return ResumeForDiversion();
|
||||
ResumeForDiversion();
|
||||
}
|
||||
|
||||
void ParentChannelListener::SetupInterception(
|
||||
|
@ -43,7 +43,7 @@ class ParentChannelListener final : public nsIInterfaceRequestor,
|
||||
dom::BrowserParent* aBrowserParent);
|
||||
|
||||
// For channel diversion from child to parent.
|
||||
MOZ_MUST_USE nsresult DivertTo(nsIStreamListener* aListener);
|
||||
void DivertTo(nsIStreamListener* aListener);
|
||||
MOZ_MUST_USE nsresult SuspendForDiversion();
|
||||
|
||||
void SetupInterception(const nsHttpResponseHead& aResponseHead);
|
||||
@ -57,7 +57,7 @@ class ParentChannelListener final : public nsIInterfaceRequestor,
|
||||
virtual ~ParentChannelListener();
|
||||
|
||||
// Private partner function to SuspendForDiversion.
|
||||
MOZ_MUST_USE nsresult ResumeForDiversion();
|
||||
void ResumeForDiversion();
|
||||
|
||||
// Can be the original HttpChannelParent that created this object (normal
|
||||
// case), a different {HTTP|FTP}ChannelParent that we've been redirected to,
|
||||
|
@ -62,8 +62,7 @@ nsHttpAuthCache::nsHttpAuthCache()
|
||||
nsHttpAuthCache::~nsHttpAuthCache() {
|
||||
LOG(("nsHttpAuthCache::~nsHttpAuthCache %p", this));
|
||||
|
||||
DebugOnly<nsresult> rv = ClearAll();
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
ClearAll();
|
||||
nsCOMPtr<nsIObserverService> obsSvc = services::GetObserverService();
|
||||
if (obsSvc) {
|
||||
obsSvc->RemoveObserver(mObserver, "clear-origin-attributes-data");
|
||||
@ -144,10 +143,9 @@ void nsHttpAuthCache::ClearAuthEntry(const char* scheme, const char* host,
|
||||
mDB.Remove(key);
|
||||
}
|
||||
|
||||
nsresult nsHttpAuthCache::ClearAll() {
|
||||
void nsHttpAuthCache::ClearAll() {
|
||||
LOG(("nsHttpAuthCache::ClearAll %p\n", this));
|
||||
mDB.Clear();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -196,7 +196,7 @@ class nsHttpAuthCache {
|
||||
const char* realm, nsACString const& originSuffix);
|
||||
|
||||
// expire all existing auth list entries including proxy auths.
|
||||
MOZ_MUST_USE nsresult ClearAll();
|
||||
void ClearAll();
|
||||
|
||||
private:
|
||||
nsHttpAuthNode* LookupAuthNode(const char* scheme, const char* host,
|
||||
|
@ -104,10 +104,8 @@ nsHttpAuthManager::SetAuthIdentity(
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHttpAuthManager::ClearAll() {
|
||||
nsresult rv = mAuthCache->ClearAll();
|
||||
nsresult rv2 = mPrivateAuthCache->ClearAll();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv2)) return rv2;
|
||||
mAuthCache->ClearAll();
|
||||
mPrivateAuthCache->ClearAll();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -3558,8 +3558,7 @@ nsresult nsHttpChannel::ProcessPartialContent(
|
||||
}
|
||||
|
||||
// merge any new headers with the cached response headers
|
||||
rv = mCachedResponseHead->UpdateHeaders(mResponseHead);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
mCachedResponseHead->UpdateHeaders(mResponseHead);
|
||||
|
||||
// update the cached response head
|
||||
nsAutoCString head;
|
||||
@ -3702,8 +3701,7 @@ nsresult nsHttpChannel::ProcessNotModified(
|
||||
}
|
||||
|
||||
// merge any new headers with the cached response headers
|
||||
rv = mCachedResponseHead->UpdateHeaders(mResponseHead);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
mCachedResponseHead->UpdateHeaders(mResponseHead);
|
||||
|
||||
// update the cached response head
|
||||
nsAutoCString head;
|
||||
|
@ -626,7 +626,7 @@ nsresult nsHttpConnectionMgr::UpdateRequestTokenBucket(
|
||||
aBucket);
|
||||
}
|
||||
|
||||
nsresult nsHttpConnectionMgr::ClearConnectionHistory() {
|
||||
void nsHttpConnectionMgr::ClearConnectionHistory() {
|
||||
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
|
||||
|
||||
LOG(("nsHttpConnectionMgr::ClearConnectionHistory"));
|
||||
@ -640,8 +640,6 @@ nsresult nsHttpConnectionMgr::ClearConnectionHistory() {
|
||||
iter.Remove();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsHttpConnectionMgr::CloseIdleConnection(nsHttpConnection* conn) {
|
||||
|
@ -182,7 +182,7 @@ class nsHttpConnectionMgr final : public nsIObserver, public AltSvcCache {
|
||||
MOZ_MUST_USE nsresult UpdateRequestTokenBucket(EventTokenBucket* aBucket);
|
||||
|
||||
// clears the connection history mCT
|
||||
MOZ_MUST_USE nsresult ClearConnectionHistory();
|
||||
void ClearConnectionHistory();
|
||||
|
||||
void ReportFailedToProcess(nsIURI* uri);
|
||||
|
||||
|
@ -2170,8 +2170,8 @@ nsHttpHandler::Observe(nsISupports* subject, const char* topic,
|
||||
mHandlerActive = false;
|
||||
|
||||
// clear cache of all authentication credentials.
|
||||
Unused << mAuthCache.ClearAll();
|
||||
Unused << mPrivateAuthCache.ClearAll();
|
||||
mAuthCache.ClearAll();
|
||||
mPrivateAuthCache.ClearAll();
|
||||
if (mWifiTickler) mWifiTickler->Cancel();
|
||||
|
||||
// Inform nsIOService that network is tearing down.
|
||||
@ -2206,8 +2206,8 @@ nsHttpHandler::Observe(nsISupports* subject, const char* topic,
|
||||
rv = InitConnectionMgr();
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
} else if (!strcmp(topic, "net:clear-active-logins")) {
|
||||
Unused << mAuthCache.ClearAll();
|
||||
Unused << mPrivateAuthCache.ClearAll();
|
||||
mAuthCache.ClearAll();
|
||||
mPrivateAuthCache.ClearAll();
|
||||
} else if (!strcmp(topic, "net:cancel-all-connections")) {
|
||||
if (mConnMgr) {
|
||||
mConnMgr->AbortAndCloseAllConnections(0, nullptr);
|
||||
@ -2240,7 +2240,7 @@ nsHttpHandler::Observe(nsISupports* subject, const char* topic,
|
||||
nsCOMPtr<nsIURI> uri = do_QueryInterface(subject);
|
||||
#endif
|
||||
} else if (!strcmp(topic, "last-pb-context-exited")) {
|
||||
Unused << mPrivateAuthCache.ClearAll();
|
||||
mPrivateAuthCache.ClearAll();
|
||||
if (mConnMgr) {
|
||||
mConnMgr->ClearAltServiceMappings();
|
||||
}
|
||||
|
@ -841,7 +841,7 @@ bool nsHttpResponseHead::ExpiresInPast_locked() const {
|
||||
NS_SUCCEEDED(GetDateValue_locked(&dateVal)) && expiresVal < dateVal;
|
||||
}
|
||||
|
||||
nsresult nsHttpResponseHead::UpdateHeaders(nsHttpResponseHead* aOther) {
|
||||
void nsHttpResponseHead::UpdateHeaders(nsHttpResponseHead* aOther) {
|
||||
LOG(("nsHttpResponseHead::UpdateHeaders [this=%p]\n", this));
|
||||
|
||||
RecursiveMutexAutoLock monitor(mRecursiveMutex);
|
||||
@ -884,8 +884,6 @@ nsresult nsHttpResponseHead::UpdateHeaders(nsHttpResponseHead* aOther) {
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsHttpResponseHead::Reset() {
|
||||
|
@ -132,7 +132,7 @@ class nsHttpResponseHead {
|
||||
bool ExpiresInPast();
|
||||
|
||||
// update headers...
|
||||
MOZ_MUST_USE nsresult UpdateHeaders(nsHttpResponseHead* headers);
|
||||
void UpdateHeaders(nsHttpResponseHead* headers);
|
||||
|
||||
// reset the response head to it's initial state
|
||||
void Reset();
|
||||
|
@ -111,7 +111,7 @@ nsDirIndexParser::Field nsDirIndexParser::gFieldTable[] = {
|
||||
nsrefcnt nsDirIndexParser::gRefCntParser = 0;
|
||||
nsITextToSubURI* nsDirIndexParser::gTextToSubURI;
|
||||
|
||||
nsresult nsDirIndexParser::ParseFormat(const char* aFormatStr) {
|
||||
void nsDirIndexParser::ParseFormat(const char* aFormatStr) {
|
||||
// Parse a "200" format line, and remember the fields and their
|
||||
// ordering in mFormat. Multiple 200 lines stomp on each other.
|
||||
unsigned int formatNum = 0;
|
||||
@ -146,28 +146,25 @@ nsresult nsDirIndexParser::ParseFormat(const char* aFormatStr) {
|
||||
}
|
||||
|
||||
} while (*aFormatStr && (formatNum < (ArrayLength(mFormat) - 1)));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDirIndexParser::ParseData(nsIDirIndex* aIdx, char* aDataStr,
|
||||
int32_t aLineLen) {
|
||||
void nsDirIndexParser::ParseData(nsIDirIndex* aIdx, char* aDataStr,
|
||||
int32_t aLineLen) {
|
||||
// Parse a "201" data line, using the field ordering specified in
|
||||
// mFormat.
|
||||
|
||||
if (mFormat[0] == -1) {
|
||||
// Ignore if we haven't seen a format yet.
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsAutoCString filename;
|
||||
int32_t lineLen = aLineLen;
|
||||
|
||||
for (int32_t i = 0; mFormat[i] != -1; ++i) {
|
||||
// If we've exhausted the data before we run out of fields, just bail.
|
||||
if (!*aDataStr || (lineLen < 1)) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
while ((lineLen > 0) && nsCRT::IsAsciiSpace(*aDataStr)) {
|
||||
@ -177,7 +174,7 @@ nsresult nsDirIndexParser::ParseData(nsIDirIndex* aIdx, char* aDataStr,
|
||||
|
||||
if (lineLen < 1) {
|
||||
// invalid format, bail
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
char* value = aDataStr;
|
||||
@ -197,7 +194,7 @@ nsresult nsDirIndexParser::ParseData(nsIDirIndex* aIdx, char* aDataStr,
|
||||
|
||||
if (!lineLen) {
|
||||
// invalid format, bail
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// it's unquoted. snarf until we see whitespace.
|
||||
@ -226,8 +223,8 @@ nsresult nsDirIndexParser::ParseData(nsIDirIndex* aIdx, char* aDataStr,
|
||||
|
||||
if (gTextToSubURI) {
|
||||
nsAutoString result;
|
||||
if (NS_SUCCEEDED(rv = gTextToSubURI->UnEscapeAndConvert(
|
||||
mEncoding, filename, result))) {
|
||||
if (NS_SUCCEEDED(gTextToSubURI->UnEscapeAndConvert(
|
||||
mEncoding, filename, result))) {
|
||||
if (!result.IsEmpty()) {
|
||||
aIdx->SetLocation(filename);
|
||||
if (!mHasDescription) aIdx->SetDescription(result);
|
||||
@ -289,8 +286,6 @@ nsresult nsDirIndexParser::ParseData(nsIDirIndex* aIdx, char* aDataStr,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -337,7 +332,6 @@ nsresult nsDirIndexParser::ProcessData(nsIRequest* aRequest,
|
||||
mLineStart = eol + 1;
|
||||
|
||||
if (lineLen >= 4) {
|
||||
nsresult rv;
|
||||
const char* buf = line;
|
||||
|
||||
if (buf[0] == '1') {
|
||||
@ -362,19 +356,12 @@ nsresult nsDirIndexParser::ProcessData(nsIRequest* aRequest,
|
||||
if (buf[1] == '0') {
|
||||
if (buf[2] == '0' && buf[3] == ':') {
|
||||
// 200. Define field names
|
||||
rv = ParseFormat(buf + 4);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
ParseFormat(buf + 4);
|
||||
} else if (buf[2] == '1' && buf[3] == ':') {
|
||||
// 201. Field data
|
||||
nsCOMPtr<nsIDirIndex> idx = new nsDirIndex();
|
||||
|
||||
rv = ParseData(idx, ((char*)buf) + 4, lineLen - 4);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
ParseData(idx, ((char*)buf) + 4, lineLen - 4);
|
||||
mListener->OnIndexAvailable(aRequest, aCtxt, idx);
|
||||
}
|
||||
}
|
||||
|
@ -58,8 +58,8 @@ class nsDirIndexParser : public nsIDirIndexParser {
|
||||
int mFormat[8];
|
||||
|
||||
nsresult ProcessData(nsIRequest* aRequest, nsISupports* aCtxt);
|
||||
nsresult ParseFormat(const char* buf);
|
||||
nsresult ParseData(nsIDirIndex* aIdx, char* aDataStr, int32_t lineLen);
|
||||
void ParseFormat(const char* buf);
|
||||
void ParseData(nsIDirIndex* aIdx, char* aDataStr, int32_t lineLen);
|
||||
|
||||
struct Field {
|
||||
const char* mName;
|
||||
|
Loading…
Reference in New Issue
Block a user