From 2b65bd604786a26a2beb0e162426e2c70792d35e Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Mon, 19 Jan 2015 19:50:16 +0200 Subject: [PATCH] Bug 819090 - Replace nsVoidArray with nsTArray in netwerk/cache/. r=michal --- netwerk/cache/nsCacheEntryDescriptor.cpp | 11 +++++------ netwerk/cache/nsCacheEntryDescriptor.h | 5 ++--- netwerk/cache/nsCacheService.cpp | 17 +++++++---------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/netwerk/cache/nsCacheEntryDescriptor.cpp b/netwerk/cache/nsCacheEntryDescriptor.cpp index 4869fefdfd21..14de08411da3 100644 --- a/netwerk/cache/nsCacheEntryDescriptor.cpp +++ b/netwerk/cache/nsCacheEntryDescriptor.cpp @@ -99,7 +99,7 @@ nsCacheEntryDescriptor::~nsCacheEntryDescriptor() if (mCacheEntry) Close(); - NS_ASSERTION(mInputWrappers.Count() == 0, + NS_ASSERTION(mInputWrappers.IsEmpty(), "We have still some input wrapper!"); NS_ASSERTION(!mOutputWrapper, "We have still an output wrapper!"); @@ -565,9 +565,8 @@ nsCacheEntryDescriptor::Close() // Make sure no other stream can be opened mClosingDescriptor = true; outputWrapper = mOutputWrapper; - for (int32_t i = 0 ; i < mInputWrappers.Count() ; i++) - inputWrappers.AppendElement(static_cast( - mInputWrappers[i])); + for (size_t i = 0; i < mInputWrappers.Length(); i++) + inputWrappers.AppendElement(mInputWrappers[i]); } // Call Close() on the streams outside the lock since it might need to call @@ -678,7 +677,7 @@ nsCacheEntryDescriptor::nsInputStreamWrapper::Release() if (0 == count) { // don't use desc here since mDescriptor might be already nulled out if (mDescriptor) { - NS_ASSERTION(mDescriptor->mInputWrappers.IndexOf(this) != -1, + NS_ASSERTION(mDescriptor->mInputWrappers.Contains(this), "Wrapper not found in array!"); mDescriptor->mInputWrappers.RemoveElement(this); } @@ -872,7 +871,7 @@ nsCacheEntryDescriptor::nsDecompressInputStreamWrapper::Release() if (0 == count) { // don't use desc here since mDescriptor might be already nulled out if (mDescriptor) { - NS_ASSERTION(mDescriptor->mInputWrappers.IndexOf(this) != -1, + NS_ASSERTION(mDescriptor->mInputWrappers.Contains(this), "Wrapper not found in array!"); mDescriptor->mInputWrappers.RemoveElement(this); } diff --git a/netwerk/cache/nsCacheEntryDescriptor.h b/netwerk/cache/nsCacheEntryDescriptor.h index c443f728c693..34ada0569cbd 100644 --- a/netwerk/cache/nsCacheEntryDescriptor.h +++ b/netwerk/cache/nsCacheEntryDescriptor.h @@ -15,7 +15,6 @@ #include "nsCacheService.h" #include "zlib.h" #include "mozilla/Mutex.h" -#include "nsVoidArray.h" /****************************************************************************** * nsCacheEntryDescriptor @@ -45,7 +44,7 @@ public: nsCacheEntry * CacheEntry(void) { return mCacheEntry; } bool ClearCacheEntry(void) { - NS_ASSERTION(mInputWrappers.Count() == 0, "Bad state"); + NS_ASSERTION(mInputWrappers.IsEmpty(), "Bad state"); NS_ASSERTION(!mOutputWrapper, "Bad state"); bool doomEntry = false; @@ -226,7 +225,7 @@ private: */ nsCacheEntry * mCacheEntry; // we are a child of the entry nsCacheAccessMode mAccessGranted; - nsVoidArray mInputWrappers; + nsTArray mInputWrappers; nsOutputStreamWrapper * mOutputWrapper; mozilla::Mutex mLock; bool mAsyncDoomPending; diff --git a/netwerk/cache/nsCacheService.cpp b/netwerk/cache/nsCacheService.cpp index 164ed0f66e55..894ad9d7c951 100644 --- a/netwerk/cache/nsCacheService.cpp +++ b/netwerk/cache/nsCacheService.cpp @@ -33,7 +33,6 @@ #include "nsAppDirectoryServiceDefs.h" #include "nsThreadUtils.h" #include "nsProxyRelease.h" -#include "nsVoidArray.h" #include "nsDeleteDir.h" #include "nsNetCID.h" #include // for log() @@ -2967,7 +2966,7 @@ nsCacheService::GetActiveEntries(PLDHashTable * table, uint32_t number, void * arg) { - static_cast(arg)->AppendElement( + static_cast*>(arg)->AppendElement( ((nsCacheEntryHashTableEntry *)hdr)->cacheEntry); return PL_DHASH_NEXT; } @@ -3022,12 +3021,12 @@ nsCacheService::CloseAllStreams() { nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_CLOSEALLSTREAMS)); - nsVoidArray entries; + nsTArray entries; #if DEBUG // make sure there is no active entry mActiveEntries.VisitEntries(GetActiveEntries, &entries); - NS_ASSERTION(entries.Count() == 0, "Bad state"); + NS_ASSERTION(entries.IsEmpty(), "Bad state"); #endif // Get doomed entries @@ -3039,8 +3038,8 @@ nsCacheService::CloseAllStreams() } // Iterate through all entries and collect input and output streams - for (int32_t i = 0 ; i < entries.Count() ; i++) { - entry = static_cast(entries.ElementAt(i)); + for (size_t i = 0; i < entries.Length(); i++) { + entry = entries.ElementAt(i); nsTArray > descs; entry->GetDescriptors(descs); @@ -3049,10 +3048,8 @@ nsCacheService::CloseAllStreams() if (descs[j]->mOutputWrapper) outputs.AppendElement(descs[j]->mOutputWrapper); - for (int32_t k = 0 ; k < descs[j]->mInputWrappers.Count() ; k++) - inputs.AppendElement(static_cast< - nsCacheEntryDescriptor::nsInputStreamWrapper *>( - descs[j]->mInputWrappers[k])); + for (size_t k = 0; k < descs[j]->mInputWrappers.Length(); k++) + inputs.AppendElement(descs[j]->mInputWrappers[k]); } } }