зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1634281
- Use nsTHashMap for nsBaseHashtable/nsDataHashtable uses with RefPtr data type. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D105963
This commit is contained in:
Родитель
32b1a38aa7
Коммит
bc9766c354
|
@ -16,28 +16,26 @@
|
|||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/ThrottledEventQueue.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsTHashMap.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
static StaticRefPtr<BrowsingContextGroup> sChromeGroup;
|
||||
|
||||
static StaticAutoPtr<
|
||||
nsDataHashtable<nsUint64HashKey, RefPtr<BrowsingContextGroup>>>
|
||||
static StaticAutoPtr<nsTHashMap<uint64_t, RefPtr<BrowsingContextGroup>>>
|
||||
sBrowsingContextGroups;
|
||||
|
||||
already_AddRefed<BrowsingContextGroup> BrowsingContextGroup::GetOrCreate(
|
||||
uint64_t aId) {
|
||||
if (!sBrowsingContextGroups) {
|
||||
sBrowsingContextGroups =
|
||||
new nsDataHashtable<nsUint64HashKey, RefPtr<BrowsingContextGroup>>();
|
||||
new nsTHashMap<nsUint64HashKey, RefPtr<BrowsingContextGroup>>();
|
||||
ClearOnShutdown(&sBrowsingContextGroups);
|
||||
}
|
||||
|
||||
RefPtr<BrowsingContextGroup> group =
|
||||
sBrowsingContextGroups->LookupOrInsertWith(
|
||||
aId, [&aId] { return do_AddRef(new BrowsingContextGroup(aId)); });
|
||||
return group.forget();
|
||||
return do_AddRef(sBrowsingContextGroups->LookupOrInsertWith(
|
||||
aId, [&aId] { return do_AddRef(new BrowsingContextGroup(aId)); }));
|
||||
}
|
||||
|
||||
already_AddRefed<BrowsingContextGroup> BrowsingContextGroup::Create() {
|
||||
|
@ -226,7 +224,8 @@ void BrowsingContextGroup::Destroy() {
|
|||
MOZ_ASSERT(mHosts.Count() == 0);
|
||||
MOZ_ASSERT(mSubscribers.Count() == 0);
|
||||
MOZ_ASSERT_IF(sBrowsingContextGroups,
|
||||
sBrowsingContextGroups->Get(Id()) != this);
|
||||
!sBrowsingContextGroups->Contains(Id()) ||
|
||||
*sBrowsingContextGroups->Lookup(Id()) != this);
|
||||
}
|
||||
mDestroyed = true;
|
||||
#endif
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "nsIEventListenerService.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTObserverArray.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsTHashMap.h"
|
||||
#include "nsGkAtoms.h"
|
||||
|
||||
class nsIMutableArray;
|
||||
|
@ -93,7 +93,7 @@ class EventListenerService final : public nsIEventListenerService {
|
|||
nsAtom* aName);
|
||||
nsTObserverArray<nsCOMPtr<nsIListenerChangeListener>> mChangeListeners;
|
||||
nsCOMPtr<nsIMutableArray> mPendingListenerChanges;
|
||||
nsDataHashtable<nsISupportsHashKey, RefPtr<EventListenerChange>>
|
||||
nsTHashMap<nsISupportsHashKey, RefPtr<EventListenerChange>>
|
||||
mPendingListenerChangesSet;
|
||||
|
||||
static EventListenerService* sInstance;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "nsCRT.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsQueryObject.h"
|
||||
#include "nsTHashMap.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
@ -165,7 +166,7 @@ class ProcessPriorityManagerImpl final : public nsIObserver,
|
|||
void ObserveContentParentCreated(nsISupports* aContentParent);
|
||||
void ObserveContentParentDestroyed(nsISupports* aSubject);
|
||||
|
||||
nsDataHashtable<nsUint64HashKey, RefPtr<ParticularProcessPriorityManager> >
|
||||
nsTHashMap<uint64_t, RefPtr<ParticularProcessPriorityManager> >
|
||||
mParticularManagers;
|
||||
|
||||
/** Contains the PIDs of child processes holding high-priority wakelocks */
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "mozilla/plugins/PluginTypes.h"
|
||||
|
||||
#include "npruntime.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsTHashMap.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace plugins {
|
||||
|
@ -247,8 +247,7 @@ class PluginScriptableObjectChild : public PPluginScriptableObjectChild {
|
|||
static StoredIdentifier* HashIdentifier(const nsCString& aIdentifier);
|
||||
static void UnhashIdentifier(StoredIdentifier* aIdentifier);
|
||||
|
||||
typedef nsDataHashtable<nsCStringHashKey, RefPtr<StoredIdentifier>>
|
||||
IdentifierTable;
|
||||
typedef nsTHashMap<nsCString, RefPtr<StoredIdentifier>> IdentifierTable;
|
||||
static IdentifierTable sIdentifiers;
|
||||
|
||||
struct NPObjectData : public nsPtrHashKey<NPObject> {
|
||||
|
|
|
@ -110,7 +110,7 @@ LocalStorageCache* LocalStorageManager::GetCache(
|
|||
|
||||
already_AddRefed<StorageUsage> LocalStorageManager::GetOriginUsage(
|
||||
const nsACString& aOriginNoSuffix, const uint32_t aPrivateBrowsingId) {
|
||||
RefPtr<StorageUsage> usage = mUsages.LookupOrInsertWith(aOriginNoSuffix, [&] {
|
||||
return do_AddRef(mUsages.LookupOrInsertWith(aOriginNoSuffix, [&] {
|
||||
auto usage = MakeRefPtr<StorageUsage>(aOriginNoSuffix);
|
||||
|
||||
StorageDBChild* storageChild =
|
||||
|
@ -120,9 +120,7 @@ already_AddRefed<StorageUsage> LocalStorageManager::GetOriginUsage(
|
|||
}
|
||||
|
||||
return usage;
|
||||
});
|
||||
|
||||
return usage.forget();
|
||||
}));
|
||||
}
|
||||
|
||||
already_AddRefed<LocalStorageCache> LocalStorageManager::PutCache(
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
#include "mozilla/dom/Storage.h"
|
||||
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsTHashMap.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -124,7 +124,7 @@ class LocalStorageManager final : public nsIDOMStorageManager,
|
|||
|
||||
private:
|
||||
// Keeps usage cache objects for eTLD+1 scopes we have touched.
|
||||
nsDataHashtable<nsCStringHashKey, RefPtr<StorageUsage> > mUsages;
|
||||
nsTHashMap<nsCString, RefPtr<StorageUsage> > mUsages;
|
||||
|
||||
friend class LocalStorageCache;
|
||||
friend class StorageDBChild;
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
#include "nsTArray.h" // for nsTArray
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "mozilla/EnumeratedArray.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "MediaInfo.h"
|
||||
#include "nsTHashMap.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
struct ID3D10Texture2D;
|
||||
|
@ -877,7 +877,7 @@ class SourceSurfaceImage final : public Image {
|
|||
private:
|
||||
gfx::IntSize mSize;
|
||||
RefPtr<gfx::SourceSurface> mSourceSurface;
|
||||
nsDataHashtable<nsUint32HashKey, RefPtr<TextureClient>> mTextureClients;
|
||||
nsTHashMap<uint32_t, RefPtr<TextureClient>> mTextureClients;
|
||||
TextureFlags mTextureFlags;
|
||||
};
|
||||
|
||||
|
|
|
@ -1381,11 +1381,11 @@ void gfxFcPlatformFontList::AddPatternToFontList(
|
|||
GetFaceNames(aFont, aFamilyName, psname, fullname);
|
||||
if (!psname.IsEmpty()) {
|
||||
ToLowerCase(psname);
|
||||
mLocalNames.InsertOrUpdate(psname, aFont);
|
||||
mLocalNames.InsertOrUpdate(psname, RefPtr{aFont});
|
||||
}
|
||||
if (!fullname.IsEmpty()) {
|
||||
ToLowerCase(fullname);
|
||||
mLocalNames.InsertOrUpdate(fullname, aFont);
|
||||
mLocalNames.InsertOrUpdate(fullname, RefPtr{aFont});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1909,12 +1909,12 @@ gfxFontEntry* gfxFcPlatformFontList::LookupLocalFont(
|
|||
}
|
||||
|
||||
// if name is not in the global list, done
|
||||
FcPattern* fontPattern = mLocalNames.Get(keyName);
|
||||
const auto fontPattern = mLocalNames.Lookup(keyName);
|
||||
if (!fontPattern) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new gfxFontconfigFontEntry(aFontName, fontPattern, aWeightForEntry,
|
||||
return new gfxFontconfigFontEntry(aFontName, *fontPattern, aWeightForEntry,
|
||||
aStretchForEntry, aStyleForEntry);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsTHashMap.h"
|
||||
|
||||
#include <fontconfig/fontconfig.h>
|
||||
#include "ft2build.h"
|
||||
|
@ -350,7 +351,7 @@ class gfxFcPlatformFontList final : public gfxPlatformFontList {
|
|||
|
||||
// to avoid enumerating all fonts, maintain a mapping of local font
|
||||
// names to family
|
||||
nsBaseHashtable<nsCStringHashKey, RefPtr<FcPattern>, FcPattern*> mLocalNames;
|
||||
nsTHashMap<nsCString, RefPtr<FcPattern>> mLocalNames;
|
||||
|
||||
// caching generic/lang ==> font family list
|
||||
nsClassHashtable<nsCStringHashKey, PrefFontList> mGenericMappings;
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#include "nsPrintfCString.h"
|
||||
#include "nsSubDocumentFrame.h"
|
||||
#include "nsTransitionManager.h"
|
||||
#include "nsTHashMap.h"
|
||||
|
||||
using namespace mozilla::layers;
|
||||
using namespace mozilla::gfx;
|
||||
|
@ -1692,7 +1693,7 @@ class ContainerState {
|
|||
Maybe<size_t> mAncestorIndex;
|
||||
};
|
||||
|
||||
nsDataHashtable<nsGenericHashKey<MaskLayerKey>, RefPtr<ImageLayer>>
|
||||
nsTHashMap<nsGenericHashKey<MaskLayerKey>, RefPtr<ImageLayer>>
|
||||
mRecycledMaskImageLayers;
|
||||
// Keep display port of AGR to avoid wasting time on doing the same
|
||||
// thing repeatly.
|
||||
|
@ -5609,7 +5610,8 @@ void ContainerState::CollectOldLayers() {
|
|||
NS_ASSERTION(maskLayer->GetType() == Layer::TYPE_IMAGE,
|
||||
"Could not recycle mask layer, unsupported layer type.");
|
||||
mRecycledMaskImageLayers.InsertOrUpdate(
|
||||
MaskLayerKey(layer, Nothing()), static_cast<ImageLayer*>(maskLayer));
|
||||
MaskLayerKey(layer, Nothing()),
|
||||
RefPtr{static_cast<ImageLayer*>(maskLayer)});
|
||||
}
|
||||
for (size_t i = 0; i < layer->GetAncestorMaskLayerCount(); i++) {
|
||||
Layer* maskLayer = layer->GetAncestorMaskLayerAt(i);
|
||||
|
@ -5617,7 +5619,8 @@ void ContainerState::CollectOldLayers() {
|
|||
NS_ASSERTION(maskLayer->GetType() == Layer::TYPE_IMAGE,
|
||||
"Could not recycle mask layer, unsupported layer type.");
|
||||
mRecycledMaskImageLayers.InsertOrUpdate(
|
||||
MaskLayerKey(layer, Some(i)), static_cast<ImageLayer*>(maskLayer));
|
||||
MaskLayerKey(layer, Some(i)),
|
||||
RefPtr{static_cast<ImageLayer*>(maskLayer)});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -653,7 +653,8 @@ static PresShell* GetFocusedPresShell() {
|
|||
void nsDisplayListBuilder::BeginFrame() {
|
||||
nsCSSRendering::BeginFrameTreesLocked();
|
||||
mCurrentAGR = mRootAGR;
|
||||
mFrameToAnimatedGeometryRootMap.InsertOrUpdate(mReferenceFrame, mRootAGR);
|
||||
mFrameToAnimatedGeometryRootMap.InsertOrUpdate(mReferenceFrame,
|
||||
RefPtr{mRootAGR});
|
||||
|
||||
mIsPaintingToWindow = false;
|
||||
mUseHighQualityScaling = false;
|
||||
|
@ -777,8 +778,9 @@ AnimatedGeometryRoot* nsDisplayListBuilder::WrapAGRForFrame(
|
|||
DebugOnly<bool> dummy;
|
||||
MOZ_ASSERT(IsAnimatedGeometryRoot(aAnimatedGeometryRoot, dummy) == AGR_YES);
|
||||
|
||||
RefPtr<AnimatedGeometryRoot> result;
|
||||
if (!mFrameToAnimatedGeometryRootMap.Get(aAnimatedGeometryRoot, &result)) {
|
||||
RefPtr<AnimatedGeometryRoot> result =
|
||||
mFrameToAnimatedGeometryRootMap.Get(aAnimatedGeometryRoot);
|
||||
if (!result) {
|
||||
MOZ_ASSERT(nsLayoutUtils::IsAncestorFrameCrossDoc(RootReferenceFrame(),
|
||||
aAnimatedGeometryRoot));
|
||||
RefPtr<AnimatedGeometryRoot> parent = aParent;
|
||||
|
@ -795,7 +797,7 @@ AnimatedGeometryRoot* nsDisplayListBuilder::WrapAGRForFrame(
|
|||
result = AnimatedGeometryRoot::CreateAGRForFrame(
|
||||
aAnimatedGeometryRoot, parent, aIsAsync, IsRetainingDisplayList());
|
||||
mFrameToAnimatedGeometryRootMap.InsertOrUpdate(aAnimatedGeometryRoot,
|
||||
result);
|
||||
RefPtr{result});
|
||||
}
|
||||
MOZ_ASSERT(!aParent || result->mParentAGR == aParent);
|
||||
return result;
|
||||
|
@ -818,15 +820,17 @@ AnimatedGeometryRoot* nsDisplayListBuilder::FindAnimatedGeometryRootFor(
|
|||
if (aFrame == mCurrentFrame) {
|
||||
return mCurrentAGR;
|
||||
}
|
||||
RefPtr<AnimatedGeometryRoot> result;
|
||||
if (mFrameToAnimatedGeometryRootMap.Get(aFrame, &result)) {
|
||||
|
||||
RefPtr<AnimatedGeometryRoot> result =
|
||||
mFrameToAnimatedGeometryRootMap.Get(aFrame);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool isAsync;
|
||||
nsIFrame* agrFrame = FindAnimatedGeometryRootFrameFor(aFrame, isAsync);
|
||||
result = WrapAGRForFrame(agrFrame, isAsync);
|
||||
mFrameToAnimatedGeometryRootMap.InsertOrUpdate(aFrame, result);
|
||||
mFrameToAnimatedGeometryRootMap.InsertOrUpdate(aFrame, RefPtr{result});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include <stdint.h>
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsTHashMap.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <algorithm>
|
||||
|
@ -1848,7 +1849,7 @@ class nsDisplayListBuilder {
|
|||
nsIFrame* aAnimatedGeometryRoot, bool aIsAsync,
|
||||
AnimatedGeometryRoot* aParent = nullptr);
|
||||
|
||||
nsDataHashtable<nsPtrHashKey<nsIFrame>, RefPtr<AnimatedGeometryRoot>>
|
||||
nsTHashMap<nsIFrame*, RefPtr<AnimatedGeometryRoot>>
|
||||
mFrameToAnimatedGeometryRootMap;
|
||||
|
||||
/**
|
||||
|
|
|
@ -429,7 +429,7 @@ void SocketProcessChild::AddDataBridgeToMap(
|
|||
uint64_t aChannelId, BackgroundDataBridgeParent* aActor) {
|
||||
ipc::AssertIsOnBackgroundThread();
|
||||
MutexAutoLock lock(mMutex);
|
||||
mBackgroundDataBridgeMap.InsertOrUpdate(aChannelId, aActor);
|
||||
mBackgroundDataBridgeMap.InsertOrUpdate(aChannelId, RefPtr{aActor});
|
||||
}
|
||||
|
||||
void SocketProcessChild::RemoveDataBridgeFromMap(uint64_t aChannelId) {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "mozilla/ipc/InputStreamUtils.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "nsRefPtrHashtable.h"
|
||||
#include "nsTHashMap.h"
|
||||
|
||||
namespace mozilla {
|
||||
class ChildProfilerController;
|
||||
|
@ -153,7 +154,7 @@ class SocketProcessChild final
|
|||
bool mShuttingDown;
|
||||
// Protect the table below.
|
||||
Mutex mMutex;
|
||||
nsDataHashtable<nsUint64HashKey, RefPtr<BackgroundDataBridgeParent>>
|
||||
nsTHashMap<uint64_t, RefPtr<BackgroundDataBridgeParent>>
|
||||
mBackgroundDataBridgeMap;
|
||||
};
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIAsyncOutputStream.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsTHashMap.h"
|
||||
#include "TimingStruct.h"
|
||||
#include "Http2Push.h"
|
||||
#include "mozilla/net/DNS.h"
|
||||
|
@ -517,8 +518,7 @@ class nsHttpTransaction final : public nsAHttpTransaction,
|
|||
Atomic<int32_t> mProxyConnectResponseCode;
|
||||
|
||||
OnPushCallback mOnPushCallback;
|
||||
nsDataHashtable<nsUint32HashKey, RefPtr<Http2PushedStreamWrapper>>
|
||||
mIDToStreamMap;
|
||||
nsTHashMap<uint32_t, RefPtr<Http2PushedStreamWrapper>> mIDToStreamMap;
|
||||
|
||||
nsCOMPtr<nsICancelable> mDNSRequest;
|
||||
Atomic<uint32_t, Relaxed> mHTTPSSVCReceivedStage;
|
||||
|
|
|
@ -91,9 +91,8 @@ void ScreenHelperAndroid::Refresh() {
|
|||
mScreens.Remove(0);
|
||||
|
||||
AutoTArray<RefPtr<Screen>, 1> screenList;
|
||||
RefPtr<Screen> screen = MakePrimaryScreen();
|
||||
if (screen) {
|
||||
mScreens.InsertOrUpdate(0, screen);
|
||||
if (RefPtr<Screen> screen = MakePrimaryScreen()) {
|
||||
mScreens.InsertOrUpdate(0, std::move(screen));
|
||||
}
|
||||
|
||||
for (auto iter = mScreens.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
|
@ -110,11 +109,10 @@ void ScreenHelperAndroid::AddScreen(uint32_t aScreenId,
|
|||
MOZ_ASSERT(aScreenId > 0);
|
||||
MOZ_ASSERT(!mScreens.Get(aScreenId, nullptr));
|
||||
|
||||
RefPtr<Screen> screen =
|
||||
new Screen(aRect, aRect, 24, 24, DesktopToLayoutDeviceScale(aDensity),
|
||||
CSSToLayoutDeviceScale(1.0f), 160.0f);
|
||||
|
||||
mScreens.InsertOrUpdate(aScreenId, screen);
|
||||
mScreens.InsertOrUpdate(
|
||||
aScreenId, MakeRefPtr<Screen>(aRect, aRect, 24, 24,
|
||||
DesktopToLayoutDeviceScale(aDensity),
|
||||
CSSToLayoutDeviceScale(1.0f), 160.0f));
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#define ScreenHelperAndroid_h___
|
||||
|
||||
#include "mozilla/widget/ScreenManager.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsTHashMap.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
@ -31,7 +31,7 @@ class ScreenHelperAndroid final : public ScreenManager::Helper {
|
|||
already_AddRefed<Screen> ScreenForId(uint32_t aScreenId);
|
||||
|
||||
private:
|
||||
nsDataHashtable<nsUint32HashKey, RefPtr<Screen>> mScreens;
|
||||
nsTHashMap<uint32_t, RefPtr<Screen>> mScreens;
|
||||
};
|
||||
|
||||
} // namespace widget
|
||||
|
|
Загрузка…
Ссылка в новой задаче