mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
Bug 708901 - Migrate to nsTHashSet in toolkit/components/telemetry/core. r=chutten
Depends on D106950 Differential Revision: https://phabricator.services.mozilla.com/D107686
This commit is contained in:
parent
e5674e128d
commit
67753c4382
@ -1731,8 +1731,7 @@ TelemetryImpl::GetAllStores(JSContext* aCx, JS::MutableHandleValue aResult) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
for (auto iter = stores.Iter(); !iter.Done(); iter.Next()) {
|
||||
auto& value = iter.Get()->GetKey();
|
||||
for (const auto& value : stores) {
|
||||
JS::RootedValue store(aCx);
|
||||
|
||||
store.setString(ToJSString(aCx, value));
|
||||
|
@ -9,7 +9,9 @@
|
||||
#include "jsapi.h"
|
||||
#include "mozilla/TypedEnumBits.h"
|
||||
#include "mozilla/TelemetryProcessEnums.h"
|
||||
#include "nsHashtablesFwd.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsTHashSet.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
@ -18,7 +20,7 @@ namespace mozilla {
|
||||
namespace Telemetry {
|
||||
namespace Common {
|
||||
|
||||
typedef nsTHashtable<nsCStringHashKey> StringHashSet;
|
||||
typedef nsTHashSet<nsCString> StringHashSet;
|
||||
|
||||
enum class RecordedProcessType : uint16_t {
|
||||
Main = (1 << GeckoProcessType_Default), // Also known as "parent process"
|
||||
|
@ -288,10 +288,10 @@ bool gCanRecordExtended;
|
||||
nsClassHashtable<nsCStringHashKey, EventKey> gEventNameIDMap(kEventCount);
|
||||
|
||||
// The CategoryName set.
|
||||
nsTHashtable<nsCStringHashKey> gCategoryNames;
|
||||
nsTHashSet<nsCString> gCategoryNames;
|
||||
|
||||
// This tracks the IDs of the categories for which recording is enabled.
|
||||
nsTHashtable<nsCStringHashKey> gEnabledCategories;
|
||||
nsTHashSet<nsCString> gEnabledCategories;
|
||||
|
||||
// The main event storage. Events are inserted here, keyed by process id and
|
||||
// in recording order.
|
||||
@ -386,21 +386,21 @@ EventKey* GetEventKey(const StaticMutexAutoLock& lock,
|
||||
|
||||
static bool CheckExtraKeysValid(const EventKey& eventKey,
|
||||
const ExtraArray& extra) {
|
||||
nsTHashtable<nsCStringHashKey> validExtraKeys;
|
||||
nsTHashSet<nsCString> validExtraKeys;
|
||||
if (!eventKey.dynamic) {
|
||||
const CommonEventInfo& common = gEventInfo[eventKey.id].common_info;
|
||||
for (uint32_t i = 0; i < common.extra_count; ++i) {
|
||||
validExtraKeys.PutEntry(common.extra_key(i));
|
||||
validExtraKeys.Insert(common.extra_key(i));
|
||||
}
|
||||
} else if (gDynamicEventInfo) {
|
||||
const DynamicEventInfo& info = (*gDynamicEventInfo)[eventKey.id];
|
||||
for (uint32_t i = 0, len = info.extra_keys.Length(); i < len; ++i) {
|
||||
validExtraKeys.PutEntry(info.extra_keys[i]);
|
||||
validExtraKeys.Insert(info.extra_keys[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < extra.Length(); ++i) {
|
||||
if (!validExtraKeys.GetEntry(extra[i].key)) {
|
||||
if (!validExtraKeys.Contains(extra[i].key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -459,7 +459,7 @@ RecordEventResult RecordEvent(const StaticMutexAutoLock& lock,
|
||||
processType, dynamicNonBuiltin);
|
||||
|
||||
// Check whether this event's category has recording enabled
|
||||
if (!gEnabledCategories.GetEntry(GetCategory(lock, *eventKey))) {
|
||||
if (!gEnabledCategories.Contains(GetCategory(lock, *eventKey))) {
|
||||
return RecordEventResult::Ok;
|
||||
}
|
||||
|
||||
@ -537,13 +537,13 @@ void RegisterEvents(const StaticMutexAutoLock& lock, const nsACString& category,
|
||||
|
||||
// If it is a builtin, add the category name in order to enable it later.
|
||||
if (aBuiltin) {
|
||||
gCategoryNames.PutEntry(category);
|
||||
gCategoryNames.Insert(category);
|
||||
}
|
||||
|
||||
if (!aBuiltin) {
|
||||
// Now after successful registration enable recording for this category
|
||||
// (if not a dynamic builtin).
|
||||
gEnabledCategories.PutEntry(category);
|
||||
gEnabledCategories.Insert(category);
|
||||
}
|
||||
}
|
||||
|
||||
@ -704,11 +704,11 @@ void TelemetryEvent::InitializeGlobalState(bool aCanRecordBase,
|
||||
gEventNameIDMap.InsertOrUpdate(
|
||||
UniqueEventName(info),
|
||||
UniquePtr<EventKey>{new EventKey{eventId, false}});
|
||||
gCategoryNames.PutEntry(info.common_info.category());
|
||||
gCategoryNames.Insert(info.common_info.category());
|
||||
}
|
||||
|
||||
// A hack until bug 1691156 is fixed
|
||||
gEnabledCategories.PutEntry("avif"_ns);
|
||||
gEnabledCategories.Insert("avif"_ns);
|
||||
|
||||
gInitDone = true;
|
||||
}
|
||||
@ -1341,9 +1341,9 @@ void TelemetryEvent::SetEventRecordingEnabled(const nsACString& category,
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
gEnabledCategories.PutEntry(category);
|
||||
gEnabledCategories.Insert(category);
|
||||
} else {
|
||||
gEnabledCategories.RemoveEntry(category);
|
||||
gEnabledCategories.Remove(category);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2763,7 +2763,7 @@ nsresult TelemetryHistogram::GetAllStores(StringHashSet& set) {
|
||||
const char* name = &gHistogramStringTable[storeIdx];
|
||||
nsAutoCString store;
|
||||
store.AssignASCII(name);
|
||||
if (!set.PutEntry(store)) {
|
||||
if (!set.Insert(store, mozilla::fallible)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
@ -3744,7 +3744,7 @@ nsresult TelemetryScalar::GetAllStores(StringHashSet& set) {
|
||||
const char* name = &gScalarsStringTable[storeIdx];
|
||||
nsAutoCString store;
|
||||
store.AssignASCII(name);
|
||||
if (!set.PutEntry(store)) {
|
||||
if (!set.Insert(store, mozilla::fallible)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
@ -3753,7 +3753,7 @@ nsresult TelemetryScalar::GetAllStores(StringHashSet& set) {
|
||||
for (auto& ptr : *gDynamicStoreNames) {
|
||||
nsAutoCString store;
|
||||
ptr->ToUTF8String(store);
|
||||
if (!set.PutEntry(store)) {
|
||||
if (!set.Insert(store, mozilla::fallible)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user