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,
GetUserTiming().AddMarkToPerformanceTimeline(*performance_mark);
NotifyObserversOfEntry(*performance_mark);
}
if (RuntimeEnabledFeatures::CustomUserTimingEnabled())
return performance_mark;
return nullptr;
return performance_mark;
}
void Performance::clearMarks(const AtomicString& mark_name) {
......@@ -721,78 +719,57 @@ PerformanceMeasure* Performance::MeasureInternal(
base::Optional<String> end_mark,
ExceptionState& exception_state) {
DCHECK(!start_or_options.IsNull());
if (RuntimeEnabledFeatures::CustomUserTimingEnabled()) {
// An empty option is treated with no difference as null, undefined.
if (start_or_options.IsPerformanceMeasureOptions() &&
!IsMeasureOptionsEmpty(
*start_or_options.GetAsPerformanceMeasureOptions())) {
// measure("name", { start, end }, *)
if (end_mark) {
exception_state.ThrowTypeError(
"If a non-empty PerformanceMeasureOptions object was passed, "
"|end_mark| must not be passed.");
return nullptr;
}
const PerformanceMeasureOptions* options =
start_or_options.GetAsPerformanceMeasureOptions();
if (!options->hasStart() && !options->hasEnd()) {
exception_state.ThrowTypeError(
"If a non-empty PerformanceMeasureOptions object was passed, at "
"least one of its 'start' or 'end' properties must be present.");
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();
}
// An empty option is treated with no difference as null, undefined.
if (start_or_options.IsPerformanceMeasureOptions() &&
!IsMeasureOptionsEmpty(
*start_or_options.GetAsPerformanceMeasureOptions())) {
// measure("name", { start, end }, *)
if (end_mark) {
exception_state.ThrowTypeError(
"If a non-empty PerformanceMeasureOptions object was passed, "
"|end_mark| must not be passed.");
return nullptr;
}
const PerformanceMeasureOptions* options =
start_or_options.GetAsPerformanceMeasureOptions();
if (!options->hasStart() && !options->hasEnd()) {
exception_state.ThrowTypeError(
"If a non-empty PerformanceMeasureOptions object was passed, at "
"least one of its 'start' or 'end' properties must be present.");
return nullptr;
}
return MeasureWithDetail(script_state, measure_name, options->start(),
std::move(duration), options->end(),
options->detail(), exception_state);
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;
}
// measure("name", "mark1", *)
StringOrDouble converted_start;
if (start_or_options.IsString()) {
converted_start =
StringOrDouble::FromString(start_or_options.GetAsString());
base::Optional<double> duration = base::nullopt;
if (options->hasDuration()) {
duration = options->duration();
}
// 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, converted_start,
/* duration = */ base::nullopt,
end_mark ? StringOrDouble::FromString(*end_mark)
: 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'.
return MeasureWithDetail(script_state, measure_name, options->start(),
std::move(duration), options->end(),
options->detail(), exception_state);
}
// measure("name", "mark1", *)
StringOrDouble converted_start;
if (!start_or_options.IsPerformanceMeasureOptions()) {
// |start_or_options| is not nullable.
DCHECK(start_or_options.IsString());
if (start_or_options.IsString()) {
converted_start =
StringOrDouble::FromString(start_or_options.GetAsString());
}
MeasureWithDetail(script_state, measure_name, converted_start,
/* duration = */ base::nullopt,
end_mark ? StringOrDouble::FromString(*end_mark)
: NativeValueTraits<StringOrDouble>::NullValue(),
ScriptValue::CreateNull(script_state->GetIsolate()),
exception_state);
// Return nullptr to distinguish from L3.
return nullptr;
// 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, converted_start,
/* duration = */ base::nullopt,
end_mark ? StringOrDouble::FromString(*end_mark)
: NativeValueTraits<StringOrDouble>::NullValue(),
ScriptValue::CreateNull(script_state->GetIsolate()), exception_state);
}
PerformanceMeasure* Performance::MeasureWithDetail(
......
......@@ -58,22 +58,13 @@ interface Performance : EventTarget {
// User Timing
// https://w3c.github.io/user-timing/#extensions-performance-interface
// 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.
[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);
// TODO(https://crbug.com/996275): Once our IDL parser supports it, we need
// to supply a default-value of '{}' to markOptions.
[MeasureAs=UserTiming, CallWith=ScriptState, RaisesException] PerformanceMark mark(DOMString markName, optional PerformanceMarkOptions markOptions);
[MeasureAs=UserTiming] void clearMarks(optional DOMString markName);
// Doing either of the following requires enabling CustomUserTiming:
// * passing PerformanceMeasureOptions to |startOrOptions|
// * 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);
// TODO(https://crbug.com/996275): Once our IDL parser supports it, we need
// to supply a default-value of '{}' to startOrOptions.
[MeasureAs=UserTiming, CallWith=ScriptState, RaisesException] PerformanceMeasure measure(DOMString measureName, optional (DOMString or PerformanceMeasureOptions) startOrOptions, optional DOMString end);
[MeasureAs=UserTiming] void clearMeasures(optional DOMString measureName);
// TODO(foolip): There is no spec for the Memory Info API, see blink-dev:
......
......@@ -30,5 +30,5 @@
ConstructorCallWith=ScriptState,
RaisesException=Constructor]
interface PerformanceMark : PerformanceEntry {
[CallWith=ScriptState, RuntimeEnabled=CustomUserTiming] readonly attribute any detail;
[CallWith=ScriptState] readonly attribute any detail;
};
......@@ -27,5 +27,5 @@
[Exposed=(Window,Worker)]
interface PerformanceMeasure : PerformanceEntry {
[CallWith=ScriptState, RuntimeEnabled=CustomUserTiming] readonly attribute any detail;
[CallWith=ScriptState] readonly attribute any detail;
};
......@@ -116,7 +116,7 @@ PerformanceMark* UserTiming::CreatePerformanceMark(
}
ScriptValue detail = ScriptValue::CreateNull(script_state->GetIsolate());
if (RuntimeEnabledFeatures::CustomUserTimingEnabled() && mark_options)
if (mark_options)
detail = mark_options->detail();
bool is_worker_global_scope =
......
......@@ -504,10 +504,6 @@
origin_trial_feature_name: "WebComponentsV0",
status: "stable",
},
{
name: "CustomUserTiming",
status: "stable",
},
{
name: "Database",
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