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

Side by Side Diff: third_party/WebKit/Source/core/timing/PerformanceBase.cpp

Issue 2528513003: first-paint and first-contentful paint (Closed)
Patch Set: idl format Created 4 years 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Inc. All rights reserved. 3 * Copyright (C) 2012 Intel Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 entries.appendVector(m_resourceTimingBuffer); 82 entries.appendVector(m_resourceTimingBuffer);
83 if (m_navigationTiming) 83 if (m_navigationTiming)
84 entries.append(m_navigationTiming); 84 entries.append(m_navigationTiming);
85 entries.appendVector(m_frameTimingBuffer); 85 entries.appendVector(m_frameTimingBuffer);
86 86
87 if (m_userTiming) { 87 if (m_userTiming) {
88 entries.appendVector(m_userTiming->getMarks()); 88 entries.appendVector(m_userTiming->getMarks());
89 entries.appendVector(m_userTiming->getMeasures()); 89 entries.appendVector(m_userTiming->getMeasures());
90 } 90 }
91 91
92 for (const auto& entry : m_paintTimingBuffer) {
93 entries.append(entry.value);
94 }
95
92 std::sort(entries.begin(), entries.end(), 96 std::sort(entries.begin(), entries.end(),
93 PerformanceEntry::startTimeCompareLessThan); 97 PerformanceEntry::startTimeCompareLessThan);
94 return entries; 98 return entries;
95 } 99 }
96 100
97 PerformanceEntryVector PerformanceBase::getEntriesByType( 101 PerformanceEntryVector PerformanceBase::getEntriesByType(
98 const String& entryType) { 102 const String& entryType) {
99 PerformanceEntryVector entries; 103 PerformanceEntryVector entries;
100 PerformanceEntry::EntryType type = 104 PerformanceEntry::EntryType type =
101 PerformanceEntry::toEntryTypeEnum(entryType); 105 PerformanceEntry::toEntryTypeEnum(entryType);
102 106
103 switch (type) { 107 switch (type) {
104 case PerformanceEntry::Invalid: 108 case PerformanceEntry::Invalid:
105 return entries; 109 return entries;
106 case PerformanceEntry::LongTask: 110 case PerformanceEntry::LongTask:
107 // Unsupported for LongTask. Per the spec, Long task entries can only be 111 // Unsupported for LongTask. Per the spec, Long task entries can only be
108 // accessed via Performance Observer. No separate buffer is maintained. 112 // accessed via Performance Observer. No separate buffer is maintained.
109 return entries; 113 return entries;
110 case PerformanceEntry::Resource: 114 case PerformanceEntry::Resource:
111 for (const auto& resource : m_resourceTimingBuffer) 115 for (const auto& resource : m_resourceTimingBuffer)
112 entries.append(resource); 116 entries.append(resource);
113 break; 117 break;
114 case PerformanceEntry::Navigation: 118 case PerformanceEntry::Navigation:
115 if (m_navigationTiming) 119 if (m_navigationTiming)
116 entries.append(m_navigationTiming); 120 entries.append(m_navigationTiming);
117 break; 121 break;
122 case PerformanceEntry::Paint:
123 for (const auto& entry : m_paintTimingBuffer) {
124 entries.append(entry.value);
125 }
126 break;
118 case PerformanceEntry::Composite: 127 case PerformanceEntry::Composite:
119 case PerformanceEntry::Render: 128 case PerformanceEntry::Render:
120 for (const auto& frame : m_frameTimingBuffer) { 129 for (const auto& frame : m_frameTimingBuffer) {
121 if (type == frame->entryTypeEnum()) { 130 if (type == frame->entryTypeEnum()) {
122 entries.append(frame); 131 entries.append(frame);
123 } 132 }
124 } 133 }
125 break; 134 break;
126 case PerformanceEntry::Mark: 135 case PerformanceEntry::Mark:
127 if (m_userTiming) 136 if (m_userTiming)
(...skipping 25 matching lines...) Expand all
153 if (resource->name() == name) 162 if (resource->name() == name)
154 entries.append(resource); 163 entries.append(resource);
155 } 164 }
156 } 165 }
157 166
158 if (entryType.isNull() || type == PerformanceEntry::Navigation) { 167 if (entryType.isNull() || type == PerformanceEntry::Navigation) {
159 if (m_navigationTiming && m_navigationTiming->name() == name) 168 if (m_navigationTiming && m_navigationTiming->name() == name)
160 entries.append(m_navigationTiming); 169 entries.append(m_navigationTiming);
161 } 170 }
162 171
172 if (entryType.isNull() || type == PerformanceEntry::Paint) {
173 for (const auto& paintEntry : m_paintTimingBuffer) {
174 if (paintEntry.value->name() == name)
175 entries.append(paintEntry.value);
176 }
177 }
178
163 if (entryType.isNull() || type == PerformanceEntry::Composite || 179 if (entryType.isNull() || type == PerformanceEntry::Composite ||
164 type == PerformanceEntry::Render) { 180 type == PerformanceEntry::Render) {
165 for (const auto& frame : m_frameTimingBuffer) { 181 for (const auto& frame : m_frameTimingBuffer) {
166 if (frame->name() == name && 182 if (frame->name() == name &&
167 (entryType.isNull() || entryType == frame->entryType())) 183 (entryType.isNull() || entryType == frame->entryType()))
168 entries.append(frame); 184 entries.append(frame);
169 } 185 }
170 } 186 }
171 187
172 if (m_userTiming) { 188 if (m_userTiming) {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 documentLoader->getNavigationType(), documentLoadTiming.redirectStart(), 364 documentLoader->getNavigationType(), documentLoadTiming.redirectStart(),
349 documentLoadTiming.redirectEnd(), documentLoadTiming.fetchStart(), 365 documentLoadTiming.redirectEnd(), documentLoadTiming.fetchStart(),
350 documentLoadTiming.responseEnd(), 366 documentLoadTiming.responseEnd(),
351 documentLoadTiming.hasCrossOriginRedirect(), 367 documentLoadTiming.hasCrossOriginRedirect(),
352 documentLoadTiming.hasSameOriginAsPreviousDocument(), resourceLoadTiming, 368 documentLoadTiming.hasSameOriginAsPreviousDocument(), resourceLoadTiming,
353 lastRedirectEndTime, finishTime, transferSize, encodedBodyLength, 369 lastRedirectEndTime, finishTime, transferSize, encodedBodyLength,
354 decodedBodyLength, didReuseConnection); 370 decodedBodyLength, didReuseConnection);
355 notifyObserversOfEntry(*m_navigationTiming); 371 notifyObserversOfEntry(*m_navigationTiming);
356 } 372 }
357 373
374 void PerformanceBase::addPaintTiming(PerformancePaintTiming::PaintType type,
375 double startTime) {
376 if (!RuntimeEnabledFeatures::performancePaintTimingEnabled())
377 return;
378 PerformanceEntry* entry = new PerformancePaintTiming(
379 type, monotonicTimeToDOMHighResTimeStamp(startTime));
380 notifyObserversOfEntry(*entry);
381 // Only allow one entry for each type, keep the newest one.
382 m_paintTimingBuffer.set(PerformancePaintTiming::fromPaintTypeToString(type),
383 entry);
384 }
385
386 void PerformanceBase::clearPaintTimingBuffer() {
387 m_paintTimingBuffer.clear();
388 }
389
358 void PerformanceBase::addResourceTimingBuffer(PerformanceEntry& entry) { 390 void PerformanceBase::addResourceTimingBuffer(PerformanceEntry& entry) {
359 m_resourceTimingBuffer.append(&entry); 391 m_resourceTimingBuffer.append(&entry);
360 392
361 if (isResourceTimingBufferFull()) { 393 if (isResourceTimingBufferFull()) {
362 dispatchEvent(Event::create(EventTypeNames::resourcetimingbufferfull)); 394 dispatchEvent(Event::create(EventTypeNames::resourcetimingbufferfull));
363 dispatchEvent( 395 dispatchEvent(
364 Event::create(EventTypeNames::webkitresourcetimingbufferfull)); 396 Event::create(EventTypeNames::webkitresourcetimingbufferfull));
365 } 397 }
366 } 398 }
367 399
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 } 560 }
529 561
530 DEFINE_TRACE(PerformanceBase) { 562 DEFINE_TRACE(PerformanceBase) {
531 visitor->trace(m_frameTimingBuffer); 563 visitor->trace(m_frameTimingBuffer);
532 visitor->trace(m_resourceTimingBuffer); 564 visitor->trace(m_resourceTimingBuffer);
533 visitor->trace(m_navigationTiming); 565 visitor->trace(m_navigationTiming);
534 visitor->trace(m_userTiming); 566 visitor->trace(m_userTiming);
535 visitor->trace(m_observers); 567 visitor->trace(m_observers);
536 visitor->trace(m_activeObservers); 568 visitor->trace(m_activeObservers);
537 visitor->trace(m_suspendedObservers); 569 visitor->trace(m_suspendedObservers);
570 visitor->trace(m_paintTimingBuffer);
538 EventTargetWithInlineData::trace(visitor); 571 EventTargetWithInlineData::trace(visitor);
539 } 572 }
540 573
541 } // namespace blink 574 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698