Commit 4679d0a3 authored by Nicolas Pena's avatar Nicolas Pena Committed by Commit Bot

EventTiming: Add UseCounter to track explicit usage

This CL adds a UseCounter that tracks the two ways to use EventTiming
explicitly:
* getEntriesByType or getEntriesByName with event/firstInput.
* Having PerformanceObservers of event/firstInput.

Bug: 851484
Change-Id: I8c2af71d089dbbf7db87b94b8b5d9f56e1699998
Reviewed-on: https://chromium-review.googlesource.com/1115511Reviewed-by: default avatarTimothy Dresser <tdresser@chromium.org>
Reviewed-by: default avatarSteve Kobes <skobes@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570539}
parent 68be7e38
......@@ -1947,6 +1947,7 @@ enum WebFeature {
kLegacySymantecCertMainFrameResource = 2484,
kLegacySymantecCertInSubresource = 2485,
kLegacySymantecCertInSubframeMainResource = 2486,
kEventTimingExplicitlyRequested = 2487,
// Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots.
......
......@@ -171,10 +171,14 @@ PerformanceEntryVector Performance::getEntriesByType(const String& entry_type) {
entries.push_back(resource);
break;
case PerformanceEntry::kEvent:
UseCounter::Count(GetExecutionContext(),
WebFeature::kEventTimingExplicitlyRequested);
for (const auto& event : event_timing_buffer_)
entries.push_back(event);
break;
case PerformanceEntry::kFirstInput:
UseCounter::Count(GetExecutionContext(),
WebFeature::kEventTimingExplicitlyRequested);
if (first_input_timing_)
entries.push_back(first_input_timing_);
break;
......@@ -246,11 +250,19 @@ PerformanceEntryVector Performance::getEntriesByName(const String& name,
entries.push_back(event);
}
}
if (type == PerformanceEntry::kEvent) {
UseCounter::Count(GetExecutionContext(),
WebFeature::kEventTimingExplicitlyRequested);
}
if (entry_type.IsNull() || type == PerformanceEntry::kFirstInput) {
if (first_input_timing_ && first_input_timing_->name() == name)
entries.push_back(first_input_timing_);
}
if (type == PerformanceEntry::kFirstInput) {
UseCounter::Count(GetExecutionContext(),
WebFeature::kEventTimingExplicitlyRequested);
}
if (entry_type.IsNull() || type == PerformanceEntry::kNavigation) {
if (!navigation_timing_)
......
......@@ -371,8 +371,11 @@ void WindowPerformance::ReportEventTimings(WebLayerTreeView::SwapResult result,
if (duration_in_ms <= kEventTimingDurationThresholdInMs)
continue;
if (ObservingEventTimingEntries())
if (ObservingEventTimingEntries()) {
UseCounter::Count(GetFrame(),
WebFeature::kEventTimingExplicitlyRequested);
NotifyObserversOfEntry(*entry);
}
if (ShouldBufferEventTiming() && !IsEventTimingBufferFull())
AddEventTimingBuffer(*entry);
......@@ -388,8 +391,10 @@ void WindowPerformance::DispatchFirstInputTiming(
if (!entry)
return;
DCHECK_EQ("firstInput", entry->entryType());
if (HasObserverFor(PerformanceEntry::kFirstInput))
if (HasObserverFor(PerformanceEntry::kFirstInput)) {
UseCounter::Count(GetFrame(), WebFeature::kEventTimingExplicitlyRequested);
NotifyObserversOfEntry(*entry);
}
DCHECK(!first_input_timing_);
if (ShouldBufferEventTiming())
......
......@@ -19058,6 +19058,7 @@ Called by update_net_error_codes.py.-->
<int value="2484" label="LegacySymantecCertMainFrameResource"/>
<int value="2485" label="LegacySymantecCertInSubresource"/>
<int value="2486" label="LegacySymantecCertInSubframeMainResource"/>
<int value="2487" label="EventTimingExplicitlyRequested"/>
</enum>
<enum name="FeedbackSource">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment