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 16 matching lines...) Expand all Loading... | |
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 "core/timing/Performance.h" | 32 #include "core/timing/Performance.h" |
33 | 33 |
34 #include "bindings/core/v8/ScriptValue.h" | 34 #include "bindings/core/v8/ScriptValue.h" |
35 #include "bindings/core/v8/V8ObjectBuilder.h" | 35 #include "bindings/core/v8/V8ObjectBuilder.h" |
36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
37 #include "core/dom/QualifiedName.h" | |
38 #include "core/frame/DOMWindow.h" | |
37 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
38 #include "core/frame/UseCounter.h" | 40 #include "core/frame/UseCounter.h" |
41 #include "core/html/HTMLFrameOwnerElement.h" | |
39 #include "core/loader/DocumentLoader.h" | 42 #include "core/loader/DocumentLoader.h" |
40 #include "core/origin_trials/OriginTrials.h" | 43 #include "core/origin_trials/OriginTrials.h" |
41 #include "core/timing/PerformanceTiming.h" | 44 #include "core/timing/PerformanceTiming.h" |
42 | 45 |
46 #include <tuple> | |
skobes
2016/11/22 00:42:39
You can remove this now.
panicker
2016/11/22 00:45:08
Done.
| |
47 | |
43 static const double kLongTaskThreshold = 0.05; | 48 static const double kLongTaskThreshold = 0.05; |
44 | 49 |
45 static const char kUnknownAttribution[] = "unknown"; | 50 static const char kUnknownAttribution[] = "unknown"; |
46 static const char kAmbugiousAttribution[] = "multiple-contexts"; | 51 static const char kAmbugiousAttribution[] = "multiple-contexts"; |
47 static const char kSameOriginAttribution[] = "same-origin"; | 52 static const char kSameOriginAttribution[] = "same-origin"; |
48 static const char kAncestorAttribution[] = "cross-origin-ancestor"; | 53 static const char kAncestorAttribution[] = "cross-origin-ancestor"; |
49 static const char kDescendantAttribution[] = "cross-origin-descendant"; | 54 static const char kDescendantAttribution[] = "cross-origin-descendant"; |
50 static const char kCrossOriginAttribution[] = "cross-origin-unreachable"; | 55 static const char kCrossOriginAttribution[] = "cross-origin-unreachable"; |
51 | 56 |
52 namespace blink { | 57 namespace blink { |
53 | 58 |
59 namespace { | |
60 | |
61 String getFrameAttribute(HTMLFrameOwnerElement* frameOwner, | |
62 const QualifiedName& attrName, | |
63 bool truncate) { | |
64 String attrValue; | |
65 if (frameOwner->hasAttribute(attrName)) { | |
66 attrValue = frameOwner->getAttribute(attrName); | |
67 if (truncate && attrValue.length() > 100) | |
68 attrValue = attrValue.substring(0, 100); // Truncate to 100 chars | |
69 } | |
70 return attrValue; | |
71 } | |
72 | |
73 } // namespace | |
74 | |
54 static double toTimeOrigin(LocalFrame* frame) { | 75 static double toTimeOrigin(LocalFrame* frame) { |
55 if (!frame) | 76 if (!frame) |
56 return 0.0; | 77 return 0.0; |
57 | 78 |
58 Document* document = frame->document(); | 79 Document* document = frame->document(); |
59 if (!document) | 80 if (!document) |
60 return 0.0; | 81 return 0.0; |
61 | 82 |
62 DocumentLoader* loader = document->loader(); | 83 DocumentLoader* loader = document->loader(); |
63 if (!loader) | 84 if (!loader) |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 } | 209 } |
189 return std::make_pair(kCrossOriginAttribution, nullptr); | 210 return std::make_pair(kCrossOriginAttribution, nullptr); |
190 } | 211 } |
191 | 212 |
192 void Performance::reportLongTask( | 213 void Performance::reportLongTask( |
193 double startTime, | 214 double startTime, |
194 double endTime, | 215 double endTime, |
195 const HeapHashSet<Member<Frame>>& contextFrames) { | 216 const HeapHashSet<Member<Frame>>& contextFrames) { |
196 std::pair<String, DOMWindow*> attribution = | 217 std::pair<String, DOMWindow*> attribution = |
197 Performance::sanitizedAttribution(contextFrames, frame()); | 218 Performance::sanitizedAttribution(contextFrames, frame()); |
198 addLongTaskTiming(startTime, endTime, attribution.first, attribution.second); | 219 DOMWindow* culpritDomWindow = attribution.second; |
220 if (!culpritDomWindow || !culpritDomWindow->document() || | |
221 !culpritDomWindow->document()->localOwner()) { | |
222 addLongTaskTiming(startTime, endTime, attribution.first, "", "", ""); | |
223 } else { | |
224 HTMLFrameOwnerElement* frameOwner = | |
225 culpritDomWindow->document()->localOwner(); | |
226 addLongTaskTiming(startTime, endTime, attribution.first, | |
227 getFrameAttribute(frameOwner, HTMLNames::srcAttr, false), | |
228 getFrameAttribute(frameOwner, HTMLNames::idAttr, true), | |
229 getFrameAttribute(frameOwner, HTMLNames::nameAttr, true)); | |
230 } | |
199 } | 231 } |
200 | 232 |
201 } // namespace blink | 233 } // namespace blink |
OLD | NEW |