OLD | NEW |
---|---|
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 23 matching lines...) Expand all Loading... | |
34 | 34 |
35 #include "Document.h" | 35 #include "Document.h" |
36 #include "DocumentLoader.h" | 36 #include "DocumentLoader.h" |
37 #include "MemoryInfo.h" | 37 #include "MemoryInfo.h" |
38 #include "PerformanceEntry.h" | 38 #include "PerformanceEntry.h" |
39 #include "PerformanceNavigation.h" | 39 #include "PerformanceNavigation.h" |
40 #include "PerformanceResourceTiming.h" | 40 #include "PerformanceResourceTiming.h" |
41 #include "PerformanceTiming.h" | 41 #include "PerformanceTiming.h" |
42 #include "PerformanceUserTiming.h" | 42 #include "PerformanceUserTiming.h" |
43 #include "ResourceResponse.h" | 43 #include "ResourceResponse.h" |
44 #include "ResourceTimingInfo.h" | |
44 #include <wtf/CurrentTime.h> | 45 #include <wtf/CurrentTime.h> |
45 | 46 |
46 #include "Frame.h" | 47 #include "Frame.h" |
47 | 48 |
48 namespace WebCore { | 49 namespace WebCore { |
49 | 50 |
50 static const size_t defaultResourceTimingBufferSize = 150; | 51 static const size_t defaultResourceTimingBufferSize = 150; |
51 | 52 |
52 Performance::Performance(Frame* frame) | 53 Performance::Performance(Frame* frame) |
53 : DOMWindowProperty(frame) | 54 : DOMWindowProperty(frame) |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 m_resourceTimingBuffer.clear(); | 154 m_resourceTimingBuffer.clear(); |
154 } | 155 } |
155 | 156 |
156 void Performance::webkitSetResourceTimingBufferSize(unsigned size) | 157 void Performance::webkitSetResourceTimingBufferSize(unsigned size) |
157 { | 158 { |
158 m_resourceTimingBufferSize = size; | 159 m_resourceTimingBufferSize = size; |
159 if (isResourceTimingBufferFull()) | 160 if (isResourceTimingBufferFull()) |
160 dispatchEvent(Event::create(eventNames().webkitresourcetimingbufferfullE vent, false, false)); | 161 dispatchEvent(Event::create(eventNames().webkitresourcetimingbufferfullE vent, false, false)); |
161 } | 162 } |
162 | 163 |
163 void Performance::addResourceTiming(const String& initiatorName, Document* initi atorDocument, const ResourceRequest& request, const ResourceResponse& response, double initiationTime, double finishTime) | 164 static bool passesTimingAllowCheck(const ResourceResponse& response, Document* r equestingDocument) |
165 { | |
166 AtomicallyInitializedStatic(AtomicString&, timingAllowOrigin = *new AtomicSt ring("timing-allow-origin")); | |
167 | |
168 RefPtr<SecurityOrigin> resourceOrigin = SecurityOrigin::create(response.url( )); | |
169 if (resourceOrigin->isSameSchemeHostPort(requestingDocument->securityOrigin( ))) | |
170 return true; | |
171 | |
172 const String& timingAllowOriginString = response.httpHeaderField(timingAllow Origin); | |
173 if (timingAllowOriginString.isEmpty() || equalIgnoringCase(timingAllowOrigin String, "null")) | |
174 return false; | |
175 | |
176 if (timingAllowOriginString == "*") | |
177 return true; | |
178 | |
179 const String& securityOrigin = requestingDocument->securityOrigin()->toStrin g(); | |
180 Vector<String> timingAllowOrigins; | |
181 timingAllowOriginString.split(" ", timingAllowOrigins); | |
182 for (size_t i = 0; i < timingAllowOrigins.size(); ++i) | |
183 if (timingAllowOrigins[i] == securityOrigin) | |
184 return true; | |
185 | |
186 return false; | |
187 } | |
188 | |
189 void Performance::addResourceTiming(const ResourceTimingInfo& info, Document* in itiatorDocument) | |
164 { | 190 { |
165 if (isResourceTimingBufferFull()) | 191 if (isResourceTimingBufferFull()) |
166 return; | 192 return; |
167 | 193 |
168 RefPtr<PerformanceEntry> entry = PerformanceResourceTiming::create(initiator Name, request, response, initiationTime, finishTime, initiatorDocument); | 194 bool shouldReportDetails = true; |
195 Vector<ResourceResponse> redirectChain = info.redirectChain(); | |
169 | 196 |
197 for (size_t i = 0; i < redirectChain.size(); i++) | |
198 if (false == (shouldReportDetails = passesTimingAllowCheck(redirectChain [i], initiatorDocument))) | |
199 break; | |
200 | |
201 if (shouldReportDetails) | |
202 shouldReportDetails = passesTimingAllowCheck(info.finalResponse(), initi atorDocument); | |
203 | |
204 double lastRedirectEndTime = 0.0; | |
205 if (redirectChain.size() != 0) { | |
206 ResourceLoadTiming* loadTiming = redirectChain.last().resourceLoadTiming (); | |
207 ASSERT(loadTiming); | |
Pan
2013/04/17 15:38:16
I observed that resourceLoadTiming is not containe
James Simonsen
2013/04/18 02:57:37
That's determined entirely by Blink, not Chrome. R
| |
208 lastRedirectEndTime = loadTiming->convertResourceLoadTimeToMonotonicTime (loadTiming->receiveHeadersEnd); | |
Pan
2013/04/19 14:54:59
can we assume redirect response will never be cach
James Simonsen
2013/04/23 00:31:37
No, we do cache redirects. There's a bug to do a b
| |
209 } | |
210 | |
211 double startTime = info.initialTime(); | |
212 if (!shouldReportDetails && lastRedirectEndTime) | |
213 startTime = info.finalResponse().resourceLoadTiming()->requestTime; | |
214 | |
215 RefPtr<PerformanceEntry> entry = PerformanceResourceTiming::create(info, ini tiatorDocument, startTime, lastRedirectEndTime, shouldReportDetails); | |
170 m_resourceTimingBuffer.append(entry); | 216 m_resourceTimingBuffer.append(entry); |
171 | 217 |
172 if (isResourceTimingBufferFull()) | 218 if (isResourceTimingBufferFull()) |
173 dispatchEvent(Event::create(eventNames().webkitresourcetimingbufferfullE vent, false, false)); | 219 dispatchEvent(Event::create(eventNames().webkitresourcetimingbufferfullE vent, false, false)); |
174 } | 220 } |
175 | 221 |
176 bool Performance::isResourceTimingBufferFull() | 222 bool Performance::isResourceTimingBufferFull() |
177 { | 223 { |
178 return m_resourceTimingBuffer.size() >= m_resourceTimingBufferSize; | 224 return m_resourceTimingBuffer.size() >= m_resourceTimingBufferSize; |
179 } | 225 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 m_userTiming = UserTiming::create(this); | 263 m_userTiming = UserTiming::create(this); |
218 m_userTiming->clearMeasures(measureName); | 264 m_userTiming->clearMeasures(measureName); |
219 } | 265 } |
220 | 266 |
221 double Performance::now() const | 267 double Performance::now() const |
222 { | 268 { |
223 return 1000.0 * m_frame->document()->loader()->timing()->monotonicTimeToZero BasedDocumentTime(monotonicallyIncreasingTime()); | 269 return 1000.0 * m_frame->document()->loader()->timing()->monotonicTimeToZero BasedDocumentTime(monotonicallyIncreasingTime()); |
224 } | 270 } |
225 | 271 |
226 } // namespace WebCore | 272 } // namespace WebCore |
OLD | NEW |