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

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

Issue 2528513003: first-paint and first-contentful paint (Closed)
Patch Set: addressed comments 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 PerformanceEntryVector PerformanceBase::getEntriesByType( 118 PerformanceEntryVector PerformanceBase::getEntriesByType(
119 const String& entryType) { 119 const String& entryType) {
120 PerformanceEntryVector entries; 120 PerformanceEntryVector entries;
121 PerformanceEntry::EntryType type = 121 PerformanceEntry::EntryType type =
122 PerformanceEntry::toEntryTypeEnum(entryType); 122 PerformanceEntry::toEntryTypeEnum(entryType);
123 123
124 switch (type) { 124 switch (type) {
125 case PerformanceEntry::Invalid: 125 case PerformanceEntry::Invalid:
126 return entries; 126 return entries;
127 case PerformanceEntry::Paint:
128 // Unsupported for Paint. Per the spec, Paint entries
129 // can only be accessed via Performance Observer.
130 // No separate buffer is maintained.
127 case PerformanceEntry::LongTask: 131 case PerformanceEntry::LongTask:
128 // Unsupported for LongTask. Per the spec, Long task entries can only be 132 // Unsupported for LongTask. Per the spec, Long task entries
129 // accessed via Performance Observer. No separate buffer is maintained. 133 // can only be accessed via Performance Observer.
134 // No separate buffer is maintained.
130 return entries; 135 return entries;
131 case PerformanceEntry::Resource: 136 case PerformanceEntry::Resource:
132 for (const auto& resource : m_resourceTimingBuffer) 137 for (const auto& resource : m_resourceTimingBuffer)
133 entries.append(resource); 138 entries.append(resource);
134 break; 139 break;
135 case PerformanceEntry::Navigation: 140 case PerformanceEntry::Navigation:
136 if (m_navigationTiming) 141 if (m_navigationTiming)
137 entries.append(m_navigationTiming); 142 entries.append(m_navigationTiming);
138 break; 143 break;
139 case PerformanceEntry::Composite: 144 case PerformanceEntry::Composite:
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 documentTiming ? documentTiming->domComplete() : 0, type, 375 documentTiming ? documentTiming->domComplete() : 0, type,
371 documentLoadTiming.redirectStart(), documentLoadTiming.redirectEnd(), 376 documentLoadTiming.redirectStart(), documentLoadTiming.redirectEnd(),
372 documentLoadTiming.fetchStart(), documentLoadTiming.responseEnd(), 377 documentLoadTiming.fetchStart(), documentLoadTiming.responseEnd(),
373 documentLoadTiming.hasCrossOriginRedirect(), 378 documentLoadTiming.hasCrossOriginRedirect(),
374 documentLoadTiming.hasSameOriginAsPreviousDocument(), resourceLoadTiming, 379 documentLoadTiming.hasSameOriginAsPreviousDocument(), resourceLoadTiming,
375 lastRedirectEndTime, finishTime, transferSize, encodedBodyLength, 380 lastRedirectEndTime, finishTime, transferSize, encodedBodyLength,
376 decodedBodyLength, didReuseConnection); 381 decodedBodyLength, didReuseConnection);
377 notifyObserversOfEntry(*m_navigationTiming); 382 notifyObserversOfEntry(*m_navigationTiming);
378 } 383 }
379 384
385 void PerformanceBase::addFirstPaintTiming(double startTime) {
386 addPaintTiming(PerformancePaintTiming::PaintType::FirstPaint, startTime);
387 }
388
389 void PerformanceBase::addFirstContentfulPaintTiming(double startTime) {
390 addPaintTiming(PerformancePaintTiming::PaintType::FirstContentfulPaint,
391 startTime);
392 }
393
394 void PerformanceBase::addPaintTiming(PerformancePaintTiming::PaintType type,
395 double startTime) {
396 if (!RuntimeEnabledFeatures::performancePaintTimingEnabled())
397 return;
398 PerformanceEntry* entry = new PerformancePaintTiming(
399 type, monotonicTimeToDOMHighResTimeStamp(startTime));
400 notifyObserversOfEntry(*entry);
401 }
402
380 void PerformanceBase::addResourceTimingBuffer(PerformanceEntry& entry) { 403 void PerformanceBase::addResourceTimingBuffer(PerformanceEntry& entry) {
381 m_resourceTimingBuffer.append(&entry); 404 m_resourceTimingBuffer.append(&entry);
382 405
383 if (isResourceTimingBufferFull()) { 406 if (isResourceTimingBufferFull()) {
384 dispatchEvent(Event::create(EventTypeNames::resourcetimingbufferfull)); 407 dispatchEvent(Event::create(EventTypeNames::resourcetimingbufferfull));
385 dispatchEvent( 408 dispatchEvent(
386 Event::create(EventTypeNames::webkitresourcetimingbufferfull)); 409 Event::create(EventTypeNames::webkitresourcetimingbufferfull));
387 } 410 }
388 } 411 }
389 412
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 visitor->trace(m_resourceTimingBuffer); 577 visitor->trace(m_resourceTimingBuffer);
555 visitor->trace(m_navigationTiming); 578 visitor->trace(m_navigationTiming);
556 visitor->trace(m_userTiming); 579 visitor->trace(m_userTiming);
557 visitor->trace(m_observers); 580 visitor->trace(m_observers);
558 visitor->trace(m_activeObservers); 581 visitor->trace(m_activeObservers);
559 visitor->trace(m_suspendedObservers); 582 visitor->trace(m_suspendedObservers);
560 EventTargetWithInlineData::trace(visitor); 583 EventTargetWithInlineData::trace(visitor);
561 } 584 }
562 585
563 } // namespace blink 586 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698