Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(995)

Unified Diff: third_party/WebKit/Source/core/timing/PerformanceBase.cpp

Issue 2528513003: first-paint and first-contentful paint (Closed)
Patch Set: Got rid of DCHECK cause it breaks unit tests Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/timing/PerformanceBase.cpp
diff --git a/third_party/WebKit/Source/core/timing/PerformanceBase.cpp b/third_party/WebKit/Source/core/timing/PerformanceBase.cpp
index df50c039e0b04050277236a20330c5b9f19b14ca..462a8b845989e86d327a6fabc3f194e4278c70be 100644
--- a/third_party/WebKit/Source/core/timing/PerformanceBase.cpp
+++ b/third_party/WebKit/Source/core/timing/PerformanceBase.cpp
@@ -157,9 +157,11 @@ PerformanceEntryVector PerformanceBase::getEntriesByType(
if (m_userTiming)
entries.appendVector(m_userTiming->getMeasures());
break;
- // Unsupported for LongTask, TaskAttribution.
+ // Unsupported for Paint, LongTask, TaskAttribution.
// Per the spec, these entries can only be accessed via
// Performance Observer. No separate buffer is maintained.
+ case PerformanceEntry::Paint:
+ break;
case PerformanceEntry::LongTask:
break;
case PerformanceEntry::TaskAttribution:
@@ -400,6 +402,24 @@ void PerformanceBase::addNavigationTiming(LocalFrame* frame) {
notifyObserversOfEntry(*m_navigationTiming);
}
+void PerformanceBase::addFirstPaintTiming(double startTime) {
+ addPaintTiming(PerformancePaintTiming::PaintType::FirstPaint, startTime);
+}
+
+void PerformanceBase::addFirstContentfulPaintTiming(double startTime) {
+ addPaintTiming(PerformancePaintTiming::PaintType::FirstContentfulPaint,
+ startTime);
+}
+
+void PerformanceBase::addPaintTiming(PerformancePaintTiming::PaintType type,
+ double startTime) {
+ if (!RuntimeEnabledFeatures::performancePaintTimingEnabled())
+ return;
+ PerformanceEntry* entry = new PerformancePaintTiming(
+ type, monotonicTimeToDOMHighResTimeStamp(startTime));
+ notifyObserversOfEntry(*entry);
+}
+
void PerformanceBase::addResourceTimingBuffer(PerformanceEntry& entry) {
m_resourceTimingBuffer.push_back(&entry);
@@ -557,7 +577,8 @@ DOMHighResTimeStamp PerformanceBase::monotonicTimeToDOMHighResTimeStamp(
return 0.0;
double timeInSeconds = monotonicTime - timeOrigin;
- DCHECK_GE(timeInSeconds, 0);
+ if (timeInSeconds < 0)
+ return 0.0;
return convertSecondsToDOMHighResTimeStamp(
clampTimeResolution(timeInSeconds));
}
« no previous file with comments | « third_party/WebKit/Source/core/timing/PerformanceBase.h ('k') | third_party/WebKit/Source/core/timing/PerformanceEntry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698