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

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

Issue 2899023003: buffer paint entries so they can queried with getEntries (Closed)
Patch Set: update test Created 3 years, 7 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 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 if (navigation_timing_) 101 if (navigation_timing_)
102 entries.push_back(navigation_timing_); 102 entries.push_back(navigation_timing_);
103 entries.AppendVector(frame_timing_buffer_); 103 entries.AppendVector(frame_timing_buffer_);
104 104
105 if (user_timing_) { 105 if (user_timing_) {
106 entries.AppendVector(user_timing_->GetMarks()); 106 entries.AppendVector(user_timing_->GetMarks());
107 entries.AppendVector(user_timing_->GetMeasures()); 107 entries.AppendVector(user_timing_->GetMeasures());
108 } 108 }
109 109
110 entries.AppendVector(server_timing_buffer_); 110 entries.AppendVector(server_timing_buffer_);
111 if (first_paint_timing_)
112 entries.push_back(first_paint_timing_);
113 if (first_contentful_paint_timing_)
114 entries.push_back(first_contentful_paint_timing_);
111 115
112 std::sort(entries.begin(), entries.end(), 116 std::sort(entries.begin(), entries.end(),
113 PerformanceEntry::StartTimeCompareLessThan); 117 PerformanceEntry::StartTimeCompareLessThan);
114 return entries; 118 return entries;
115 } 119 }
116 120
117 PerformanceEntryVector PerformanceBase::getEntriesByType( 121 PerformanceEntryVector PerformanceBase::getEntriesByType(
118 const String& entry_type) { 122 const String& entry_type) {
119 PerformanceEntryVector entries; 123 PerformanceEntryVector entries;
120 PerformanceEntry::EntryType type = 124 PerformanceEntry::EntryType type =
(...skipping 22 matching lines...) Expand all
143 if (user_timing_) 147 if (user_timing_)
144 entries.AppendVector(user_timing_->GetMarks()); 148 entries.AppendVector(user_timing_->GetMarks());
145 break; 149 break;
146 case PerformanceEntry::kMeasure: 150 case PerformanceEntry::kMeasure:
147 if (user_timing_) 151 if (user_timing_)
148 entries.AppendVector(user_timing_->GetMeasures()); 152 entries.AppendVector(user_timing_->GetMeasures());
149 break; 153 break;
150 case PerformanceEntry::kServer: 154 case PerformanceEntry::kServer:
151 entries.AppendVector(server_timing_buffer_); 155 entries.AppendVector(server_timing_buffer_);
152 break; 156 break;
153 // Unsupported for Paint, LongTask, TaskAttribution. 157 case PerformanceEntry::kPaint:
158 if (first_paint_timing_)
159 entries.push_back(first_paint_timing_);
160 if (first_contentful_paint_timing_)
161 entries.push_back(first_contentful_paint_timing_);
162 break;
163 // Unsupported for LongTask, TaskAttribution.
154 // Per the spec, these entries can only be accessed via 164 // Per the spec, these entries can only be accessed via
155 // Performance Observer. No separate buffer is maintained. 165 // Performance Observer. No separate buffer is maintained.
156 case PerformanceEntry::kPaint:
157 break;
158 case PerformanceEntry::kLongTask: 166 case PerformanceEntry::kLongTask:
159 break; 167 break;
160 case PerformanceEntry::kTaskAttribution: 168 case PerformanceEntry::kTaskAttribution:
161 break; 169 break;
162 case PerformanceEntry::kInvalid: 170 case PerformanceEntry::kInvalid:
163 break; 171 break;
164 } 172 }
165 173
166 std::sort(entries.begin(), entries.end(), 174 std::sort(entries.begin(), entries.end(),
167 PerformanceEntry::StartTimeCompareLessThan); 175 PerformanceEntry::StartTimeCompareLessThan);
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 407
400 void PerformanceBase::AddFirstContentfulPaintTiming(double start_time) { 408 void PerformanceBase::AddFirstContentfulPaintTiming(double start_time) {
401 AddPaintTiming(PerformancePaintTiming::PaintType::kFirstContentfulPaint, 409 AddPaintTiming(PerformancePaintTiming::PaintType::kFirstContentfulPaint,
402 start_time); 410 start_time);
403 } 411 }
404 412
405 void PerformanceBase::AddPaintTiming(PerformancePaintTiming::PaintType type, 413 void PerformanceBase::AddPaintTiming(PerformancePaintTiming::PaintType type,
406 double start_time) { 414 double start_time) {
407 if (!RuntimeEnabledFeatures::performancePaintTimingEnabled()) 415 if (!RuntimeEnabledFeatures::performancePaintTimingEnabled())
408 return; 416 return;
417
409 PerformanceEntry* entry = new PerformancePaintTiming( 418 PerformanceEntry* entry = new PerformancePaintTiming(
410 type, MonotonicTimeToDOMHighResTimeStamp(start_time)); 419 type, MonotonicTimeToDOMHighResTimeStamp(start_time));
420 // Always buffer First Paint & First Contentful Paint.
421 if (type == PerformancePaintTiming::PaintType::kFirstPaint)
422 first_paint_timing_ = entry;
423 else if (type == PerformancePaintTiming::PaintType::kFirstContentfulPaint)
424 first_contentful_paint_timing_ = entry;
411 NotifyObserversOfEntry(*entry); 425 NotifyObserversOfEntry(*entry);
412 } 426 }
413 427
414 void PerformanceBase::AddResourceTimingBuffer(PerformanceEntry& entry) { 428 void PerformanceBase::AddResourceTimingBuffer(PerformanceEntry& entry) {
415 resource_timing_buffer_.push_back(&entry); 429 resource_timing_buffer_.push_back(&entry);
416 430
417 if (IsResourceTimingBufferFull()) 431 if (IsResourceTimingBufferFull())
418 DispatchEvent(Event::Create(EventTypeNames::resourcetimingbufferfull)); 432 DispatchEvent(Event::Create(EventTypeNames::resourcetimingbufferfull));
419 } 433 }
420 434
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 DOMHighResTimeStamp PerformanceBase::now() const { 606 DOMHighResTimeStamp PerformanceBase::now() const {
593 return MonotonicTimeToDOMHighResTimeStamp(MonotonicallyIncreasingTime()); 607 return MonotonicTimeToDOMHighResTimeStamp(MonotonicallyIncreasingTime());
594 } 608 }
595 609
596 DEFINE_TRACE(PerformanceBase) { 610 DEFINE_TRACE(PerformanceBase) {
597 visitor->Trace(frame_timing_buffer_); 611 visitor->Trace(frame_timing_buffer_);
598 visitor->Trace(resource_timing_buffer_); 612 visitor->Trace(resource_timing_buffer_);
599 visitor->Trace(navigation_timing_); 613 visitor->Trace(navigation_timing_);
600 visitor->Trace(user_timing_); 614 visitor->Trace(user_timing_);
601 visitor->Trace(server_timing_buffer_); 615 visitor->Trace(server_timing_buffer_);
616 visitor->Trace(first_paint_timing_);
617 visitor->Trace(first_contentful_paint_timing_);
602 visitor->Trace(observers_); 618 visitor->Trace(observers_);
603 visitor->Trace(active_observers_); 619 visitor->Trace(active_observers_);
604 visitor->Trace(suspended_observers_); 620 visitor->Trace(suspended_observers_);
605 EventTargetWithInlineData::Trace(visitor); 621 EventTargetWithInlineData::Trace(visitor);
606 } 622 }
607 623
608 } // namespace blink 624 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698