Bug 1186794 (part 6) - Replace nsBaseHashtable::EnumerateRead() calls in embedding/ with iterators. r=bz.

This commit is contained in:
Nicholas Nethercote 2015-11-01 18:42:54 -08:00
parent 0a79215646
commit 984587207a
2 changed files with 18 additions and 39 deletions

View File

@ -2426,16 +2426,28 @@ nsWebBrowserPersist::CalcTotalProgress()
mTotalCurrentProgress = 0;
mTotalMaxProgress = 0;
if (mOutputMap.Count() > 0)
{
if (mOutputMap.Count() > 0) {
// Total up the progress of each output stream
mOutputMap.EnumerateRead(EnumCalcProgress, this);
for (auto iter = mOutputMap.Iter(); !iter.Done(); iter.Next()) {
// Only count toward total progress if destination file is local.
OutputData* data = iter.UserData();
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(data->mFile);
if (fileURL) {
mTotalCurrentProgress += data->mSelfProgress;
mTotalMaxProgress += data->mSelfProgressMax;
}
}
}
if (mUploadList.Count() > 0)
{
if (mUploadList.Count() > 0) {
// Total up the progress of each upload
mUploadList.EnumerateRead(EnumCalcUploadProgress, this);
for (auto iter = mUploadList.Iter(); !iter.Done(); iter.Next()) {
UploadData* data = iter.UserData();
if (data) {
mTotalCurrentProgress += data->mSelfProgress;
mTotalMaxProgress += data->mSelfProgressMax;
}
}
}
// XXX this code seems pretty bogus and pointless
@ -2447,33 +2459,6 @@ nsWebBrowserPersist::CalcTotalProgress()
}
}
PLDHashOperator
nsWebBrowserPersist::EnumCalcProgress(nsISupports *aKey, OutputData *aData, void* aClosure)
{
nsWebBrowserPersist *pthis = static_cast<nsWebBrowserPersist*>(aClosure);
// only count toward total progress if destination file is local
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(aData->mFile);
if (fileURL)
{
pthis->mTotalCurrentProgress += aData->mSelfProgress;
pthis->mTotalMaxProgress += aData->mSelfProgressMax;
}
return PL_DHASH_NEXT;
}
PLDHashOperator
nsWebBrowserPersist::EnumCalcUploadProgress(nsISupports *aKey, UploadData *aData, void* aClosure)
{
if (aData && aClosure)
{
nsWebBrowserPersist *pthis = static_cast<nsWebBrowserPersist*>(aClosure);
pthis->mTotalCurrentProgress += aData->mSelfProgress;
pthis->mTotalMaxProgress += aData->mSelfProgressMax;
}
return PL_DHASH_NEXT;
}
nsresult
nsWebBrowserPersist::StoreURI(
const char *aURI, bool aNeedsPersisting, URIData **aData)

View File

@ -136,12 +136,6 @@ private:
void SetApplyConversionIfNeeded(nsIChannel *aChannel);
// Hash table enumerators
static PLDHashOperator EnumCalcProgress(
nsISupports *aKey, OutputData *aData, void* aClosure);
static PLDHashOperator EnumCalcUploadProgress(
nsISupports *aKey, UploadData *aData, void* aClosure);
nsCOMPtr<nsIURI> mCurrentDataPath;
bool mCurrentDataPathIsRelative;
nsCString mCurrentRelativePathToData;