| 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 |
| 43 static const double kLongTaskThreshold = 0.05; | 46 static const double kLongTaskThreshold = 0.05; |
| 44 | 47 |
| 45 static const char kUnknownAttribution[] = "unknown"; | 48 static const char kUnknownAttribution[] = "unknown"; |
| 46 static const char kAmbugiousAttribution[] = "multiple-contexts"; | 49 static const char kAmbugiousAttribution[] = "multiple-contexts"; |
| 47 static const char kSameOriginAttribution[] = "same-origin"; | 50 static const char kSameOriginAttribution[] = "same-origin"; |
| 48 static const char kAncestorAttribution[] = "cross-origin-ancestor"; | 51 static const char kAncestorAttribution[] = "cross-origin-ancestor"; |
| 49 static const char kDescendantAttribution[] = "cross-origin-descendant"; | 52 static const char kDescendantAttribution[] = "cross-origin-descendant"; |
| 50 static const char kCrossOriginAttribution[] = "cross-origin-unreachable"; | 53 static const char kCrossOriginAttribution[] = "cross-origin-unreachable"; |
| 51 | 54 |
| 52 namespace blink { | 55 namespace blink { |
| 53 | 56 |
| 57 namespace { |
| 58 |
| 59 String getFrameAttribute(HTMLFrameOwnerElement* frameOwner, |
| 60 const QualifiedName& attrName, |
| 61 bool truncate) { |
| 62 String attrValue; |
| 63 if (frameOwner->hasAttribute(attrName)) { |
| 64 attrValue = frameOwner->getAttribute(attrName); |
| 65 if (truncate && attrValue.length() > 100) |
| 66 attrValue = attrValue.substring(0, 100); // Truncate to 100 chars |
| 67 } |
| 68 return attrValue; |
| 69 } |
| 70 |
| 71 } // namespace |
| 72 |
| 54 static double toTimeOrigin(LocalFrame* frame) { | 73 static double toTimeOrigin(LocalFrame* frame) { |
| 55 if (!frame) | 74 if (!frame) |
| 56 return 0.0; | 75 return 0.0; |
| 57 | 76 |
| 58 Document* document = frame->document(); | 77 Document* document = frame->document(); |
| 59 if (!document) | 78 if (!document) |
| 60 return 0.0; | 79 return 0.0; |
| 61 | 80 |
| 62 DocumentLoader* loader = document->loader(); | 81 DocumentLoader* loader = document->loader(); |
| 63 if (!loader) | 82 if (!loader) |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 } | 207 } |
| 189 return std::make_pair(kCrossOriginAttribution, nullptr); | 208 return std::make_pair(kCrossOriginAttribution, nullptr); |
| 190 } | 209 } |
| 191 | 210 |
| 192 void Performance::reportLongTask( | 211 void Performance::reportLongTask( |
| 193 double startTime, | 212 double startTime, |
| 194 double endTime, | 213 double endTime, |
| 195 const HeapHashSet<Member<Frame>>& contextFrames) { | 214 const HeapHashSet<Member<Frame>>& contextFrames) { |
| 196 std::pair<String, DOMWindow*> attribution = | 215 std::pair<String, DOMWindow*> attribution = |
| 197 Performance::sanitizedAttribution(contextFrames, frame()); | 216 Performance::sanitizedAttribution(contextFrames, frame()); |
| 198 addLongTaskTiming(startTime, endTime, attribution.first, attribution.second); | 217 DOMWindow* culpritDomWindow = attribution.second; |
| 218 if (!culpritDomWindow || !culpritDomWindow->document() || |
| 219 !culpritDomWindow->document()->localOwner()) { |
| 220 addLongTaskTiming(startTime, endTime, attribution.first, "", "", ""); |
| 221 } else { |
| 222 HTMLFrameOwnerElement* frameOwner = |
| 223 culpritDomWindow->document()->localOwner(); |
| 224 addLongTaskTiming(startTime, endTime, attribution.first, |
| 225 getFrameAttribute(frameOwner, HTMLNames::srcAttr, false), |
| 226 getFrameAttribute(frameOwner, HTMLNames::idAttr, false), |
| 227 getFrameAttribute(frameOwner, HTMLNames::nameAttr, true)); |
| 228 } |
| 199 } | 229 } |
| 200 | 230 |
| 201 } // namespace blink | 231 } // namespace blink |
| OLD | NEW |