Source code

Copy as Markdown

Other Tools

// -*- mode: C++ -*-
// AUTOGENERATED BY glean_parser. DO NOT EDIT.
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/glean/bindings/GleanJSPingsLookup.h"
#include "mozilla/PerfectHash.h"
#include "nsString.h"
#include "mozilla/PerfectHash.h"
#define GLEAN_PING_INDEX_BITS (16)
#define GLEAN_PING_ID(entry) ((entry) >> GLEAN_PING_INDEX_BITS)
#define GLEAN_PING_INDEX(entry) ((entry) & ((1UL << GLEAN_PING_INDEX_BITS) - 1))
namespace mozilla::glean {
// Contains the ping id and the index into the ping string table.
using ping_entry_t = uint32_t;
Maybe<uint32_t> ping_result_check(const nsACString& aKey, ping_entry_t aEntry);
#if defined(_MSC_VER) && !defined(__clang__)
const char gPingStringTable[] = {
#else
constexpr char gPingStringTable[] = {
#endif
/* 0 - "messagingSystem" */ 'm', 'e', 's', 's', 'a', 'g', 'i', 'n', 'g', 'S', 'y', 's', 't', 'e', 'm', '\0',
/* 16 - "newtab" */ 'n', 'e', 'w', 't', 'a', 'b', '\0',
/* 23 - "spoc" */ 's', 'p', 'o', 'c', '\0',
/* 28 - "topSites" */ 't', 'o', 'p', 'S', 'i', 't', 'e', 's', '\0',
/* 37 - "pocketButton" */ 'p', 'o', 'c', 'k', 'e', 't', 'B', 'u', 't', 't', 'o', 'n', '\0',
/* 50 - "searchWith" */ 's', 'e', 'a', 'r', 'c', 'h', 'W', 'i', 't', 'h', '\0',
/* 61 - "serpCategorization" */ 's', 'e', 'r', 'p', 'C', 'a', 't', 'e', 'g', 'o', 'r', 'i', 'z', 'a', 't', 'i', 'o', 'n', '\0',
/* 80 - "quickSuggest" */ 'q', 'u', 'i', 'c', 'k', 'S', 'u', 'g', 'g', 'e', 's', 't', '\0',
/* 93 - "urlbarPotentialExposure" */ 'u', 'r', 'l', 'b', 'a', 'r', 'P', 'o', 't', 'e', 'n', 't', 'i', 'a', 'l', 'E', 'x', 'p', 'o', 's', 'u', 'r', 'e', '\0',
/* 117 - "prototypeNoCodeEvents" */ 'p', 'r', 'o', 't', 'o', 't', 'y', 'p', 'e', 'N', 'o', 'C', 'o', 'd', 'e', 'E', 'v', 'e', 'n', 't', 's', '\0',
/* 139 - "pageload" */ 'p', 'a', 'g', 'e', 'l', 'o', 'a', 'd', '\0',
/* 148 - "useCounters" */ 'u', 's', 'e', 'C', 'o', 'u', 'n', 't', 'e', 'r', 's', '\0',
/* 160 - "backgroundTasks" */ 'b', 'a', 'c', 'k', 'g', 'r', 'o', 'u', 'n', 'd', 'T', 'a', 's', 'k', 's', '\0',
/* 176 - "crash" */ 'c', 'r', 'a', 's', 'h', '\0',
/* 182 - "onePingOnly" */ 'o', 'n', 'e', 'P', 'i', 'n', 'g', 'O', 'n', 'l', 'y', '\0',
/* 194 - "rideAlongPing" */ 'r', 'i', 'd', 'e', 'A', 'l', 'o', 'n', 'g', 'P', 'i', 'n', 'g', '\0',
/* 208 - "testOhttpPing" */ 't', 'e', 's', 't', 'O', 'h', 't', 't', 'p', 'P', 'i', 'n', 'g', '\0',
/* 222 - "testPing" */ 't', 'e', 's', 't', 'P', 'i', 'n', 'g', '\0',
/* 231 - "brokenSiteReport" */ 'b', 'r', 'o', 'k', 'e', 'n', 'S', 'i', 't', 'e', 'R', 'e', 'p', 'o', 'r', 't', '\0',
/* 248 - "userCharacteristics" */ 'u', 's', 'e', 'r', 'C', 'h', 'a', 'r', 'a', 'c', 't', 'e', 'r', 'i', 's', 't', 'i', 'c', 's', '\0',
/* 268 - "firstStartup" */ 'f', 'i', 'r', 's', 't', 'S', 't', 'a', 'r', 't', 'u', 'p', '\0',
/* 281 - "defaultAgent" */ 'd', 'e', 'f', 'a', 'u', 'l', 't', 'A', 'g', 'e', 'n', 't', '\0',
/* 294 - "backgroundUpdate" */ 'b', 'a', 'c', 'k', 'g', 'r', 'o', 'u', 'n', 'd', 'U', 'p', 'd', 'a', 't', 'e', '\0',
};
const ping_entry_t sPingByNameLookupEntries[] = {
721035,
1114320,
1310968,
1442073,
852128,
917680,
524368,
655477,
327717,
1507622,
1376524,
393266,
1048770,
786580,
262172,
589917,
458813,
983222,
65536,
1245415,
131088,
1179870,
196631
};
Maybe<uint32_t>
PingByNameLookup(const nsACString& aKey)
{
static const uint8_t BASES[] = {
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0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0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
const char* bytes = aKey.BeginReading();
size_t length = aKey.Length();
auto& entry = mozilla::perfecthash::Lookup(bytes, length, BASES,
sPingByNameLookupEntries);
return ping_result_check(aKey, entry);
}
/**
* Get a ping's name given its entry from the PHF.
*/
const char* GetPingName(ping_entry_t aEntry) {
uint32_t idx = GLEAN_PING_INDEX(aEntry);
MOZ_ASSERT(idx < sizeof(gPingStringTable), "Ping index larger than string table");
return &gPingStringTable[idx];
}
/**
* Check if the found entry is pointing at the correct ping.
* PHF can false-positive a result when the key isn't present, so we check
* for a string match. If it fails, return Nothing(). If we found it,
* return the ping's id.
*/
Maybe<uint32_t> ping_result_check(const nsACString& aKey, ping_entry_t aEntry) {
uint32_t idx = GLEAN_PING_INDEX(aEntry);
uint32_t id = GLEAN_PING_ID(aEntry);
if (MOZ_UNLIKELY(idx > sizeof(gPingStringTable))) {
return Nothing();
}
if (aKey.EqualsASCII(&gPingStringTable[idx])) {
return Some(id);
}
return Nothing();
}
#undef GLEAN_PING_INDEX_BITS
#undef GLEAN_PING_ID
#undef GLEAN_PING_INDEX
} // namespace mozilla::glean