Bug 1599615 - Make some necko code less nsresult-happy. r=kershaw,valentin
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 02 Dec 2019 13:21:06 +0000
changeset 504825 02b544b1570d9108081db22cf30ee5fee564a807
parent 504824 995ac9a0ab02933978a7b8a49bd985214d28d703
child 504826 9dea219937cd181806ec08f5f6e55a6d4685fef4
push id36870
push usernerli@mozilla.com
push dateMon, 02 Dec 2019 18:41:58 +0000
treeherdermozilla-central@bc2e8add2746 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskershaw, valentin
bugs1599615
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
netwerk/base/nsBufferedStreams.cpp
netwerk/base/nsBufferedStreams.h
netwerk/cache2/CacheFile.cpp
netwerk/cache2/CacheFile.h
netwerk/cache2/CacheFileChunk.cpp
netwerk/cache2/CacheFileChunk.h
netwerk/cache2/CacheFileContextEvictor.cpp
netwerk/cache2/CacheFileContextEvictor.h
netwerk/cache2/CacheFileIOManager.cpp
netwerk/cache2/CacheFileIOManager.h
netwerk/cache2/CacheFileInputStream.cpp
netwerk/cache2/CacheFileInputStream.h
netwerk/cache2/CacheFileMetadata.cpp
netwerk/cache2/CacheFileMetadata.h
netwerk/cache2/CacheIndex.cpp
netwerk/cache2/CacheIndex.h
netwerk/cache2/OldWrappers.cpp
netwerk/ipc/DocumentLoadListener.cpp
netwerk/protocol/http/HttpBaseChannel.cpp
netwerk/protocol/http/HttpBaseChannel.h
netwerk/protocol/http/HttpChannelParent.cpp
netwerk/protocol/http/HttpTrafficAnalyzer.cpp
netwerk/protocol/http/HttpTrafficAnalyzer.h
netwerk/protocol/http/InterceptedChannel.cpp
netwerk/protocol/http/InterceptedChannel.h
netwerk/protocol/http/ParentChannelListener.cpp
netwerk/protocol/http/ParentChannelListener.h
netwerk/protocol/http/nsHttpAuthCache.cpp
netwerk/protocol/http/nsHttpAuthCache.h
netwerk/protocol/http/nsHttpAuthManager.cpp
netwerk/protocol/http/nsHttpChannel.cpp
netwerk/protocol/http/nsHttpConnectionMgr.cpp
netwerk/protocol/http/nsHttpConnectionMgr.h
netwerk/protocol/http/nsHttpHandler.cpp
netwerk/protocol/http/nsHttpResponseHead.cpp
netwerk/protocol/http/nsHttpResponseHead.h
netwerk/streamconv/converters/nsDirIndexParser.cpp
netwerk/streamconv/converters/nsDirIndexParser.h
--- a/netwerk/base/nsBufferedStreams.cpp
+++ b/netwerk/base/nsBufferedStreams.cpp
@@ -72,17 +72,17 @@ nsresult nsBufferedStream::Init(nsISuppo
   mCursor = 0;
   mBuffer = new (mozilla::fallible) char[bufferSize];
   if (mBuffer == nullptr) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
   return NS_OK;
 }
 
