Bug 1202706 - Part 3: Hook up worker use counters to WebIDL bindings; r=bzbarsky

Differential Revision: https://phabricator.services.mozilla.com/D53749

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Edgar Chen 2019-11-26 05:08:39 +00:00
Родитель ab7bcaf8da
Коммит a8a12bf5b1
3 изменённых файлов: 36 добавлений и 1 удалений

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

@ -3880,6 +3880,13 @@ void SetUseCounter(JSObject* aObject, UseCounter aUseCounter) {
}
}
void SetUseCounter(UseCounterWorker aUseCounter) {
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(workerPrivate);
workerPrivate->SetUseCounter(aUseCounter);
}
namespace {
#define DEPRECATED_OPERATION(_op) #_op,

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

@ -50,6 +50,7 @@ class nsGenericHTMLElement;
namespace mozilla {
enum UseCounter : int16_t;
enum class UseCounterWorker : int16_t;
namespace dom {
class CustomElementReactionsStack;
@ -3097,6 +3098,7 @@ already_AddRefed<Element> CreateXULOrHTMLElement(
JS::Handle<JSObject*> aGivenProto, ErrorResult& aRv);
void SetUseCounter(JSObject* aObject, UseCounter aUseCounter);
void SetUseCounter(UseCounterWorker aUseCounter);
// Warnings
void DeprecationWarning(JSContext* aCx, JSObject* aObject,

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

@ -8095,7 +8095,33 @@ class CGPerSignatureCall(CGThing):
if useCounterName:
# Generate a telemetry call for when [UseCounter] is used.
code = "SetUseCounter(obj, eUseCounter_%s);\n" % useCounterName
windowCode = fill(
"""
SetUseCounter(obj, eUseCounter_${useCounterName});
""",
useCounterName = useCounterName)
workerCode = fill(
"""
SetUseCounter(UseCounterWorker::${useCounterName});
""",
useCounterName = useCounterName)
code = ""
if idlNode.isExposedInWindow() and idlNode.isExposedInAnyWorker():
code += fill(
"""
if (NS_IsMainThread()) {
${windowCode}
} else {
${workerCode}
}
""",
windowCode=windowCode,
workerCode=workerCode)
elif idlNode.isExposedInWindow():
code += windowCode
elif idlNode.isExposedInAnyWorker():
code += workerCode
cgThings.append(CGGeneric(code))
self.cgRoot = CGList(cgThings)