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

Side by Side Diff: Source/core/timing/Performance.cpp

Issue 390193003: [not for review] Add Draw entries to window Performance Timeline (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Git pull syncup Created 6 years, 3 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
« no previous file with comments | « Source/core/timing/Performance.h ('k') | Source/core/timing/Performance.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 17 matching lines...) Expand all
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32 #include "config.h" 32 #include "config.h"
33 #include "core/timing/Performance.h" 33 #include "core/timing/Performance.h"
34 34
35 #include "core/dom/Document.h" 35 #include "core/dom/Document.h"
36 #include "core/frame/LocalFrame.h" 36 #include "core/frame/LocalFrame.h"
37 #include "core/loader/DocumentLoader.h" 37 #include "core/loader/DocumentLoader.h"
38 #include "core/timing/PerformanceResourceTiming.h"
39 #include "core/timing/PerformanceSmoothnessTiming.h"
40 #include "core/timing/PerformanceUserTiming.h"
38 #include "core/timing/ResourceTimingInfo.h" 41 #include "core/timing/ResourceTimingInfo.h"
39 #include "core/timing/PerformanceResourceTiming.h"
40 #include "core/timing/PerformanceUserTiming.h"
41 #include "platform/weborigin/SecurityOrigin.h" 42 #include "platform/weborigin/SecurityOrigin.h"
42 #include "wtf/CurrentTime.h" 43 #include "wtf/CurrentTime.h"
43 44
44 namespace blink { 45 namespace blink {
45 46
46 static const size_t defaultResourceTimingBufferSize = 150; 47 static const size_t defaultResourceTimingBufferSize = 150;
48 static const size_t defaultSmoothnessTimingBufferSize = 150;
47 49
48 Performance::Performance(LocalFrame* frame) 50 Performance::Performance(LocalFrame* frame)
49 : DOMWindowProperty(frame) 51 : DOMWindowProperty(frame)
50 , m_resourceTimingBufferSize(defaultResourceTimingBufferSize) 52 , m_resourceTimingBufferSize(defaultResourceTimingBufferSize)
53 , m_smoothnessTimingBufferSize(defaultSmoothnessTimingBufferSize)
51 , m_referenceTime(frame && frame->host() ? frame->document()->loader()->timi ng()->referenceMonotonicTime() : 0.0) 54 , m_referenceTime(frame && frame->host() ? frame->document()->loader()->timi ng()->referenceMonotonicTime() : 0.0)
52 , m_userTiming(nullptr) 55 , m_userTiming(nullptr)
53 { 56 {
54 } 57 }
55 58
56 Performance::~Performance() 59 Performance::~Performance()
57 { 60 {
58 } 61 }
59 62
60 const AtomicString& Performance::interfaceName() const 63 const AtomicString& Performance::interfaceName() const
(...skipping 28 matching lines...) Expand all
89 92
90 return m_timing.get(); 93 return m_timing.get();
91 } 94 }
92 95
93 PerformanceEntryVector Performance::getEntries() const 96 PerformanceEntryVector Performance::getEntries() const
94 { 97 {
95 PerformanceEntryVector entries; 98 PerformanceEntryVector entries;
96 99
97 entries.appendVector(m_resourceTimingBuffer); 100 entries.appendVector(m_resourceTimingBuffer);
98 101
102 entries.appendVector(m_smoothnessTimingBuffer);
103
99 if (m_userTiming) { 104 if (m_userTiming) {
100 entries.appendVector(m_userTiming->getMarks()); 105 entries.appendVector(m_userTiming->getMarks());
101 entries.appendVector(m_userTiming->getMeasures()); 106 entries.appendVector(m_userTiming->getMeasures());
102 } 107 }
103 108
104 std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompare LessThan); 109 std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompare LessThan);
105 return entries; 110 return entries;
106 } 111 }
107 112
108 PerformanceEntryVector Performance::getEntriesByType(const String& entryType) 113 PerformanceEntryVector Performance::getEntriesByType(const String& entryType)
109 { 114 {
110 PerformanceEntryVector entries; 115 PerformanceEntryVector entries;
111 116
112 if (equalIgnoringCase(entryType, "resource")) 117 if (equalIgnoringCase(entryType, "resource"))
113 for (PerformanceEntryVector::const_iterator resource = m_resourceTimingB uffer.begin(); resource != m_resourceTimingBuffer.end(); ++resource) 118 for (PerformanceEntryVector::const_iterator resource = m_resourceTimingB uffer.begin(); resource != m_resourceTimingBuffer.end(); ++resource)
114 entries.append(*resource); 119 entries.append(*resource);
115 120
121 if (equalIgnoringCase(entryType, "smoothness"))
122 for (PerformanceEntryVector::const_iterator smoothness = m_smoothnessTim ingBuffer.begin(); smoothness != m_smoothnessTimingBuffer.end(); ++smoothness)
123 entries.append(*smoothness);
124
116 if (m_userTiming) { 125 if (m_userTiming) {
117 if (equalIgnoringCase(entryType, "mark")) 126 if (equalIgnoringCase(entryType, "mark"))
118 entries.appendVector(m_userTiming->getMarks()); 127 entries.appendVector(m_userTiming->getMarks());
119 else if (equalIgnoringCase(entryType, "measure")) 128 else if (equalIgnoringCase(entryType, "measure"))
120 entries.appendVector(m_userTiming->getMeasures()); 129 entries.appendVector(m_userTiming->getMeasures());
121 } 130 }
122 131
123 std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompare LessThan); 132 std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompare LessThan);
124 return entries; 133 return entries;
125 } 134 }
126 135
127 PerformanceEntryVector Performance::getEntriesByName(const String& name, const S tring& entryType) 136 PerformanceEntryVector Performance::getEntriesByName(const String& name, const S tring& entryType)
128 { 137 {
129 PerformanceEntryVector entries; 138 PerformanceEntryVector entries;
130 139
131 if (entryType.isNull() || equalIgnoringCase(entryType, "resource")) 140 if (entryType.isNull() || equalIgnoringCase(entryType, "resource"))
132 for (PerformanceEntryVector::const_iterator resource = m_resourceTimingB uffer.begin(); resource != m_resourceTimingBuffer.end(); ++resource) 141 for (PerformanceEntryVector::const_iterator resource = m_resourceTimingB uffer.begin(); resource != m_resourceTimingBuffer.end(); ++resource)
133 if ((*resource)->name() == name) 142 if ((*resource)->name() == name)
134 entries.append(*resource); 143 entries.append(*resource);
135 144
145 if (entryType.isNull() || equalIgnoringCase(entryType, "smoothness")) {
146 for (PerformanceEntryVector::const_iterator smoothness = m_smoothnessTim ingBuffer.begin(); smoothness != m_smoothnessTimingBuffer.end(); ++smoothness) {
147 if ((*smoothness)->name() == name)
148 entries.append(*smoothness);
149 }
150 }
151
136 if (m_userTiming) { 152 if (m_userTiming) {
137 if (entryType.isNull() || equalIgnoringCase(entryType, "mark")) 153 if (entryType.isNull() || equalIgnoringCase(entryType, "mark"))
138 entries.appendVector(m_userTiming->getMarks(name)); 154 entries.appendVector(m_userTiming->getMarks(name));
139 if (entryType.isNull() || equalIgnoringCase(entryType, "measure")) 155 if (entryType.isNull() || equalIgnoringCase(entryType, "measure"))
140 entries.appendVector(m_userTiming->getMeasures(name)); 156 entries.appendVector(m_userTiming->getMeasures(name));
141 } 157 }
142 158
143 std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompare LessThan); 159 std::sort(entries.begin(), entries.end(), PerformanceEntry::startTimeCompare LessThan);
144 return entries; 160 return entries;
145 } 161 }
146 162
147 void Performance::webkitClearResourceTimings() 163 void Performance::webkitClearResourceTimings()
148 { 164 {
149 m_resourceTimingBuffer.clear(); 165 m_resourceTimingBuffer.clear();
150 } 166 }
151 167
152 void Performance::webkitSetResourceTimingBufferSize(unsigned size) 168 void Performance::webkitSetResourceTimingBufferSize(unsigned size)
153 { 169 {
154 m_resourceTimingBufferSize = size; 170 m_resourceTimingBufferSize = size;
155 if (isResourceTimingBufferFull()) 171 if (isResourceTimingBufferFull())
156 dispatchEvent(Event::create(EventTypeNames::webkitresourcetimingbufferfu ll)); 172 dispatchEvent(Event::create(EventTypeNames::webkitresourcetimingbufferfu ll));
157 } 173 }
158 174
175 void Performance::webkitClearSmoothnessTimings()
176 {
177 m_smoothnessTimingBuffer.clear();
178 }
179
180 void Performance::webkitSetSmoothnessTimingBufferSize(unsigned size)
181 {
182 m_smoothnessTimingBufferSize = size;
183 if (isSmoothnessTimingBufferFull())
184 dispatchEvent(Event::create(EventTypeNames::webkitsmoothnesstimingbuffer full));
185 }
186
159 static bool passesTimingAllowCheck(const ResourceResponse& response, Document* r equestingDocument, const AtomicString& originalTimingAllowOrigin) 187 static bool passesTimingAllowCheck(const ResourceResponse& response, Document* r equestingDocument, const AtomicString& originalTimingAllowOrigin)
160 { 188 {
161 AtomicallyInitializedStatic(AtomicString&, timingAllowOrigin = *new AtomicSt ring("timing-allow-origin")); 189 AtomicallyInitializedStatic(AtomicString&, timingAllowOrigin = *new AtomicSt ring("timing-allow-origin"));
162 190
163 RefPtr<SecurityOrigin> resourceOrigin = SecurityOrigin::create(response.url( )); 191 RefPtr<SecurityOrigin> resourceOrigin = SecurityOrigin::create(response.url( ));
164 if (resourceOrigin->isSameSchemeHostPort(requestingDocument->securityOrigin( ))) 192 if (resourceOrigin->isSameSchemeHostPort(requestingDocument->securityOrigin( )))
165 return true; 193 return true;
166 194
167 const AtomicString& timingAllowOriginString = originalTimingAllowOrigin.isEm pty() ? response.httpHeaderField(timingAllowOrigin) : originalTimingAllowOrigin; 195 const AtomicString& timingAllowOriginString = originalTimingAllowOrigin.isEm pty() ? response.httpHeaderField(timingAllowOrigin) : originalTimingAllowOrigin;
168 if (timingAllowOriginString.isEmpty() || equalIgnoringCase(timingAllowOrigin String, "null")) 196 if (timingAllowOriginString.isEmpty() || equalIgnoringCase(timingAllowOrigin String, "null"))
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 264
237 if (isResourceTimingBufferFull()) 265 if (isResourceTimingBufferFull())
238 dispatchEvent(Event::create(EventTypeNames::webkitresourcetimingbufferfu ll)); 266 dispatchEvent(Event::create(EventTypeNames::webkitresourcetimingbufferfu ll));
239 } 267 }
240 268
241 bool Performance::isResourceTimingBufferFull() 269 bool Performance::isResourceTimingBufferFull()
242 { 270 {
243 return m_resourceTimingBuffer.size() >= m_resourceTimingBufferSize; 271 return m_resourceTimingBuffer.size() >= m_resourceTimingBufferSize;
244 } 272 }
245 273
274 void Performance::addSmoothnessTiming(const String& name, Document* initiatorDoc ument, unsigned sourceFrame, double startTime)
275 {
276 if (isSmoothnessTimingBufferFull())
277 return;
278
279 RefPtrWillBeRawPtr<PerformanceEntry> entry = PerformanceSmoothnessTiming::cr eate(name, initiatorDocument, sourceFrame, startTime);
280 addSmoothnessTimingBuffer(entry);
281 }
282
283 void Performance::addSmoothnessTimingBuffer(PassRefPtrWillBeRawPtr<PerformanceEn try> entry)
284 {
285 m_smoothnessTimingBuffer.append(entry);
286
287 if (isSmoothnessTimingBufferFull())
288 dispatchEvent(Event::create(EventTypeNames::webkitsmoothnesstimingbuffer full));
289 }
290
291 bool Performance::isSmoothnessTimingBufferFull()
292 {
293 return m_smoothnessTimingBuffer.size() >= m_smoothnessTimingBufferSize;
294 }
295
246 void Performance::mark(const String& markName, ExceptionState& exceptionState) 296 void Performance::mark(const String& markName, ExceptionState& exceptionState)
247 { 297 {
248 if (!m_userTiming) 298 if (!m_userTiming)
249 m_userTiming = UserTiming::create(this); 299 m_userTiming = UserTiming::create(this);
250 m_userTiming->mark(markName, exceptionState); 300 m_userTiming->mark(markName, exceptionState);
251 } 301 }
252 302
253 void Performance::clearMarks(const String& markName) 303 void Performance::clearMarks(const String& markName)
254 { 304 {
255 if (!m_userTiming) 305 if (!m_userTiming)
(...skipping 18 matching lines...) Expand all
274 double Performance::now() const 324 double Performance::now() const
275 { 325 {
276 return 1000.0 * (monotonicallyIncreasingTime() - m_referenceTime); 326 return 1000.0 * (monotonicallyIncreasingTime() - m_referenceTime);
277 } 327 }
278 328
279 void Performance::trace(Visitor* visitor) 329 void Performance::trace(Visitor* visitor)
280 { 330 {
281 visitor->trace(m_navigation); 331 visitor->trace(m_navigation);
282 visitor->trace(m_timing); 332 visitor->trace(m_timing);
283 visitor->trace(m_resourceTimingBuffer); 333 visitor->trace(m_resourceTimingBuffer);
334 visitor->trace(m_smoothnessTimingBuffer);
284 visitor->trace(m_userTiming); 335 visitor->trace(m_userTiming);
285 EventTargetWithInlineData::trace(visitor); 336 EventTargetWithInlineData::trace(visitor);
286 DOMWindowProperty::trace(visitor); 337 DOMWindowProperty::trace(visitor);
287 } 338 }
288 339
289 } // namespace blink 340 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/timing/Performance.h ('k') | Source/core/timing/Performance.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698