Bug 1695162 - Use range-based for instead of custom hashtable iterators. r=xpcom-reviewers,kmag

Differential Revision: https://phabricator.services.mozilla.com/D108585
This commit is contained in:
Simon Giesecke 2021-03-17 15:49:46 +00:00
Родитель 07e9a5b088
Коммит b9621d6376
87 изменённых файлов: 555 добавлений и 550 удалений

Просмотреть файл

@ -234,10 +234,10 @@ void nsChromeRegistryChrome::SendRegisteredChrome(
nsTArray<SubstitutionMapping> resources;
nsTArray<OverrideMapping> overrides;
for (auto iter = mPackagesHash.Iter(); !iter.Done(); iter.Next()) {
for (const auto& entry : mPackagesHash) {
ChromePackage chromePackage;
ChromePackageFromPackageEntry(iter.Key(), iter.UserData(), &chromePackage,
SKIN);
ChromePackageFromPackageEntry(entry.GetKey(), entry.GetWeak(),
&chromePackage, SKIN);
packages.AppendElement(chromePackage);
}
@ -258,14 +258,14 @@ void nsChromeRegistryChrome::SendRegisteredChrome(
NS_ENSURE_SUCCESS_VOID(rv);
}
for (auto iter = mOverrideTable.Iter(); !iter.Done(); iter.Next()) {
for (const auto& entry : mOverrideTable) {
SerializedURI chromeURI, overrideURI;
SerializeURI(iter.Key(), chromeURI);
SerializeURI(iter.UserData(), overrideURI);
SerializeURI(entry.GetKey(), chromeURI);
SerializeURI(entry.GetWeak(), overrideURI);
OverrideMapping override = {chromeURI, overrideURI};
overrides.AppendElement(override);
overrides.AppendElement(
OverrideMapping{std::move(chromeURI), std::move(overrideURI)});
}
nsAutoCString appLocale;

Просмотреть файл

@ -395,8 +395,8 @@ BrowsingContextGroup* BrowsingContextGroup::GetChromeGroup() {
void BrowsingContextGroup::GetDocGroups(nsTArray<DocGroup*>& aDocGroups) {
MOZ_ASSERT(NS_IsMainThread());
for (auto iter = mDocGroups.ConstIter(); !iter.Done(); iter.Next()) {
aDocGroups.AppendElement(iter.Data());
for (const auto& entry : mDocGroups) {
aDocGroups.AppendElement(entry.GetData());
}
}

Просмотреть файл

@ -140,8 +140,6 @@ class BrowsingContextGroup final : public nsWrapperCache {
// Called by Document when a Document needs to be removed to a DocGroup.
void RemoveDocument(const nsACString& aKey, Document* aDocument);
auto DocGroups() const { return mDocGroups.ConstIter(); }
mozilla::ThrottledEventQueue* GetTimerEventQueue() const {
return mTimerEventQueue;
}

Просмотреть файл

@ -412,8 +412,8 @@ RefPtr<ClientOpPromise> ClientManagerService::MatchAll(
RefPtr<PromiseListHolder> promiseList = new PromiseListHolder();
for (auto iter = mSourceTable.Iter(); !iter.Done(); iter.Next()) {
ClientSourceParent* source = iter.UserData();
for (const auto& entry : mSourceTable) {
ClientSourceParent* source = entry.GetWeak();
MOZ_DIAGNOSTIC_ASSERT(source);
if (source->IsFrozen() || !source->ExecutionReady()) {
@ -508,8 +508,8 @@ RefPtr<ClientOpPromise> ClientManagerService::Claim(
RefPtr<PromiseListHolder> promiseList = new PromiseListHolder();
for (auto iter = mSourceTable.Iter(); !iter.Done(); iter.Next()) {
ClientSourceParent* source = iter.UserData();
for (const auto& entry : mSourceTable) {
ClientSourceParent* source = entry.GetWeak();
MOZ_DIAGNOSTIC_ASSERT(source);
if (source->IsFrozen()) {

Просмотреть файл

@ -34,8 +34,8 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsCommandManager)
NS_IMPL_CYCLE_COLLECTION_UNLINK_WEAK_REFERENCE
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsCommandManager)
for (auto iter = tmp->mObserversTable.Iter(); !iter.Done(); iter.Next()) {
nsCommandManager::ObserverList* observers = iter.UserData();
for (const auto& entry : tmp->mObserversTable) {
nsCommandManager::ObserverList* observers = entry.GetWeak();
int32_t numItems = observers->Length();
for (int32_t i = 0; i < numItems; ++i) {
cb.NoteXPCOMChild(observers->ElementAt(i));

Просмотреть файл

@ -5543,7 +5543,7 @@ bool EventStateManager::SetContentState(nsIContent* aContent,
}
void EventStateManager::ResetLastOverForContent(
const uint32_t& aIdx, RefPtr<OverOutElementsWrapper>& aElemWrapper,
const uint32_t& aIdx, const RefPtr<OverOutElementsWrapper>& aElemWrapper,
nsIContent* aContent) {
if (aElemWrapper && aElemWrapper->mLastOverElement &&
nsContentUtils::ContentIsFlattenedTreeDescendantOf(
@ -5649,9 +5649,8 @@ void EventStateManager::ContentRemoved(Document* aDocument,
// See bug 292146 for why we want to null this out
ResetLastOverForContent(0, mMouseEnterLeaveHelper, aContent);
for (auto iter = mPointersEnterLeaveHelper.Iter(); !iter.Done();
iter.Next()) {
ResetLastOverForContent(iter.Key(), iter.Data(), aContent);
for (const auto& entry : mPointersEnterLeaveHelper) {
ResetLastOverForContent(entry.GetKey(), entry.GetData(), aContent);
}
}

Просмотреть файл

@ -1105,9 +1105,9 @@ class EventStateManager : public nsSupportsWeakReference, public nsIObserver {
static void UpdateAncestorState(nsIContent* aStartNode,
nsIContent* aStopBefore, EventStates aState,
bool aAddState);
static void ResetLastOverForContent(const uint32_t& aIdx,
RefPtr<OverOutElementsWrapper>& aChunk,
nsIContent* aClosure);
static void ResetLastOverForContent(
const uint32_t& aIdx, const RefPtr<OverOutElementsWrapper>& aChunk,
nsIContent* aClosure);
/**
* Update the attribute mLastRefPoint of the mouse event. It should be

Просмотреть файл

@ -182,10 +182,10 @@ void PointerEventHandler::ReleasePointerCaptureById(uint32_t aPointerId) {
/* static */
void PointerEventHandler::ReleaseAllPointerCapture() {
for (auto iter = sPointerCaptureList->Iter(); !iter.Done(); iter.Next()) {
PointerCaptureInfo* data = iter.UserData();
for (const auto& entry : *sPointerCaptureList) {
PointerCaptureInfo* data = entry.GetWeak();
if (data && data->mPendingElement) {
ReleasePointerCaptureById(iter.Key());
ReleasePointerCaptureById(entry.GetKey());
}
}
}
@ -444,11 +444,11 @@ Element* PointerEventHandler::GetPointerCapturingElement(
void PointerEventHandler::ReleaseIfCaptureByDescendant(nsIContent* aContent) {
// We should check that aChild does not contain pointer capturing elements.
// If it does we should release the pointer capture for the elements.
for (auto iter = sPointerCaptureList->Iter(); !iter.Done(); iter.Next()) {
PointerCaptureInfo* data = iter.UserData();
for (const auto& entry : *sPointerCaptureList) {
PointerCaptureInfo* data = entry.GetWeak();
if (data && data->mPendingElement &&
data->mPendingElement->IsInclusiveDescendantOf(aContent)) {
ReleasePointerCaptureById(iter.Key());
ReleasePointerCaptureById(entry.GetKey());
}
}
}

Просмотреть файл

@ -189,23 +189,23 @@ class BlobURLsReporter final : public nsIMemoryReporter {
// Determine number of URLs per mozilla::dom::BlobImpl, to handle the case
// where it's > 1.
for (auto iter = gDataTable->Iter(); !iter.Done(); iter.Next()) {
if (iter.UserData()->mObjectType != mozilla::dom::DataInfo::eBlobImpl) {
for (const auto& entry : *gDataTable) {
if (entry.GetWeak()->mObjectType != mozilla::dom::DataInfo::eBlobImpl) {
continue;
}
mozilla::dom::BlobImpl* blobImpl = iter.UserData()->mBlobImpl;
mozilla::dom::BlobImpl* blobImpl = entry.GetWeak()->mBlobImpl;
MOZ_ASSERT(blobImpl);
refCounts.LookupOrInsert(blobImpl, 0) += 1;
}
for (auto iter = gDataTable->Iter(); !iter.Done(); iter.Next()) {
nsCStringHashKey::KeyType key = iter.Key();
mozilla::dom::DataInfo* info = iter.UserData();
for (const auto& entry : *gDataTable) {
nsCStringHashKey::KeyType key = entry.GetKey();
mozilla::dom::DataInfo* info = entry.GetWeak();
if (iter.UserData()->mObjectType == mozilla::dom::DataInfo::eBlobImpl) {
mozilla::dom::BlobImpl* blobImpl = iter.UserData()->mBlobImpl;
if (entry.GetWeak()->mObjectType == mozilla::dom::DataInfo::eBlobImpl) {
mozilla::dom::BlobImpl* blobImpl = entry.GetWeak()->mBlobImpl;
MOZ_ASSERT(blobImpl);
constexpr auto desc =
@ -606,8 +606,8 @@ bool BlobURLProtocolHandler::ForEachBlobURL(
return false;
}
for (auto iter = gDataTable->ConstIter(); !iter.Done(); iter.Next()) {
mozilla::dom::DataInfo* info = iter.UserData();
for (const auto& entry : *gDataTable) {
mozilla::dom::DataInfo* info = entry.GetWeak();
MOZ_ASSERT(info);
if (info->mObjectType != mozilla::dom::DataInfo::eBlobImpl) {
@ -616,7 +616,7 @@ bool BlobURLProtocolHandler::ForEachBlobURL(
MOZ_ASSERT(info->mBlobImpl);
if (!aCb(info->mBlobImpl, info->mPrincipal, info->mAgentClusterId,
iter.Key(), info->mRevoked)) {
entry.GetKey(), info->mRevoked)) {
return false;
}
}

Просмотреть файл

@ -624,8 +624,8 @@ void GamepadManager::StopHaptics() {
return;
}
for (auto iter = mGamepads.Iter(); !iter.Done(); iter.Next()) {
const GamepadHandle handle = iter.UserData()->GetHandle();
for (const auto& entry : mGamepads) {
const GamepadHandle handle = entry.GetWeak()->GetHandle();
if (handle.GetKind() == GamepadHandleKind::VR) {
if (gfx::VRManagerChild::IsCreated()) {
gfx::VRManagerChild* vm = gfx::VRManagerChild::Get();

Просмотреть файл

@ -3358,12 +3358,12 @@ void HTMLMediaElement::MozGetMetadata(JSContext* cx,
return;
}
if (mTags) {
for (auto iter = mTags->ConstIter(); !iter.Done(); iter.Next()) {
for (const auto& entry : *mTags) {
nsString wideValue;
CopyUTF8toUTF16(iter.UserData(), wideValue);
CopyUTF8toUTF16(entry.GetData(), wideValue);
JS::Rooted<JSString*> string(cx,
JS_NewUCStringCopyZ(cx, wideValue.Data()));
if (!string || !JS_DefineProperty(cx, tags, iter.Key().Data(), string,
if (!string || !JS_DefineProperty(cx, tags, entry.GetKey().Data(), string,
JSPROP_ENUMERATE)) {
NS_WARNING("couldn't create metadata object!");
aRv.Throw(NS_ERROR_FAILURE);
@ -3963,15 +3963,14 @@ static unsigned MediaElementTableCount(HTMLMediaElement* aElement,
}
uint32_t uriCount = 0;
uint32_t otherCount = 0;
for (auto it = gElementTable->ConstIter(); !it.Done(); it.Next()) {
const MediaElementSetForURI* entry = it.Get();
for (const auto& entry : *gElementTable) {
uint32_t count = 0;
for (const auto& elem : entry->mElements) {
for (const auto& elem : entry.mElements) {
if (elem == aElement) {
count++;
}
}
if (URISafeEquals(aURI, entry->GetKey())) {
if (URISafeEquals(aURI, entry.GetKey())) {
uriCount = count;
} else {
otherCount += count;

Просмотреть файл

@ -616,11 +616,10 @@ bool nsHTMLDocument::ResolveName(JSContext* aCx, const nsAString& aName,
}
void nsHTMLDocument::GetSupportedNames(nsTArray<nsString>& aNames) {
for (auto iter = mIdentifierMap.Iter(); !iter.Done(); iter.Next()) {
IdentifierMapEntry* entry = iter.Get();
if (entry->HasNameElement() ||
entry->HasIdElementExposedAsHTMLDocumentProperty()) {
aNames.AppendElement(entry->GetKeyAsString());
for (const auto& entry : mIdentifierMap) {
if (entry.HasNameElement() ||
entry.HasIdElementExposedAsHTMLDocumentProperty()) {
aNames.AppendElement(entry.GetKeyAsString());
}
}
}

Просмотреть файл

@ -2262,7 +2262,7 @@ void MediaManager::DeviceListChanged() {
// mActiveWindows and will assert-crash since the iterator is
// active and the table is being enumerated.
nsTArray<RefPtr<GetUserMediaWindowListener>> stopListeners;
for (auto iter = mActiveWindows.Iter(); !iter.Done();
for (auto iter = mActiveWindows.ConstIter(); !iter.Done();
iter.Next()) {
stopListeners.AppendElement(iter.UserData());
}
@ -3299,7 +3299,7 @@ void MediaManager::OnCameraMute(bool aMute) {
mCamerasMuted = aMute;
// This is safe since we're on main-thread, and the windowlist can only
// be added to from the main-thread
for (auto iter = mActiveWindows.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mActiveWindows.ConstIter(); !iter.Done(); iter.Next()) {
iter.UserData()->MuteOrUnmuteCameras(aMute);
}
}
@ -3310,7 +3310,7 @@ void MediaManager::OnMicrophoneMute(bool aMute) {
mMicrophonesMuted = aMute;
// This is safe since we're on main-thread, and the windowlist can only
// be added to from the main-thread
for (auto iter = mActiveWindows.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mActiveWindows.ConstIter(); !iter.Done(); iter.Next()) {
iter.UserData()->MuteOrUnmuteMicrophones(aMute);
}
}
@ -3508,7 +3508,8 @@ void MediaManager::Shutdown() {
// listeners first.
nsTArray<RefPtr<GetUserMediaWindowListener>> listeners(
GetActiveWindows()->Count());
for (auto iter = GetActiveWindows()->Iter(); !iter.Done(); iter.Next()) {
for (auto iter = GetActiveWindows()->ConstIter(); !iter.Done();
iter.Next()) {
listeners.AppendElement(iter.UserData());
}
for (auto& listener : listeners) {
@ -3811,9 +3812,9 @@ nsresult MediaManager::GetActiveMediaCaptureWindows(nsIArray** aArray) {
nsCOMPtr<nsIMutableArray> array = nsArray::Create();
for (auto iter = mActiveWindows.Iter(); !iter.Done(); iter.Next()) {
const uint64_t& id = iter.Key();
RefPtr<GetUserMediaWindowListener> winListener = iter.UserData();
for (const auto& entry : mActiveWindows) {
const uint64_t& id = entry.GetKey();
RefPtr<GetUserMediaWindowListener> winListener = entry.GetData();
if (!winListener) {
continue;
}

Просмотреть файл

@ -685,9 +685,9 @@ void MediaTrackGraphImpl::CloseAudioInputImpl(
MOZ_ASSERT(OnGraphThread());
// It is possible to not know the ID here, find it first.
if (aID.isNothing()) {
for (auto iter = mInputDeviceUsers.Iter(); !iter.Done(); iter.Next()) {
if (iter.Data().Contains(aListener)) {
aID = Some(iter.Key());
for (const auto& entry : mInputDeviceUsers) {
if (entry.GetData().Contains(aListener)) {
aID = Some(entry.GetKey());
}
}
MOZ_ASSERT(aID.isSome(), "Closing an audio input that was not opened.");

Просмотреть файл

@ -662,8 +662,8 @@ UniquePtr<TrackInfo> FlacTrackDemuxer::GetInfo() const {
UniquePtr<TrackInfo> info = mParser->Info().Clone();
UniquePtr<MetadataTags> tags(mParser->GetTags());
if (tags) {
for (auto iter = tags->Iter(); !iter.Done(); iter.Next()) {
info->mTags.AppendElement(MetadataTag(iter.Key(), iter.Data()));
for (const auto& entry : *tags) {
info->mTags.AppendElement(MetadataTag(entry.GetKey(), entry.GetData()));
}
}
return info;

Просмотреть файл

@ -457,8 +457,8 @@ void OggDemuxer::FillTags(TrackInfo* aInfo, UniquePtr<MetadataTags>&& aTags) {
return;
}
UniquePtr<MetadataTags> tags(std::move(aTags));
for (auto iter = tags->Iter(); !iter.Done(); iter.Next()) {
aInfo->mTags.AppendElement(MetadataTag(iter.Key(), iter.Data()));
for (const auto& entry : *tags) {
aInfo->mTags.AppendElement(MetadataTag(entry.GetKey(), entry.GetData()));
}
}

Просмотреть файл

@ -290,9 +290,9 @@ class OriginKeyStore : public nsISupports {
if (count != versionBuffer.Length()) {
return NS_ERROR_UNEXPECTED;
}
for (auto iter = mKeys.Iter(); !iter.Done(); iter.Next()) {
const nsACString& origin = iter.Key();
OriginKey* originKey = iter.UserData();
for (const auto& entry : mKeys) {
const nsACString& origin = entry.GetKey();
OriginKey* originKey = entry.GetWeak();
if (!originKey->mSecondsStamp) {
continue; // don't write temporal ones

Просмотреть файл

@ -415,14 +415,14 @@ void SpeechDispatcherService::Setup() {
void SpeechDispatcherService::RegisterVoices() {
RefPtr<nsSynthVoiceRegistry> registry = nsSynthVoiceRegistry::GetInstance();
for (auto iter = mVoices.Iter(); !iter.Done(); iter.Next()) {
RefPtr<SpeechDispatcherVoice>& voice = iter.Data();
for (const auto& entry : mVoices) {
const RefPtr<SpeechDispatcherVoice>& voice = entry.GetData();
// This service can only speak one utterance at a time, so we set
// aQueuesUtterances to true in order to track global state and schedule
// access to this service.
DebugOnly<nsresult> rv =
registry->AddVoice(this, iter.Key(), voice->mName, voice->mLanguage,
registry->AddVoice(this, entry.GetKey(), voice->mName, voice->mLanguage,
voice->mName.EqualsLiteral("default"), true);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to add voice");

Просмотреть файл

@ -3685,10 +3685,9 @@ void PluginInstanceChild::ClearAllSurfaces() {
}
static void InvalidateObjects(nsTHashtable<DeletingObjectEntry>& aEntries) {
for (auto iter = aEntries.Iter(); !iter.Done(); iter.Next()) {
DeletingObjectEntry* e = iter.Get();
NPObject* o = e->GetKey();
if (!e->mDeleted && o->_class && o->_class->invalidate) {
for (const auto& e : aEntries) {
NPObject* o = e.GetKey();
if (!e.mDeleted && o->_class && o->_class->invalidate) {
o->_class->invalidate(o);
}
}

Просмотреть файл

@ -321,16 +321,16 @@ LocalStorageManager::IsPreloaded(nsIPrincipal* aPrincipal, JSContext* aContext,
void LocalStorageManager::ClearCaches(uint32_t aUnloadFlags,
const OriginAttributesPattern& aPattern,
const nsACString& aOriginScope) {
for (auto iter1 = mCaches.Iter(); !iter1.Done(); iter1.Next()) {
for (const auto& cacheEntry : mCaches) {
OriginAttributes oa;
DebugOnly<bool> rv = oa.PopulateFromSuffix(iter1.Key());
DebugOnly<bool> rv = oa.PopulateFromSuffix(cacheEntry.GetKey());
MOZ_ASSERT(rv);
if (!aPattern.Matches(oa)) {
// This table doesn't match the given origin attributes pattern
continue;
}
CacheOriginHashtable* table = iter1.UserData();
CacheOriginHashtable* table = cacheEntry.GetWeak();
for (auto iter2 = table->Iter(); !iter2.Done(); iter2.Next()) {
LocalStorageCache* cache = iter2.Get()->cache();

Просмотреть файл

@ -111,7 +111,8 @@ uint32_t SessionStorageCache::Length(DataSetType aDataSetType) {
void SessionStorageCache::Key(DataSetType aDataSetType, uint32_t aIndex,
nsAString& aResult) {
aResult.SetIsVoid(true);
for (auto iter = Set(aDataSetType)->mKeys.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = Set(aDataSetType)->mKeys.ConstIter(); !iter.Done();
iter.Next()) {
if (aIndex == 0) {
aResult = iter.Key();
return;
@ -132,7 +133,8 @@ void SessionStorageCache::GetItem(DataSetType aDataSetType,
void SessionStorageCache::GetKeys(DataSetType aDataSetType,
nsTArray<nsString>& aKeys) {
for (auto iter = Set(aDataSetType)->mKeys.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = Set(aDataSetType)->mKeys.ConstIter(); !iter.Done();
iter.Next()) {
aKeys.AppendElement(iter.Key());
}
}
@ -223,15 +225,19 @@ already_AddRefed<SessionStorageCache> SessionStorageCache::Clone() const {
RefPtr<SessionStorageCache> cache = new SessionStorageCache();
cache->mDefaultSet.mOriginQuotaUsage = mDefaultSet.mOriginQuotaUsage;
for (auto iter = mDefaultSet.mKeys.ConstIter(); !iter.Done(); iter.Next()) {
cache->mDefaultSet.mKeys.InsertOrUpdate(iter.Key(), iter.Data());
cache->mDefaultSet.mWriteOptimizer.InsertItem(iter.Key(), iter.Data());
for (const auto& keyEntry : mDefaultSet.mKeys) {
cache->mDefaultSet.mKeys.InsertOrUpdate(keyEntry.GetKey(),
keyEntry.GetData());
cache->mDefaultSet.mWriteOptimizer.InsertItem(keyEntry.GetKey(),
keyEntry.GetData());
}
cache->mSessionSet.mOriginQuotaUsage = mSessionSet.mOriginQuotaUsage;
for (auto iter = mSessionSet.mKeys.ConstIter(); !iter.Done(); iter.Next()) {
cache->mSessionSet.mKeys.InsertOrUpdate(iter.Key(), iter.Data());
cache->mSessionSet.mWriteOptimizer.InsertItem(iter.Key(), iter.Data());
for (const auto& keyEntry : mSessionSet.mKeys) {
cache->mSessionSet.mKeys.InsertOrUpdate(keyEntry.GetKey(),
keyEntry.GetData());
cache->mSessionSet.mWriteOptimizer.InsertItem(keyEntry.GetKey(),
keyEntry.GetData());
}
return cache.forget();
@ -240,11 +246,8 @@ already_AddRefed<SessionStorageCache> SessionStorageCache::Clone() const {
nsTArray<SSSetItemInfo> SessionStorageCache::SerializeData(
DataSetType aDataSetType) {
nsTArray<SSSetItemInfo> data;
for (auto iter = Set(aDataSetType)->mKeys.Iter(); !iter.Done(); iter.Next()) {
SSSetItemInfo keyValuePair;
keyValuePair.key() = iter.Key();
keyValuePair.value() = iter.Data();
data.EmplaceBack(std::move(keyValuePair));
for (const auto& keyEntry : Set(aDataSetType)->mKeys) {
data.EmplaceBack(nsString{keyEntry.GetKey()}, keyEntry.GetData());
}
return data;
}

Просмотреть файл

@ -492,20 +492,20 @@ void SessionStorageManager::ClearStorages(
}
}
for (auto iter1 = mOATable.Iter(); !iter1.Done(); iter1.Next()) {
for (const auto& oaEntry : mOATable) {
OriginAttributes oa;
DebugOnly<bool> ok = oa.PopulateFromSuffix(iter1.Key());
DebugOnly<bool> ok = oa.PopulateFromSuffix(oaEntry.GetKey());
MOZ_ASSERT(ok);
if (!aPattern.Matches(oa)) {
// This table doesn't match the given origin attributes pattern
continue;
}
OriginKeyHashTable* table = iter1.UserData();
for (auto iter2 = table->Iter(); !iter2.Done(); iter2.Next()) {
OriginKeyHashTable* table = oaEntry.GetWeak();
for (const auto& originKeyEntry : *table) {
if (aOriginScope.IsEmpty() ||
StringBeginsWith(iter2.Key(), aOriginScope)) {
const auto cache = iter2.Data()->mCache;
StringBeginsWith(originKeyEntry.GetKey(), aOriginScope)) {
const auto cache = originKeyEntry.GetData()->mCache;
if (aType == eAll) {
cache->Clear(SessionStorageCache::eDefaultSetType, false);
cache->Clear(SessionStorageCache::eSessionSetType, false);
@ -516,8 +516,8 @@ void SessionStorageManager::ClearStorages(
if (CanLoadData()) {
MOZ_ASSERT(ActorExists());
CheckpointDataInternal(nsCString{iter1.Key()}, nsCString{iter2.Key()},
*cache);
CheckpointDataInternal(nsCString{oaEntry.GetKey()},
nsCString{originKeyEntry.GetKey()}, *cache);
}
}
}

Просмотреть файл

@ -259,10 +259,10 @@ StorageActivityService::GetActiveOrigins(PRTime aFrom, PRTime aTo,
return rv;
}
for (auto iter = mActivities.Iter(); !iter.Done(); iter.Next()) {
if (iter.UserData() >= aFrom && iter.UserData() <= aTo) {
for (const auto& activityEntry : mActivities) {
if (activityEntry.GetData() >= aFrom && activityEntry.GetData() <= aTo) {
RefPtr<BasePrincipal> principal =
BasePrincipal::CreateContentPrincipal(iter.Key());
BasePrincipal::CreateContentPrincipal(activityEntry.GetKey());
MOZ_ASSERT(principal);
rv = devices->AppendElement(principal);

Просмотреть файл

@ -691,11 +691,11 @@ void nsWebBrowserPersist::SerializeNextFile() {
// mTargetBaseURI is used to create the relative URLs and will be different
// with each serialized document.
RefPtr<FlatURIMap> flatMap = new FlatURIMap(targetBaseSpec);
for (auto iter = mURIMap.Iter(); !iter.Done(); iter.Next()) {
for (const auto& uriEntry : mURIMap) {
nsAutoCString mapTo;
nsresult rv = iter.UserData()->GetLocalURI(mTargetBaseURI, mapTo);
nsresult rv = uriEntry.GetWeak()->GetLocalURI(mTargetBaseURI, mapTo);
if (NS_SUCCEEDED(rv) || !mapTo.IsVoid()) {
flatMap->Add(iter.Key(), mapTo);
flatMap->Add(uriEntry.GetKey(), mapTo);
}
}
mFlatURIMap = std::move(flatMap);
@ -1824,7 +1824,7 @@ void nsWebBrowserPersist::Cleanup() {
MutexAutoLock lock(mOutputMapMutex);
mOutputMap.SwapElements(outputMapCopy);
}
for (auto iter = outputMapCopy.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = outputMapCopy.ConstIter(); !iter.Done(); iter.Next()) {
nsCOMPtr<nsIChannel> channel = do_QueryInterface(iter.Key());
if (channel) {
channel->Cancel(NS_BINDING_ABORTED);
@ -1832,7 +1832,7 @@ void nsWebBrowserPersist::Cleanup() {
}
outputMapCopy.Clear();
for (auto iter = mUploadList.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mUploadList.ConstIter(); !iter.Done(); iter.Next()) {
nsCOMPtr<nsIChannel> channel = do_QueryInterface(iter.Key());
if (channel) {
channel->Cancel(NS_BINDING_ABORTED);
@ -2379,7 +2379,7 @@ nsresult nsWebBrowserPersist::FixRedirectedChannelEntry(
nsCOMPtr<nsIURI> originalURI;
aNewChannel->GetOriginalURI(getter_AddRefs(originalURI));
nsISupports* matchingKey = nullptr;
for (auto iter = mOutputMap.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mOutputMap.ConstIter(); !iter.Done(); iter.Next()) {
nsISupports* key = iter.Key();
nsCOMPtr<nsIChannel> thisChannel = do_QueryInterface(key);
nsCOMPtr<nsIURI> thisURI;
@ -2421,7 +2421,7 @@ void nsWebBrowserPersist::CalcTotalProgress() {
if (mOutputMap.Count() > 0) {
// Total up the progress of each output stream
for (auto iter = mOutputMap.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mOutputMap.ConstIter(); !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);
@ -2434,7 +2434,7 @@ void nsWebBrowserPersist::CalcTotalProgress() {
if (mUploadList.Count() > 0) {
// Total up the progress of each upload
for (auto iter = mUploadList.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mUploadList.ConstIter(); !iter.Done(); iter.Next()) {
UploadData* data = iter.UserData();
if (data) {
mTotalCurrentProgress += data->mSelfProgress;

Просмотреть файл

@ -627,7 +627,8 @@ PermissionManager::PermissionManager()
PermissionManager::~PermissionManager() {
// NOTE: Make sure to reject each of the promises in mPermissionKeyPromiseMap
// before destroying.
for (auto iter = mPermissionKeyPromiseMap.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mPermissionKeyPromiseMap.ConstIter(); !iter.Done();
iter.Next()) {
if (iter.Data()) {
iter.Data()->Reject(NS_ERROR_FAILURE, __func__);
}
@ -1946,16 +1947,15 @@ nsresult PermissionManager::RemovePermissionEntries(T aCondition) {
EnsureReadCompleted();
Vector<Tuple<nsCOMPtr<nsIPrincipal>, nsCString, nsCString>, 10> array;
for (auto iter = mPermissionTable.Iter(); !iter.Done(); iter.Next()) {
PermissionHashKey* entry = iter.Get();
for (const auto& permEntry : entry->GetPermissions()) {
for (const PermissionHashKey& entry : mPermissionTable) {
for (const auto& permEntry : entry.GetPermissions()) {
if (!aCondition(permEntry)) {
continue;
}
nsCOMPtr<nsIPrincipal> principal;
nsresult rv = GetPrincipalFromOrigin(
entry->GetKey()->mOrigin,
entry.GetKey()->mOrigin,
IsOAForceStripPermission(mTypeArray[permEntry.mType]),
getter_AddRefs(principal));
if (NS_FAILED(rv)) {
@ -1963,7 +1963,7 @@ nsresult PermissionManager::RemovePermissionEntries(T aCondition) {
}
if (!array.emplaceBack(principal, mTypeArray[permEntry.mType],
entry->GetKey()->mOrigin)) {
entry.GetKey()->mOrigin)) {
continue;
}
}
@ -2259,9 +2259,8 @@ nsresult PermissionManager::GetPermissionEntries(
EnsureReadCompleted();
for (auto iter = mPermissionTable.Iter(); !iter.Done(); iter.Next()) {
PermissionHashKey* entry = iter.Get();
for (const auto& permEntry : entry->GetPermissions()) {
for (const PermissionHashKey& entry : mPermissionTable) {
for (const auto& permEntry : entry.GetPermissions()) {
// Given how "default" permissions work and the possibility of them being
// overridden with UNKNOWN_ACTION, we might see this value here - but we
// do *not* want to return them via the enumerator.
@ -2282,7 +2281,7 @@ nsresult PermissionManager::GetPermissionEntries(
nsCOMPtr<nsIPrincipal> principal;
nsresult rv = GetPrincipalFromOrigin(
entry->GetKey()->mOrigin,
entry.GetKey()->mOrigin,
IsOAForceStripPermission(mTypeArray[permEntry.mType]),
getter_AddRefs(principal));
if (NS_FAILED(rv)) {
@ -2462,11 +2461,9 @@ nsresult PermissionManager::RemovePermissionsWithAttributes(
EnsureReadCompleted();
Vector<Tuple<nsCOMPtr<nsIPrincipal>, nsCString, nsCString>, 10> permissions;
for (auto iter = mPermissionTable.Iter(); !iter.Done(); iter.Next()) {
PermissionHashKey* entry = iter.Get();
for (const PermissionHashKey& entry : mPermissionTable) {
nsCOMPtr<nsIPrincipal> principal;
nsresult rv = GetPrincipalFromOrigin(entry->GetKey()->mOrigin, false,
nsresult rv = GetPrincipalFromOrigin(entry.GetKey()->mOrigin, false,
getter_AddRefs(principal));
if (NS_FAILED(rv)) {
continue;
@ -2476,9 +2473,9 @@ nsresult PermissionManager::RemovePermissionsWithAttributes(
continue;
}
for (const auto& permEntry : entry->GetPermissions()) {
for (const auto& permEntry : entry.GetPermissions()) {
if (!permissions.emplaceBack(principal, mTypeArray[permEntry.mType],
entry->GetKey()->mOrigin)) {
entry.GetKey()->mOrigin)) {
continue;
}
}
@ -2977,14 +2974,12 @@ bool PermissionManager::GetPermissionsFromOriginOrKey(
return false;
}
for (auto iter = mPermissionTable.Iter(); !iter.Done(); iter.Next()) {
PermissionHashKey* entry = iter.Get();
for (const PermissionHashKey& entry : mPermissionTable) {
nsAutoCString permissionKey;
if (aOrigin.IsEmpty()) {
// We can't check for individual OA strip perms here.
// Don't force strip origin attributes.
GetKeyForOrigin(entry->GetKey()->mOrigin, false, permissionKey);
GetKeyForOrigin(entry.GetKey()->mOrigin, false, permissionKey);
// If the keys don't match, and we aren't getting the default "" key, then
// we can exit early. We have to keep looking if we're getting the default
@ -2992,14 +2987,14 @@ bool PermissionManager::GetPermissionsFromOriginOrKey(
if (aKey != permissionKey && !aKey.IsEmpty()) {
continue;
}
} else if (aOrigin != entry->GetKey()->mOrigin) {
} else if (aOrigin != entry.GetKey()->mOrigin) {
// If the origins don't match, then we can exit early. We have to keep
// looking if we're getting the default origin, as we may see a preload
// permission which should be transmitted.
continue;
}
for (const auto& permEntry : entry->GetPermissions()) {
for (const auto& permEntry : entry.GetPermissions()) {
// Given how "default" permissions work and the possibility of them
// being overridden with UNKNOWN_ACTION, we might see this value here -
// but we do not want to send it to the content process.
@ -3013,11 +3008,11 @@ bool PermissionManager::GetPermissionsFromOriginOrKey(
shouldAppend = (isPreload && aKey.IsEmpty()) ||
(!isPreload && aKey == permissionKey);
} else {
shouldAppend = (!isPreload && aOrigin == entry->GetKey()->mOrigin);
shouldAppend = (!isPreload && aOrigin == entry.GetKey()->mOrigin);
}
if (shouldAppend) {
aPerms.AppendElement(
IPC::Permission(entry->GetKey()->mOrigin,
IPC::Permission(entry.GetKey()->mOrigin,
mTypeArray[permEntry.mType], permEntry.mPermission,
permEntry.mExpireType, permEntry.mExpireTime));
}

Просмотреть файл

@ -135,6 +135,9 @@ class PermissionManager final : public nsIPermissionManager,
enum { ALLOW_MEMMOVE = false };
inline nsTArray<PermissionEntry>& GetPermissions() { return mPermissions; }
inline const nsTArray<PermissionEntry>& GetPermissions() const {
return mPermissions;
}
inline int32_t GetPermissionIndex(uint32_t aType) const {
for (uint32_t i = 0; i < mPermissions.Length(); ++i)

Просмотреть файл

@ -216,7 +216,7 @@ NS_IMETHODIMP mozHunspell::SetPersonalDictionary(
NS_IMETHODIMP mozHunspell::GetDictionaryList(
nsTArray<nsCString>& aDictionaries) {
MOZ_ASSERT(aDictionaries.IsEmpty());
for (auto iter = mDictionaries.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mDictionaries.ConstIter(); !iter.Done(); iter.Next()) {
aDictionaries.AppendElement(NS_ConvertUTF16toUTF8(iter.Key()));
}
@ -276,8 +276,9 @@ void mozHunspell::LoadDictionaryList(bool aNotifyChildProcesses) {
LoadDictionariesFromDir(mDynamicDirectories[i]);
}
for (auto iter = mDynamicDictionaries.Iter(); !iter.Done(); iter.Next()) {
mDictionaries.InsertOrUpdate(iter.Key(), iter.Data());
for (const auto& dictionaryEntry : mDynamicDictionaries) {
mDictionaries.InsertOrUpdate(dictionaryEntry.GetKey(),
dictionaryEntry.GetData());
}
DictionariesChanged(aNotifyChildProcesses);

Просмотреть файл

@ -320,20 +320,21 @@ WrAnimations CompositorAnimationStorage::CollectWebRenderAnimations() const {
WrAnimations animations;
for (auto iter = mAnimatedValues.ConstIter(); !iter.Done(); iter.Next()) {
AnimatedValue* value = iter.UserData();
for (const auto& animatedValueEntry : mAnimatedValues) {
AnimatedValue* value = animatedValueEntry.GetWeak();
value->Value().match(
[&](const AnimationTransform& aTransform) {
animations.mTransformArrays.AppendElement(wr::ToWrTransformProperty(
iter.Key(), aTransform.mFrameTransform));
animatedValueEntry.GetKey(), aTransform.mFrameTransform));
},
[&](const float& aOpacity) {
animations.mOpacityArrays.AppendElement(
wr::ToWrOpacityProperty(iter.Key(), aOpacity));
wr::ToWrOpacityProperty(animatedValueEntry.GetKey(), aOpacity));
},
[&](const nscolor& aColor) {
animations.mColorArrays.AppendElement(wr::ToWrColorProperty(
iter.Key(), ToDeviceColor(gfx::sRGBColor::FromABGR(aColor))));
animatedValueEntry.GetKey(),
ToDeviceColor(gfx::sRGBColor::FromABGR(aColor))));
});
}

Просмотреть файл

@ -36,8 +36,8 @@ void TextureSourceProvider::ReadUnlockTextures() {
texture->ReadUnlock();
}
}
for (auto it = texturesIdsToUnlockByPid.ConstIter(); !it.Done(); it.Next()) {
TextureSync::SetTexturesUnlocked(it.Key(), *it.UserData());
for (const auto& entry : texturesIdsToUnlockByPid) {
TextureSync::SetTexturesUnlocked(entry.GetKey(), *entry.GetWeak());
}
#else
for (auto& texture : mUnlockAfterComposition) {

Просмотреть файл

@ -202,13 +202,14 @@ void SharedSurfacesParent::AccumulateMemoryReport(
return;
}
for (auto i = sInstance->mSurfaces.ConstIter(); !i.Done(); i.Next()) {
SourceSurfaceSharedDataWrapper* surface = i.Data();
for (const auto& entry : sInstance->mSurfaces) {
SourceSurfaceSharedDataWrapper* surface = entry.GetData();
if (surface->GetCreatorPid() == aPid) {
aReport.mSurfaces.insert(std::make_pair(
i.Key(), SharedSurfacesMemoryReport::SurfaceEntry{
aPid, surface->GetSize(), surface->Stride(),
surface->GetConsumers(), surface->HasCreatorRef()}));
entry.GetKey(),
SharedSurfacesMemoryReport::SurfaceEntry{
aPid, surface->GetSize(), surface->Stride(),
surface->GetConsumers(), surface->HasCreatorRef()}));
}
}
}
@ -230,10 +231,10 @@ bool SharedSurfacesParent::AccumulateMemoryReport(
return true;
}
for (auto i = sInstance->mSurfaces.ConstIter(); !i.Done(); i.Next()) {
SourceSurfaceSharedDataWrapper* surface = i.Data();
for (const auto& entry : sInstance->mSurfaces) {
SourceSurfaceSharedDataWrapper* surface = entry.GetData();
aReport.mSurfaces.insert(std::make_pair(
i.Key(),
entry.GetKey(),
SharedSurfacesMemoryReport::SurfaceEntry{
surface->GetCreatorPid(), surface->GetSize(), surface->Stride(),
surface->GetConsumers(), surface->HasCreatorRef()}));

Просмотреть файл

@ -2289,8 +2289,8 @@ void CompositorOGL::TryUnlockTextures() {
}
}
mMaybeUnlockBeforeNextComposition.Clear();
for (auto it = texturesIdsToUnlockByPid.ConstIter(); !it.Done(); it.Next()) {
TextureSync::SetTexturesUnlocked(it.Key(), *it.UserData());
for (const auto& entry : texturesIdsToUnlockByPid) {
TextureSync::SetTexturesUnlocked(entry.GetKey(), *entry.GetWeak());
}
}
#endif

Просмотреть файл

@ -344,9 +344,9 @@ void AsyncImagePipelineManager::ApplyAsyncImagesOfImageBridge(
// We use a pipeline with a very small display list for each video element.
// Update each of them if needed.
for (auto iter = mAsyncImagePipelines.Iter(); !iter.Done(); iter.Next()) {
wr::PipelineId pipelineId = wr::AsPipelineId(iter.Key());
AsyncImagePipeline* pipeline = iter.UserData();
for (const auto& entry : mAsyncImagePipelines) {
wr::PipelineId pipelineId = wr::AsPipelineId(entry.GetKey());
AsyncImagePipeline* pipeline = entry.GetWeak();
#ifdef XP_WIN
if (isChanged) {

Просмотреть файл

@ -703,7 +703,7 @@ class FontNameCache {
size_t EntryCount() const { return mMap.EntryCount(); }
void DropStaleEntries() {
for (auto iter = mMap.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mMap.ConstIter(); !iter.Done(); iter.Next()) {
auto entry = static_cast<FNCMapEntry*>(iter.Get());
if (!entry->mFileExists) {
iter.Remove();
@ -718,7 +718,7 @@ class FontNameCache {
LOG(("Writing FontNameCache:"));
nsAutoCString buf;
for (auto iter = mMap.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mMap.ConstIter(); !iter.Done(); iter.Next()) {
auto entry = static_cast<FNCMapEntry*>(iter.Get());
MOZ_ASSERT(entry->mFileExists);
buf.Append(entry->mFilename);
@ -1371,7 +1371,7 @@ void gfxFT2FontList::AppendFacesFromOmnijarEntry(nsZipArchive* aArchive,
// if aSortFaces is true this will sort faces to give priority to "standard"
// font files.
static void FinalizeFamilyMemberList(nsCStringHashKey::KeyType aKey,
RefPtr<gfxFontFamily>& aFamily,
const RefPtr<gfxFontFamily>& aFamily,
bool aSortFaces) {
gfxFontFamily* family = aFamily.get();
@ -1615,8 +1615,8 @@ void gfxFT2FontList::AppendFaceFromFontListEntry(const FontListEntry& aFLE,
}
void gfxFT2FontList::ReadSystemFontList(nsTArray<FontListEntry>* aList) {
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
auto family = static_cast<FT2FontFamily*>(iter.Data().get());
for (const auto& entry : mFontFamilies) {
auto family = static_cast<FT2FontFamily*>(entry.GetData().get());
family->AddFacesToFontList(aList);
}
}
@ -1643,9 +1643,9 @@ nsresult gfxFT2FontList::InitFontListForPlatform() {
// Finalize the families by sorting faces into standard order
// and marking "simple" families.
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
nsCStringHashKey::KeyType key = iter.Key();
RefPtr<gfxFontFamily>& family = iter.Data();
for (const auto& entry : mFontFamilies) {
nsCStringHashKey::KeyType key = entry.GetKey();
const RefPtr<gfxFontFamily>& family = entry.GetData();
FinalizeFamilyMemberList(key, family, /* aSortFaces */ true);
}
@ -1663,9 +1663,9 @@ nsresult gfxFT2FontList::InitFontListForPlatform() {
// We don't need to sort faces (because they were already sorted by the
// chrome process, so we just maintain the existing order)
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
nsCStringHashKey::KeyType key = iter.Key();
RefPtr<gfxFontFamily>& family = iter.Data();
for (const auto& entry : mFontFamilies) {
nsCStringHashKey::KeyType key = entry.GetKey();
const RefPtr<gfxFontFamily>& family = entry.GetData();
FinalizeFamilyMemberList(key, family, /* aSortFaces */ false);
}
@ -1728,10 +1728,10 @@ gfxFontEntry* gfxFT2FontList::LookupLocalFont(const nsACString& aFontName,
// walk over list of names
FT2FontEntry* fontEntry = nullptr;
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mFontFamilies.ConstIter(); !iter.Done(); iter.Next()) {
// Check family name, based on the assumption that the
// first part of the full name is the family name
RefPtr<gfxFontFamily>& fontFamily = iter.Data();
const RefPtr<gfxFontFamily>& fontFamily = iter.Data();
// does the family name match up to the length of the family name?
const nsCString& family = fontFamily->Name();

Просмотреть файл

@ -292,20 +292,20 @@ void gfxFontCache::DestroyFont(gfxFont* aFont) {
void gfxFontCache::WordCacheExpirationTimerCallback(nsITimer* aTimer,
void* aCache) {
gfxFontCache* cache = static_cast<gfxFontCache*>(aCache);
for (auto it = cache->mFonts.Iter(); !it.Done(); it.Next()) {
it.Get()->mFont->AgeCachedWords();
for (const auto& entry : cache->mFonts) {
entry.mFont->AgeCachedWords();
}
}
void gfxFontCache::FlushShapedWordCaches() {
for (auto it = mFonts.Iter(); !it.Done(); it.Next()) {
it.Get()->mFont->ClearCachedWords();
for (const auto& entry : mFonts) {
entry.mFont->ClearCachedWords();
}
}
void gfxFontCache::NotifyGlyphsChanged() {
for (auto it = mFonts.Iter(); !it.Done(); it.Next()) {
it.Get()->mFont->NotifyGlyphsChanged();
for (const auto& entry : mFonts) {
entry.mFont->NotifyGlyphsChanged();
}
}
@ -314,8 +314,8 @@ void gfxFontCache::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
// TODO: add the overhead of the expiration tracker (generation arrays)
aSizes->mFontInstances += mFonts.ShallowSizeOfExcludingThis(aMallocSizeOf);
for (auto iter = mFonts.ConstIter(); !iter.Done(); iter.Next()) {
iter.Get()->mFont->AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
for (const auto& entry : mFonts) {
entry.mFont->AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
}
}

Просмотреть файл

@ -1449,6 +1449,8 @@ void gfxFontEntry::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
if (mFeatureInputs) {
aSizes->mFontTableCacheSize +=
mFeatureInputs->ShallowSizeOfIncludingThis(aMallocSizeOf);
// XXX Can't this simply be
// aSizes->mFontTableCacheSize += 8192 * mFeatureInputs->Count();
for (auto iter = mFeatureInputs->ConstIter(); !iter.Done(); iter.Next()) {
// There's no API to get the real size of an hb_set, so we'll use
// an approximation based on knowledge of the implementation.

Просмотреть файл

@ -118,22 +118,22 @@ class imgMemoryReporter final : public nsIMemoryReporter {
nsTArray<ImageMemoryCounter> uncached;
for (uint32_t i = 0; i < mKnownLoaders.Length(); i++) {
for (auto iter = mKnownLoaders[i]->mChromeCache.Iter(); !iter.Done();
for (auto iter = mKnownLoaders[i]->mChromeCache.ConstIter(); !iter.Done();
iter.Next()) {
imgCacheEntry* entry = iter.UserData();
RefPtr<imgRequest> req = entry->GetRequest();
RecordCounterForRequest(req, &chrome, !entry->HasNoProxies());
}
for (auto iter = mKnownLoaders[i]->mCache.Iter(); !iter.Done();
for (auto iter = mKnownLoaders[i]->mCache.ConstIter(); !iter.Done();
iter.Next()) {
imgCacheEntry* entry = iter.UserData();
RefPtr<imgRequest> req = entry->GetRequest();
RecordCounterForRequest(req, &content, !entry->HasNoProxies());
}
MutexAutoLock lock(mKnownLoaders[i]->mUncachedImagesMutex);
for (auto iter = mKnownLoaders[i]->mUncachedImages.Iter(); !iter.Done();
iter.Next()) {
nsPtrHashKey<imgRequest>* entry = iter.Get();
for (auto iter = mKnownLoaders[i]->mUncachedImages.ConstIter();
!iter.Done(); iter.Next()) {
const nsPtrHashKey<imgRequest>* entry = iter.Get();
RefPtr<imgRequest> req = entry->GetKey();
RecordCounterForRequest(req, &uncached, req->HasConsumers());
}
@ -166,7 +166,8 @@ class imgMemoryReporter final : public nsIMemoryReporter {
size_t n = 0;
for (uint32_t i = 0; i < imgLoader::sMemReporter->mKnownLoaders.Length();
i++) {
for (auto iter = imgLoader::sMemReporter->mKnownLoaders[i]->mCache.Iter();
for (auto iter =
imgLoader::sMemReporter->mKnownLoaders[i]->mCache.ConstIter();
!iter.Done(); iter.Next()) {
imgCacheEntry* entry = iter.UserData();
if (entry->HasNoProxies()) {
@ -1238,8 +1239,8 @@ imgLoader::~imgLoader() {
// If there are any of our imgRequest's left they are in the uncached
// images set, so clear their pointer to us.
MutexAutoLock lock(mUncachedImagesMutex);
for (auto iter = mUncachedImages.Iter(); !iter.Done(); iter.Next()) {
nsPtrHashKey<imgRequest>* entry = iter.Get();
for (auto iter = mUncachedImages.ConstIter(); !iter.Done(); iter.Next()) {
const nsPtrHashKey<imgRequest>* entry = iter.Get();
RefPtr<imgRequest> req = entry->GetKey();
req->ClearLoader();
}
@ -1381,8 +1382,8 @@ imgLoader::RemoveEntriesFromPrincipal(nsIPrincipal* aPrincipal) {
AutoTArray<RefPtr<imgCacheEntry>, 128> entriesToBeRemoved;
imgCacheTable& cache = GetCache(aPrincipal->IsSystemPrincipal());
for (auto iter = cache.Iter(); !iter.Done(); iter.Next()) {
auto& key = iter.Key();
for (const auto& entry : cache) {
const auto& key = entry.GetKey();
if (key.OriginAttributesRef() !=
BasePrincipal::Cast(aPrincipal)->OriginAttributesRef()) {
@ -1396,7 +1397,7 @@ imgLoader::RemoveEntriesFromPrincipal(nsIPrincipal* aPrincipal) {
}
if (imageOrigin == origin) {
entriesToBeRemoved.AppendElement(iter.Data());
entriesToBeRemoved.AppendElement(entry.GetData());
}
}
@ -1467,10 +1468,10 @@ imgLoader::ClearCacheForControlledDocument(Document* aDoc) {
MOZ_ASSERT(aDoc);
AutoTArray<RefPtr<imgCacheEntry>, 128> entriesToBeRemoved;
imgCacheTable& cache = GetCache(false);
for (auto iter = cache.Iter(); !iter.Done(); iter.Next()) {
auto& key = iter.Key();
for (const auto& entry : cache) {
const auto& key = entry.GetKey();
if (key.ControlledDocument() == aDoc) {
entriesToBeRemoved.AppendElement(iter.Data());
entriesToBeRemoved.AppendElement(entry.GetData());
}
}
for (auto& entry : entriesToBeRemoved) {
@ -2036,8 +2037,8 @@ nsresult imgLoader::EvictEntries(imgCacheTable& aCacheToClear) {
// We have to make a temporary, since RemoveFromCache removes the element
// from the queue, invalidating iterators.
nsTArray<RefPtr<imgCacheEntry> > entries;
for (auto iter = aCacheToClear.Iter(); !iter.Done(); iter.Next()) {
RefPtr<imgCacheEntry>& data = iter.Data();
for (auto iter = aCacheToClear.ConstIter(); !iter.Done(); iter.Next()) {
const RefPtr<imgCacheEntry>& data = iter.Data();
entries.AppendElement(data);
}

Просмотреть файл

@ -511,22 +511,22 @@ class ChannelCountReporter final : public nsIMemoryReporter {
if (!sChannelCounts) {
return NS_OK;
}
for (auto iter = sChannelCounts->Iter(); !iter.Done(); iter.Next()) {
nsPrintfCString pathNow("ipc-channels/%s", iter.Key());
nsPrintfCString pathMax("ipc-channels-peak/%s", iter.Key());
for (const auto& entry : *sChannelCounts) {
nsPrintfCString pathNow("ipc-channels/%s", entry.GetKey());
nsPrintfCString pathMax("ipc-channels-peak/%s", entry.GetKey());
nsPrintfCString descNow(
"Number of IPC channels for"
" top-level actor type %s",
iter.Key());
entry.GetKey());
nsPrintfCString descMax(
"Peak number of IPC channels for"
" top-level actor type %s",
iter.Key());
entry.GetKey());
aHandleReport->Callback(""_ns, pathNow, KIND_OTHER, UNITS_COUNT,
iter.Data().mNow, descNow, aData);
entry.GetData().mNow, descNow, aData);
aHandleReport->Callback(""_ns, pathMax, KIND_OTHER, UNITS_COUNT,
iter.Data().mMax, descMax, aData);
entry.GetData().mMax, descMax, aData);
}
return NS_OK;
}

Просмотреть файл

@ -479,9 +479,9 @@ static size_t SizeOfTableExcludingThis(
const nsBaseHashtable<Key, Data, UserData, Converter>& aTable,
MallocSizeOf aMallocSizeOf) {
size_t n = aTable.ShallowSizeOfExcludingThis(aMallocSizeOf);
for (auto iter = aTable.ConstIter(); !iter.Done(); iter.Next()) {
n += iter.Key().SizeOfExcludingThisIfUnshared(aMallocSizeOf);
n += iter.Data()->SizeOfIncludingThis(aMallocSizeOf);
for (const auto& entry : aTable) {
n += entry.GetKey().SizeOfExcludingThisIfUnshared(aMallocSizeOf);
n += entry.GetData()->SizeOfIncludingThis(aMallocSizeOf);
}
return n;
}

Просмотреть файл

@ -1459,7 +1459,7 @@ void PresShell::Destroy() {
mAutoWeakFrames->Clear(this);
}
nsTArray<WeakFrame*> toRemove(mWeakFrames.Count());
for (auto iter = mWeakFrames.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mWeakFrames.ConstIter(); !iter.Done(); iter.Next()) {
toRemove.AppendElement(iter.Get()->GetKey());
}
for (WeakFrame* weakFrame : toRemove) {
@ -2673,7 +2673,7 @@ void PresShell::PostPendingScrollAnchorSelection(
}
void PresShell::FlushPendingScrollAnchorSelections() {
for (auto iter = mPendingScrollAnchorSelection.Iter(); !iter.Done();
for (auto iter = mPendingScrollAnchorSelection.ConstIter(); !iter.Done();
iter.Next()) {
nsIScrollableFrame* scroll = iter.Get()->GetKey();
scroll->Anchor()->SelectAnchor();
@ -2687,7 +2687,7 @@ void PresShell::PostPendingScrollAnchorAdjustment(
}
void PresShell::FlushPendingScrollAnchorAdjustments() {
for (auto iter = mPendingScrollAnchorAdjustment.Iter(); !iter.Done();
for (auto iter = mPendingScrollAnchorAdjustment.ConstIter(); !iter.Done();
iter.Next()) {
nsIScrollableFrame* scroll = iter.Get()->GetKey();
scroll->Anchor()->ApplyAdjustments();
@ -3076,7 +3076,7 @@ void PresShell::ClearFrameRefs(nsIFrame* aFrame) {
}
AutoTArray<WeakFrame*, 4> toRemove;
for (auto iter = mWeakFrames.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mWeakFrames.ConstIter(); !iter.Done(); iter.Next()) {
WeakFrame* weakFrame = iter.Get()->GetKey();
if (weakFrame->GetFrame() == aFrame) {
toRemove.AppendElement(weakFrame);
@ -5833,7 +5833,7 @@ void PresShell::MarkFramesInListApproximatelyVisible(
void PresShell::DecApproximateVisibleCount(
VisibleFrames& aFrames, const Maybe<OnNonvisible>& aNonvisibleAction
/* = Nothing() */) {
for (auto iter = aFrames.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = aFrames.ConstIter(); !iter.Done(); iter.Next()) {
nsIFrame* frame = iter.Get()->GetKey();
// Decrement the frame's visible count if we're still tracking its
// visibility. (We may not be, if the frame disabled visibility tracking
@ -9662,9 +9662,9 @@ bool PresShell::DoReflow(nsIFrame* target, bool aInterruptible,
bool interrupted = mPresContext->HasPendingInterrupt();
if (interrupted) {
// Make sure target gets reflowed again.
for (auto iter = mFramesToDirty.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mFramesToDirty.ConstIter(); !iter.Done(); iter.Next()) {
// Mark frames dirty until target frame.
nsPtrHashKey<nsIFrame>* p = iter.Get();
const nsPtrHashKey<nsIFrame>* p = iter.Get();
for (nsIFrame* f = p->GetKey(); f && !f->IsSubtreeDirty();
f = f->GetParent()) {
f->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
@ -10628,8 +10628,8 @@ void ReflowCountMgr::DoGrandTotals() {
printf("-");
}
printf("\n");
for (auto iter = mCounts.Iter(); !iter.Done(); iter.Next()) {
iter.Data()->DisplayTotals(iter.Key());
for (const auto& entry : mCounts) {
entry.GetData()->DisplayTotals(entry.GetKey());
}
}
@ -10671,7 +10671,7 @@ void ReflowCountMgr::DoIndiTotalsTree() {
printf("------------------------------------------------\n");
printf("-- Individual Counts of Frames not in Root Tree\n");
printf("------------------------------------------------\n");
for (auto iter = mIndiFrameCounts.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mIndiFrameCounts.ConstIter(); !iter.Done(); iter.Next()) {
IndiReflowCounter* counter = iter.UserData();
if (!counter->mHasBeenOutput) {
char* name = ToNewCString(counter->mName);
@ -10702,8 +10702,8 @@ void ReflowCountMgr::DoGrandHTMLTotals() {
}
fprintf(mFD, "</tr>\n");
for (auto iter = mCounts.Iter(); !iter.Done(); iter.Next()) {
iter.Data()->DisplayHTMLTotals(iter.Key());
for (const auto& entry : mCounts) {
entry.GetData()->DisplayHTMLTotals(entry.GetKey());
}
}
@ -10753,7 +10753,7 @@ void ReflowCountMgr::DisplayHTMLTotals(const char* aStr) {
//------------------------------------------------------------------
void ReflowCountMgr::ClearTotals() {
for (auto iter = mCounts.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mCounts.ConstIter(); !iter.Done(); iter.Next()) {
iter.Data()->ClearTotals();
}
}
@ -10781,12 +10781,12 @@ void ReflowCountMgr::DisplayDiffsInTotals() {
ClearGrandTotals();
}
for (auto iter = mCounts.Iter(); !iter.Done(); iter.Next()) {
for (const auto& entry : mCounts) {
if (mCycledOnce) {
iter.Data()->CalcDiffInTotals();
iter.Data()->DisplayDiffTotals(iter.Key());
entry.GetData()->CalcDiffInTotals();
entry.GetData()->DisplayDiffTotals(entry.GetKey());
}
iter.Data()->SetTotalsCache();
entry.GetData()->SetTotalsCache();
}
mCycledOnce = true;
@ -11003,7 +11003,7 @@ nsresult PresShell::UpdateImageLockingState() {
if (locked) {
// Request decodes for visible image frames; we want to start decoding as
// quickly as possible when we get foregrounded to minimize flashing.
for (auto iter = mApproximatelyVisibleFrames.Iter(); !iter.Done();
for (auto iter = mApproximatelyVisibleFrames.ConstIter(); !iter.Done();
iter.Next()) {
nsImageFrame* imageFrame = do_QueryFrame(iter.Get()->GetKey());
if (imageFrame) {

Просмотреть файл

@ -314,7 +314,7 @@ nsCounterList* nsCounterManager::CounterListFor(nsAtom* aCounterName) {
}
void nsCounterManager::RecalcAll() {
for (auto iter = mNames.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mNames.ConstIter(); !iter.Done(); iter.Next()) {
nsCounterList* list = iter.UserData();
if (list->IsDirty()) {
list->RecalcAll();
@ -323,7 +323,7 @@ void nsCounterManager::RecalcAll() {
}
void nsCounterManager::SetAllDirty() {
for (auto iter = mNames.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mNames.ConstIter(); !iter.Done(); iter.Next()) {
iter.UserData()->SetDirty();
}
}
@ -332,7 +332,7 @@ bool nsCounterManager::DestroyNodesFor(nsIFrame* aFrame) {
MOZ_ASSERT(aFrame->HasAnyStateBits(NS_FRAME_HAS_CSS_COUNTER_STYLE),
"why call me?");
bool destroyedAny = false;
for (auto iter = mNames.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mNames.ConstIter(); !iter.Done(); iter.Next()) {
nsCounterList* list = iter.UserData();
if (list->DestroyNodesFor(aFrame)) {
destroyedAny = true;
@ -345,10 +345,10 @@ bool nsCounterManager::DestroyNodesFor(nsIFrame* aFrame) {
#ifdef DEBUG
void nsCounterManager::Dump() {
printf("\n\nCounter Manager Lists:\n");
for (auto iter = mNames.Iter(); !iter.Done(); iter.Next()) {
printf("Counter named \"%s\":\n", nsAtomCString(iter.Key()).get());
for (const auto& entry : mNames) {
printf("Counter named \"%s\":\n", nsAtomCString(entry.GetKey()).get());
nsCounterList* list = iter.UserData();
nsCounterList* list = entry.GetWeak();
int32_t i = 0;
for (nsCounterNode* node = list->First(); node; node = list->Next(node)) {
const char* types[] = {"RESET", "INCREMENT", "SET", "USE"};

Просмотреть файл

@ -54,7 +54,7 @@ nsLayoutHistoryState::GetKeys(nsTArray<nsCString>& aKeys) {
}
aKeys.SetCapacity(mStates.Count());
for (auto iter = mStates.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mStates.ConstIter(); !iter.Done(); iter.Next()) {
aKeys.AppendElement(iter.Key());
}
@ -127,7 +127,7 @@ void nsLayoutHistoryState::SetScrollPositionOnly(const bool aFlag) {
}
void nsLayoutHistoryState::ResetScrollState() {
for (auto iter = mStates.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mStates.ConstIter(); !iter.Done(); iter.Next()) {
PresState* state = iter.Data().get();
if (state) {
state->scrollState() = nsPoint(0, 0);
@ -141,9 +141,9 @@ void nsLayoutHistoryState::GetContents(bool* aScrollPositionOnly,
*aScrollPositionOnly = mScrollPositionOnly;
aKeys.SetCapacity(mStates.Count());
aStates.SetCapacity(mStates.Count());
for (auto iter = mStates.Iter(); !iter.Done(); iter.Next()) {
aKeys.AppendElement(iter.Key());
aStates.AppendElement(*(iter.Data().get()));
for (const auto& entry : mStates) {
aKeys.AppendElement(entry.GetKey());
aStates.AppendElement(*(entry.GetData().get()));
}
}

Просмотреть файл

@ -2953,9 +2953,9 @@ void PrintHitTestInfoStats(nsDisplayList* aList) {
// respective remote browsers.
static void ApplyEffectsUpdates(
const nsTHashMap<nsPtrHashKey<RemoteBrowser>, EffectsInfo>& aUpdates) {
for (auto iter = aUpdates.ConstIter(); !iter.Done(); iter.Next()) {
auto browser = iter.Key();
auto update = iter.Data();
for (const auto& entry : aUpdates) {
auto* browser = entry.GetKey();
const auto& update = entry.GetData();
browser->UpdateEffects(update);
}
}

Просмотреть файл

@ -2219,9 +2219,9 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) {
* for refresh events.
*/
for (auto iter = mStartTable.Iter(); !iter.Done(); iter.Next()) {
const uint32_t& delay = iter.Key();
ImageStartData* data = iter.UserData();
for (const auto& entry : mStartTable) {
const uint32_t& delay = entry.GetKey();
ImageStartData* data = entry.GetWeak();
if (data->mStartTime) {
TimeStamp& start = *data->mStartTime;
@ -2255,8 +2255,8 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) {
// images to refresh, and then we refresh each image in that array.
nsCOMArray<imgIContainer> imagesToRefresh(mRequests.Count());
for (auto iter = mRequests.Iter(); !iter.Done(); iter.Next()) {
nsISupportsHashKey* entry = iter.Get();
for (auto iter = mRequests.ConstIter(); !iter.Done(); iter.Next()) {
const nsISupportsHashKey* entry = iter.Get();
auto req = static_cast<imgIRequest*>(entry->GetKey());
MOZ_ASSERT(req, "Unable to retrieve the image request");
nsCOMPtr<imgIContainer> image;
@ -2407,7 +2407,7 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) {
void nsRefreshDriver::BeginRefreshingImages(RequestTable& aEntries,
mozilla::TimeStamp aDesired) {
for (auto iter = aEntries.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = aEntries.ConstIter(); !iter.Done(); iter.Next()) {
auto req = static_cast<imgIRequest*>(iter.Get()->GetKey());
MOZ_ASSERT(req, "Unable to retrieve the image request");

Просмотреть файл

@ -2203,11 +2203,11 @@ size_t Loader::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
n += mObservers.ShallowSizeOfExcludingThis(aMallocSizeOf);
n += mInlineSheets.ShallowSizeOfExcludingThis(aMallocSizeOf);
for (auto iter = mInlineSheets.ConstIter(); !iter.Done(); iter.Next()) {
n += iter.Key().SizeOfExcludingThisIfUnshared(aMallocSizeOf);
for (const auto& entry : mInlineSheets) {
n += entry.GetKey().SizeOfExcludingThisIfUnshared(aMallocSizeOf);
// If the sheet has a parent, then its parent will report it so we don't
// have to worry about it here.
const StyleSheet* sheet = iter.UserData();
const StyleSheet* sheet = entry.GetWeak();
MOZ_ASSERT(!sheet->GetParentSheet(),
"How did an @import rule end up here?");
if (!sheet->GetOwnerNode()) {

Просмотреть файл

@ -2696,8 +2696,8 @@ size_t nsPrefBranch::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
n += mPrefRoot.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
n += mObservers.ShallowSizeOfExcludingThis(aMallocSizeOf);
for (auto iter = mObservers.ConstIter(); !iter.Done(); iter.Next()) {
const PrefCallback* data = iter.UserData();
for (const auto& entry : mObservers) {
const PrefCallback* data = entry.GetWeak();
n += data->SizeOfIncludingThis(aMallocSizeOf);
}
@ -3190,8 +3190,8 @@ PreferenceServiceReporter::CollectReports(
// Count of the number of referents for each preference.
nsTHashMap<nsCStringHashKey, uint32_t> prefCounter;
for (auto iter = rootBranch->mObservers.Iter(); !iter.Done(); iter.Next()) {
auto callback = iter.UserData();
for (const auto& entry : rootBranch->mObservers) {
auto* callback = entry.GetWeak();
if (callback->IsWeak()) {
nsCOMPtr<nsIObserver> callbackRef = do_QueryReferent(callback->mWeakRef);
@ -3903,8 +3903,8 @@ Preferences::GetDefaultBranch(const char* aPrefRoot, nsIPrefBranch** aRetVal) {
NS_IMETHODIMP
Preferences::ReadStats(nsIPrefStatsCallback* aCallback) {
#ifdef ACCESS_COUNTS
for (auto iter = gAccessCounts->Iter(); !iter.Done(); iter.Next()) {
aCallback->Visit(iter.Key(), iter.Data());
for (const auto& entry : *gAccessCounts) {
aCallback->Visit(entry.GetKey(), entry.GetData());
}
return NS_OK;

Просмотреть файл

@ -676,9 +676,9 @@ class MOZ_RAII SharedPrefMapBuilder {
}
size_t defaultsOffset = UserCount();
for (auto iter = mDefaultEntries.ConstIter(); !iter.Done(); iter.Next()) {
const auto& entry = iter.Data();
buffer[defaultsOffset + entry.mIndex] = entry.mDefaultValue;
for (const auto& entry : mDefaultEntries) {
const auto& data = entry.GetData();
buffer[defaultsOffset + data.mIndex] = data.mDefaultValue;
}
}

Просмотреть файл

@ -2270,12 +2270,12 @@ void CacheFile::NotifyListenersAboutOutputRemoval() {
}
// Fail all update listeners
for (auto iter = mChunks.Iter(); !iter.Done(); iter.Next()) {
const RefPtr<CacheFileChunk>& chunk = iter.Data();
for (const auto& entry : mChunks) {
const RefPtr<CacheFileChunk>& chunk = entry.GetData();
LOG(
("CacheFile::NotifyListenersAboutOutputRemoval() - fail2 "
"[this=%p, idx=%u]",
this, iter.Key()));
this, entry.GetKey()));
if (chunk->IsReady()) {
chunk->NotifyUpdateListeners();

Просмотреть файл

@ -890,16 +890,16 @@ nsresult CacheStorageService::ClearOriginInternal(
mozilla::MutexAutoLock lock(mLock);
if (sGlobalEntryTables) {
for (auto iter = sGlobalEntryTables->Iter(); !iter.Done(); iter.Next()) {
for (const auto& globalEntry : *sGlobalEntryTables) {
bool matches = false;
rv =
CacheFileUtils::KeyMatchesLoadContextInfo(iter.Key(), info, &matches);
rv = CacheFileUtils::KeyMatchesLoadContextInfo(globalEntry.GetKey(), info,
&matches);
NS_ENSURE_SUCCESS(rv, rv);
if (!matches) {
continue;
}
CacheEntryTable* table = iter.UserData();
CacheEntryTable* table = globalEntry.GetWeak();
MOZ_ASSERT(table);
nsTArray<RefPtr<CacheEntry>> entriesToDelete;
@ -1951,9 +1951,9 @@ nsresult CacheStorageService::DoomStorageEntries(
CacheEntryTable* diskEntries;
if (memoryEntries && sGlobalEntryTables->Get(aContextKey, &diskEntries)) {
for (auto iter = memoryEntries->Iter(); !iter.Done(); iter.Next()) {
auto entry = iter.Data();
RemoveExactEntry(diskEntries, iter.Key(), entry, false);
for (const auto& memoryEntry : *memoryEntries) {
auto entry = memoryEntry.GetData();
RemoveExactEntry(diskEntries, memoryEntry.GetKey(), entry, false);
}
}
}
@ -2275,22 +2275,22 @@ CacheStorageService::CollectReports(nsIHandleReportCallback* aHandleReport,
// 1 CacheFileOutputStream
// N CacheFileInputStream
if (sGlobalEntryTables) {
for (auto iter1 = sGlobalEntryTables->Iter(); !iter1.Done(); iter1.Next()) {
for (const auto& globalEntry : *sGlobalEntryTables) {
CacheStorageService::Self()->Lock().AssertCurrentThreadOwns();
CacheEntryTable* table = iter1.UserData();
CacheEntryTable* table = globalEntry.GetWeak();
size_t size = 0;
mozilla::MallocSizeOf mallocSizeOf = CacheStorageService::MallocSizeOf;
size += table->ShallowSizeOfIncludingThis(mallocSizeOf);
for (auto iter2 = table->Iter(); !iter2.Done(); iter2.Next()) {
size += iter2.Key().SizeOfExcludingThisIfUnshared(mallocSizeOf);
for (const auto& tableEntry : *table) {
size += tableEntry.GetKey().SizeOfExcludingThisIfUnshared(mallocSizeOf);
// Bypass memory-only entries, those will be reported when iterating the
// memory only table. Memory-only entries are stored in both ALL_ENTRIES
// and MEMORY_ONLY hashtables.
RefPtr<mozilla::net::CacheEntry> const& entry = iter2.Data();
RefPtr<mozilla::net::CacheEntry> const& entry = tableEntry.GetData();
if (table->Type() == CacheEntryTable::MEMORY_ONLY ||
entry->IsUsingDisk()) {
size += entry->SizeOfIncludingThis(mallocSizeOf);
@ -2302,7 +2302,8 @@ CacheStorageService::CollectReports(nsIHandleReportCallback* aHandleReport,
nsPrintfCString(
"explicit/network/cache2/%s-storage(%s)",
table->Type() == CacheEntryTable::MEMORY_ONLY ? "memory" : "disk",
aAnonymize ? "<anonymized>" : iter1.Key().BeginReading()),
aAnonymize ? "<anonymized>"
: globalEntry.GetKey().BeginReading()),
nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES, size,
"Memory used by the cache storage."_ns, aData);
}

Просмотреть файл

@ -141,8 +141,8 @@ size_t CookieStorage::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
void CookieStorage::GetCookies(nsTArray<RefPtr<nsICookie>>& aCookies) const {
aCookies.SetCapacity(mCookieCount);
for (auto iter = mHostTable.ConstIter(); !iter.Done(); iter.Next()) {
const CookieEntry::ArrayType& cookies = iter.Get()->GetCookies();
for (const auto& entry : mHostTable) {
const CookieEntry::ArrayType& cookies = entry.GetCookies();
for (CookieEntry::IndexType i = 0; i < cookies.Length(); ++i) {
aCookies.AppendElement(cookies[i]);
}
@ -152,8 +152,8 @@ void CookieStorage::GetCookies(nsTArray<RefPtr<nsICookie>>& aCookies) const {
void CookieStorage::GetSessionCookies(
nsTArray<RefPtr<nsICookie>>& aCookies) const {
aCookies.SetCapacity(mCookieCount);
for (auto iter = mHostTable.ConstIter(); !iter.Done(); iter.Next()) {
const CookieEntry::ArrayType& cookies = iter.Get()->GetCookies();
for (const auto& entry : mHostTable) {
const CookieEntry::ArrayType& cookies = entry.GetCookies();
for (CookieEntry::IndexType i = 0; i < cookies.Length(); ++i) {
Cookie* cookie = cookies[i];
// Filter out non-session cookies.
@ -236,8 +236,8 @@ uint32_t CookieStorage::CountCookiesFromHost(const nsACString& aBaseDomain,
void CookieStorage::GetAll(nsTArray<RefPtr<nsICookie>>& aResult) const {
aResult.SetCapacity(mCookieCount);
for (auto iter = mHostTable.ConstIter(); !iter.Done(); iter.Next()) {
const CookieEntry::ArrayType& cookies = iter.Get()->GetCookies();
for (const auto& entry : mHostTable) {
const CookieEntry::ArrayType& cookies = entry.GetCookies();
for (CookieEntry::IndexType i = 0; i < cookies.Length(); ++i) {
aResult.AppendElement(cookies[i]);
}

Просмотреть файл

@ -672,24 +672,25 @@ void TRR::SaveAdditionalRecords(
return;
}
nsresult rv;
for (auto iter = aRecords.ConstIter(); !iter.Done(); iter.Next()) {
if (iter.Data() && iter.Data()->mAddresses.IsEmpty()) {
for (const auto& recordEntry : aRecords) {
if (recordEntry.GetData() && recordEntry.GetData()->mAddresses.IsEmpty()) {
// no point in adding empty records.
continue;
}
RefPtr<nsHostRecord> hostRecord;
rv = mHostResolver->GetHostRecord(
iter.Key(), EmptyCString(), nsIDNSService::RESOLVE_TYPE_DEFAULT,
mRec->flags, AF_UNSPEC, mRec->pb, mRec->originSuffix,
getter_AddRefs(hostRecord));
recordEntry.GetKey(), EmptyCString(),
nsIDNSService::RESOLVE_TYPE_DEFAULT, mRec->flags, AF_UNSPEC, mRec->pb,
mRec->originSuffix, getter_AddRefs(hostRecord));
if (NS_FAILED(rv)) {
LOG(("Failed to get host record for additional record %s",
nsCString(iter.Key()).get()));
nsCString(recordEntry.GetKey()).get()));
continue;
}
RefPtr<AddrInfo> ai(new AddrInfo(iter.Key(), ResolverType(), TRRTYPE_A,
std::move(iter.Data()->mAddresses),
iter.Data()->mTtl));
RefPtr<AddrInfo> ai(
new AddrInfo(recordEntry.GetKey(), ResolverType(), TRRTYPE_A,
std::move(recordEntry.GetData()->mAddresses),
recordEntry.GetData()->mTtl));
mHostResolver->MaybeRenewHostRecord(hostRecord);
// Since we're not actually calling NameLookup for this record, we need
@ -699,7 +700,8 @@ void TRR::SaveAdditionalRecords(
hostRecord->mEffectiveTRRMode = mRec->mEffectiveTRRMode;
RefPtr<AddrHostRecord> addrRec = do_QueryObject(hostRecord);
addrRec->mTrrStart = TimeStamp::Now();
LOG(("Completing lookup for additional: %s", nsCString(iter.Key()).get()));
LOG(("Completing lookup for additional: %s",
nsCString(recordEntry.GetKey()).get()));
(void)mHostResolver->CompleteLookup(hostRecord, NS_OK, ai, mPB,
mOriginSuffix, TRRSkippedReason::TRR_OK,
this);

Просмотреть файл

@ -861,7 +861,7 @@ void nsHostResolver::Shutdown() {
mIdleTaskCV.NotifyAll();
}
for (auto iter = mRecordDB.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mRecordDB.ConstIter(); !iter.Done(); iter.Next()) {
iter.UserData()->Cancel();
}
// empty host database
@ -2305,10 +2305,10 @@ nsresult nsHostResolver::Create(uint32_t maxCacheEntries,
void nsHostResolver::GetDNSCacheEntries(nsTArray<DNSCacheEntries>* args) {
MutexAutoLock lock(mLock);
for (auto iter = mRecordDB.Iter(); !iter.Done(); iter.Next()) {
for (const auto& recordEntry : mRecordDB) {
// We don't pay attention to address literals, only resolved domains.
// Also require a host.
nsHostRecord* rec = iter.UserData();
nsHostRecord* rec = recordEntry.GetWeak();
MOZ_ASSERT(rec, "rec should never be null here!");
if (!rec) {
@ -2347,7 +2347,7 @@ void nsHostResolver::GetDNSCacheEntries(nsTArray<DNSCacheEntries>* args) {
info.TRR = addrRec->addr_info->IsTRROrODoH();
}
info.originAttributesSuffix = iter.Key().originSuffix;
info.originAttributesSuffix = recordEntry.GetKey().originSuffix;
args->AppendElement(std::move(info));
}

Просмотреть файл

@ -47,7 +47,7 @@ void nsHttpConnectionMgr::OnMsgPrintDiagnostics(int32_t, ARefBase*) {
mLogData.AppendPrintf("mNumActiveConns = %d\n", mNumActiveConns);
mLogData.AppendPrintf("mNumIdleConns = %d\n", mNumIdleConns);
for (auto iter = mCT.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mCT.ConstIter(); !iter.Done(); iter.Next()) {
RefPtr<ConnectionEntry> ent = iter.Data();
mLogData.AppendPrintf(
@ -100,12 +100,13 @@ void ConnectionEntry::PrintDiagnostics(nsCString& log,
void PendingTransactionQueue::PrintDiagnostics(nsCString& log) {
uint32_t i = 0;
for (auto it = mPendingTransactionTable.Iter(); !it.Done(); it.Next()) {
log.AppendPrintf(
" :: Pending Transactions with Window ID = %" PRIu64 "\n", it.Key());
for (uint32_t j = 0; j < it.UserData()->Length(); ++j) {
for (const auto& entry : mPendingTransactionTable) {
log.AppendPrintf(" :: Pending Transactions with Window ID = %" PRIu64
"\n",
entry.GetKey());
for (uint32_t j = 0; j < entry.GetData()->Length(); ++j) {
log.AppendPrintf(" ::: Pending Transaction #%u\n", i);
it.UserData()->ElementAt(j)->PrintDiagnostics(log);
entry.GetData()->ElementAt(j)->PrintDiagnostics(log);
++i;
}
}

Просмотреть файл

@ -4345,8 +4345,8 @@ nsresult HttpBaseChannel::SetupReplacementChannel(nsIURI* newURI,
// transfer any properties
nsCOMPtr<nsIWritablePropertyBag> bag(do_QueryInterface(newChannel));
if (bag) {
for (auto iter = mPropertyHash.Iter(); !iter.Done(); iter.Next()) {
bag->SetProperty(iter.Key(), iter.UserData());
for (const auto& entry : mPropertyHash) {
bag->SetProperty(entry.GetKey(), entry.GetWeak());
}
}

Просмотреть файл

@ -175,26 +175,26 @@ void PendingTransactionQueue::AppendPendingQForNonFocusedWindows(
uint32_t maxCount) {
// XXX Adjust the order of transactions in a smarter manner.
uint32_t totalCount = 0;
for (auto it = mPendingTransactionTable.Iter(); !it.Done(); it.Next()) {
if (windowId && it.Key() == windowId) {
for (const auto& entry : mPendingTransactionTable) {
if (windowId && entry.GetKey() == windowId) {
continue;
}
uint32_t count = 0;
for (; count < it.UserData()->Length(); ++count) {
for (; count < entry.GetWeak()->Length(); ++count) {
if (maxCount && totalCount == maxCount) {
break;
}
// Because elements in |result| could come from multiple penndingQ,
// call |InsertTransactionSorted| to make sure the order is correct.
InsertTransactionSorted(result, it.UserData()->ElementAt(count));
InsertTransactionSorted(result, entry.GetWeak()->ElementAt(count));
++totalCount;
}
it.UserData()->RemoveElementsAt(0, count);
entry.GetWeak()->RemoveElementsAt(0, count);
if (maxCount && totalCount == maxCount) {
if (it.UserData()->Length()) {
if (entry.GetWeak()->Length()) {
// There are still some pending transactions for background
// tabs but we limit their dispatch. This is considered as
// an active tab optimization.
@ -250,9 +250,9 @@ void PendingTransactionQueue::PrintPendingQ() {
for (const auto& info : mUrgentStartQ) {
LOG((" %p", info->Transaction()));
}
for (auto it = mPendingTransactionTable.Iter(); !it.Done(); it.Next()) {
LOG(("] window id = %" PRIx64 " queue [", it.Key()));
for (const auto& info : *it.UserData()) {
for (const auto& entry : mPendingTransactionTable) {
LOG(("] window id = %" PRIx64 " queue [", entry.GetKey()));
for (const auto& info : *entry.GetWeak()) {
LOG((" %p", info->Transaction()));
}
}
@ -261,7 +261,7 @@ void PendingTransactionQueue::PrintPendingQ() {
void PendingTransactionQueue::Compact() {
mUrgentStartQ.Compact();
for (auto it = mPendingTransactionTable.Iter(); !it.Done(); it.Next()) {
for (auto it = mPendingTransactionTable.ConstIter(); !it.Done(); it.Next()) {
it.UserData()->Compact();
}
}
@ -274,7 +274,7 @@ void PendingTransactionQueue::CancelAllTransactions(nsresult reason) {
}
mUrgentStartQ.Clear();
for (auto it = mPendingTransactionTable.Iter(); !it.Done(); it.Next()) {
for (auto it = mPendingTransactionTable.ConstIter(); !it.Done(); it.Next()) {
for (const auto& pendingTransInfo : *it.UserData()) {
LOG(("PendingTransactionQueue::CancelAllTransactions %p\n",
pendingTransInfo->Transaction()));

Просмотреть файл

@ -1203,7 +1203,7 @@ nsresult nsHttpConnectionMgr::MakeNewConnection(
// If the global number of connections is preventing the opening of new
// connections to a host without idle connections, then close them
// regardless of their TTL.
auto iter = mCT.Iter();
auto iter = mCT.ConstIter();
while (mNumIdleConns + mNumActiveConns + 1 >= mMaxConns && !iter.Done()) {
RefPtr<ConnectionEntry> entry = iter.Data();
entry->CloseIdleConnections((mNumIdleConns + mNumActiveConns + 1) -
@ -1217,7 +1217,7 @@ nsresult nsHttpConnectionMgr::MakeNewConnection(
// If the global number of connections is preventing the opening of new
// connections to a host without idle connections, then close any spdy
// ASAP.
for (auto iter = mCT.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mCT.ConstIter(); !iter.Done(); iter.Next()) {
RefPtr<ConnectionEntry> entry = iter.Data();
while (entry->MakeFirstActiveSpdyConnDontReuse()) {
// Stop on <= (particularly =) because this dontreuse
@ -1846,7 +1846,7 @@ void nsHttpConnectionMgr::ProcessSpdyPendingQ(ConnectionEntry* ent) {
void nsHttpConnectionMgr::OnMsgProcessAllSpdyPendingQ(int32_t, ARefBase*) {
MOZ_ASSERT(OnSocketThread(), "not on socket thread");
LOG(("nsHttpConnectionMgr::OnMsgProcessAllSpdyPendingQ\n"));
for (auto iter = mCT.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mCT.ConstIter(); !iter.Done(); iter.Next()) {
ProcessSpdyPendingQ(iter.Data().get());
}
}
@ -2097,7 +2097,7 @@ void nsHttpConnectionMgr::OnMsgProcessPendingQ(int32_t, ARefBase* param) {
if (!ci) {
LOG(("nsHttpConnectionMgr::OnMsgProcessPendingQ [ci=nullptr]\n"));
// Try and dispatch everything
for (auto iter = mCT.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mCT.ConstIter(); !iter.Done(); iter.Next()) {
Unused << ProcessPendingQForEntry(iter.Data().get(), true);
}
return;
@ -2111,7 +2111,7 @@ void nsHttpConnectionMgr::OnMsgProcessPendingQ(int32_t, ARefBase* param) {
if (!(ent && ProcessPendingQForEntry(ent, false))) {
// if we reach here, it means that we couldn't dispatch a transaction
// for the specified connection info. walk the connection table...
for (auto iter = mCT.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mCT.ConstIter(); !iter.Done(); iter.Next()) {
if (ProcessPendingQForEntry(iter.Data().get(), false)) {
break;
}
@ -2201,7 +2201,7 @@ void nsHttpConnectionMgr::OnMsgPruneNoTraffic(int32_t, ARefBase*) {
LOG(("nsHttpConnectionMgr::OnMsgPruneNoTraffic\n"));
// Prune connections without traffic
for (auto iter = mCT.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mCT.ConstIter(); !iter.Done(); iter.Next()) {
// Close the connections with no registered traffic.
RefPtr<ConnectionEntry> ent = iter.Data();
ent->PruneNoTraffic();
@ -2221,7 +2221,7 @@ void nsHttpConnectionMgr::OnMsgVerifyTraffic(int32_t, ARefBase*) {
}
// Mark connections for traffic verification
for (auto iter = mCT.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mCT.ConstIter(); !iter.Done(); iter.Next()) {
iter.Data()->VerifyTraffic();
}
@ -2249,7 +2249,7 @@ void nsHttpConnectionMgr::OnMsgDoShiftReloadConnectionCleanup(int32_t,
nsHttpConnectionInfo* ci = static_cast<nsHttpConnectionInfo*>(param);
for (auto iter = mCT.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mCT.ConstIter(); !iter.Done(); iter.Next()) {
iter.Data()->ClosePersistentConnections();
}
@ -2575,12 +2575,12 @@ void nsHttpConnectionMgr::LogActiveTransactions(char operation) {
trs = mActiveTransactions[true].Get(mCurrentTopLevelOuterContentWindowId);
at = trs ? trs->Length() : 0;
for (auto iter = mActiveTransactions[false].Iter(); !iter.Done();
for (auto iter = mActiveTransactions[false].ConstIter(); !iter.Done();
iter.Next()) {
bu += iter.UserData()->Length();
}
bu -= au;
for (auto iter = mActiveTransactions[true].Iter(); !iter.Done();
for (auto iter = mActiveTransactions[true].ConstIter(); !iter.Done();
iter.Next()) {
bt += iter.UserData()->Length();
}
@ -3050,13 +3050,13 @@ void nsHttpConnectionMgr::ResumeReadOf(
nsClassHashtable<nsUint64HashKey, nsTArray<RefPtr<nsHttpTransaction>>>&
hashtable,
bool excludeForActiveTab) {
for (auto iter = hashtable.Iter(); !iter.Done(); iter.Next()) {
for (const auto& entry : hashtable) {
if (excludeForActiveTab &&
iter.Key() == mCurrentTopLevelOuterContentWindowId) {
entry.GetKey() == mCurrentTopLevelOuterContentWindowId) {
// These have never been throttled (never stopped reading)
continue;
}
ResumeReadOf(iter.UserData());
ResumeReadOf(entry.GetWeak());
}
}
@ -3189,7 +3189,7 @@ void nsHttpConnectionMgr::TimeoutTick() {
// reduce it to their local needs.
mTimeoutTickNext = 3600; // 1hr
for (auto iter = mCT.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mCT.ConstIter(); !iter.Done(); iter.Next()) {
RefPtr<ConnectionEntry> ent = iter.Data();
uint32_t timeoutTickNext = ent->TimeoutTick();
@ -3354,7 +3354,7 @@ void nsHttpConnectionMgr::RegisterOriginCoalescingKey(HttpConnectionBase* conn,
}
bool nsHttpConnectionMgr::GetConnectionData(nsTArray<HttpRetParams>* aArg) {
for (auto iter = mCT.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mCT.ConstIter(); !iter.Done(); iter.Next()) {
RefPtr<ConnectionEntry> ent = iter.Data();
if (ent->mConnInfo->GetPrivate()) {

Просмотреть файл

@ -1715,9 +1715,9 @@ void nsHttpTransaction::Close(nsresult reason) {
mChunkedDecoder = nullptr;
}
for (auto iter = mEchRetryCounterMap.ConstIter(); !iter.Done(); iter.Next()) {
Telemetry::Accumulate(static_cast<Telemetry::HistogramID>(iter.Key()),
iter.UserData());
for (const auto& entry : mEchRetryCounterMap) {
Telemetry::Accumulate(static_cast<Telemetry::HistogramID>(entry.GetKey()),
entry.GetData());
}
// closing this pipe triggers the channel's OnStopRequest method.

Просмотреть файл

@ -236,15 +236,16 @@ void SubstitutingProtocolHandler::ConstructInternal() {
nsresult SubstitutingProtocolHandler::CollectSubstitutions(
nsTArray<SubstitutionMapping>& aMappings) {
AutoReadLock lock(mSubstitutionsLock);
for (auto iter = mSubstitutions.ConstIter(); !iter.Done(); iter.Next()) {
const SubstitutionEntry& entry = iter.Data();
for (const auto& substitutionEntry : mSubstitutions) {
const SubstitutionEntry& entry = substitutionEntry.GetData();
nsCOMPtr<nsIURI> uri = entry.baseURI;
SerializedURI serialized;
if (uri) {
nsresult rv = uri->GetSpec(serialized.spec);
NS_ENSURE_SUCCESS(rv, rv);
}
SubstitutionMapping substitution = {mScheme, nsCString(iter.Key()),
SubstitutionMapping substitution = {mScheme,
nsCString(substitutionEntry.GetKey()),
serialized, entry.flags};
aMappings.AppendElement(substitution);
}

Просмотреть файл

@ -189,9 +189,9 @@ nsresult nsStreamConverterService::FindConverter(
// Create a corresponding color table for each vertex in the graph.
BFSHashTable lBFSTable;
for (auto iter = mAdjacencyList.Iter(); !iter.Done(); iter.Next()) {
const nsACString& key = iter.Key();
MOZ_ASSERT(iter.UserData(), "no data in the table iteration");
for (const auto& entry : mAdjacencyList) {
const nsACString& key = entry.GetKey();
MOZ_ASSERT(entry.GetWeak(), "no data in the table iteration");
lBFSTable.InsertOrUpdate(key, mozilla::MakeUnique<BFSTableData>(key));
}

Просмотреть файл

@ -297,9 +297,9 @@ void SandboxBroker::Policy::FixRecursivePermissions() {
SANDBOX_LOG_ERROR("fixing recursive policy entries");
}
for (auto iter = oldMap.ConstIter(); !iter.Done(); iter.Next()) {
const nsACString& path = iter.Key();
const int& localPerms = iter.Data();
for (const auto& entry : oldMap) {
const nsACString& path = entry.GetKey();
const int& localPerms = entry.GetData();
int inheritedPerms = 0;
nsAutoCString ancestor(path);
@ -359,9 +359,9 @@ int SandboxBroker::Policy::Lookup(const nsACString& aPath) const {
// directory permission. We'll have to check the entire
// whitelist for the best match (slower).
int allPerms = 0;
for (auto iter = mMap.ConstIter(); !iter.Done(); iter.Next()) {
const nsACString& whiteListPath = iter.Key();
const int& perms = iter.Data();
for (const auto& entry : mMap) {
const nsACString& whiteListPath = entry.GetKey();
const int& perms = entry.GetData();
if (!(perms & RECURSIVE)) continue;

Просмотреть файл

@ -150,8 +150,8 @@ already_AddRefed<mozIStorageError> AsyncBindingParams::bind(
nsCOMPtr<mozIStorageError> err;
for (auto iter = mNamedParameters.Iter(); !iter.Done(); iter.Next()) {
const nsACString& key = iter.Key();
for (const auto& entry : mNamedParameters) {
const nsACString& key = entry.GetKey();
// We do not accept any forms of names other than ":name", but we need to
// add the colon for SQLite.
@ -171,7 +171,7 @@ already_AddRefed<mozIStorageError> AsyncBindingParams::bind(
// can't cram aValue into mParameters using ReplaceObjectAt so that
// we can freeload off of the BindingParams::Bind implementation.
int rc = variantToSQLiteT(BindingColumnData(aStatement, oneIdx - 1),
iter.UserData());
entry.GetWeak());
if (rc != SQLITE_OK) {
// We had an error while trying to bind. Now we need to create an error
// object with the right message. Note that we special case

Просмотреть файл

@ -999,7 +999,7 @@ nsresult Connection::databaseElementExists(
bool Connection::findFunctionByInstance(mozIStorageFunction* aInstance) {
sharedDBMutex.assertCurrentThreadOwns();
for (auto iter = mFunctions.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mFunctions.ConstIter(); !iter.Done(); iter.Next()) {
if (iter.UserData().function == aInstance) {
return true;
}
@ -1687,9 +1687,9 @@ nsresult Connection::initializeClone(Connection* aClone, bool aReadOnly) {
// Copy any functions that have been added to this connection.
SQLiteMutexAutoLock lockedScope(sharedDBMutex);
for (auto iter = mFunctions.Iter(); !iter.Done(); iter.Next()) {
const nsACString& key = iter.Key();
Connection::FunctionInfo data = iter.UserData();
for (const auto& entry : mFunctions) {
const nsACString& key = entry.GetKey();
Connection::FunctionInfo data = entry.GetData();
rv = aClone->CreateFunction(key, data.numArgs, data.function);
if (NS_FAILED(rv)) {

Просмотреть файл

@ -47,9 +47,9 @@ GleanMemoryDistribution::TestGetValue(const nsACString& aPingName,
return NS_ERROR_FAILURE;
}
auto& data = result.ref().values;
for (auto iter = data.ConstIter(); !iter.Done(); iter.Next()) {
const uint64_t bucket = iter.Key();
const uint64_t count = iter.UserData();
for (const auto& entry : data) {
const uint64_t bucket = entry.GetKey();
const uint64_t count = entry.GetData();
if (!JS_DefineProperty(aCx, valuesObj,
nsPrintfCString("%" PRIu64, bucket).get(),
static_cast<double>(count), JSPROP_ENUMERATE)) {

Просмотреть файл

@ -62,9 +62,9 @@ GleanTimingDistribution::TestGetValue(const nsACString& aPingName,
return NS_ERROR_FAILURE;
}
auto& data = result.ref().values;
for (auto iter = data.ConstIter(); !iter.Done(); iter.Next()) {
const uint64_t bucket = iter.Key();
const uint64_t count = iter.UserData();
for (const auto& entry : data) {
const uint64_t bucket = entry.GetKey();
const uint64_t count = entry.GetData();
if (!JS_DefineProperty(aCx, valuesObj,
nsPrintfCString("%" PRIu64, bucket).get(),
static_cast<double>(count), JSPROP_ENUMERATE)) {

Просмотреть файл

@ -149,9 +149,9 @@ TEST(FOG, TestCppMemoryDistWorks)
// Sum is in bytes, test_only::do_you_remember is in megabytes. So
// multiplication ahoy!
ASSERT_EQ(data.sum, 24UL * 1024 * 1024);
for (auto iter = data.values.Iter(); !iter.Done(); iter.Next()) {
const uint64_t bucket = iter.Key();
const uint64_t count = iter.UserData();
for (const auto& entry : data.values) {
const uint64_t bucket = entry.GetKey();
const uint64_t count = entry.GetData();
ASSERT_TRUE(count == 0 ||
(count == 1 && (bucket == 17520006 || bucket == 7053950)))
<< "Only two occupied buckets";
@ -210,7 +210,7 @@ TEST(FOG, TestCppTimingDistWorks)
// We also can't guarantee the buckets, but we can guarantee two samples.
uint64_t sampleCount = 0;
for (auto iter = data.values.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = data.values.ConstIter(); !iter.Done(); iter.Next()) {
sampleCount += iter.UserData();
}
ASSERT_EQ(sampleCount, (uint64_t)2);

Просмотреть файл

@ -1896,8 +1896,9 @@ nsresult nsNavHistory::GetQueryResults(
NS_ENSURE_SUCCESS(rv, rv);
}
for (auto iter = addParams.Iter(); !iter.Done(); iter.Next()) {
nsresult rv = statement->BindUTF8StringByName(iter.Key(), iter.Data());
for (const auto& entry : addParams) {
nsresult rv =
statement->BindUTF8StringByName(entry.GetKey(), entry.GetData());
if (NS_FAILED(rv)) {
break;
}
@ -2088,8 +2089,9 @@ nsNavHistory::AsyncExecuteLegacyQuery(nsINavHistoryQuery* aQuery,
NS_ENSURE_SUCCESS(rv, rv);
}
for (auto iter = addParams.Iter(); !iter.Done(); iter.Next()) {
nsresult rv = statement->BindUTF8StringByName(iter.Key(), iter.Data());
for (const auto& entry : addParams) {
nsresult rv =
statement->BindUTF8StringByName(entry.GetKey(), entry.GetData());
if (NS_FAILED(rv)) {
break;
}

Просмотреть файл

@ -1247,8 +1247,8 @@ nsresult TelemetryEvent::CreateSnapshots(uint32_t aDataset, bool aClear,
auto snapshotter = [aDataset, &locker, &processEvents, &leftovers, aClear,
optional_argc,
aEventLimit](EventRecordsMapType& aProcessStorage) {
for (auto iter = aProcessStorage.Iter(); !iter.Done(); iter.Next()) {
const EventRecordArray* eventStorage = iter.UserData();
for (const auto& entry : aProcessStorage) {
const EventRecordArray* eventStorage = entry.GetWeak();
EventRecordArray events;
EventRecordArray leftoverEvents;
@ -1267,12 +1267,11 @@ nsresult TelemetryEvent::CreateSnapshots(uint32_t aDataset, bool aClear,
}
if (events.Length()) {
const char* processName = GetNameForProcessID(ProcessID(iter.Key()));
processEvents.AppendElement(
std::make_pair(processName, std::move(events)));
const char* processName =
GetNameForProcessID(ProcessID(entry.GetKey()));
processEvents.EmplaceBack(processName, std::move(events));
if (leftoverEvents.Length()) {
leftovers.AppendElement(
std::make_pair(iter.Key(), std::move(leftoverEvents)));
leftovers.EmplaceBack(entry.GetKey(), std::move(leftoverEvents));
}
}
}
@ -1355,7 +1354,7 @@ size_t TelemetryEvent::SizeOfIncludingThis(
auto getSizeOfRecords = [aMallocSizeOf](auto& storageMap) {
size_t partial = storageMap.ShallowSizeOfExcludingThis(aMallocSizeOf);
for (auto iter = storageMap.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = storageMap.ConstIter(); !iter.Done(); iter.Next()) {
EventRecordArray* eventRecords = iter.UserData();
partial += eventRecords->ShallowSizeOfIncludingThis(aMallocSizeOf);

Просмотреть файл

@ -1093,8 +1093,8 @@ namespace {
nsresult internal_ReflectKeyedHistogram(
const KeyedHistogramSnapshotData& aSnapshot, const HistogramInfo& info,
JSContext* aCx, JS::Handle<JSObject*> aObj) {
for (auto iter = aSnapshot.ConstIter(); !iter.Done(); iter.Next()) {
const HistogramSnapshotData& keyData = iter.Data();
for (const auto& entry : aSnapshot) {
const HistogramSnapshotData& keyData = entry.GetData();
JS::RootedObject histogramSnapshot(aCx, JS_NewPlainObject(aCx));
if (!histogramSnapshot) {
@ -1106,7 +1106,7 @@ nsresult internal_ReflectKeyedHistogram(
return NS_ERROR_FAILURE;
}
const NS_ConvertUTF8toUTF16 key(iter.Key());
const NS_ConvertUTF8toUTF16 key(entry.GetKey());
if (!JS_DefineUCProperty(aCx, aObj, key.Data(), key.Length(),
histogramSnapshot, JSPROP_ENUMERATE)) {
return NS_ERROR_FAILURE;
@ -1400,8 +1400,8 @@ nsresult KeyedHistogram::GetSnapshot(const StaticMutexAutoLock& aLock,
}
// Snapshot every key.
for (auto iter = histogramMap->ConstIter(); !iter.Done(); iter.Next()) {
base::Histogram* keyData = iter.UserData();
for (const auto& entry : *histogramMap) {
base::Histogram* keyData = entry.GetWeak();
if (!keyData) {
return NS_ERROR_FAILURE;
}
@ -1413,7 +1413,7 @@ nsresult KeyedHistogram::GetSnapshot(const StaticMutexAutoLock& aLock,
}
// Append to the final snapshot.
aSnapshot.InsertOrUpdate(iter.Key(), std::move(keySnapshot));
aSnapshot.InsertOrUpdate(entry.GetKey(), std::move(keySnapshot));
}
if (aClearSubsession) {
@ -3263,9 +3263,9 @@ nsresult TelemetryHistogram::SerializeKeyedHistograms(
aWriter.StartObjectProperty(mozilla::MakeStringSpan(info.name()));
// Each key is a new object with a "sum" and a "counts" property.
for (auto iter = hData.data.ConstIter(); !iter.Done(); iter.Next()) {
const HistogramSnapshotData& keyData = iter.Data();
aWriter.StartObjectProperty(PromiseFlatCString(iter.Key()));
for (const auto& entry : hData.data) {
const HistogramSnapshotData& keyData = entry.GetData();
aWriter.StartObjectProperty(PromiseFlatCString(entry.GetKey()));
internal_ReflectHistogramToJSON(keyData, aWriter);
aWriter.EndObject();
}

Просмотреть файл

@ -187,10 +187,9 @@ uint32_t PrioDataCount(const StaticMutexAutoLock& lock) {
// [(metric1, [[1], [1]]), (metric1, [[0], [1]])]
nsresult AppEncodeTo(const StaticMutexAutoLock& lock,
IdBoolsPairArray& aResult) {
auto iter = gMetricToOriginBag->ConstIter();
for (; !iter.Done(); iter.Next()) {
OriginMetricID id = iter.Key();
const OriginBag& bag = iter.Data();
for (const auto& bagEntry : *gMetricToOriginBag) {
OriginMetricID id = bagEntry.GetKey();
const OriginBag& bag = bagEntry.GetData();
uint32_t generation = 1;
uint32_t maxGeneration = 1;
@ -211,13 +210,12 @@ nsresult AppEncodeTo(const StaticMutexAutoLock& lock,
metricDatum = false;
}
auto originIt = bag.ConstIter();
for (; !originIt.Done(); originIt.Next()) {
uint32_t originCount = originIt.Data();
for (const auto& originEntry : bag) {
uint32_t originCount = originEntry.GetData();
if (originCount >= generation) {
maxGeneration = std::max(maxGeneration, originCount);
const nsACString& origin = originIt.Key();
const nsACString& origin = originEntry.GetKey();
size_t index;
if (!gOriginToIndexMap->Get(origin, &index)) {
return NS_ERROR_FAILURE;
@ -443,22 +441,21 @@ nsresult TelemetryOrigin::GetOriginSnapshot(bool aClear, JSContext* aCx,
return NS_ERROR_FAILURE;
}
aResult.setObject(*rootObj);
for (auto iter = copy.ConstIter(); !iter.Done(); iter.Next()) {
for (const auto& entry : copy) {
JS::RootedObject originsObj(aCx, JS_NewPlainObject(aCx));
if (NS_WARN_IF(!originsObj)) {
return NS_ERROR_FAILURE;
}
if (!JS_DefineProperty(aCx, rootObj, GetNameForMetricID(iter.Key()),
if (!JS_DefineProperty(aCx, rootObj, GetNameForMetricID(entry.GetKey()),
originsObj, JSPROP_ENUMERATE)) {
NS_WARNING("Failed to define property in origin snapshot.");
return NS_ERROR_FAILURE;
}
auto originIt = iter.Data().ConstIter();
for (; !originIt.Done(); originIt.Next()) {
for (const auto& originEntry : entry.GetData()) {
if (!JS_DefineProperty(aCx, originsObj,
nsPromiseFlatCString(originIt.Key()).get(),
originIt.Data(), JSPROP_ENUMERATE)) {
nsPromiseFlatCString(originEntry.GetKey()).get(),
originEntry.GetData(), JSPROP_ENUMERATE)) {
NS_WARNING("Failed to define origin and count in snapshot.");
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -1021,8 +1021,8 @@ void KeyedScalar::SetMaximum(const StaticMutexAutoLock& locker,
*/
nsresult KeyedScalar::GetValue(const nsACString& aStoreName, bool aClearStorage,
nsTArray<KeyValuePair>& aValues) {
for (auto iter = mScalarKeys.ConstIter(); !iter.Done(); iter.Next()) {
ScalarBase* scalar = iter.UserData();
for (const auto& entry : mScalarKeys) {
ScalarBase* scalar = entry.GetWeak();
// Get the scalar value.
nsCOMPtr<nsIVariant> scalarValue;
@ -1036,7 +1036,8 @@ nsresult KeyedScalar::GetValue(const nsACString& aStoreName, bool aClearStorage,
}
// Append it to value list.
aValues.AppendElement(std::make_pair(nsCString(iter.Key()), scalarValue));
aValues.AppendElement(
std::make_pair(nsCString(entry.GetKey()), scalarValue));
}
return NS_OK;
@ -1139,7 +1140,7 @@ ScalarResult KeyedScalar::GetScalarForKey(const StaticMutexAutoLock& locker,
size_t KeyedScalar::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) {
size_t n = aMallocSizeOf(this);
for (auto iter = mScalarKeys.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mScalarKeys.ConstIter(); !iter.Done(); iter.Next()) {
ScalarBase* scalar = iter.UserData();
n += scalar->SizeOfIncludingThis(aMallocSizeOf);
}
@ -1988,23 +1989,22 @@ nsresult internal_ScalarSnapshotter(const StaticMutexAutoLock& aLock,
const nsACString& aStoreName) {
// Iterate the scalars in aProcessStorage. The storage may contain empty or
// yet to be initialized scalars from all the supported processes.
for (auto iter = aProcessStorage.Iter(); !iter.Done(); iter.Next()) {
ScalarStorageMapType* scalarStorage = iter.UserData();
for (const auto& entry : aProcessStorage) {
ScalarStorageMapType* scalarStorage = entry.GetWeak();
ScalarTupleArray& processScalars =
aScalarsToReflect.LookupOrInsert(iter.Key());
aScalarsToReflect.LookupOrInsert(entry.GetKey());
// Are we in the "Dynamic" process?
bool isDynamicProcess =
ProcessID::Dynamic == static_cast<ProcessID>(iter.Key());
ProcessID::Dynamic == static_cast<ProcessID>(entry.GetKey());
// Iterate each available child storage.
for (auto childIter = scalarStorage->Iter(); !childIter.Done();
childIter.Next()) {
ScalarBase* scalar = childIter.UserData();
for (const auto& childEntry : *scalarStorage) {
ScalarBase* scalar = childEntry.GetWeak();
// Get the informations for this scalar.
const BaseScalarInfo& info = internal_GetScalarInfo(
aLock, ScalarKey{childIter.Key(),
aLock, ScalarKey{childEntry.GetKey(),
aIsBuiltinDynamic ? true : isDynamicProcess});
// Serialize the scalar if it's in the desired dataset.
@ -2025,7 +2025,7 @@ nsresult internal_ScalarSnapshotter(const StaticMutexAutoLock& aLock,
}
}
if (processScalars.Length() == 0) {
aScalarsToReflect.Remove(iter.Key());
aScalarsToReflect.Remove(entry.GetKey());
}
}
return NS_OK;
@ -2048,22 +2048,21 @@ nsresult internal_KeyedScalarSnapshotter(
bool aClearScalars, const nsACString& aStoreName) {
// Iterate the scalars in aProcessStorage. The storage may contain empty or
// yet to be initialized scalars from all the supported processes.
for (auto iter = aProcessStorage.Iter(); !iter.Done(); iter.Next()) {
KeyedScalarStorageMapType* scalarStorage = iter.UserData();
for (const auto& entry : aProcessStorage) {
KeyedScalarStorageMapType* scalarStorage = entry.GetWeak();
KeyedScalarTupleArray& processScalars =
aScalarsToReflect.LookupOrInsert(iter.Key());
aScalarsToReflect.LookupOrInsert(entry.GetKey());
// Are we in the "Dynamic" process?
bool isDynamicProcess =
ProcessID::Dynamic == static_cast<ProcessID>(iter.Key());
ProcessID::Dynamic == static_cast<ProcessID>(entry.GetKey());
for (auto childIter = scalarStorage->Iter(); !childIter.Done();
childIter.Next()) {
KeyedScalar* scalar = childIter.UserData();
for (const auto& childEntry : *scalarStorage) {
KeyedScalar* scalar = childEntry.GetWeak();
// Get the informations for this scalar.
const BaseScalarInfo& info = internal_GetScalarInfo(
aLock, ScalarKey{childIter.Key(),
aLock, ScalarKey{childEntry.GetKey(),
aIsBuiltinDynamic ? true : isDynamicProcess});
// Serialize the scalar if it's in the desired dataset.
@ -2085,7 +2084,7 @@ nsresult internal_KeyedScalarSnapshotter(
}
}
if (processScalars.Length() == 0) {
aScalarsToReflect.Remove(iter.Key());
aScalarsToReflect.Remove(entry.GetKey());
}
}
return NS_OK;
@ -3168,9 +3167,9 @@ nsresult TelemetryScalar::CreateSnapshots(unsigned int aDataset,
}
// Reflect it to JS.
for (auto iter = scalarsToReflect.Iter(); !iter.Done(); iter.Next()) {
ScalarTupleArray& processScalars = iter.Data();
const char* processName = GetNameForProcessID(ProcessID(iter.Key()));
for (const auto& entry : scalarsToReflect) {
const ScalarTupleArray& processScalars = entry.GetData();
const char* processName = GetNameForProcessID(ProcessID(entry.GetKey()));
// Create the object that will hold the scalars for this process and add it
// to the returned root object.
@ -3245,9 +3244,9 @@ nsresult TelemetryScalar::CreateKeyedSnapshots(
}
// Reflect it to JS.
for (auto iter = scalarsToReflect.Iter(); !iter.Done(); iter.Next()) {
KeyedScalarTupleArray& processScalars = iter.Data();
const char* processName = GetNameForProcessID(ProcessID(iter.Key()));
for (const auto& entry : scalarsToReflect) {
const KeyedScalarTupleArray& processScalars = entry.GetData();
const char* processName = GetNameForProcessID(ProcessID(entry.GetKey()));
// Create the object that will hold the scalars for this process and add it
// to the returned root object.
@ -3559,9 +3558,9 @@ size_t TelemetryScalar::GetScalarSizesOfIncludingThis(
auto getSizeOf = [aMallocSizeOf](auto& storageMap) {
size_t partial = 0;
for (auto iter = storageMap.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = storageMap.ConstIter(); !iter.Done(); iter.Next()) {
auto scalarStorage = iter.UserData();
for (auto childIter = scalarStorage->Iter(); !childIter.Done();
for (auto childIter = scalarStorage->ConstIter(); !childIter.Done();
childIter.Next()) {
auto scalar = childIter.UserData();
partial += scalar->SizeOfIncludingThis(aMallocSizeOf);
@ -3792,9 +3791,9 @@ nsresult TelemetryScalar::SerializeScalars(mozilla::JSONWriter& aWriter) {
}
// Persist the scalars to the JSON object.
for (auto iter = scalarsToReflect.Iter(); !iter.Done(); iter.Next()) {
ScalarTupleArray& processScalars = iter.Data();
const char* processName = GetNameForProcessID(ProcessID(iter.Key()));
for (const auto& entry : scalarsToReflect) {
const ScalarTupleArray& processScalars = entry.GetData();
const char* processName = GetNameForProcessID(ProcessID(entry.GetKey()));
aWriter.StartObjectProperty(mozilla::MakeStringSpan(processName));
@ -3843,9 +3842,9 @@ nsresult TelemetryScalar::SerializeKeyedScalars(mozilla::JSONWriter& aWriter) {
}
// Persist the scalars to the JSON object.
for (auto iter = keyedScalarsToReflect.Iter(); !iter.Done(); iter.Next()) {
KeyedScalarTupleArray& processScalars = iter.Data();
const char* processName = GetNameForProcessID(ProcessID(iter.Key()));
for (const auto& entry : keyedScalarsToReflect) {
const KeyedScalarTupleArray& processScalars = entry.GetData();
const char* processName = GetNameForProcessID(ProcessID(entry.GetKey()));
aWriter.StartObjectProperty(mozilla::MakeStringSpan(processName));
@ -4004,13 +4003,14 @@ nsresult TelemetryScalar::DeserializePersistedScalars(JSContext* aCx,
{
StaticMutexAutoLock lock(gTelemetryScalarsMutex);
for (auto iter = scalarsToUpdate.ConstIter(); !iter.Done(); iter.Next()) {
const PersistedScalarArray& processScalars = iter.Data();
for (const auto& entry : scalarsToUpdate) {
const PersistedScalarArray& processScalars = entry.GetData();
for (PersistedScalarArray::size_type i = 0; i < processScalars.Length();
i++) {
mozilla::Unused << internal_UpdateScalar(
lock, processScalars[i].first, ScalarActionType::eSet,
processScalars[i].second, ProcessID(iter.Key()), true /* aForce */);
processScalars[i].second, ProcessID(entry.GetKey()),
true /* aForce */);
}
}
}
@ -4178,14 +4178,14 @@ nsresult TelemetryScalar::DeserializePersistedKeyedScalars(
{
StaticMutexAutoLock lock(gTelemetryScalarsMutex);
for (auto iter = scalarsToUpdate.ConstIter(); !iter.Done(); iter.Next()) {
const PersistedKeyedScalarArray& processScalars = iter.Data();
for (const auto& entry : scalarsToUpdate) {
const PersistedKeyedScalarArray& processScalars = entry.GetData();
for (PersistedKeyedScalarArray::size_type i = 0;
i < processScalars.Length(); i++) {
mozilla::Unused << internal_UpdateKeyedScalar(
lock, mozilla::Get<0>(processScalars[i]),
mozilla::Get<1>(processScalars[i]), ScalarActionType::eSet,
mozilla::Get<2>(processScalars[i]), ProcessID(iter.Key()),
mozilla::Get<2>(processScalars[i]), ProcessID(entry.GetKey()),
true /* aForce */);
}
}

Просмотреть файл

@ -117,38 +117,38 @@ class SendBatchRunnable : public Runnable {
gJICTimer->Cancel();
}
for (auto iter = mBatch.Iter(); !iter.Done(); iter.Next()) {
const nsCString& histogramName = PromiseFlatCString(iter.Key());
const nsTArray<uint32_t>& samples = iter.Data();
for (const auto& entry : mBatch) {
const nsCString& histogramName = PromiseFlatCString(entry.GetKey());
const nsTArray<uint32_t>& samples = entry.GetData();
mDelegate->ReceiveHistogramSamples(histogramName, samples);
}
mBatch.Clear();
for (auto iter = mCategoricalBatch.Iter(); !iter.Done(); iter.Next()) {
const nsCString& histogramName = PromiseFlatCString(iter.Key());
const nsTArray<uint32_t>& samples = iter.Data();
for (const auto& entry : mCategoricalBatch) {
const nsCString& histogramName = PromiseFlatCString(entry.GetKey());
const nsTArray<uint32_t>& samples = entry.GetData();
mDelegate->ReceiveCategoricalHistogramSamples(histogramName, samples);
}
mCategoricalBatch.Clear();
for (auto iter = mBoolScalars.Iter(); !iter.Done(); iter.Next()) {
const nsCString& scalarName = PromiseFlatCString(iter.Key());
mDelegate->ReceiveBoolScalarValue(scalarName, iter.Data());
for (const auto& entry : mBoolScalars) {
const nsCString& scalarName = PromiseFlatCString(entry.GetKey());
mDelegate->ReceiveBoolScalarValue(scalarName, entry.GetData());
}
mBoolScalars.Clear();
for (auto iter = mStringScalars.Iter(); !iter.Done(); iter.Next()) {
const nsCString& scalarName = PromiseFlatCString(iter.Key());
const nsCString& scalarValue = PromiseFlatCString(iter.Data());
for (const auto& entry : mStringScalars) {
const nsCString& scalarName = PromiseFlatCString(entry.GetKey());
const nsCString& scalarValue = PromiseFlatCString(entry.GetData());
mDelegate->ReceiveStringScalarValue(scalarName, scalarValue);
}
mStringScalars.Clear();
for (auto iter = mUintScalars.Iter(); !iter.Done(); iter.Next()) {
const nsCString& scalarName = PromiseFlatCString(iter.Key());
mDelegate->ReceiveUintScalarValue(scalarName, iter.Data());
for (const auto& entry : mUintScalars) {
const nsCString& scalarName = PromiseFlatCString(entry.GetKey());
mDelegate->ReceiveUintScalarValue(scalarName, entry.GetData());
}
mUintScalars.Clear();

Просмотреть файл

@ -420,13 +420,13 @@ nsresult UntrustedModulesDataSerializer::AddSingleData(
const UntrustedModulesData& aData) {
// Serialize each entry in the modules hashtable out to the "modules" array
// and store the indices in |mIndexMap|
for (auto iter = aData.mModules.ConstIter(); !iter.Done(); iter.Next()) {
if (!mIndexMap.WithEntryHandle(iter.Key(), [&](auto&& addPtr) {
for (const auto& entry : aData.mModules) {
if (!mIndexMap.WithEntryHandle(entry.GetKey(), [&](auto&& addPtr) {
if (!addPtr) {
addPtr.Insert(mCurModulesArrayIdx);
JS::RootedValue jsModule(mCx);
if (!SerializeModule(mCx, &jsModule, iter.Data(), mFlags) ||
if (!SerializeModule(mCx, &jsModule, entry.GetData(), mFlags) ||
!JS_DefineElement(mCx, mModulesArray, mCurModulesArrayIdx,
jsModule, JSPROP_ENUMERATE)) {
return false;

Просмотреть файл

@ -341,8 +341,8 @@ struct CachedFullHashResponse {
fullHashes.Count() != aOther.fullHashes.Count()) {
return false;
}
for (auto iter = fullHashes.ConstIter(); !iter.Done(); iter.Next()) {
if (iter.Data() != aOther.fullHashes.Get(iter.Key())) {
for (const auto& entry : fullHashes) {
if (entry.GetData() != aOther.fullHashes.Get(entry.GetKey())) {
return false;
}
}
@ -355,9 +355,9 @@ typedef nsClassHashtable<nsUint32HashKey, CachedFullHashResponse>
template <class T>
void CopyClassHashTable(const T& aSource, T& aDestination) {
for (auto iter = aSource.ConstIter(); !iter.Done(); iter.Next()) {
auto value = aDestination.GetOrInsertNew(iter.Key());
*value = *(iter.Data());
for (const auto& entry : aSource) {
auto value = aDestination.GetOrInsertNew(entry.GetKey());
*value = *(entry.GetData());
}
}

Просмотреть файл

@ -363,29 +363,29 @@ void LookupCache::GetCacheInfo(nsIUrlClassifierCacheInfo** aCache) const {
RefPtr<nsUrlClassifierCacheInfo> info = new nsUrlClassifierCacheInfo;
info->table = mTableName;
for (auto iter = mFullHashCache.ConstIter(); !iter.Done(); iter.Next()) {
for (const auto& cacheEntry : mFullHashCache) {
RefPtr<nsUrlClassifierCacheEntry> entry = new nsUrlClassifierCacheEntry;
// Set prefix of the cache entry.
nsAutoCString prefix(reinterpret_cast<const char*>(&iter.Key()),
nsAutoCString prefix(reinterpret_cast<const char*>(&cacheEntry.GetKey()),
PREFIX_SIZE);
CStringToHexString(prefix, entry->prefix);
// Set expiry of the cache entry.
CachedFullHashResponse* response = iter.UserData();
CachedFullHashResponse* response = cacheEntry.GetWeak();
entry->expirySec = response->negativeCacheExpirySec;
// Set positive cache.
FullHashExpiryCache& fullHashes = response->fullHashes;
for (auto iter2 = fullHashes.ConstIter(); !iter2.Done(); iter2.Next()) {
for (const auto& fullHashEntry : fullHashes) {
RefPtr<nsUrlClassifierPositiveCacheEntry> match =
new nsUrlClassifierPositiveCacheEntry;
// Set fullhash of positive cache entry.
CStringToHexString(iter2.Key(), match->fullhash);
CStringToHexString(fullHashEntry.GetKey(), match->fullhash);
// Set expiry of positive cache entry.
match->expirySec = iter2.Data();
match->expirySec = fullHashEntry.GetData();
entry->matches.AppendElement(
static_cast<nsIUrlClassifierPositiveCacheEntry*>(match));
@ -659,22 +659,23 @@ void LookupCache::DumpCache() const {
return;
}
for (auto iter = mFullHashCache.ConstIter(); !iter.Done(); iter.Next()) {
CachedFullHashResponse* response = iter.UserData();
for (const auto& cacheEntry : mFullHashCache) {
CachedFullHashResponse* response = cacheEntry.GetWeak();
nsAutoCString prefix;
CStringToHexString(
nsCString(reinterpret_cast<const char*>(&iter.Key()), PREFIX_SIZE),
nsCString(reinterpret_cast<const char*>(&cacheEntry.GetKey()),
PREFIX_SIZE),
prefix);
LOG(("Cache prefix(%s): %s, Expiry: %s", mTableName.get(), prefix.get(),
GetFormattedTimeString(response->negativeCacheExpirySec).get()));
FullHashExpiryCache& fullHashes = response->fullHashes;
for (auto iter2 = fullHashes.ConstIter(); !iter2.Done(); iter2.Next()) {
for (const auto& fullHashEntry : fullHashes) {
nsAutoCString fullhash;
CStringToHexString(iter2.Key(), fullhash);
CStringToHexString(fullHashEntry.GetKey(), fullhash);
LOG((" - %s, Expiry: %s", fullhash.get(),
GetFormattedTimeString(iter2.Data()).get()));
GetFormattedTimeString(fullHashEntry.GetData()).get()));
}
}
}

Просмотреть файл

@ -512,19 +512,19 @@ nsresult LookupCacheV4::LoadMetadata(nsACString& aState, nsACString& aSHA256) {
}
VLPrefixSet::VLPrefixSet(const PrefixStringMap& aMap) : mCount(0) {
for (auto iter = aMap.ConstIter(); !iter.Done(); iter.Next()) {
uint32_t size = iter.Key();
MOZ_ASSERT(iter.Data()->Length() % size == 0,
for (const auto& entry : aMap) {
uint32_t size = entry.GetKey();
MOZ_ASSERT(entry.GetData()->Length() % size == 0,
"PrefixString must be a multiple of the prefix size.");
mMap.InsertOrUpdate(size, MakeUnique<PrefixString>(*iter.Data(), size));
mCount += iter.Data()->Length() / size;
mMap.InsertOrUpdate(size, MakeUnique<PrefixString>(*entry.GetData(), size));
mCount += entry.GetData()->Length() / size;
}
}
void VLPrefixSet::Merge(PrefixStringMap& aPrefixMap) {
for (auto iter = mMap.ConstIter(); !iter.Done(); iter.Next()) {
nsCString* prefixString = aPrefixMap.GetOrInsertNew(iter.Key());
PrefixString* str = iter.UserData();
for (const auto& entry : mMap) {
nsCString* prefixString = aPrefixMap.GetOrInsertNew(entry.GetKey());
PrefixString* str = entry.GetWeak();
nsAutoCString remainingString;
str->getRemainingString(remainingString);
@ -537,8 +537,8 @@ void VLPrefixSet::Merge(PrefixStringMap& aPrefixMap) {
bool VLPrefixSet::GetSmallestPrefix(nsACString& aOutString) const {
PrefixString* pick = nullptr;
for (auto iter = mMap.ConstIter(); !iter.Done(); iter.Next()) {
PrefixString* str = iter.UserData();
for (const auto& entry : mMap) {
PrefixString* str = entry.GetWeak();
if (str->remaining() <= 0) {
continue;
@ -546,7 +546,7 @@ bool VLPrefixSet::GetSmallestPrefix(nsACString& aOutString) const {
if (aOutString.IsEmpty()) {
str->getPrefix(aOutString);
MOZ_ASSERT(aOutString.Length() == iter.Key());
MOZ_ASSERT(aOutString.Length() == entry.GetKey());
pick = str;
continue;
}
@ -555,7 +555,7 @@ bool VLPrefixSet::GetSmallestPrefix(nsACString& aOutString) const {
str->getPrefix(cur);
if (!cur.IsEmpty() && cur < aOutString) {
aOutString.Assign(cur);
MOZ_ASSERT(aOutString.Length() == iter.Key());
MOZ_ASSERT(aOutString.Length() == entry.GetKey());
pick = str;
}
}

Просмотреть файл

@ -170,14 +170,14 @@ nsresult VariableLengthPrefixSet::SetPrefixes(PrefixStringMap& aPrefixMap) {
}
// 5~32 bytes prefixes are stored in mVLPrefixSet.
for (auto iter = aPrefixMap.ConstIter(); !iter.Done(); iter.Next()) {
for (const auto& entry : aPrefixMap) {
// Skip 4bytes prefixes because it is already stored in mFixedPrefixSet.
if (iter.Key() == PREFIX_SIZE_FIXED) {
if (entry.GetKey() == PREFIX_SIZE_FIXED) {
continue;
}
mVLPrefixSet.InsertOrUpdate(iter.Key(),
MakeUnique<nsCString>(*iter.Data()));
mVLPrefixSet.InsertOrUpdate(entry.GetKey(),
MakeUnique<nsCString>(*entry.GetData()));
}
return NS_OK;
@ -208,8 +208,9 @@ nsresult VariableLengthPrefixSet::GetPrefixes(PrefixStringMap& aPrefixMap) {
}
// Copy variable-length prefix set
for (auto iter = mVLPrefixSet.ConstIter(); !iter.Done(); iter.Next()) {
aPrefixMap.InsertOrUpdate(iter.Key(), MakeUnique<nsCString>(*iter.Data()));
for (const auto& entry : mVLPrefixSet) {
aPrefixMap.InsertOrUpdate(entry.GetKey(),
MakeUnique<nsCString>(*entry.GetData()));
}
return NS_OK;
@ -273,9 +274,9 @@ nsresult VariableLengthPrefixSet::Matches(uint32_t aPrefix,
return NS_OK;
}
for (auto iter = mVLPrefixSet.ConstIter(); !iter.Done(); iter.Next()) {
if (BinarySearch(aFullHash, *iter.Data(), iter.Key())) {
*aLength = iter.Key();
for (const auto& entry : mVLPrefixSet) {
if (BinarySearch(aFullHash, *entry.GetData(), entry.GetKey())) {
*aLength = entry.GetKey();
MOZ_ASSERT(*aLength > 4);
return NS_OK;
}
@ -405,10 +406,10 @@ nsresult VariableLengthPrefixSet::WritePrefixes(
NS_ENSURE_TRUE(written == writelen, NS_ERROR_FAILURE);
// Store PrefixSize, Length of Prefix String and then Prefix String
for (auto iter = mVLPrefixSet.ConstIter(); !iter.Done(); iter.Next()) {
const nsCString& vlPrefixes = *iter.Data();
for (const auto& entry : mVLPrefixSet) {
const nsCString& vlPrefixes = *entry.GetData();
uint8_t prefixSize = iter.Key();
uint8_t prefixSize = entry.GetKey();
writelen = sizeof(uint8_t);
rv = out->Write(reinterpret_cast<char*>(&prefixSize), writelen, &written);
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -1058,11 +1058,11 @@ nsresult nsUrlClassifierDBServiceWorker::CacheResultToTableUpdate(
if (LOG_ENABLED()) {
const FullHashExpiryCache& fullHashes = result->response.fullHashes;
for (auto iter = fullHashes.ConstIter(); !iter.Done(); iter.Next()) {
for (const auto& entry : fullHashes) {
Completion completion;
completion.Assign(iter.Key());
completion.Assign(entry.GetKey());
LOG(("CacheCompletion(v4) hash %X, CacheExpireTime %" PRId64,
completion.ToUint32(), iter.Data()));
completion.ToUint32(), entry.GetData()));
}
}

Просмотреть файл

@ -124,18 +124,18 @@ nsresult PrefixArrayToPrefixStringMap(const _PrefixArray& aPrefixArray,
// The resulting map entries will be a concatenation of all
// prefix data for the prefixes of a given size.
for (auto iter = table.Iter(); !iter.Done(); iter.Next()) {
uint32_t size = iter.Key();
uint32_t count = iter.Data()->Length();
for (const auto& entry : table) {
uint32_t size = entry.GetKey();
uint32_t count = entry.GetData()->Length();
auto str = MakeUnique<_Prefix>();
str->SetLength(size * count);
char* dst = str->BeginWriting();
iter.Data()->Sort();
entry.GetData()->Sort();
for (uint32_t i = 0; i < count; i++) {
memcpy(dst, iter.Data()->ElementAt(i).get(), size);
memcpy(dst, entry.GetData()->ElementAt(i).get(), size);
dst += size;
}
@ -185,9 +185,9 @@ void CheckContent(LookupCacheV4* aCache, const _PrefixArray& aPrefixArray) {
PrefixStringMap expected;
PrefixArrayToPrefixStringMap(aPrefixArray, expected);
for (auto iter = vlPSetMap.Iter(); !iter.Done(); iter.Next()) {
nsCString* expectedPrefix = expected.Get(iter.Key());
nsCString* resultPrefix = iter.UserData();
for (const auto& entry : vlPSetMap) {
nsCString* expectedPrefix = expected.Get(entry.GetKey());
nsCString* resultPrefix = entry.GetWeak();
ASSERT_TRUE(resultPrefix->Equals(*expectedPrefix));
}

Просмотреть файл

@ -126,13 +126,13 @@ TEST(UrlClassifierProtocolParser, SingleValueEncoding)
const TableUpdateArray& tus = p->GetTableUpdates();
RefPtr<const TableUpdateV4> tuv4 = TableUpdate::Cast<TableUpdateV4>(tus[0]);
auto& prefixMap = tuv4->Prefixes();
for (auto iter = prefixMap.ConstIter(); !iter.Done(); iter.Next()) {
for (const auto& entry : prefixMap) {
// This prefix map should contain only a single 4-byte prefixe.
ASSERT_EQ(iter.Key(), 4u);
ASSERT_EQ(entry.GetKey(), 4u);
// The fixed-length prefix string from ProtocolParser should
// exactly match the expected prefix string.
nsCString* prefix = iter.UserData();
nsCString* prefix = entry.GetWeak();
ASSERT_TRUE(prefix->Equals(nsCString(expectedPrefix, 4)));
}

Просмотреть файл

@ -114,9 +114,9 @@ static void GenerateUpdateData(bool fullUpdate, PrefixStringMap& add,
RefPtr<TableUpdateV4> tableUpdate = new TableUpdateV4(GTEST_TABLE);
tableUpdate->SetFullUpdate(fullUpdate);
for (auto iter = add.ConstIter(); !iter.Done(); iter.Next()) {
nsCString* pstring = iter.UserData();
tableUpdate->NewPrefixes(iter.Key(), *pstring);
for (const auto& entry : add) {
nsCString* pstring = entry.GetWeak();
tableUpdate->NewPrefixes(entry.GetKey(), *pstring);
}
if (removal) {
@ -150,9 +150,9 @@ static void VerifyPrefixSet(PrefixStringMap& expected) {
PrefixStringMap prefixesInFile;
lookup->GetPrefixes(prefixesInFile);
for (auto iter = expected.ConstIter(); !iter.Done(); iter.Next()) {
nsCString* expectedPrefix = iter.UserData();
nsCString* resultPrefix = prefixesInFile.Get(iter.Key());
for (const auto& entry : expected) {
nsCString* expectedPrefix = entry.GetWeak();
nsCString* resultPrefix = prefixesInFile.Get(entry.GetKey());
ASSERT_TRUE(*resultPrefix == *expectedPrefix);
}

Просмотреть файл

@ -312,13 +312,13 @@ void UntrustedModulesData::AddNewLoads(
Vector<Telemetry::ProcessedStack>&& aStacks) {
MOZ_ASSERT(aEvents.length() == aStacks.length());
for (auto iter = aModules.ConstIter(); !iter.Done(); iter.Next()) {
if (iter.Data()->IsTrusted()) {
for (const auto& entry : aModules) {
if (entry.GetData()->IsTrusted()) {
// Filter out trusted module records
continue;
}
Unused << mModules.LookupOrInsert(iter.Key(), iter.Data());
Unused << mModules.LookupOrInsert(entry.GetKey(), entry.GetData());
}
// This constant matches the maximum in Telemetry::CombinedStacks

Просмотреть файл

@ -337,10 +337,10 @@ struct ParamTraits<mozilla::ModulesMap> {
static void Write(Message* aMsg, const paramType& aParam) {
aMsg->WriteUInt32(aParam.Count());
for (auto iter = aParam.ConstIter(); !iter.Done(); iter.Next()) {
MOZ_RELEASE_ASSERT(iter.Data());
WriteParam(aMsg, iter.Key());
WriteParam(aMsg, *(iter.Data()));
for (const auto& entry : aParam) {
MOZ_RELEASE_ASSERT(entry.GetData());
WriteParam(aMsg, entry.GetKey());
WriteParam(aMsg, *(entry.GetData()));
}
}

Просмотреть файл

@ -405,12 +405,11 @@ TEST_F(UntrustedModulesFixture, Backup) {
backupSvc->SettleAllStagingData();
EXPECT_TRUE(backupSvc->Ref(BackupType::Staging).IsEmpty());
for (auto iter = backupSvc->Ref(BackupType::Settled).ConstIter();
!iter.Done(); iter.Next()) {
const RefPtr<UntrustedModulesDataContainer>& container = iter.Data();
for (const auto& entry : backupSvc->Ref(BackupType::Settled)) {
const RefPtr<UntrustedModulesDataContainer>& container = entry.GetData();
EXPECT_TRUE(!!container);
const UntrustedModulesData& data = container->mData;
EXPECT_EQ(iter.Key(), ProcessHashKey(data.mProcessType, data.mPid));
EXPECT_EQ(entry.GetKey(), ProcessHashKey(data.mProcessType, data.mPid));
ValidateUntrustedModules(data);
}
}

Просмотреть файл

@ -2155,9 +2155,9 @@ void nsIWidget::UpdateRegisteredPluginWindowVisibility(
// Our visible list is associated with a compositor which is associated with
// a specific top level window. We use the parent widget during iteration
// to skip the plugin widgets owned by other top level windows.
for (auto iter = sPluginWidgetList->Iter(); !iter.Done(); iter.Next()) {
const void* windowId = iter.Key();
nsIWidget* widget = iter.UserData();
for (const auto& entry : *sPluginWidgetList) {
const void* windowId = entry.GetKey();
nsIWidget* widget = entry.GetWeak();
MOZ_ASSERT(windowId);
MOZ_ASSERT(widget);
@ -2180,9 +2180,9 @@ void nsIWidget::CaptureRegisteredPlugins(uintptr_t aOwnerWidget) {
// Our visible list is associated with a compositor which is associated with
// a specific top level window. We use the parent widget during iteration
// to skip the plugin widgets owned by other top level windows.
for (auto iter = sPluginWidgetList->Iter(); !iter.Done(); iter.Next()) {
DebugOnly<const void*> windowId = iter.Key();
nsIWidget* widget = iter.UserData();
for (const auto& entry : *sPluginWidgetList) {
DebugOnly<const void*> windowId = entry.GetKey();
nsIWidget* widget = entry.GetWeak();
MOZ_ASSERT(windowId);
MOZ_ASSERT(widget);

Просмотреть файл

@ -168,7 +168,7 @@ nsresult nsINIParser::GetString(const char* aSection, const char* aKey,
}
nsresult nsINIParser::GetSections(INISectionCallback aCB, void* aClosure) {
for (auto iter = mSections.Iter(); !iter.Done(); iter.Next()) {
for (auto iter = mSections.ConstIter(); !iter.Done(); iter.Next()) {
if (!aCB(iter.Key(), aClosure)) {
break;
}
@ -294,9 +294,9 @@ nsresult nsINIParser::RenameSection(const char* aSection,
nsresult nsINIParser::WriteToFile(nsIFile* aFile) {
nsCString buffer;
for (auto iter = mSections.Iter(); !iter.Done(); iter.Next()) {
buffer.AppendPrintf("[%s]\n", iter.Key());
INIValue* val = iter.UserData();
for (const auto& entry : mSections) {
buffer.AppendPrintf("[%s]\n", entry.GetKey());
INIValue* val = entry.GetWeak();
while (val) {
buffer.AppendPrintf("%s=%s\n", val->key, val->value);
val = val->next.get();

Просмотреть файл

@ -1884,15 +1884,15 @@ nsMemoryReporterManager::GetReportsForThisProcessExtended(
{
mozilla::MutexAutoLock autoLock(mMutex);
for (auto iter = mStrongReporters->Iter(); !iter.Done(); iter.Next()) {
DispatchReporter(iter.Key(), iter.Data(), aHandleReport,
for (const auto& entry : *mStrongReporters) {
DispatchReporter(entry.GetKey(), entry.GetData(), aHandleReport,
aHandleReportData, aAnonymize);
}
for (auto iter = mWeakReporters->Iter(); !iter.Done(); iter.Next()) {
nsCOMPtr<nsIMemoryReporter> reporter = iter.Key();
DispatchReporter(reporter, iter.Data(), aHandleReport, aHandleReportData,
aAnonymize);
for (const auto& entry : *mWeakReporters) {
nsCOMPtr<nsIMemoryReporter> reporter = entry.GetKey();
DispatchReporter(reporter, entry.GetData(), aHandleReport,
aHandleReportData, aAnonymize);
}
}

Просмотреть файл

@ -135,11 +135,11 @@ CategoryEnumerator* CategoryEnumerator::Create(
return nullptr;
}
for (auto iter = aTable.Iter(); !iter.Done(); iter.Next()) {
for (const auto& entry : aTable) {
// if a category has no entries, we pretend it doesn't exist
CategoryNode* aNode = iter.UserData();
CategoryNode* aNode = entry.GetWeak();
if (aNode->Count()) {
enumObj->mArray[enumObj->mCount++] = iter.Key();
enumObj->mArray[enumObj->mCount++] = entry.GetKey();
}
}

Просмотреть файл

@ -236,9 +236,8 @@ nsHashPropertyBagBase::SetPropertyAsInterface(const nsAString& aProp,
}
void nsHashPropertyBagBase::CopyFrom(const nsHashPropertyBagBase* aOther) {
for (auto iter = aOther->mPropertyHash.ConstIter(); !iter.Done();
iter.Next()) {
SetProperty(iter.Key(), iter.UserData());
for (const auto& entry : aOther->mPropertyHash) {
SetProperty(entry.GetKey(), entry.GetWeak());
}
}