Commit 76cef01c authored by Tom McKee's avatar Tom McKee Committed by Commit Bot

[UserTimingL3] Removing CustomUserTiming REF.

Since User Timing L3 is the default, we don't need the CustomUserTiming
runtime enabled feature anymore. With this removal, we can remove
the L2 code as well as simplify the IDL for performance.mark()
and performance.measure().

Bug: 805566
Change-Id: Ifaec5f5c50aed0d50d140751c32cf80cd95a2fbd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1831561Reviewed-by: default avatarNicolás Peña Moreno <npm@chromium.org>
Reviewed-by: default avatarSteve Kobes <skobes@chromium.org>
Commit-Queue: Tom McKee <tommckee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703875}
parent 923f4596
...@@ -658,9 +658,7 @@ PerformanceMark* Performance::mark(ScriptState* script_state, ...@@ -658,9 +658,7 @@ PerformanceMark* Performance::mark(ScriptState* script_state,
GetUserTiming().AddMarkToPerformanceTimeline(*performance_mark); GetUserTiming().AddMarkToPerformanceTimeline(*performance_mark);
NotifyObserversOfEntry(*performance_mark); NotifyObserversOfEntry(*performance_mark);
} }
if (RuntimeEnabledFeatures::CustomUserTimingEnabled()) return performance_mark;
return performance_mark;
return nullptr;
} }
void Performance::clearMarks(const AtomicString& mark_name) { void Performance::clearMarks(const AtomicString& mark_name) {
...@@ -721,78 +719,57 @@ PerformanceMeasure* Performance::MeasureInternal( ...@@ -721,78 +719,57 @@ PerformanceMeasure* Performance::MeasureInternal(
base::Optional<String> end_mark, base::Optional<String> end_mark,
ExceptionState& exception_state) { ExceptionState& exception_state) {
DCHECK(!start_or_options.IsNull()); DCHECK(!start_or_options.IsNull());
if (RuntimeEnabledFeatures::CustomUserTimingEnabled()) { // An empty option is treated with no difference as null, undefined.
// An empty option is treated with no difference as null, undefined. if (start_or_options.IsPerformanceMeasureOptions() &&
if (start_or_options.IsPerformanceMeasureOptions() && !IsMeasureOptionsEmpty(
!IsMeasureOptionsEmpty( *start_or_options.GetAsPerformanceMeasureOptions())) {
*start_or_options.GetAsPerformanceMeasureOptions())) { // measure("name", { start, end }, *)
// measure("name", { start, end }, *) if (end_mark) {
if (end_mark) { exception_state.ThrowTypeError(
exception_state.ThrowTypeError( "If a non-empty PerformanceMeasureOptions object was passed, "
"If a non-empty PerformanceMeasureOptions object was passed, " "|end_mark| must not be passed.");
"|end_mark| must not be passed."); return nullptr;
return nullptr; }
} const PerformanceMeasureOptions* options =
const PerformanceMeasureOptions* options = start_or_options.GetAsPerformanceMeasureOptions();
start_or_options.GetAsPerformanceMeasureOptions(); if (!options->hasStart() && !options->hasEnd()) {
if (!options->hasStart() && !options->hasEnd()) { exception_state.ThrowTypeError(
exception_state.ThrowTypeError( "If a non-empty PerformanceMeasureOptions object was passed, at "
"If a non-empty PerformanceMeasureOptions object was passed, at " "least one of its 'start' or 'end' properties must be present.");
"least one of its 'start' or 'end' properties must be present."); return nullptr;
return nullptr; }
}
if (options->hasStart() && options->hasDuration() && options->hasEnd()) {
exception_state.ThrowTypeError(
"If a non-empty PerformanceMeasureOptions object was passed, it "
"must not have all of its 'start', 'duration', and 'end' "
"properties defined");
return nullptr;
}
base::Optional<double> duration = base::nullopt;
if (options->hasDuration()) {
duration = options->duration();
}
return MeasureWithDetail(script_state, measure_name, options->start(), if (options->hasStart() && options->hasDuration() && options->hasEnd()) {
std::move(duration), options->end(), exception_state.ThrowTypeError(
options->detail(), exception_state); "If a non-empty PerformanceMeasureOptions object was passed, it "
"must not have all of its 'start', 'duration', and 'end' "
"properties defined");
return nullptr;
} }
// measure("name", "mark1", *)
StringOrDouble converted_start; base::Optional<double> duration = base::nullopt;
if (start_or_options.IsString()) { if (options->hasDuration()) {
converted_start = duration = options->duration();
StringOrDouble::FromString(start_or_options.GetAsString());
} }
// We let |end_mark| behave the same whether it's empty, undefined or null
// in JS, as long as |end_mark| is null in C++. return MeasureWithDetail(script_state, measure_name, options->start(),
return MeasureWithDetail( std::move(duration), options->end(),
script_state, measure_name, converted_start, options->detail(), exception_state);
/* duration = */ base::nullopt, }
end_mark ? StringOrDouble::FromString(*end_mark) // measure("name", "mark1", *)
: NativeValueTraits<StringOrDouble>::NullValue(),
ScriptValue::CreateNull(script_state->GetIsolate()), exception_state);
}
// For consistency with UserTimingL2: the L2 API took |start| as a string,
// so any object passed in became a string '[object, object]', null became
// string 'null'.
StringOrDouble converted_start; StringOrDouble converted_start;
if (!start_or_options.IsPerformanceMeasureOptions()) { if (start_or_options.IsString()) {
// |start_or_options| is not nullable.
DCHECK(start_or_options.IsString());
converted_start = converted_start =
StringOrDouble::FromString(start_or_options.GetAsString()); StringOrDouble::FromString(start_or_options.GetAsString());
} }
// We let |end_mark| behave the same whether it's empty, undefined or null
MeasureWithDetail(script_state, measure_name, converted_start, // in JS, as long as |end_mark| is null in C++.
/* duration = */ base::nullopt, return MeasureWithDetail(
end_mark ? StringOrDouble::FromString(*end_mark) script_state, measure_name, converted_start,
: NativeValueTraits<StringOrDouble>::NullValue(), /* duration = */ base::nullopt,
ScriptValue::CreateNull(script_state->GetIsolate()), end_mark ? StringOrDouble::FromString(*end_mark)
exception_state); : NativeValueTraits<StringOrDouble>::NullValue(),
// Return nullptr to distinguish from L3. ScriptValue::CreateNull(script_state->GetIsolate()), exception_state);
return nullptr;
} }
PerformanceMeasure* Performance::MeasureWithDetail( PerformanceMeasure* Performance::MeasureWithDetail(
......
...@@ -58,22 +58,13 @@ interface Performance : EventTarget { ...@@ -58,22 +58,13 @@ interface Performance : EventTarget {
// User Timing // User Timing
// https://w3c.github.io/user-timing/#extensions-performance-interface // https://w3c.github.io/user-timing/#extensions-performance-interface
// We use the returned value for feature detection: // TODO(https://crbug.com/996275): Once our IDL parser supports it, we need
// * L2 API returns null but this is a bug: crbug.com/914441. // to supply a default-value of '{}' to markOptions.
// * L3 API returns the created entry. [MeasureAs=UserTiming, CallWith=ScriptState, RaisesException] PerformanceMark mark(DOMString markName, optional PerformanceMarkOptions markOptions);
[MeasureAs=UserTiming, CallWith=ScriptState, RaisesException] PerformanceMark? mark(DOMString markName);
// TODO(maxlg): PerformanceMarkOptions will be changed to optional after L3 is default to be enabled.
[MeasureAs=UserTiming, CallWith=ScriptState, RuntimeEnabled=CustomUserTiming, RaisesException] PerformanceMark? mark(DOMString markName, PerformanceMarkOptions markOptions);
[MeasureAs=UserTiming] void clearMarks(optional DOMString markName); [MeasureAs=UserTiming] void clearMarks(optional DOMString markName);
// TODO(https://crbug.com/996275): Once our IDL parser supports it, we need
// Doing either of the following requires enabling CustomUserTiming: // to supply a default-value of '{}' to startOrOptions.
// * passing PerformanceMeasureOptions to |startOrOptions| [MeasureAs=UserTiming, CallWith=ScriptState, RaisesException] PerformanceMeasure measure(DOMString measureName, optional (DOMString or PerformanceMeasureOptions) startOrOptions, optional DOMString end);
// * passing timestamps to |startOrOptions| or |end|
// We use the returned value for feature detection:
// * L2 API returns null but this is a bug: crbug.com/914441.
// * L3 API returns the created entry.
// https://w3c.github.io/user-timing/#extensions-performance-interface
[MeasureAs=UserTiming, CallWith=ScriptState, RaisesException] PerformanceMeasure? measure(DOMString measureName, optional (DOMString or PerformanceMeasureOptions) startOrOptions, optional DOMString end);
[MeasureAs=UserTiming] void clearMeasures(optional DOMString measureName); [MeasureAs=UserTiming] void clearMeasures(optional DOMString measureName);
// TODO(foolip): There is no spec for the Memory Info API, see blink-dev: // TODO(foolip): There is no spec for the Memory Info API, see blink-dev:
......
...@@ -30,5 +30,5 @@ ...@@ -30,5 +30,5 @@
ConstructorCallWith=ScriptState, ConstructorCallWith=ScriptState,
RaisesException=Constructor] RaisesException=Constructor]
interface PerformanceMark : PerformanceEntry { interface PerformanceMark : PerformanceEntry {
[CallWith=ScriptState, RuntimeEnabled=CustomUserTiming] readonly attribute any detail; [CallWith=ScriptState] readonly attribute any detail;
}; };
...@@ -27,5 +27,5 @@ ...@@ -27,5 +27,5 @@
[Exposed=(Window,Worker)] [Exposed=(Window,Worker)]
interface PerformanceMeasure : PerformanceEntry { interface PerformanceMeasure : PerformanceEntry {
[CallWith=ScriptState, RuntimeEnabled=CustomUserTiming] readonly attribute any detail; [CallWith=ScriptState] readonly attribute any detail;
}; };
...@@ -116,7 +116,7 @@ PerformanceMark* UserTiming::CreatePerformanceMark( ...@@ -116,7 +116,7 @@ PerformanceMark* UserTiming::CreatePerformanceMark(
} }
ScriptValue detail = ScriptValue::CreateNull(script_state->GetIsolate()); ScriptValue detail = ScriptValue::CreateNull(script_state->GetIsolate());
if (RuntimeEnabledFeatures::CustomUserTimingEnabled() && mark_options) if (mark_options)
detail = mark_options->detail(); detail = mark_options->detail();
bool is_worker_global_scope = bool is_worker_global_scope =
......
...@@ -504,10 +504,6 @@ ...@@ -504,10 +504,6 @@
origin_trial_feature_name: "WebComponentsV0", origin_trial_feature_name: "WebComponentsV0",
status: "stable", status: "stable",
}, },
{
name: "CustomUserTiming",
status: "stable",
},
{ {
name: "Database", name: "Database",
status: "stable", status: "stable",
......
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