mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1867997 - Add support for tracking the success rate of group initialization; r=dom-storage-reviewers,jari
This patch adds support for tracking the success rate of group initialization by adding two new keys for QM_FIRST_INITIALIZATION_ATTEMPT keyd histogram. The new keys are PersistentGroup and TemporaryGroup. Differential Revision: https://phabricator.services.mozilla.com/D196822
This commit is contained in:
parent
8517ddc5a8
commit
f50143aab1
@ -7206,6 +7206,18 @@ auto QuotaManager::ExecuteInitialization(const Initialization aInitialization,
|
||||
aContext, std::forward<Func>(aFunc));
|
||||
}
|
||||
|
||||
template <typename Func>
|
||||
auto QuotaManager::ExecuteGroupInitialization(
|
||||
const nsACString& aGroup, const GroupInitialization aInitialization,
|
||||
const nsACString& aContext, Func&& aFunc)
|
||||
-> std::invoke_result_t<Func, const FirstInitializationAttempt<
|
||||
Initialization, StringGenerator>&> {
|
||||
return quota::ExecuteInitialization(
|
||||
mInitializationInfo.MutableGroupInitializationInfoRef(
|
||||
aGroup, CreateIfNonExistent{}),
|
||||
aInitialization, aContext, std::forward<Func>(aFunc));
|
||||
}
|
||||
|
||||
template <typename Func>
|
||||
auto QuotaManager::ExecuteOriginInitialization(
|
||||
const nsACString& aOrigin, const OriginInitialization aInitialization,
|
||||
|
@ -42,6 +42,20 @@ nsLiteralCString StringGenerator::GetString(
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
nsLiteralCString StringGenerator::GetString(
|
||||
const GroupInitialization aGroupInitialization) {
|
||||
switch (aGroupInitialization) {
|
||||
case GroupInitialization::PersistentGroup:
|
||||
return "PersistentGroup"_ns;
|
||||
case GroupInitialization::TemporaryGroup:
|
||||
return "TemporaryGroup"_ns;
|
||||
|
||||
default:
|
||||
MOZ_CRASH("Bad group initialization value!");
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
nsLiteralCString StringGenerator::GetString(
|
||||
const OriginInitialization aOriginInitialization) {
|
||||
|
@ -35,6 +35,12 @@ enum class Initialization {
|
||||
PersistentRepository = 1 << 11,
|
||||
};
|
||||
|
||||
enum class GroupInitialization {
|
||||
None = 0,
|
||||
PersistentGroup = 1 << 0,
|
||||
TemporaryGroup = 1 << 1,
|
||||
};
|
||||
|
||||
enum class OriginInitialization {
|
||||
None = 0,
|
||||
PersistentOrigin = 1 << 0,
|
||||
@ -42,6 +48,7 @@ enum class OriginInitialization {
|
||||
};
|
||||
|
||||
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Initialization)
|
||||
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(GroupInitialization)
|
||||
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(OriginInitialization)
|
||||
|
||||
class StringGenerator final {
|
||||
@ -49,6 +56,9 @@ class StringGenerator final {
|
||||
// TODO: Use constexpr here once bug 1594094 is addressed.
|
||||
static nsLiteralCString GetString(Initialization aInitialization);
|
||||
|
||||
// TODO: Use constexpr here once bug 1594094 is addressed.
|
||||
static nsLiteralCString GetString(GroupInitialization aGroupInitialization);
|
||||
|
||||
// TODO: Use constexpr here once bug 1594094 is addressed.
|
||||
static nsLiteralCString GetString(OriginInitialization aOriginInitialization);
|
||||
};
|
||||
@ -56,12 +66,29 @@ class StringGenerator final {
|
||||
using OriginInitializationInfo =
|
||||
FirstInitializationAttempts<OriginInitialization, StringGenerator>;
|
||||
|
||||
using GroupInitializationInfo =
|
||||
FirstInitializationAttempts<GroupInitialization, StringGenerator>;
|
||||
|
||||
class InitializationInfo
|
||||
: public FirstInitializationAttempts<Initialization, StringGenerator> {
|
||||
nsTHashMap<nsCStringHashKey, GroupInitializationInfo>
|
||||
mGroupInitializationInfos;
|
||||
nsTHashMap<nsCStringHashKey, OriginInitializationInfo>
|
||||
mOriginInitializationInfos;
|
||||
|
||||
public:
|
||||
GroupInitializationInfo& MutableGroupInitializationInfoRef(
|
||||
const nsACString& aGroup) {
|
||||
return *mGroupInitializationInfos.Lookup(aGroup);
|
||||
}
|
||||
|
||||
GroupInitializationInfo& MutableGroupInitializationInfoRef(
|
||||
const nsACString& aGroup, const CreateIfNonExistent&) {
|
||||
return mGroupInitializationInfos.LookupOrInsert(aGroup);
|
||||
}
|
||||
|
||||
void ResetGroupInitializationInfos() { mGroupInitializationInfos.Clear(); }
|
||||
|
||||
OriginInitializationInfo& MutableOriginInitializationInfoRef(
|
||||
const nsACString& aOrigin) {
|
||||
return *mOriginInitializationInfos.Lookup(aOrigin);
|
||||
|
@ -792,6 +792,13 @@ class QuotaManager final : public BackgroundThreadObject {
|
||||
-> std::invoke_result_t<Func, const FirstInitializationAttempt<
|
||||
Initialization, StringGenerator>&>;
|
||||
|
||||
template <typename Func>
|
||||
auto ExecuteGroupInitialization(const nsACString& aGroup,
|
||||
const GroupInitialization aInitialization,
|
||||
const nsACString& aContext, Func&& aFunc)
|
||||
-> std::invoke_result_t<Func, const FirstInitializationAttempt<
|
||||
Initialization, StringGenerator>&>;
|
||||
|
||||
template <typename Func>
|
||||
auto ExecuteOriginInitialization(const nsACString& aOrigin,
|
||||
const OriginInitialization aInitialization,
|
||||
|
Loading…
Reference in New Issue
Block a user