Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/timing/PerformanceLongTaskTiming.h" | 5 #include "core/timing/PerformanceLongTaskTiming.h" |
| 6 | 6 |
| 7 #include "core/frame/DOMWindow.h" | 7 #include "core/frame/DOMWindow.h" |
| 8 #include "core/timing/TaskAttributionTiming.h" | |
| 8 | 9 |
| 9 namespace blink { | 10 namespace blink { |
| 10 | 11 |
| 11 namespace { | 12 namespace { |
| 12 | 13 |
| 13 double clampToMillisecond(double timeInMillis) { | 14 double clampToMillisecond(double timeInMillis) { |
| 14 // Long task times are clamped to 1 millisecond for security. | 15 // Long task times are clamped to 1 millisecond for security. |
| 15 return floor(timeInMillis); | 16 return floor(timeInMillis); |
| 16 } | 17 } |
| 17 | 18 |
| 18 } // namespace | 19 } // namespace |
| 19 | 20 |
| 21 // static | |
| 22 PerformanceLongTaskTiming* PerformanceLongTaskTiming::create( | |
| 23 double startTime, | |
| 24 double endTime, | |
| 25 String name, | |
| 26 String culpritFrameSrc, | |
| 27 String culpritFrameId, | |
| 28 String culpritFrameName) { | |
|
tdresser
2017/01/05 13:34:14
I'd strip the culprit prefix throughout - I don't
panicker
2017/01/05 20:56:49
Done.
| |
| 29 return new PerformanceLongTaskTiming(startTime, endTime, name, | |
| 30 culpritFrameSrc, culpritFrameId, | |
| 31 culpritFrameName); | |
| 32 } | |
| 33 | |
| 20 PerformanceLongTaskTiming::PerformanceLongTaskTiming(double startTime, | 34 PerformanceLongTaskTiming::PerformanceLongTaskTiming(double startTime, |
| 21 double endTime, | 35 double endTime, |
| 22 String name, | 36 String name, |
| 23 String culpritFrameSrc, | 37 String culpritFrameSrc, |
| 24 String culpritFrameId, | 38 String culpritFrameId, |
| 25 String culpritFrameName) | 39 String culpritFrameName) |
| 26 : PerformanceEntry(name, | 40 : PerformanceEntry(name, |
| 27 "longtask", | 41 "longtask", |
| 28 clampToMillisecond(startTime), | 42 clampToMillisecond(startTime), |
| 29 clampToMillisecond(endTime)), | 43 clampToMillisecond(endTime)) { |
| 30 m_culpritFrameSrc(culpritFrameSrc), | 44 // Only one possible name ("frame") currently. |
| 31 m_culpritFrameId(culpritFrameId), | 45 TaskAttributionTiming* attributionEntry = TaskAttributionTiming::create( |
| 32 m_culpritFrameName(culpritFrameName) {} | 46 "frame", culpritFrameSrc, culpritFrameId, culpritFrameName); |
| 47 m_attribution.append(*attributionEntry); | |
| 48 } | |
| 33 | 49 |
| 34 PerformanceLongTaskTiming::~PerformanceLongTaskTiming() {} | 50 PerformanceLongTaskTiming::~PerformanceLongTaskTiming() {} |
| 35 | 51 |
| 36 String PerformanceLongTaskTiming::culpritFrameSrc() const { | 52 TaskAttributionVector PerformanceLongTaskTiming::attribution() const { |
| 37 return m_culpritFrameSrc; | 53 return m_attribution; |
| 38 } | |
| 39 | |
| 40 String PerformanceLongTaskTiming::culpritFrameId() const { | |
| 41 return m_culpritFrameId; | |
| 42 } | |
| 43 | |
| 44 String PerformanceLongTaskTiming::culpritFrameName() const { | |
| 45 return m_culpritFrameName; | |
| 46 } | 54 } |
| 47 | 55 |
| 48 DEFINE_TRACE(PerformanceLongTaskTiming) { | 56 DEFINE_TRACE(PerformanceLongTaskTiming) { |
| 57 visitor->trace(m_attribution); | |
| 49 PerformanceEntry::trace(visitor); | 58 PerformanceEntry::trace(visitor); |
| 50 } | 59 } |
| 51 | 60 |
| 52 } // namespace blink | 61 } // namespace blink |
| OLD | NEW |