Commit 262009cc authored by panicker's avatar panicker Committed by Commit bot

Create TaskAttributionTiming PerformanceEntry for attribution in...

Create TaskAttributionTiming PerformanceEntry for attribution in PerformanceLongTaskTiming. Move culprit-frame-related fields in there

BUG=676484

Review-Url: https://codereview.chromium.org/2610063006
Cr-Commit-Position: refs/heads/master@{#441814}
parent 95355aa2
...@@ -7,17 +7,27 @@ async_test(function (t) { ...@@ -7,17 +7,27 @@ async_test(function (t) {
var observer = new PerformanceObserver( var observer = new PerformanceObserver(
t.step_func(function (entryList) { t.step_func(function (entryList) {
var entries = entryList.getEntries(); var entries = entryList.getEntries();
/* TODO(panicker): Update after fixing http://crbug.com/651461 */ assert_equals(entries.length, 1,
for (var i = 0; i < entries.length; i++) { "Exactly one entry is expected.");
assert_equals(entries[i].entryType, "longtask", var longtask = entries[0];
"entryType expected to be: longtask"); assert_equals(longtask.entryType, "longtask",
assert_equals(entries[i].name, "same-origin-self", "entryType expected to be: longtask");
"name expected to be: same-origin-self"); assert_equals(longtask.name, "same-origin-self",
assert_greater_than(entries[i].duration, 50, "name expected to be: same-origin-self");
"duration expected to be greater than 50ms threshold"); assert_greater_than(longtask.duration, 50,
assert_equals(entries[i].startTime, Math.floor(entries[i].startTime), "duration expected to be greater than 50ms threshold");
"startTime expected to have 1 miilisecond granularity"); assert_equals(longtask.startTime, Math.floor(longtask.startTime),
} "startTime expected to have 1 miillisecond granularity");
// Assert the TaskAttributionTiming entry in attribution.
assert_equals(longtask.attribution.length, 1,
"Exactly one attribution entry is expected");
var attribution = longtask.attribution[0];
assert_equals(attribution.entryType, "taskattribution");
assert_equals(attribution.name, "frame");
assert_equals(attribution.duration, 0);
assert_equals(attribution.startTime, 0);
observer.disconnect(); observer.disconnect();
t.done(); t.done();
}) })
......
...@@ -4567,9 +4567,7 @@ interface PerformanceEntry ...@@ -4567,9 +4567,7 @@ interface PerformanceEntry
method toJSON method toJSON
interface PerformanceLongTaskTiming : PerformanceEntry interface PerformanceLongTaskTiming : PerformanceEntry
attribute @@toStringTag attribute @@toStringTag
getter culpritFrameId getter attribution
getter culpritFrameName
getter culpritFrameSrc
method constructor method constructor
interface PerformanceMark : PerformanceEntry interface PerformanceMark : PerformanceEntry
attribute @@toStringTag attribute @@toStringTag
...@@ -6455,6 +6453,12 @@ interface SyncManager ...@@ -6455,6 +6453,12 @@ interface SyncManager
method constructor method constructor
method getTags method getTags
method register method register
interface TaskAttributionTiming : PerformanceEntry
attribute @@toStringTag
getter frameId
getter frameName
getter frameSrc
method constructor
interface Text : CharacterData interface Text : CharacterData
attribute @@toStringTag attribute @@toStringTag
getter assignedSlot getter assignedSlot
......
...@@ -401,6 +401,7 @@ core_idl_files = get_path_info([ ...@@ -401,6 +401,7 @@ core_idl_files = get_path_info([
"timing/PerformanceObserverEntryList.idl", "timing/PerformanceObserverEntryList.idl",
"timing/PerformanceResourceTiming.idl", "timing/PerformanceResourceTiming.idl",
"timing/PerformanceTiming.idl", "timing/PerformanceTiming.idl",
"timing/TaskAttributionTiming.idl",
"timing/WorkerPerformance.idl", "timing/WorkerPerformance.idl",
"workers/SharedWorker.idl", "workers/SharedWorker.idl",
"workers/Worker.idl", "workers/Worker.idl",
......
...@@ -34,6 +34,8 @@ blink_core_sources("timing") { ...@@ -34,6 +34,8 @@ blink_core_sources("timing") {
"PerformanceUserTiming.cpp", "PerformanceUserTiming.cpp",
"PerformanceUserTiming.h", "PerformanceUserTiming.h",
"SharedWorkerPerformance.cpp", "SharedWorkerPerformance.cpp",
"TaskAttributionTiming.cpp",
"TaskAttributionTiming.h",
"WorkerGlobalScopePerformance.cpp", "WorkerGlobalScopePerformance.cpp",
"WorkerGlobalScopePerformance.h", "WorkerGlobalScopePerformance.h",
"WorkerPerformance.cpp", "WorkerPerformance.cpp",
......
...@@ -133,12 +133,6 @@ PerformanceEntryVector PerformanceBase::getEntriesByType( ...@@ -133,12 +133,6 @@ PerformanceEntryVector PerformanceBase::getEntriesByType(
PerformanceEntry::toEntryTypeEnum(entryType); PerformanceEntry::toEntryTypeEnum(entryType);
switch (type) { switch (type) {
case PerformanceEntry::Invalid:
return entries;
case PerformanceEntry::LongTask:
// Unsupported for LongTask. Per the spec, Long task entries can only be
// accessed via Performance Observer. No separate buffer is maintained.
return entries;
case PerformanceEntry::Resource: case PerformanceEntry::Resource:
for (const auto& resource : m_resourceTimingBuffer) for (const auto& resource : m_resourceTimingBuffer)
entries.append(resource); entries.append(resource);
...@@ -163,6 +157,15 @@ PerformanceEntryVector PerformanceBase::getEntriesByType( ...@@ -163,6 +157,15 @@ PerformanceEntryVector PerformanceBase::getEntriesByType(
if (m_userTiming) if (m_userTiming)
entries.appendVector(m_userTiming->getMeasures()); entries.appendVector(m_userTiming->getMeasures());
break; break;
// Unsupported for LongTask, TaskAttribution.
// Per the spec, these entries can only be accessed via
// Performance Observer. No separate buffer is maintained.
case PerformanceEntry::LongTask:
break;
case PerformanceEntry::TaskAttribution:
break;
case PerformanceEntry::Invalid:
break;
} }
std::sort(entries.begin(), entries.end(), std::sort(entries.begin(), entries.end(),
...@@ -428,15 +431,15 @@ bool PerformanceBase::isFrameTimingBufferFull() { ...@@ -428,15 +431,15 @@ bool PerformanceBase::isFrameTimingBufferFull() {
void PerformanceBase::addLongTaskTiming(double startTime, void PerformanceBase::addLongTaskTiming(double startTime,
double endTime, double endTime,
const String& name, const String& name,
const String& culpritFrameSrc, const String& frameSrc,
const String& culpritFrameId, const String& frameId,
const String& culpritFrameName) { const String& frameName) {
if (!hasObserverFor(PerformanceEntry::LongTask)) if (!hasObserverFor(PerformanceEntry::LongTask))
return; return;
PerformanceEntry* entry = PerformanceLongTaskTiming::create( PerformanceEntry* entry = PerformanceLongTaskTiming::create(
monotonicTimeToDOMHighResTimeStamp(startTime), monotonicTimeToDOMHighResTimeStamp(startTime),
monotonicTimeToDOMHighResTimeStamp(endTime), name, culpritFrameSrc, monotonicTimeToDOMHighResTimeStamp(endTime), name, frameSrc, frameId,
culpritFrameId, culpritFrameName); frameName);
notifyObserversOfEntry(*entry); notifyObserversOfEntry(*entry);
} }
......
...@@ -79,6 +79,8 @@ PerformanceEntry::EntryType PerformanceEntry::toEntryTypeEnum( ...@@ -79,6 +79,8 @@ PerformanceEntry::EntryType PerformanceEntry::toEntryTypeEnum(
return Resource; return Resource;
if (entryType == "navigation") if (entryType == "navigation")
return Navigation; return Navigation;
if (entryType == "taskattribution")
return TaskAttribution;
return Invalid; return Invalid;
} }
......
...@@ -63,6 +63,7 @@ class CORE_EXPORT PerformanceEntry ...@@ -63,6 +63,7 @@ class CORE_EXPORT PerformanceEntry
Render = 1 << 4, Render = 1 << 4,
Resource = 1 << 5, Resource = 1 << 5,
LongTask = 1 << 6, LongTask = 1 << 6,
TaskAttribution = 1 << 7,
}; };
String name() const; String name() const;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "core/timing/PerformanceLongTaskTiming.h" #include "core/timing/PerformanceLongTaskTiming.h"
#include "core/frame/DOMWindow.h" #include "core/frame/DOMWindow.h"
#include "core/timing/TaskAttributionTiming.h"
namespace blink { namespace blink {
...@@ -17,6 +18,17 @@ double clampToMillisecond(double timeInMillis) { ...@@ -17,6 +18,17 @@ double clampToMillisecond(double timeInMillis) {
} // namespace } // namespace
// static
PerformanceLongTaskTiming* PerformanceLongTaskTiming::create(double startTime,
double endTime,
String name,
String frameSrc,
String frameId,
String frameName) {
return new PerformanceLongTaskTiming(startTime, endTime, name, frameSrc,
frameId, frameName);
}
PerformanceLongTaskTiming::PerformanceLongTaskTiming(double startTime, PerformanceLongTaskTiming::PerformanceLongTaskTiming(double startTime,
double endTime, double endTime,
String name, String name,
...@@ -26,26 +38,21 @@ PerformanceLongTaskTiming::PerformanceLongTaskTiming(double startTime, ...@@ -26,26 +38,21 @@ PerformanceLongTaskTiming::PerformanceLongTaskTiming(double startTime,
: PerformanceEntry(name, : PerformanceEntry(name,
"longtask", "longtask",
clampToMillisecond(startTime), clampToMillisecond(startTime),
clampToMillisecond(endTime)), clampToMillisecond(endTime)) {
m_culpritFrameSrc(culpritFrameSrc), // Only one possible name ("frame") currently.
m_culpritFrameId(culpritFrameId), TaskAttributionTiming* attributionEntry = TaskAttributionTiming::create(
m_culpritFrameName(culpritFrameName) {} "frame", culpritFrameSrc, culpritFrameId, culpritFrameName);
m_attribution.append(*attributionEntry);
PerformanceLongTaskTiming::~PerformanceLongTaskTiming() {}
String PerformanceLongTaskTiming::culpritFrameSrc() const {
return m_culpritFrameSrc;
} }
String PerformanceLongTaskTiming::culpritFrameId() const { PerformanceLongTaskTiming::~PerformanceLongTaskTiming() {}
return m_culpritFrameId;
}
String PerformanceLongTaskTiming::culpritFrameName() const { TaskAttributionVector PerformanceLongTaskTiming::attribution() const {
return m_culpritFrameName; return m_attribution;
} }
DEFINE_TRACE(PerformanceLongTaskTiming) { DEFINE_TRACE(PerformanceLongTaskTiming) {
visitor->trace(m_attribution);
PerformanceEntry::trace(visitor); PerformanceEntry::trace(visitor);
} }
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
namespace blink { namespace blink {
class TaskAttributionTiming;
using TaskAttributionVector = HeapVector<Member<TaskAttributionTiming>>;
class PerformanceLongTaskTiming final : public PerformanceEntry { class PerformanceLongTaskTiming final : public PerformanceEntry {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
...@@ -19,17 +22,11 @@ class PerformanceLongTaskTiming final : public PerformanceEntry { ...@@ -19,17 +22,11 @@ class PerformanceLongTaskTiming final : public PerformanceEntry {
static PerformanceLongTaskTiming* create(double startTime, static PerformanceLongTaskTiming* create(double startTime,
double endTime, double endTime,
String name, String name,
String culpritFrameSrc, String frameSrc,
String culpritFrameId, String frameId,
String culpritFrameName) { String frameName);
return new PerformanceLongTaskTiming(startTime, endTime, name,
culpritFrameSrc, culpritFrameId, TaskAttributionVector attribution() const;
culpritFrameName);
}
String culpritFrameSrc() const;
String culpritFrameId() const;
String culpritFrameName() const;
DECLARE_VIRTUAL_TRACE(); DECLARE_VIRTUAL_TRACE();
...@@ -37,14 +34,12 @@ class PerformanceLongTaskTiming final : public PerformanceEntry { ...@@ -37,14 +34,12 @@ class PerformanceLongTaskTiming final : public PerformanceEntry {
PerformanceLongTaskTiming(double startTime, PerformanceLongTaskTiming(double startTime,
double endTime, double endTime,
String name, String name,
String culpritFrameSrc, String frameSrc,
String culpritFrameId, String frameId,
String culpritFrameName); String frameName);
~PerformanceLongTaskTiming() override; ~PerformanceLongTaskTiming() override;
String m_culpritFrameSrc; TaskAttributionVector m_attribution;
String m_culpritFrameId;
String m_culpritFrameName;
}; };
} // namespace blink } // namespace blink
......
...@@ -2,11 +2,9 @@ ...@@ -2,11 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// https://github.com/spanicker/longtasks // https://github.com/wicg/longtasks
[ [
OriginTrialEnabled=LongTaskObserver, OriginTrialEnabled=LongTaskObserver,
] interface PerformanceLongTaskTiming : PerformanceEntry { ] interface PerformanceLongTaskTiming : PerformanceEntry {
readonly attribute DOMString culpritFrameSrc; readonly attribute sequence<TaskAttributionTiming> attribution;
readonly attribute DOMString culpritFrameId;
readonly attribute DOMString culpritFrameName;
}; };
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "core/timing/TaskAttributionTiming.h"
#include "core/frame/DOMWindow.h"
namespace blink {
TaskAttributionTiming::TaskAttributionTiming(String name,
String frameSrc,
String frameId,
String frameName)
: PerformanceEntry(name, "taskattribution", 0.0, 0.0),
m_frameSrc(frameSrc),
m_frameId(frameId),
m_frameName(frameName) {}
TaskAttributionTiming::~TaskAttributionTiming() {}
String TaskAttributionTiming::frameSrc() const {
return m_frameSrc;
}
String TaskAttributionTiming::frameId() const {
return m_frameId;
}
String TaskAttributionTiming::frameName() const {
return m_frameName;
}
DEFINE_TRACE(TaskAttributionTiming) {
PerformanceEntry::trace(visitor);
}
} // namespace blink
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef TaskAttributionTiming_h
#define TaskAttributionTiming_h
#include "core/timing/PerformanceEntry.h"
#include "platform/heap/Handle.h"
#include "wtf/Forward.h"
#include "wtf/text/WTFString.h"
namespace blink {
class TaskAttributionTiming final : public PerformanceEntry {
DEFINE_WRAPPERTYPEINFO();
public:
static TaskAttributionTiming* create(String type,
String frameSrc,
String frameId,
String frameName) {
return new TaskAttributionTiming(type, frameSrc, frameId, frameName);
}
String frameSrc() const;
String frameId() const;
String frameName() const;
DECLARE_VIRTUAL_TRACE();
~TaskAttributionTiming() override;
private:
TaskAttributionTiming(String type,
String frameSrc,
String frameId,
String frameName);
String m_frameSrc;
String m_frameId;
String m_frameName;
};
} // namespace blink
#endif // TaskAttributionTiming_h
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://github.com/wicg/longtasks
[
OriginTrialEnabled=LongTaskObserver,
] interface TaskAttributionTiming : PerformanceEntry {
readonly attribute DOMString frameSrc;
readonly attribute DOMString frameId;
readonly attribute DOMString frameName;
};
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