-nsresult nsBufferedStream::Close() {
+void nsBufferedStream::Close() {
   // Drop the reference from nsBufferedStream::Init()
   mStream = nullptr;
   if (mBuffer) {
     delete[] mBuffer;
     mBuffer = nullptr;
     mBufferSize = 0;
     mBufferStartOffset = 0;
     mCursor = 0;
@@ -110,35 +110,32 @@ nsresult nsBufferedStream::Close() {
       for (uint32_t i = 0; i < bufstats.mBigSeekIndex; i++) {
         fprintf(tfp, "bigseek[%u] = {old: %u, new: %u}\n", i,
                 bufstats.mBigSeek[i].mOldOffset,
                 bufstats.mBigSeek[i].mNewOffset);
       }
     }
   }
 #endif
-  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBufferedStream::Seek(int32_t whence, int64_t offset) {
   if (mStream == nullptr) {
     return NS_BASE_STREAM_CLOSED;
   }
 
   // If the underlying stream isn't a random access store, then fail early.
   // We could possibly succeed for the case where the seek position denotes
   // something that happens to be read into the buffer, but that would make
   // the failure data-dependent.
   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;
   }
 
   int64_t absPos = 0;
   switch (whence) {
     case nsISeekableStream::NS_SEEK_SET:
       absPos = offset;
       break;
@@ -369,42 +366,28 @@ already_AddRefed<nsIInputStream> nsBuffe
   MOZ_ASSERT(NS_SUCCEEDED(rv));
   MOZ_ASSERT(out);
 
   return already_AddRefed<nsIInputStream>(out);
 }
 
 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
 nsBufferedInputStream::Available(uint64_t* result) {
   *result = 0;
 
   if (!mStream) {
     return NS_OK;
@@ -871,17 +854,17 @@ nsBufferedOutputStream::Init(nsIOutputSt
   // QI stream to an nsISafeOutputStream, to see if we should support it
   mSafeStream = do_QueryInterface(stream);
 
   return nsBufferedStream::Init(stream, bufferSize);
 }
 
 NS_IMETHODIMP
 nsBufferedOutputStream::Close() {
-  nsresult rv1, rv2 = NS_OK, rv3;
+  nsresult rv1, rv2 = NS_OK;
 
   rv1 = Flush();
 
 #ifdef DEBUG
   if (NS_FAILED(rv1)) {
     NS_WARNING(
         "(debug) Flush() inside nsBufferedOutputStream::Close() returned error "
         "(rv1).");
@@ -896,33 +879,25 @@ nsBufferedOutputStream::Close() {
 #ifdef DEBUG
     if (NS_FAILED(rv2)) {
       NS_WARNING(
           "(debug) Sink->Close() inside nsBufferedOutputStream::Close() "
           "returned error (rv2).");
     }
 #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;
   }
   if (NS_FAILED(rv2)) {
     return rv2;
   }
-  return rv3;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBufferedOutputStream::Write(const char* buf, uint32_t count,
                               uint32_t* result) {
   nsresult rv = NS_OK;
   uint32_t written = 0;
   *result = 0;
@@ -997,17 +972,17 @@ nsBufferedOutputStream::Flush() {
   return NS_ERROR_FAILURE;  // didn't flush all
 }
 
 // nsISafeOutputStream
 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(
         "(debug) nsBufferedOutputStream::Flush() failed in "
         "nsBufferedOutputStream::Finish()! Possible dataloss.");
 
     rv2 = Sink()->Close();
     if (NS_FAILED(rv2)) {
@@ -1021,29 +996,29 @@ nsBufferedOutputStream::Finish() {
       NS_WARNING(
           "(debug) mSafeStream->Finish() failed within "
           "nsBufferedOutputStream::Flush()! Possible dataloss.");
     }
   }
 
   // ... 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
   // nsBufferedOutputStream::Close() as reference.
 
   if (NS_FAILED(rv1)) {
     return rv1;
   }
   if (NS_FAILED(rv2)) {
     return rv2;
   }
-  return rv3;
+  return NS_OK;
 }
 
 static nsresult nsReadFromInputStream(nsIOutputStream* outStr, void* closure,
                                       char* toRawSegment, uint32_t offset,
                                       uint32_t count, uint32_t* readCount) {
   nsIInputStream* fromStream = (nsIInputStream*)closure;
   return fromStream->Read(toRawSegment, count, readCount);
 }
--- a/netwerk/base/nsBufferedStreams.h
+++ b/netwerk/base/nsBufferedStreams.h
@@ -24,17 +24,17 @@
 class nsBufferedStream : public nsISeekableStream {
  public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSISEEKABLESTREAM
   NS_DECL_NSITELLABLESTREAM
 
   nsBufferedStream();
 
-  nsresult Close();
+  void Close();
 
  protected:
   virtual ~nsBufferedStream();
 
   nsresult Init(nsISupports* stream, uint32_t bufferSize);
   nsresult GetData(nsISupports** aResult);
   NS_IMETHOD Fill() = 0;
   NS_IMETHOD Flush() = 0;
--- a/netwerk/cache2/CacheFile.cpp
+++ b/netwerk/cache2/CacheFile.cpp
@@ -432,18 +432,16 @@ nsresult CacheFile::OnChunkAvailable(nsr
 }
 
 nsresult CacheFile::OnChunkUpdated(CacheFileChunk* aChunk) {
   MOZ_CRASH("CacheFile::OnChunkUpdated should not be called!");
   return NS_ERROR_UNEXPECTED;
 }
 
 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 {
    public:
     explicit AutoFailDoomListener(CacheFileHandle* aHandle)
         : mHandle(aHandle), mAlreadyDoomed(false) {}
     ~AutoFailDoomListener() {
       if (!mListener) return;
@@ -577,23 +575,17 @@ nsresult CacheFile::OnFileOpened(CacheFi
     return NS_OK;
   }
 
   MOZ_ASSERT(NS_SUCCEEDED(aResult));
   MOZ_ASSERT(!mMetadata);
   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;
 }
 
 nsresult CacheFile::OnDataWritten(CacheFileHandle* aHandle, const char* aBuf,
                                   nsresult aResult) {
   MOZ_CRASH("CacheFile::OnDataWritten should not be called!");
   return NS_ERROR_UNEXPECTED;
 }
@@ -1121,17 +1113,18 @@ nsresult CacheFile::SetElement(const cha
 }
 
 nsresult CacheFile::VisitMetaData(nsICacheEntryMetaDataVisitor* aVisitor) {
   CacheFileAutoLock lock(this);
   MOZ_ASSERT(mMetadata);
   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) {
   CacheFileAutoLock lock(this);
 
   if (!mMetadata) return NS_ERROR_NOT_AVAILABLE;
 
   *_retval = mMetadata->ElementsSize();
@@ -1143,51 +1136,53 @@ nsresult CacheFile::SetExpirationTime(ui
 
   LOG(("CacheFile::SetExpirationTime() this=%p, expiration=%u", this,
        aExpirationTime));
 
   MOZ_ASSERT(mMetadata);
   NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
 
   PostWriteTimer();
-
-  return mMetadata->SetExpirationTime(aExpirationTime);
+  mMetadata->SetExpirationTime(aExpirationTime);
+  return NS_OK;
 }
 
 nsresult CacheFile::GetExpirationTime(uint32_t* _retval) {
   CacheFileAutoLock lock(this);
   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) {
   CacheFileAutoLock lock(this);
 
   LOG(("CacheFile::SetFrecency() this=%p, frecency=%u", this, aFrecency));
 
   MOZ_ASSERT(mMetadata);
   NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
 
   PostWriteTimer();
 
   if (mHandle && !mHandle->IsDoomed())
     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,
                                     uint64_t aOnStopTime) {
   CacheFileAutoLock lock(this);
 
   LOG(("CacheFile::SetNetworkTimes() this=%p, aOnStartTime=%" PRIu64
        ", aOnStopTime=%" PRIu64 "",
@@ -1336,17 +1331,18 @@ nsresult CacheFile::SetAltMetadata(const
 
   MOZ_ASSERT(mMetadata);
   NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
 
   PostWriteTimer();
 
   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.
     mMetadata->SetElement(CacheFileUtils::kAltDataKey, nullptr);
 
     mAltDataOffset = -1;
     mAltDataType.Truncate();
     hasAltData = false;
@@ -1359,33 +1355,35 @@ nsresult CacheFile::SetAltMetadata(const
   return rv;
 }
 
 nsresult CacheFile::GetLastModified(uint32_t* _retval) {
   CacheFileAutoLock lock(this);
   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) {
   CacheFileAutoLock lock(this);
   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) {
   if (!mHandle) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   *aDiskStorageSize = mHandle->FileSizeInK();
@@ -1397,17 +1395,18 @@ nsresult CacheFile::OnFetched() {
 
   LOG(("CacheFile::OnFetched() this=%p", this));
 
   MOZ_ASSERT(mMetadata);
   NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
 
   PostWriteTimer();
 
-  return mMetadata->OnFetched();
+  mMetadata->OnFetched();
+  return NS_OK;
 }
 
 void CacheFile::Lock() { mLock.Lock(); }
 
 void CacheFile::Unlock() {
   // move the elements out of mObjsToRelease
   // so that they can be released after we unlock
   nsTArray<RefPtr<nsISupports>> objs;
@@ -1462,18 +1461,17 @@ nsresult CacheFile::GetChunkLocked(uint3
            "[this=%p]",
            this));
       return rv;
     }
 
     if (chunk->IsReady() || aCaller == WRITER) {
       chunk.swap(*_retval);
     } else {
-      rv = QueueChunkListener(aIndex, aCallback);
-      NS_ENSURE_SUCCESS(rv, rv);
+      QueueChunkListener(aIndex, aCallback);
     }
 
     if (preload) {
       PreloadChunks(aIndex + 1);
     }
 
     return NS_OK;
   }
@@ -1535,18 +1533,17 @@ nsresult CacheFile::GetChunkLocked(uint3
     if (NS_WARN_IF(NS_FAILED(rv))) {
       RemoveChunkInternal(chunk, false);
       return rv;
     }
 
     if (aCaller == WRITER) {
       chunk.swap(*_retval);
     } else if (aCaller != PRELOADER) {
-      rv = QueueChunkListener(aIndex, aCallback);
-      NS_ENSURE_SUCCESS(rv, rv);
+      QueueChunkListener(aIndex, aCallback);
     }
 
     if (preload) {
       PreloadChunks(aIndex + 1);
     }
 
     return NS_OK;
   } else if (off == mDataSize) {
@@ -1624,18 +1621,17 @@ nsresult CacheFile::GetChunkLocked(uint3
 
   // We can be here only if the caller is reader since writer always create a
   // new chunk above and preloader calls this method to preload only chunks that
   // are not loaded but that do exist.
   MOZ_ASSERT(aCaller == READER, "Unexpected!");
 
   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;
   }
 
   return NS_OK;
 }
 
 void CacheFile::PreloadChunks(uint32_t aIndex) {
@@ -2062,20 +2058,17 @@ nsresult CacheFile::Truncate(int64_t aOf
     if (NS_FAILED(rv)) {
       LOG(
           ("CacheFile::Truncate() - New last chunk is failed "
            "[status=0x%08" PRIx32 "]",
            static_cast<uint32_t>(rv)));
       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
     // in OnChunkWritten().
     if (chunk->IsReady()) {
       mMetadata->SetHash(newLastChunk, chunk->Hash());
     }
   }
@@ -2113,18 +2106,17 @@ static uint32_t StatusToTelemetryEnum(ns
       return 6;
     default:
       return 1;  // other error
   }
 
   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 "]",
        this, aInput, static_cast<uint32_t>(aStatus)));
 
   DebugOnly<bool> found;
   found = mInputs.RemoveElement(aInput);
   MOZ_ASSERT(found);
@@ -2135,35 +2127,32 @@ nsresult CacheFile::RemoveInput(CacheFil
   if (!mMemoryOnly) WriteMetadataIfNeededLocked();
 
   // If the input didn't read all data, there might be left some preloaded
   // chunks that won't be used anymore.
   CleanUpCachedChunks();
 
   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;
 
   LOG(("CacheFile::RemoveOutput() [this=%p, output=%p, status=0x%08" PRIx32 "]",
        this, aOutput, static_cast<uint32_t>(aStatus)));
 
   if (mOutput != aOutput) {
     LOG(
         ("CacheFile::RemoveOutput() - This output was already removed, ignoring"
          " call [this=%p]",
          this));
-    return NS_OK;
+    return;
   }
 
   mOutput = nullptr;
 
   // Cancel all queued chunk and update listeners that cannot be satisfied
   NotifyListenersAboutOutputRemoval();
 
   if (!mMemoryOnly) WriteMetadataIfNeededLocked();
@@ -2205,44 +2194,38 @@ nsresult CacheFile::RemoveOutput(CacheFi
     }
   }
 
   // Notify close listener as the last action
   aOutput->NotifyCloseListener();
 
   Telemetry::Accumulate(Telemetry::NETWORK_CACHE_V2_OUTPUT_STREAM_STATUS,
                         StatusToTelemetryEnum(aStatus));
-
-  return NS_OK;
 }
 
 nsresult CacheFile::NotifyChunkListener(CacheFileChunkListener* aCallback,
                                         nsIEventTarget* aTarget,
                                         nsresult aResult, uint32_t aChunkIdx,
                                         CacheFileChunk* aChunk) {
   LOG(
       ("CacheFile::NotifyChunkListener() [this=%p, listener=%p, target=%p, "
        "rv=0x%08" PRIx32 ", idx=%u, chunk=%p]",
        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));
 
   AssertOwnsLock();
 
   MOZ_ASSERT(aCallback);
 
   ChunkListenerItem* item = new ChunkListenerItem();
@@ -2257,17 +2240,16 @@ nsresult CacheFile::QueueChunkListener(u
 
   ChunkListeners* listeners;
   if (!mChunkListeners.Get(aIndex, &listeners)) {
     listeners = new ChunkListeners();
     mChunkListeners.Put(aIndex, listeners);
   }
 
   listeners->mItems.AppendElement(item);
-  return NS_OK;
 }
 
 nsresult CacheFile::NotifyChunkListeners(uint32_t aIndex, nsresult aResult,
                                          CacheFileChunk* aChunk) {
   LOG(("CacheFile::NotifyChunkListeners() [this=%p, idx=%u, rv=0x%08" PRIx32
        ", "
        "chunk=%p]",
        this, aIndex, static_cast<uint32_t>(aResult), aChunk));
@@ -2562,18 +2544,17 @@ nsresult CacheFile::InitIndexEntry() {
 
   nsresult rv;
 
   rv = CacheFileIOManager::InitIndexEntry(
       mHandle, GetOriginAttrsHash(mMetadata->OriginAttributes()),
       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;
 
   static auto toUint16 = [](const char* s) -> uint16_t {
     if (s) {
       nsresult rv;
       uint64_t n64 = nsDependentCString(s).ToInteger64(&rv);
--- a/netwerk/cache2/CacheFile.h
+++ b/netwerk/cache2/CacheFile.h
@@ -157,23 +157,22 @@ class CacheFile final : public CacheFile
   bool OutputStreamExists(bool aAlternativeData);
   // Returns number of bytes that are available and can be read by input stream
   // without waiting for the data. The amount is counted from the start of
   // aIndex chunk and it is guaranteed that this data won't be released by
   // CleanUpCachedChunks().
   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);
   void NotifyListenersAboutOutputRemoval();
 
   bool IsDirty();
   void WriteMetadataIfNeeded();
   void WriteMetadataIfNeededLocked(bool aFireAndForget = false);
--- a/netwerk/cache2/CacheFileChunk.cpp
+++ b/netwerk/cache2/CacheFileChunk.cpp
@@ -436,17 +436,17 @@ void CacheFileChunk::WaitForUpdate(Cache
   }
   item->mCallback = aCallback;
   MOZ_ASSERT(item->mTarget);
   item->mCallback = aCallback;
 
   mUpdateListeners.AppendElement(item);
 }
 
-nsresult CacheFileChunk::CancelWait(CacheFileChunkListener* aCallback) {
+void CacheFileChunk::CancelWait(CacheFileChunkListener* aCallback) {
   AssertOwnsLock();
 
   LOG(("CacheFileChunk::CancelWait() [this=%p, listener=%p]", this, aCallback));
 
   MOZ_ASSERT(IsReady());
 
   uint32_t i;
   for (i = 0; i < mUpdateListeners.Length(); i++) {
@@ -459,18 +459,16 @@ nsresult CacheFileChunk::CancelWait(Cach
     }
   }
 
 #ifdef DEBUG
   for (; i < mUpdateListeners.Length(); i++) {
     MOZ_ASSERT(mUpdateListeners[i]->mCallback != aCallback);
   }
 #endif
-
-  return NS_OK;
 }
 
 nsresult CacheFileChunk::NotifyUpdateListeners() {
   AssertOwnsLock();
 
   LOG(("CacheFileChunk::NotifyUpdateListeners() [this=%p]", this));
 
   MOZ_ASSERT(IsReady());
@@ -545,25 +543,24 @@ void CacheFileChunk::UpdateDataSize(uint
 
   MOZ_ASSERT(mUpdateListeners.Length() == 0);
   MOZ_ASSERT(mState == READING);
 
   mValidityMap.AddPair(aOffset, 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) {
     mIsDirty = true;
   }
 
   mBuf->SetDataSize(aOffset);
-  return NS_OK;
 }
 
 nsresult CacheFileChunk::OnFileOpened(CacheFileHandle* aHandle,
                                       nsresult aResult) {
   MOZ_CRASH("CacheFileChunk::OnFileOpened should not be called!");
   return NS_ERROR_UNEXPECTED;
 }
 
--- a/netwerk/cache2/CacheFileChunk.h
+++ b/netwerk/cache2/CacheFileChunk.h
@@ -135,17 +135,17 @@ class CacheFileChunk final : public Cach
 
   CacheFileChunk(CacheFile* aFile, uint32_t aIndex, bool aInitByWriter);
 
   void InitNew();
   nsresult Read(CacheFileHandle* aHandle, uint32_t aLen,
                 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;
   CacheHash::Hash16_t Hash() const;
   uint32_t DataSize() const;
 
   NS_IMETHOD OnFileOpened(CacheFileHandle* aHandle, nsresult aResult) override;
   NS_IMETHOD OnDataWritten(CacheFileHandle* aHandle, const char* aBuf,
@@ -177,17 +177,17 @@ class CacheFileChunk final : public Cach
   friend class CacheFileOutputStream;
   friend class CacheFile;
 
   virtual ~CacheFileChunk();
 
   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);
 
   mozilla::Atomic<uint32_t, ReleaseAcquire>& ChunksMemoryUsage() const;
 
   enum EState { INITIAL = 0, READING = 1, WRITING = 2, READY = 3 };
 
--- a/netwerk/cache2/CacheFileContextEvictor.cpp
+++ b/netwerk/cache2/CacheFileContextEvictor.cpp
@@ -153,38 +153,38 @@ nsresult CacheFileContextEvictor::AddCon
     }
 
     StartEvicting();
   }
 
   return NS_OK;
 }
 
-nsresult CacheFileContextEvictor::CacheIndexStateChanged() {
+void CacheFileContextEvictor::CacheIndexStateChanged() {
   LOG(("CacheFileContextEvictor::CacheIndexStateChanged() [this=%p]", this));
 
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThread());
 
   bool isUpToDate = false;
   CacheIndex::IsUpToDate(&isUpToDate);
   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?!
     LOG(
         ("CacheFileContextEvictor::CacheIndexStateChanged() - Index is up to "
          "date, we have some context to evict but eviction is not running! "
          "Starting now."));
   }
@@ -192,56 +192,49 @@ nsresult CacheFileContextEvictor::CacheI
   mIndexIsUpToDate = isUpToDate;
 
   if (mIndexIsUpToDate) {
     CreateIterators();
     StartEvicting();
   } 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;
 
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThread());
 
   nsCOMPtr<nsILoadContextInfo> info = CacheFileUtils::ParseKey(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) {
     CacheFileContextEvictorEntry* entry = mEntries[i];
 
     if (entry->mInfo && !info->Equals(entry->mInfo)) {
       continue;
     }
 
     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) {
       // File has been modified since context eviction.
       continue;
     }
 
     LOG(
@@ -250,18 +243,16 @@ nsresult CacheFileContextEvictor::WasEvi
          entry->mPinned, entry->mTimeStamp, lastModifiedTime));
 
     if (entry->mPinned) {
       *aEvictedAsPinned = true;
     } else {
       *aEvictedAsNonPinned = true;
     }
   }
-
-  return NS_OK;
 }
 
 nsresult CacheFileContextEvictor::PersistEvictionInfoToDisk(
     nsILoadContextInfo* aLoadContextInfo, bool aPinned,
     const nsAString& aOrigin) {
   LOG(
       ("CacheFileContextEvictor::PersistEvictionInfoToDisk() [this=%p, "
        "loadContextInfo=%p]",
@@ -538,77 +529,77 @@ void CacheFileContextEvictor::StartEvict
     return;
   }
 
   if (mEntries.Length() == 0) {
     LOG(("CacheFileContextEvictor::StartEvicting() - no context to evict."));
     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();
 
   nsresult rv = ioThread->Dispatch(ev, CacheIOThread::EVICT);
   if (NS_FAILED(rv)) {
     LOG(
         ("CacheFileContextEvictor::StartEvicting() - Cannot dispatch event to "
          "IO thread. [rv=0x%08" PRIx32 "]",
          static_cast<uint32_t>(rv)));
   }
 
   mEvicting = true;
 }
 
-nsresult CacheFileContextEvictor::EvictEntries() {
+void CacheFileContextEvictor::EvictEntries() {
   LOG(("CacheFileContextEvictor::EvictEntries()"));
 
   nsresult rv;
 
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThread());
 
   mEvicting = false;
 
   if (!mIndexIsUpToDate) {
     LOG(
         ("CacheFileContextEvictor::EvictEntries() - Stopping evicting due to "
          "outdated index."));
-    return NS_OK;
+    return;
   }
 
   while (true) {
     if (CacheObserver::ShuttingDown()) {
       LOG(
           ("CacheFileContextEvictor::EvictEntries() - Stopping evicting due to "
            "shutdown."));
       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()) {
       LOG(
           ("CacheFileContextEvictor::EvictEntries() - Breaking loop for higher "
            "level events."));
       mEvicting = true;
-      return NS_OK;
+      return;
     }
 
     if (mEntries.Length() == 0) {
       LOG(
           ("CacheFileContextEvictor::EvictEntries() - Stopping evicting, there "
            "is no context to evict."));
 
       // Allow index to notify AsyncGetDiskConsumption callbacks.  The size is
       // actual again.
       CacheIndex::OnAsyncEviction(false);
-      return NS_OK;
+      return;
     }
 
     SHA1Sum::Hash hash;
     rv = mEntries[0]->mIterator->GetNextHash(&hash);
     if (rv == NS_ERROR_NOT_AVAILABLE) {
       LOG(
           ("CacheFileContextEvictor::EvictEntries() - No more entries left in "
            "iterator. [iterator=%p, info=%p]",
@@ -672,23 +663,19 @@ nsresult CacheFileContextEvictor::EvictE
       // Read metadata from the file synchronously
       RefPtr<CacheFileMetadata> metadata = new CacheFileMetadata();
       rv = metadata->SyncReadMetadata(file);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         continue;
       }
 
       // 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;
       }
 
       RefPtr<MozURL> url;
       rv = MozURL::Init(getter_AddRefs(url), uriSpec);
       if (NS_FAILED(rv)) {
@@ -738,13 +725,12 @@ nsresult CacheFileContextEvictor::EvictE
     }
 
     LOG(("CacheFileContextEvictor::EvictEntries - Removing entry."));
     file->Remove(false);
     CacheIndex::RemoveEntry(&hash);
   }
 
   MOZ_ASSERT_UNREACHABLE("We should never get here");
-  return NS_OK;
 }
 
 }  // namespace net
 }  // namespace mozilla
--- a/netwerk/cache2/CacheFileContextEvictor.h
+++ b/netwerk/cache2/CacheFileContextEvictor.h
@@ -41,24 +41,24 @@ class CacheFileContextEvictor {
   // Returns number of contexts that are being evicted.
   uint32_t ContextsCount();
   // Start evicting given context and an origin, if not empty.
   nsresult AddContext(nsILoadContextInfo* aLoadContextInfo, bool aPinned,
                       const nsAString& aOrigin);
   // 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
   // done for every context added to the evictor to be able to recover eviction
   // after a shutdown or crash. When the context file is found after startup, we
   // restore mTimeStamp from the last modified time of the file.
   nsresult PersistEvictionInfoToDisk(nsILoadContextInfo* aLoadContextInfo,
                                      bool aPinned, const nsAString& aOrigin);
@@ -70,17 +70,17 @@ class CacheFileContextEvictor {
   // after startup.
   nsresult LoadEvictInfoFromDisk();
   nsresult GetContextFile(nsILoadContextInfo* aLoadContextInfo, bool aPinned,
                           const nsAString& aOrigin, nsIFile** _retval);
 
   void CreateIterators();
   void CloseIterators();
   void StartEvicting();
-  nsresult EvictEntries();
+  void EvictEntries();
 
   // Whether eviction is in progress
   bool mEvicting;
   // Whether index is up to date. We wait with eviction until the index finishes
   // update process when it is outdated. NOTE: We also stop eviction in progress
   // when the index is found outdated, the eviction is restarted again once the
   // update process finishes.
   bool mIndexIsUpToDate;
--- a/netwerk/cache2/CacheFileIOManager.cpp
+++ b/netwerk/cache2/CacheFileIOManager.cpp
@@ -382,19 +382,19 @@ nsresult CacheFileHandles::GetHandle(con
       ("CacheFileHandles::GetHandle() hash=%08x%08x%08x%08x%08x "
        "found handle %p, entry %p",
        LOGSHA1(aHash), handle.get(), entry));
 
   handle.forget(_retval);
   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);
 
 #ifdef DEBUG_HANDLES
   LOG(("CacheFileHandles::NewHandle() [hash=%08x%08x%08x%08x%08x]",
        LOGSHA1(aHash)));
 #endif
 
@@ -412,19 +412,17 @@ nsresult CacheFileHandles::NewHandle(con
   RefPtr<CacheFileHandle> handle =
       new CacheFileHandle(entry->Hash(), aPriority, aPinning);
   entry->AddHandle(handle);
 
   LOG(
       ("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) {
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased());
   MOZ_ASSERT(aHandle);
 
   if (!aHandle) {
     return;
@@ -1202,17 +1200,17 @@ nsresult CacheFileIOManager::Shutdown() 
     gInstance->SyncRemoveAllCacheFiles();
   }
 
   gInstance = nullptr;
 
   return NS_OK;
 }
 
-nsresult CacheFileIOManager::ShutdownInternal() {
+void CacheFileIOManager::ShutdownInternal() {
   LOG(("CacheFileIOManager::ShutdownInternal() [this=%p]", this));
 
   MOZ_ASSERT(mIOThread->IsCurrentThread());
 
   // No new handles can be created after this flag is set
   mShuttingDown = true;
 
   if (mTrashTimer) {
@@ -1270,18 +1268,16 @@ nsresult CacheFileIOManager::ShutdownInt
     mTrashDirEnumerator->Close();
     mTrashDirEnumerator = nullptr;
   }
 
   if (mContextEvictor) {
     mContextEvictor->Shutdown();
     mContextEvictor = nullptr;
   }
-
-  return NS_OK;
 }
 
 // static
 nsresult CacheFileIOManager::OnProfile() {
   LOG(("CacheFileIOManager::OnProfile() [gInstance=%p]", gInstance.get()));
 
   RefPtr<CacheFileIOManager> ioMan = gInstance;
   if (!ioMan) {
@@ -1454,57 +1450,53 @@ nsresult CacheFileIOManager::UnscheduleM
 
   RefPtr<MetadataWriteScheduleEvent> event = new MetadataWriteScheduleEvent(
       ioMan, aFile, MetadataWriteScheduleEvent::UNSCHEDULE);
   nsCOMPtr<nsIEventTarget> target = ioMan->IOTarget();
   NS_ENSURE_TRUE(target, NS_ERROR_UNEXPECTED);
   return target->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
 }
 
-nsresult CacheFileIOManager::UnscheduleMetadataWriteInternal(CacheFile* aFile) {
+void CacheFileIOManager::UnscheduleMetadataWriteInternal(CacheFile* aFile) {
   MOZ_ASSERT(IsOnIOThreadOrCeased());
 
   mScheduledMetadataWrites.RemoveElement(aFile);
 
   if (mScheduledMetadataWrites.Length() == 0 && mMetadataWritesTimer) {
     mMetadataWritesTimer->Cancel();
     mMetadataWritesTimer = nullptr;
   }
-
-  return NS_OK;
 }
 
 // static
 nsresult CacheFileIOManager::ShutdownMetadataWriteScheduling() {
   RefPtr<CacheFileIOManager> ioMan = gInstance;
   NS_ENSURE_TRUE(ioMan, NS_ERROR_NOT_INITIALIZED);
 
   RefPtr<MetadataWriteScheduleEvent> event = new MetadataWriteScheduleEvent(
       ioMan, nullptr, MetadataWriteScheduleEvent::SHUTDOWN);
   nsCOMPtr<nsIEventTarget> target = ioMan->IOTarget();
   NS_ENSURE_TRUE(target, NS_ERROR_UNEXPECTED);
   return target->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
 }
 
-nsresult CacheFileIOManager::ShutdownMetadataWriteSchedulingInternal() {
+void CacheFileIOManager::ShutdownMetadataWriteSchedulingInternal() {
   MOZ_ASSERT(IsOnIOThreadOrCeased());
 
   nsTArray<RefPtr<CacheFile> > files;
   files.SwapElements(mScheduledMetadataWrites);
   for (uint32_t i = 0; i < files.Length(); ++i) {
     CacheFile* file = files[i];
     file->WriteMetadataIfNeeded();
   }
 
   if (mMetadataWritesTimer) {
     mMetadataWritesTimer->Cancel();
     mMetadataWritesTimer = nullptr;
   }
-
-  return NS_OK;
 }
 
 NS_IMETHODIMP
 CacheFileIOManager::Notify(nsITimer* aTimer) {
   MOZ_ASSERT(IsOnIOThreadOrCeased());
   MOZ_ASSERT(mMetadataWritesTimer == aTimer);
 
   mMetadataWritesTimer = nullptr;
@@ -1585,19 +1577,17 @@ nsresult CacheFileIOManager::OpenFileInt
 
   if ((aFlags & (OPEN | CREATE | CREATE_NEW)) == CREATE_NEW) {
     if (handle) {
       rv = DoomFileInternal(handle);
       NS_ENSURE_SUCCESS(rv, rv);
       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);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (exists) {
       CacheIndex::RemoveEntry(aHash);
 
@@ -1642,20 +1632,17 @@ nsresult CacheFileIOManager::OpenFileInt
   }
 
   if (exists) {
     // For existing files we determine the pinning status later, after the
     // metadata gets parsed.
     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
     // the handle ASAP we know the real pinning state after metadta has been
     // parsed.  DoomFileInternal on the |handle| doesn't doom right now, since
     // the pinning state is unknown and we pass down a pinning restriction.
     if (evictedAsPinned) {
       rv = DoomFileInternal(handle, DOOM_WHEN_PINNED);
@@ -1772,19 +1759,18 @@ nsresult CacheFileIOManager::OpenSpecial
     handle->mFileSize = 0;
   }
 
   handle->mFile.swap(file);
   handle.swap(*_retval);
   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());
 
   aHandle->Log();
 
   MOZ_ASSERT(CacheFileIOManager::IsOnIOThreadOrCeased());
 
@@ -1818,18 +1804,16 @@ nsresult CacheFileIOManager::CloseHandle
   // Don't remove handles after shutdown
   if (!mShuttingDown) {
     if (aHandle->IsSpecialFile()) {
       mSpecialHandles.RemoveElement(aHandle);
     } else {
       mHandles.RemoveHandle(aHandle);
     }
   }
-
-  return NS_OK;
 }
 
 // static
 nsresult CacheFileIOManager::Read(CacheFileHandle* aHandle, int64_t aOffset,
                                   char* aBuf, int32_t aCount,
                                   CacheFileIOListener* aCallback) {
   LOG(("CacheFileIOManager::Read() [handle=%p, offset=%" PRId64 ", count=%d, "
        "listener=%p]",
@@ -2470,40 +2454,28 @@ nsresult CacheFileIOManager::GetEntryInf
   // Read metadata from the file synchronously
   RefPtr<CacheFileMetadata> metadata = new CacheFileMetadata();
   rv = metadata->SyncReadMetadata(file);
   if (NS_FAILED(rv)) {
     return NS_OK;
   }
 
   // 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;
   }
 
   // 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,
                          expirationTime, metadata->Pinned(), info);
 
   return NS_OK;
 }
 
@@ -3190,44 +3162,42 @@ nsresult CacheFileIOManager::CacheIndexS
   nsresult rv;
 
   // CacheFileIOManager lives longer than CacheIndex so gInstance must be
   // non-null here.
   MOZ_ASSERT(gInstance);
 
   // 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);
 
   nsCOMPtr<nsIEventTarget> ioTarget = IOTarget();
   MOZ_ASSERT(ioTarget);
 
   rv = ioTarget->Dispatch(ev, nsIEventTarget::DISPATCH_NORMAL);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   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) {
   LOG(("CacheFileIOManager::TrashDirectory() [file=%s]",
        aFile->HumanReadablePath().get()));
 
   nsresult rv;
 
--- a/netwerk/cache2/CacheFileIOManager.h
+++ b/netwerk/cache2/CacheFileIOManager.h
@@ -128,19 +128,19 @@ class CacheFileHandle final : public nsI
 };
 
 class CacheFileHandles {
  public:
   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);
   void ClearAll();
   uint32_t HandleCount();
 
 #ifdef DEBUG_HANDLES
   void Log(CacheFileHandlesEntry* entry);
@@ -364,23 +364,23 @@ class CacheFileIOManager final : public 
   friend class RenameFileEvent;
   friend class CacheIndex;
   friend class MetadataWriteScheduleEvent;
   friend class CacheFileContextEvictor;
 
   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,
                          const char* aBuf, int32_t aCount, bool aValidate,
                          bool aTruncate);
   nsresult DoomFileInternal(
       CacheFileHandle* aHandle,
       PinningDoomRestriction aPinningStatusRestriction = NO_RESTRICTION);
@@ -416,21 +416,21 @@ class CacheFileIOManager final : public 
   nsresult OpenNSPRHandle(CacheFileHandle* aHandle, bool aCreate = false);
   void NSPRHandleUsed(CacheFileHandle* aHandle);
 
   // Removing all cache files during shutdown
   nsresult SyncRemoveDir(nsIFile* aFile, const char* aDir);
   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
   // start overlimit eviction or not and also in OverLimitEvictionInternal()
   // before we start an eviction loop.
   nsresult UpdateSmartCacheSize(int64_t aFreeSpace);
 
   // Memory reporting (private part)
--- a/netwerk/cache2/CacheFileInputStream.cpp
+++ b/netwerk/cache2/CacheFileInputStream.cpp
@@ -246,43 +246,41 @@ CacheFileInputStream::IsNonBlocking(bool
 NS_IMETHODIMP
 CacheFileInputStream::CloseWithStatus(nsresult aStatus) {
   CacheFileAutoLock lock(mFile);
 
   LOG(("CacheFileInputStream::CloseWithStatus() [this=%p, aStatus=0x%08" PRIx32
        "]",
        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 "]",
        this, static_cast<uint32_t>(aStatus)));
 
   if (mClosed) {
     // We notify listener and null out mCallback immediately after closing
     // the stream. If we're in ReadSegments we postpone notification until we
     // 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;
   mStatus = NS_FAILED(aStatus) ? aStatus : NS_BASE_STREAM_CLOSED;
 
   if (!mInReadSegments) {
     CleanUp();
   }
-
-  return NS_OK;
 }
 
 void CacheFileInputStream::CleanUp() {
   MOZ_ASSERT(!mInReadSegments);
   MOZ_ASSERT(mClosed);
 
   if (mChunk) {
     ReleaseChunk();
--- a/netwerk/cache2/CacheFileInputStream.h
+++ b/netwerk/cache2/CacheFileInputStream.h
@@ -42,17 +42,17 @@ class CacheFileInputStream : public nsIA
   bool IsAlternativeData() const { return mAlternativeData; };
   int64_t GetChunkIdx() const {
     return mChunk ? static_cast<int64_t>(mChunk->Index()) : -1;
   };
 
  private:
   virtual ~CacheFileInputStream();
 
-  nsresult CloseWithStatusLocked(nsresult aStatus);
+  void CloseWithStatusLocked(nsresult aStatus);
   void CleanUp();
   void ReleaseChunk();
   void EnsureCorrectChunk(bool aReleaseOnly);
 
   // CanRead returns negative value when output stream truncates the data before
   // the input stream's mPos.
   int64_t CanRead(CacheFileChunkReadHandle* aHandle);
   void NotifyListener();
--- a/netwerk/cache2/CacheFileMetadata.cpp
+++ b/netwerk/cache2/CacheFileMetadata.cpp
@@ -142,22 +142,17 @@ CacheFileMetadata::~CacheFileMetadata() 
 void CacheFileMetadata::SetHandle(CacheFileHandle* aHandle) {
   LOG(("CacheFileMetadata::SetHandle() [this=%p, handle=%p]", this, aHandle));
 
   MOZ_ASSERT(!mHandle);
 
   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));
 
   MOZ_ASSERT(!mListener);
   MOZ_ASSERT(!mHashArray);
   MOZ_ASSERT(!mBuf);
   MOZ_ASSERT(!mWriteBuf);
 
@@ -170,29 +165,29 @@ nsresult CacheFileMetadata::ReadMetadata
     // this is a new entry
     LOG(
         ("CacheFileMetadata::ReadMetadata() - Filesize == 0, creating empty "
          "metadata. [this=%p]",
          this));
 
     InitEmptyMetadata();
     aListener->OnMetadataRead(NS_OK);
-    return NS_OK;
+    return;
   }
 
   if (size < int64_t(sizeof(CacheFileMetadataHeader) + 2 * sizeof(uint32_t))) {
     // there must be at least checksum, header and offset
     LOG(
         ("CacheFileMetadata::ReadMetadata() - File is corrupted, creating "
          "empty metadata. [this=%p, filesize=%" PRId64 "]",
          this, size));
 
     InitEmptyMetadata();
     aListener->OnMetadataRead(NS_OK);
-    return NS_OK;
+    return;
   }
 
   // Set offset so that we read at least kMinMetadataRead if the file is big
   // enough.
   int64_t offset;
   if (size < kMinMetadataRead) {
     offset = 0;
   } else {
@@ -220,20 +215,17 @@ nsresult CacheFileMetadata::ReadMetadata
         ("CacheFileMetadata::ReadMetadata() - CacheFileIOManager::Read() failed"
          " synchronously, creating empty metadata. [this=%p, rv=0x%08" PRIx32
          "]",
          this, static_cast<uint32_t>(rv)));
 
     mListener = nullptr;
     InitEmptyMetadata();
     aListener->OnMetadataRead(NS_OK);
-    return NS_OK;
   }
-
-  return NS_OK;
 }
 
 uint32_t CacheFileMetadata::CalcMetadataSize(uint32_t aElementsSize,
                                              uint32_t aHashCount) {
   return sizeof(uint32_t) +                          // hash of the metadata
          aHashCount * sizeof(CacheHash::Hash16_t) +  // array of chunk hashes
          sizeof(CacheFileMetadataHeader) +           // metadata header
          mKey.Length() + 1 +                         // key with trailing null
@@ -473,34 +465,32 @@ nsresult CacheFileMetadata::SetElement(c
 
   // Update value
   memcpy(pos, aValue, valueSize);
   mElementsSize = newSize;
 
   return NS_OK;
 }
 
-nsresult CacheFileMetadata::Visit(nsICacheEntryMetaDataVisitor* aVisitor) {
+void CacheFileMetadata::Visit(nsICacheEntryMetaDataVisitor* aVisitor) {
   const char* data = mBuf;
   const char* limit = mBuf + mElementsSize;
 
   while (data < limit) {
     // Point to the value part
     const char* value = data + strlen(data) + 1;
     MOZ_ASSERT(value < limit, "Metadata elements corrupted");
 
     aVisitor->OnMetaDataElement(data, value);
 
     // Skip value part
     data = value + strlen(value) + 1;
   }
 
   MOZ_ASSERT(data == limit, "Metadata elements corrupted");
-
-  return NS_OK;
 }
 
 CacheHash::Hash16_t CacheFileMetadata::GetHash(uint32_t aIndex) {
   MOZ_ASSERT(aIndex < mHashCount);
   return NetworkEndian::readUint16(&mHashArray[aIndex]);
 }
 
 nsresult CacheFileMetadata::SetHash(uint32_t aIndex,
@@ -546,82 +536,47 @@ nsresult CacheFileMetadata::RemoveHash(u
   if (aIndex + 1 != mHashCount) {
     return NS_ERROR_INVALID_ARG;
   }
 
   mHashCount--;
   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) {
   mIsDirty = true;
   if (aUpdateLastModified) {
     mMetaHdr.mLastModified = NOW_SECONDS();
   }
 }
--- a/netwerk/cache2/CacheFileMetadata.h
+++ b/netwerk/cache2/CacheFileMetadata.h
@@ -136,51 +136,51 @@ class CacheFileMetadata final : public C
   NS_DECL_THREADSAFE_ISUPPORTS
 
   CacheFileMetadata(CacheFileHandle* aHandle, const nsACString& aKey);
   CacheFileMetadata(bool aMemoryOnly, bool aPinned, const nsACString& aKey);
   CacheFileMetadata();
 
   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);
   nsresult SyncReadMetadata(nsIFile* aFile);
 
   bool IsAnonymous() const { return mAnonymous; }
   mozilla::OriginAttributes const& OriginAttributes() const {
     return mOriginAttributes;
   }
   bool Pinned() const { return !!(mMetaHdr.mFlags & kCacheEntryIsPinned); }
 
   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; }
   void MarkDirty(bool aUpdateLastModified = true);
   bool IsDirty() { return mIsDirty; }
   uint32_t MemoryUsage() {
     return sizeof(CacheFileMetadata) + mHashArraySize + mBufSize;
   }
--- a/netwerk/cache2/CacheIndex.cpp
+++ b/netwerk/cache2/CacheIndex.cpp
@@ -2670,19 +2670,17 @@ nsresult CacheIndex::InitEntryFromDiskDa
 
   aEntry->InitNew();
   aEntry->MarkDirty();
   aEntry->MarkFresh();
 
   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;
   if (hasAltData && NS_FAILED(CacheFileUtils::ParseAlternativeDataInfo(
                         altData, nullptr, nullptr))) {
     return NS_ERROR_FAILURE;
   }
   aEntry->SetHasAltData(hasAltData);
@@ -3503,34 +3501,33 @@ nsresult CacheIndex::Run() {
       break;
     default:
       LOG(("CacheIndex::Run() - Update/Build was canceled"));
   }
 
   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;
 
   sLock.AssertCurrentThreadOwns();
 
   MOZ_RELEASE_ASSERT(IsIndexUsable());
 
   if (mState == READY && mShuttingDown) {
-    return NS_OK;
+    return;
   }
 
   switch (mState) {
     case WRITING:
       MOZ_ASSERT(aOpener == mIndexFileOpener);
       mIndexFileOpener = nullptr;
 
       if (NS_FAILED(aResult)) {
@@ -3607,18 +3604,16 @@ nsresult CacheIndex::OnFileOpenedInterna
       } else {
         StartReadingIndex();
       }
 
       break;
     default:
       MOZ_ASSERT(false, "Unexpected state!");
   }
-
-  return NS_OK;
 }
 
 nsresult CacheIndex::OnFileOpened(CacheFileHandle* aHandle, nsresult aResult) {
   MOZ_CRASH("CacheIndex::OnFileOpened should not be called!");
   return NS_ERROR_UNEXPECTED;
 }
 
 nsresult CacheIndex::OnDataWritten(CacheFileHandle* aHandle, const char* aBuf,
--- a/netwerk/cache2/CacheIndex.h
+++ b/netwerk/cache2/CacheIndex.h
@@ -788,18 +788,18 @@ class CacheIndex final : public CacheFil
  private:
   friend class CacheIndexEntryAutoManage;
   friend class FileOpenHelper;
   friend class CacheIndexIterator;
 
   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,
                         nsresult aResult) override;
   NS_IMETHOD OnFileDoomed(CacheFileHandle* aHandle, nsresult aResult) override;
   NS_IMETHOD OnEOFSet(CacheFileHandle* aHandle, nsresult aResult) override;
   NS_IMETHOD OnFileRenamed(CacheFileHandle* aHandle, nsresult aResult) override;
 
--- a/netwerk/cache2/OldWrappers.cpp
+++ b/netwerk/cache2/OldWrappers.cpp
@@ -472,20 +472,21 @@ MetaDataVisitorWrapper::VisitMetaDataEle
 NS_IMETHODIMP _OldCacheEntryWrapper::VisitMetaData(
     nsICacheEntryMetaDataVisitor* cb) {
   RefPtr<MetaDataVisitorWrapper> w = new MetaDataVisitorWrapper(cb);
   return mOldDesc->VisitMetaData(w);
 }
 
 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
   if (scheme.EqualsLiteral("http") || scheme.EqualsLiteral("https")) {
     switch (storagePolicy) {
       case nsICache::STORE_IN_MEMORY:
         if (isPrivate)
           sessionName.AssignLiteral("HTTP-memory-only-PB");
@@ -520,18 +521,16 @@ nsresult GetCacheSessionNameForStoragePo
     // recognize it too.
     sessionName.AssignLiteral("other");
     if (isPrivate) sessionName.AppendLiteral("-private");
   }
 
   nsAutoCString suffix;
   originAttribs->CreateSuffix(suffix);
   sessionName.Append(suffix);
-
-  return NS_OK;
 }
 
 nsresult GetCacheSession(const nsACString& aScheme, bool aWriteToDisk,
                          nsILoadContextInfo* aLoadInfo,
                          nsIApplicationCache* aAppCache,
                          nsICacheSession** _result) {
   nsresult rv;
 
@@ -542,20 +541,19 @@ nsresult GetCacheSession(const nsACStrin
     storagePolicy = nsICache::STORE_IN_MEMORY;
   else
     storagePolicy = nsICache::STORE_ANYWHERE;
 
   nsAutoCString clientId;
   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(),
        storagePolicy));
 
   nsCOMPtr<nsICacheService> serv =
       do_GetService(NS_CACHESERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
--- a/netwerk/ipc/DocumentLoadListener.cpp
+++ b/netwerk/ipc/DocumentLoadListener.cpp
@@ -83,18 +83,17 @@ bool DocumentLoadListener::Open(
 
   // Computation of the top window uses the docshell tree, so only
   // works in the source process. We compute it manually and override
   // it so that it gets the right value.
   // This probably isn't fission compatible.
   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 =
           PrincipalInfoToPrincipal(*aContentBlockingAllowListPrincipal);
       httpBaseChannel->SetContentBlockingAllowListPrincipal(
           contentBlockingAllowListPrincipal);
     }
 
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -1040,42 +1040,40 @@ HttpBaseChannel::ExplicitSetUploadStream
         self->ExplicitSetUploadStreamLength(aLength >= 0 ? aLength : 0,
                                             aStreamHasHeaders);
         self->MaybeResumeAsyncOpen();
       });
   mPendingInputStreamLengthOperation = true;
   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;
   header.AssignLiteral("Content-Length");
 
   // Maybe the content-length header has been already set.
   nsAutoCString value;
   nsresult rv = GetRequestHeader(header, value);
   if (NS_SUCCEEDED(rv) && !value.IsEmpty()) {
-    return NS_OK;
+    return;
   }
 
   // SetRequestHeader propagates headers to chrome if HttpChannelChild
   MOZ_ASSERT(!mWasOpened);
   nsAutoCString contentLengthStr;
   contentLengthStr.AppendInt(aContentLength);
   SetRequestHeader(header, contentLengthStr, false);
-
-  return NS_OK;
 }
 
 NS_IMETHODIMP
 HttpBaseChannel::GetUploadStreamHasHeaders(bool* hasHeaders) {
   NS_ENSURE_ARG(hasHeaders);
 
   *hasHeaders = mUploadStreamHasHeaders;
   return NS_OK;
@@ -3575,18 +3573,17 @@ nsresult HttpBaseChannel::SetupReplaceme
     // it may still be necessary for the following redirections.
     // E.g. nsHttpChannel -> InterceptedChannel -> nsHttpChannel
     RefPtr<HttpBaseChannel> realChannel;
     CallQueryInterface(newChannel, realChannel.StartAssignment());
     if (realChannel) {
       realChannel->SetContentBlockingAllowListPrincipal(
           mContentBlockingAllowListPrincipal);
 
-      rv = realChannel->SetTopWindowURI(mTopWindowURI);
-      MOZ_ASSERT(NS_SUCCEEDED(rv));
+      realChannel->SetTopWindowURI(mTopWindowURI);
     }
 
     // update the DocumentURI indicator since we are being redirected.
     // if this was a top-level document channel, then the new channel
     // should have its mDocumentURI point to newURI; otherwise, we
     // just need to pass along our mDocumentURI to the new channel.
     if (newURI && (mURI == mDocumentURI))
       rv = httpInternal->SetDocumentURI(newURI);
--- a/netwerk/protocol/http/HttpBaseChannel.h
+++ b/netwerk/protocol/http/HttpBaseChannel.h
@@ -456,20 +456,17 @@ class HttpBaseChannel : public nsHashPro
     return mRequestHead.SetHeader(nsHttp::Referer, aReferrer);
   }
 
   nsresult ClearReferrerHeader() {
     ENSURE_CALLED_BEFORE_CONNECT();
     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;
   }
 
   // Set referrerInfo and compute the referrer header if neccessary.
   // Pass true for aSetOriginal if this is a new referrer and should
   // overwrite the 'original' value, false if this is a mutation (like
@@ -617,18 +614,18 @@ class HttpBaseChannel : public nsHashPro
   nsCOMPtr<nsIStreamListener> mListener;
   // An instance of nsHTTPCompressConv
   nsCOMPtr<nsIStreamListener> mCompressListener;
 
  private:
   // 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();
 
  protected:
   nsCString mSpec;  // ASCII encoded URL spec
   nsCString mContentTypeHint;
   nsCString mContentCharsetHint;
   nsCString mUserSetCookieHeader;
--- a/netwerk/protocol/http/HttpChannelParent.cpp
+++ b/netwerk/protocol/http/HttpChannelParent.cpp
@@ -453,18 +453,17 @@ bool HttpChannelParent::DoAsyncOpen(
     // Referrer header is computed in child no need to recompute here
     rv =
         httpChannel->SetReferrerInfoInternal(aReferrerInfo, false, false, true);
     MOZ_ASSERT(NS_SUCCEEDED(rv));
   }
 
   if (apiRedirectToUri) httpChannel->RedirectTo(apiRedirectToUri);
   if (topWindowUri) {
-    rv = httpChannel->SetTopWindowURI(topWindowUri);
-    MOZ_ASSERT(NS_SUCCEEDED(rv));
+    httpChannel->SetTopWindowURI(topWindowUri);
   }
 
   if (aContentBlockingAllowListPrincipal) {
     httpChannel->SetContentBlockingAllowListPrincipal(
         aContentBlockingAllowListPrincipal);
   }
 
   if (aLoadFlags != nsIRequest::LOAD_NORMAL)
@@ -2228,18 +2227,17 @@ void HttpChannelParent::StartDiversion()
   nsCOMPtr<nsIStreamListener> converterListener;
   Unused << mChannel->DoApplyContentConversions(
       mDivertListener, getter_AddRefs(converterListener));
   if (converterListener) {
     mDivertListener = converterListener.forget();
   }
 
   // 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
   // is ready to send FlushedForDiversion and DivertMessages.
   MOZ_ASSERT(mIPCClosed || mBgParent);
 
   if (NS_WARN_IF(mIPCClosed || !mBgParent || !mBgParent->OnDiversion())) {
     FailDiversion(NS_ERROR_UNEXPECTED);
--- a/netwerk/protocol/http/HttpTrafficAnalyzer.cpp
+++ b/netwerk/protocol/http/HttpTrafficAnalyzer.cpp
@@ -171,45 +171,43 @@ HttpTrafficCategory HttpTrafficAnalyzer:
 
       return static_cast<HttpTrafficCategory>(category);
   }
 
   MOZ_ASSERT(false, "incorrect class of service");
   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());
   MOZ_ASSERT(aCategory != HttpTrafficCategory::eInvalid, "invalid category");
 
   LOG(("HttpTrafficAnalyzer::IncrementHttpTransaction [%s] [this=%p]\n",
        gKeyName[aCategory].get(), this));
 
   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());
   MOZ_ASSERT(aCategory != HttpTrafficCategory::eInvalid, "invalid category");
 
   LOG(("HttpTrafficAnalyzer::IncrementHttpConnection [%s] [this=%p]\n",
        gKeyName[aCategory].get(), this));
 
   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());
   MOZ_ASSERT(!aCategories.IsEmpty(), "empty category");
 
   nsTArray<HttpTrafficCategory> categories(std::move(aCategories));
 
   LOG(("HttpTrafficAnalyzer::IncrementHttpConnection size=%" PRIuPTR
@@ -237,36 +235,34 @@ nsresult HttpTrafficAnalyzer::IncrementH
     }
     // third party
     MOZ_ASSERT(gKeyName[24].Equals(kInvalidCategory),
                "category definition isn't consistent");
     best = category;
     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());
   MOZ_ASSERT(aCategory != HttpTrafficCategory::eInvalid, "invalid category");
 
   LOG(("HttpTrafficAnalyzer::AccumulateHttpTransferredSize [%s] rb=%" PRIu64 " "
        "sb=%" PRIu64 " [this=%p]\n",
        gKeyName[aCategory].get(), aBytesRead, aBytesSent, this));
 
   // Telemetry supports uint32_t only, and we send KB here.
   auto total = CLAMP_U32((aBytesRead >> 10) + (aBytesSent >> 10));
   if (aBytesRead || aBytesSent) {
     Telemetry::ScalarAdd(Telemetry::ScalarID::NETWORKING_DATA_TRANSFERRED_V3_KB,
                          NS_ConvertUTF8toUTF16(gKeyName[aCategory]), total);
   }
-  return NS_OK;
 }
 
 }  // namespace net
 }  // namespace mozilla
--- a/netwerk/protocol/http/HttpTrafficAnalyzer.h
+++ b/netwerk/protocol/http/HttpTrafficAnalyzer.h
@@ -1,16 +1,18 @@
 /* -*- 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/. */
 
 #ifndef mozilla_netwerk_protocol_http_HttpTrafficAnalyzer_h
 #define mozilla_netwerk_protocol_http_HttpTrafficAnalyzer_h
 
+#include "nsTArrayForwardDeclare.h"
+
 namespace mozilla {
 namespace net {
 
 #define DEFINE_CATEGORY(_name, _idx) e##_name = _idx##u,
 enum HttpTrafficCategory : uint8_t {
 #include "HttpTrafficAnalyzer.inc"
   eInvalid,
 };
@@ -30,20 +32,19 @@ class HttpTrafficAnalyzer final {
     eContent = 2,
     eFingerprinting = 3,
   };
 
   static HttpTrafficCategory CreateTrafficCategory(
       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
 }  // namespace mozilla
 
 #endif  // mozilla_netwerk_protocol_http_HttpTrafficAnalyzer_h
--- a/netwerk/protocol/http/InterceptedChannel.cpp
+++ b/netwerk/protocol/http/InterceptedChannel.cpp
@@ -67,40 +67,37 @@ void InterceptedChannelBase::DoNotifyCon
     if (NS_FAILED(rv)) {
       NS_WARNING("Failed to resume intercepted network request");
       CancelInterception(rv);
     }
   }
   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.
   nsAutoCString statusLine;
   statusLine.AppendLiteral("HTTP/1.1 ");
   statusLine.AppendInt(aStatus);
   statusLine.AppendLiteral(" ");
   statusLine.Append(aReason);
 
   (*mSynthesizedResponseHead)->ParseStatusLine(statusLine);
-  return NS_OK;
 }
 
 nsresult InterceptedChannelBase::DoSynthesizeHeader(const nsACString& aName,
                                                     const nsACString& aValue) {
   EnsureSynthesizedResponse();
 
   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
 InterceptedChannelBase::GetConsoleReportCollector(
     nsIConsoleReportCollector** aCollectorOut) {
   MOZ_ASSERT(aCollectorOut);
   nsCOMPtr<nsIConsoleReportCollector> ref = mReportCollector;
   ref.forget(aCollectorOut);
@@ -269,17 +266,18 @@ InterceptedChannelContent::ResetIntercep
 
 NS_IMETHODIMP
 InterceptedChannelContent::SynthesizeStatus(uint16_t aStatus,
                                             const nsACString& aReason) {
   if (mClosed) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
-  return DoSynthesizeStatus(aStatus, aReason);
+  DoSynthesizeStatus(aStatus, aReason);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 InterceptedChannelContent::SynthesizeHeader(const nsACString& aName,
                                             const nsACString& aValue) {
   if (mClosed) {
     return NS_ERROR_NOT_AVAILABLE;
   }
--- a/netwerk/protocol/http/InterceptedChannel.h
+++ b/netwerk/protocol/http/InterceptedChannel.h
@@ -37,18 +37,17 @@ class InterceptedChannelBase : public ns
 
   nsCOMPtr<nsIConsoleReportCollector> mReportCollector;
   nsCOMPtr<nsISupports> mReleaseHandle;
 
   bool mClosed;
 
   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);
 
   TimeStamp mLaunchServiceWorkerStart;
   TimeStamp mLaunchServiceWorkerEnd;
   TimeStamp mDispatchFetchEventStart;
   TimeStamp mDispatchFetchEventEnd;
   TimeStamp mHandleFetchEventStart;
--- a/netwerk/protocol/http/ParentChannelListener.cpp
+++ b/netwerk/protocol/http/ParentChannelListener.cpp
@@ -295,37 +295,33 @@ nsresult ParentChannelListener::SuspendF
 
   // While this is set, no OnStart/OnData/OnStop callbacks should be forwarded
   // to mNextListener.
   mSuspendedForDiversion = true;
 
   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!");
 
   // Reset mInterceptCanceled back to false every time a new listener is set.
   // We only want to cancel the interception if our current listener has
   // signaled its cleaning up.
   mInterceptCanceled = false;
 
   mNextListener = aListener;
-
-  return ResumeForDiversion();
+  ResumeForDiversion();
 }
 
 void ParentChannelListener::SetupInterception(
     const nsHttpResponseHead& aResponseHead) {
   mSynthesizedResponseHead = new nsHttpResponseHead(aResponseHead);
   mShouldIntercept = true;
 }
 
--- a/netwerk/protocol/http/ParentChannelListener.h
+++ b/netwerk/protocol/http/ParentChannelListener.h
@@ -38,31 +38,31 @@ class ParentChannelListener final : publ
   NS_DECL_NSINETWORKINTERCEPTCONTROLLER
 
   NS_DECLARE_STATIC_IID_ACCESSOR(PARENT_CHANNEL_LISTENER)
 
   explicit ParentChannelListener(nsIStreamListener* aListener,
                                  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);
   void SetupInterceptionAfterRedirect(bool aShouldIntercept);
   void ClearInterceptedChannel(nsIStreamListener* aListener);
 
   // Called to set a new listener which replaces the old one after a redirect.
   void SetListenerAfterRedirect(nsIStreamListener* aListener);
 
  private:
   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,
   // or some other listener that we have been diverted to via
   // nsIDivertableChannel.
   nsCOMPtr<nsIStreamListener> mNextListener;
   // When set, no OnStart/OnData/OnStop calls should be received.
   bool mSuspendedForDiversion;
--- a/netwerk/protocol/http/nsHttpAuthCache.cpp
+++ b/netwerk/protocol/http/nsHttpAuthCache.cpp
@@ -57,18 +57,17 @@ nsHttpAuthCache::nsHttpAuthCache()
   if (obsSvc) {
     obsSvc->AddObserver(mObserver, "clear-origin-attributes-data", false);
   }
 }
 
 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");
     mObserver->mOwner = nullptr;
   }
 }
 
 nsresult nsHttpAuthCache::GetAuthEntryForPath(const char* scheme,
@@ -139,20 +138,19 @@ void nsHttpAuthCache::ClearAuthEntry(con
                                      int32_t port, const char* realm,
                                      nsACString const& originSuffix) {
   nsAutoCString key;
   GetAuthKey(scheme, host, port, originSuffix, key);
   LOG(("nsHttpAuthCache::ClearAuthEntry %p key='%s'\n", this, key.get()));
   mDB.Remove(key);
 }
 
-nsresult nsHttpAuthCache::ClearAll() {
+void nsHttpAuthCache::ClearAll() {
   LOG(("nsHttpAuthCache::ClearAll %p\n", this));
   mDB.Clear();
-  return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
 // nsHttpAuthCache <private>
 //-----------------------------------------------------------------------------
 
 nsHttpAuthNode* nsHttpAuthCache::LookupAuthNode(const char* scheme,
                                                 const char* host, int32_t port,
--- a/netwerk/protocol/http/nsHttpAuthCache.h
+++ b/netwerk/protocol/http/nsHttpAuthCache.h
@@ -191,17 +191,17 @@ class nsHttpAuthCache {
                                      nsACString const& originSuffix,
                                      const nsHttpAuthIdentity* ident,
                                      nsISupports* metadata);
 
   void ClearAuthEntry(const char* scheme, const char* host, int32_t port,
                       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,
                                  int32_t port, nsACString const& originSuffix,
                                  nsCString& key);
 
   class OriginClearObserver : public nsIObserver {
     virtual ~OriginClearObserver() = default;
--- a/netwerk/protocol/http/nsHttpAuthManager.cpp
+++ b/netwerk/protocol/http/nsHttpAuthManager.cpp
@@ -99,17 +99,15 @@ nsHttpAuthManager::SetAuthIdentity(
       nullptr,  // credentials
       nullptr,  // challenge
       originSuffix, &ident,
       nullptr);  // metadata
 }
 
 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;
 }
 
 }  // namespace net
 }  // namespace mozilla
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -3553,18 +3553,17 @@ nsresult nsHttpChannel::ProcessPartialCo
     }
   } else {
     // suspend the current transaction
     rv = mTransactionPump->Suspend();
     if (NS_FAILED(rv)) return rv;
   }
 
   // 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;
   mCachedResponseHead->Flatten(head, true);
   rv = mCacheEntry->SetMetaDataElement("response-head", head.get());
   if (NS_FAILED(rv)) return rv;
 
   // make the cached response be the current response
@@ -3697,18 +3696,17 @@ nsresult nsHttpChannel::ProcessNotModifi
          "[%s] and [%s]\n",
          lastModifiedCached.get(), lastModified304.get()));
 
     mCacheEntry->AsyncDoom(nullptr);
     Telemetry::Accumulate(Telemetry::CACHE_LM_INCONSISTENT, true);
   }
 
   // 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;
   mCachedResponseHead->Flatten(head, true);
   rv = mCacheEntry->SetMetaDataElement("response-head", head.get());
   if (NS_FAILED(rv)) return rv;
 
   // make the cached response be the current response
--- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp
@@ -621,32 +621,30 @@ void nsHttpConnectionMgr::OnMsgUpdateReq
 nsresult nsHttpConnectionMgr::UpdateRequestTokenBucket(
     EventTokenBucket* aBucket) {
   // Call From main thread when a new EventTokenBucket has been made in order
   // to post the new value to the socket thread.
   return PostEvent(&nsHttpConnectionMgr::OnMsgUpdateRequestTokenBucket, 0,
                    aBucket);
 }
 
-nsresult nsHttpConnectionMgr::ClearConnectionHistory() {
+void nsHttpConnectionMgr::ClearConnectionHistory() {
   MOZ_ASSERT(OnSocketThread(), "not on socket thread");
 
   LOG(("nsHttpConnectionMgr::ClearConnectionHistory"));
 
   for (auto iter = mCT.Iter(); !iter.Done(); iter.Next()) {
     RefPtr<nsConnectionEntry> ent = iter.Data();
     if (ent->mIdleConns.Length() == 0 && ent->mActiveConns.Length() == 0 &&
         ent->mHalfOpens.Length() == 0 && ent->mUrgentStartQ.Length() == 0 &&
         ent->PendingQLength() == 0 &&
         ent->mHalfOpenFastOpenBackups.Length() == 0 && !ent->mDoNotDestroy) {
       iter.Remove();
     }
   }
-
-  return NS_OK;
 }
 
 nsresult nsHttpConnectionMgr::CloseIdleConnection(nsHttpConnection* conn) {
   MOZ_ASSERT(OnSocketThread(), "not on socket thread");
   LOG(("nsHttpConnectionMgr::CloseIdleConnection %p conn=%p", this, conn));
 
   if (!conn->ConnectionInfo()) {
     return NS_ERROR_UNEXPECTED;
--- a/netwerk/protocol/http/nsHttpConnectionMgr.h
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.h
@@ -177,17 +177,17 @@ class nsHttpConnectionMgr final : public
   // been initialized.
   MOZ_MUST_USE nsresult UpdateParam(nsParamName name, uint16_t value);
 
   // called from main thread to post a new request token bucket
   // to the socket thread
   MOZ_MUST_USE nsresult UpdateRequestTokenBucket(EventTokenBucket* aBucket);
 
   // clears the connection history mCT
-  MOZ_MUST_USE nsresult ClearConnectionHistory();
+  void ClearConnectionHistory();
 
   void ReportFailedToProcess(nsIURI* uri);
 
   // Causes a large amount of connection diagnostic information to be
   // printed to the javascript console
   void PrintDiagnostics();
 
   //-------------------------------------------------------------------------
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -2165,18 +2165,18 @@ nsHttpHandler::Observe(nsISupports* subj
   LOG(("nsHttpHandler::Observe [topic=\"%s\"]\n", topic));
 
   nsresult rv;
   if (!strcmp(topic, "profile-change-net-teardown") ||
       !strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
     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.
     gIOService->SetHttpHandlerAlreadyShutingDown();
 
     ShutdownConnectionManager();
 
     // need to reset the session start time since cache validation may
@@ -2201,18 +2201,18 @@ nsHttpHandler::Observe(nsISupports* subj
     } else {
       Telemetry::Accumulate(Telemetry::TCP_FAST_OPEN_STATUS, 4);
     }
   } else if (!strcmp(topic, "profile-change-net-restore")) {
     // initialize connection manager
     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);
     }
   } else if (!strcmp(topic, "net:prune-dead-connections")) {
     if (mConnMgr) {
       rv = mConnMgr->PruneDeadConnections();
       if (NS_FAILED(rv)) {
@@ -2235,17 +2235,17 @@ nsHttpHandler::Observe(nsISupports* subj
     }
 #if 0
     } else if (!strcmp(topic, "net:failed-to-process-uri-content")) {
          // nop right now - we used to cancel h1 pipelines based on this,
          // but those are no longer implemented
          nsCOMPtr<nsIURI> uri = do_QueryInterface(subject);
 #endif
   } else if (!strcmp(topic, "last-pb-context-exited")) {
-    Unused << mPrivateAuthCache.ClearAll();
+    mPrivateAuthCache.ClearAll();
     if (mConnMgr) {
       mConnMgr->ClearAltServiceMappings();
     }
   } else if (!strcmp(topic, "browser:purge-session-history")) {
     if (mConnMgr) {
       if (gSocketTransportService) {
         nsCOMPtr<nsIRunnable> event = NewRunnableMethod(
             "net::nsHttpConnectionMgr::ClearConnectionHistory", mConnMgr,
--- a/netwerk/protocol/http/nsHttpResponseHead.cpp
+++ b/netwerk/protocol/http/nsHttpResponseHead.cpp
@@ -836,17 +836,17 @@ bool nsHttpResponseHead::ExpiresInPast_l
   if (NS_SUCCEEDED(GetMaxAgeValue_locked(&maxAgeVal))) {
     return false;
   }
 
   return NS_SUCCEEDED(GetExpiresValue_locked(&expiresVal)) &&
          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);
   RecursiveMutexAutoLock monitorOther(aOther->mRecursiveMutex);
 
   uint32_t i, count = aOther->mHeaders.Count();
   for (i = 0; i < count; ++i) {
     nsHttpAtom header;
@@ -879,18 +879,16 @@ nsresult nsHttpResponseHead::UpdateHeade
       LOG(("new response header [%s: %s]\n", header.get(), val));
 
       // overwrite the current header value with the new value...
       DebugOnly<nsresult> rv =
           SetHeader_locked(header, headerNameOriginal, nsDependentCString(val));
       MOZ_ASSERT(NS_SUCCEEDED(rv));
     }
   }
-
-  return NS_OK;
 }
 
 void nsHttpResponseHead::Reset() {
   LOG(("nsHttpResponseHead::Reset\n"));
 
   RecursiveMutexAutoLock monitor(mRecursiveMutex);
 
   mHeaders.Clear();
--- a/netwerk/protocol/http/nsHttpResponseHead.h
+++ b/netwerk/protocol/http/nsHttpResponseHead.h
@@ -127,17 +127,17 @@ class nsHttpResponseHead {
   // returns true if the server appears to support byte range requests.
   bool IsResumable();
 
   // returns true if the Expires header has a value in the past relative to the
   // value of the Date header.
   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();
 
   MOZ_MUST_USE nsresult GetAgeValue(uint32_t* result);
   MOZ_MUST_USE nsresult GetMaxAgeValue(uint32_t* result);
   MOZ_MUST_USE nsresult GetStaleWhileRevalidateValue(uint32_t* result);
   MOZ_MUST_USE nsresult GetDateValue(uint32_t* result);
--- a/netwerk/streamconv/converters/nsDirIndexParser.cpp
+++ b/netwerk/streamconv/converters/nsDirIndexParser.cpp
@@ -106,17 +106,17 @@ nsDirIndexParser::Field nsDirIndexParser
     {"Last-Modified", FIELD_LASTMODIFIED},
     {"Content-Type", FIELD_CONTENTTYPE},
     {"File-Type", FIELD_FILETYPE},
     {nullptr, FIELD_UNKNOWN}};
 
 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;
   mFormat[0] = -1;
 
   do {
     while (*aFormatStr && nsCRT::IsAsciiSpace(char16_t(*aFormatStr)))
       ++aFormatStr;
@@ -141,48 +141,45 @@ nsresult nsDirIndexParser::ParseFormat(c
       if (name.EqualsIgnoreCase(i->mName)) {
         mFormat[formatNum] = i->mType;
         mFormat[++formatNum] = -1;
         break;
       }
     }
 
   } 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)) {
       ++aDataStr;
       --lineLen;
     }
 
     if (lineLen < 1) {
       // invalid format, bail
-      return NS_OK;
+      return;
     }
 
     char* value = aDataStr;
     if (*aDataStr == '"' || *aDataStr == '\'') {
       // it's a quoted string. snarf everything up to the next quote character
       const char quotechar = *(aDataStr++);
       lineLen--;
       ++value;
@@ -192,17 +189,17 @@ nsresult nsDirIndexParser::ParseData(nsI
       }
       if (lineLen > 0) {
         *aDataStr++ = '\0';
         --lineLen;
       }
 
       if (!lineLen) {
         // invalid format, bail
-        return NS_OK;
+        return;
       }
     } else {
       // it's unquoted. snarf until we see whitespace.
       value = aDataStr;
       while ((lineLen > 0) && (!nsCRT::IsAsciiSpace(*aDataStr))) {
         ++aDataStr;
         --lineLen;
       }
@@ -221,18 +218,18 @@ nsresult nsDirIndexParser::ParseData(nsI
         filename = value;
 
         bool success = false;
 
         nsAutoString entryuri;
 
         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);
               success = true;
             }
           } else {
             NS_WARNING("UnEscapeAndConvert error");
           }
@@ -284,18 +281,16 @@ nsresult nsDirIndexParser::ParseData(nsI
           aIdx->SetType(nsIDirIndex::TYPE_UNKNOWN);
         }
         break;
       case FIELD_UNKNOWN:
         // ignore
         break;
     }
   }
-
-  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDirIndexParser::OnDataAvailable(nsIRequest* aRequest, nsIInputStream* aStream,
                                   uint64_t aSourceOffset, uint32_t aCount) {
   if (aCount < 1) return NS_OK;
 
   int32_t len = mBuf.Length();
@@ -332,17 +327,16 @@ nsresult nsDirIndexParser::ProcessData(n
     mBuf.SetCharAt(char16_t('\0'), eol);
 
     const char* line = mBuf.get() + mLineStart;
 
     int32_t lineLen = eol - mLineStart;
     mLineStart = eol + 1;
 
     if (lineLen >= 4) {
-      nsresult rv;
       const char* buf = line;
 
       if (buf[0] == '1') {
         if (buf[1] == '0') {
           if (buf[2] == '0' && buf[3] == ':') {
             // 100. Human-readable comment line. Ignore
           } else if (buf[2] == '1' && buf[3] == ':') {
             // 101. Human-readable information line.
@@ -357,29 +351,22 @@ nsresult nsDirIndexParser::ProcessData(n
             // 102. Human-readable information line, HTML.
             mComment.Append(buf + 4);
           }
         }
       } else if (buf[0] == '2') {
         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);
           }
         }
       } else if (buf[0] == '3') {
         if (buf[1] == '0') {
           if (buf[2] == '0' && buf[3] == ':') {
             // 300. Self-referring URL
           } else if (buf[2] == '1' && buf[3] == ':') {
--- a/netwerk/streamconv/converters/nsDirIndexParser.h
+++ b/netwerk/streamconv/converters/nsDirIndexParser.h
@@ -53,18 +53,18 @@ class nsDirIndexParser : public nsIDirIn
   nsCString mEncoding;
   nsCString mComment;
   nsCString mBuf;
   int32_t mLineStart;
   bool mHasDescription;
   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;
     fieldType mType;
   };
 
   static Field gFieldTable[];