Chromium Code Reviews| 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 25 matching lines...) Expand all Loading... | |
| 36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
| 37 #include "core/dom/QualifiedName.h" | 37 #include "core/dom/QualifiedName.h" |
| 38 #include "core/dom/TaskRunnerHelper.h" | 38 #include "core/dom/TaskRunnerHelper.h" |
| 39 #include "core/frame/DOMWindow.h" | 39 #include "core/frame/DOMWindow.h" |
| 40 #include "core/frame/LocalFrame.h" | 40 #include "core/frame/LocalFrame.h" |
| 41 #include "core/frame/UseCounter.h" | 41 #include "core/frame/UseCounter.h" |
| 42 #include "core/html/HTMLFrameOwnerElement.h" | 42 #include "core/html/HTMLFrameOwnerElement.h" |
| 43 #include "core/loader/DocumentLoader.h" | 43 #include "core/loader/DocumentLoader.h" |
| 44 #include "core/origin_trials/OriginTrials.h" | 44 #include "core/origin_trials/OriginTrials.h" |
| 45 #include "core/timing/PerformanceTiming.h" | 45 #include "core/timing/PerformanceTiming.h" |
| 46 #include "platform/network/ResourceTimingInfo.h" | |
| 46 | 47 |
| 47 static const double kLongTaskThreshold = 0.05; | 48 static const double kLongTaskThreshold = 0.05; |
| 48 | 49 |
| 49 static const char kUnknownAttribution[] = "unknown"; | 50 static const char kUnknownAttribution[] = "unknown"; |
| 50 static const char kAmbiguousAttribution[] = "multiple-contexts"; | 51 static const char kAmbiguousAttribution[] = "multiple-contexts"; |
| 51 static const char kSameOriginAttribution[] = "same-origin"; | 52 static const char kSameOriginAttribution[] = "same-origin"; |
| 52 static const char kSameOriginSelfAttribution[] = "self"; | 53 static const char kSameOriginSelfAttribution[] = "self"; |
| 53 static const char kSameOriginAncestorAttribution[] = "same-origin-ancestor"; | 54 static const char kSameOriginAncestorAttribution[] = "same-origin-ancestor"; |
| 54 static const char kSameOriginDescendantAttribution[] = "same-origin-descendant"; | 55 static const char kSameOriginDescendantAttribution[] = "same-origin-descendant"; |
| 55 static const char kCrossOriginAncestorAttribution[] = "cross-origin-ancestor"; | 56 static const char kCrossOriginAncestorAttribution[] = "cross-origin-ancestor"; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 return m_navigation.get(); | 134 return m_navigation.get(); |
| 134 } | 135 } |
| 135 | 136 |
| 136 PerformanceTiming* Performance::timing() const { | 137 PerformanceTiming* Performance::timing() const { |
| 137 if (!m_timing) | 138 if (!m_timing) |
| 138 m_timing = PerformanceTiming::create(frame()); | 139 m_timing = PerformanceTiming::create(frame()); |
| 139 | 140 |
| 140 return m_timing.get(); | 141 return m_timing.get(); |
| 141 } | 142 } |
| 142 | 143 |
| 144 PerformanceNavigationTiming* Performance::createNavigationTimingInstance() { | |
| 145 ResourceTimingInfo* resourceTimingInfo = nullptr; | |
| 146 if (frame()) { | |
|
Kunihiko Sakamoto
2017/02/15 06:35:30
If frame() is null, can we return nullptr here? Cu
sunjian
2017/02/15 20:30:28
Agree with returning nullptr directly when frame()
panicker
2017/02/16 00:37:23
Which dchecks are being referred to here specifica
Kunihiko Sakamoto
2017/02/16 08:42:29
Ah I overlooked that m_frame is a weak pointer.
S
sunjian
2017/02/16 22:30:49
Acknowledged.
| |
| 147 const DocumentLoader* documentLoader = frame()->loader().documentLoader(); | |
| 148 DCHECK(documentLoader); | |
| 149 resourceTimingInfo = documentLoader->getNavigationTimingInfo(); | |
| 150 } | |
| 151 | |
| 152 return new PerformanceNavigationTiming(frame(), resourceTimingInfo, | |
| 153 timeOrigin()); | |
| 154 } | |
| 155 | |
| 143 void Performance::updateLongTaskInstrumentation() { | 156 void Performance::updateLongTaskInstrumentation() { |
| 144 DCHECK(frame()); | 157 DCHECK(frame()); |
| 145 if (!frame()->document()) | 158 if (!frame()->document()) |
| 146 return; | 159 return; |
| 147 | 160 |
| 148 if (hasObserverFor(PerformanceEntry::LongTask)) { | 161 if (hasObserverFor(PerformanceEntry::LongTask)) { |
| 149 UseCounter::count(frame()->localFrameRoot(), UseCounter::LongTaskObserver); | 162 UseCounter::count(frame()->localFrameRoot(), UseCounter::LongTaskObserver); |
| 150 frame()->performanceMonitor()->subscribe(PerformanceMonitor::kLongTask, | 163 frame()->performanceMonitor()->subscribe(PerformanceMonitor::kLongTask, |
| 151 kLongTaskThreshold, this); | 164 kLongTaskThreshold, this); |
| 152 } else { | 165 } else { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 HTMLFrameOwnerElement* frameOwner = | 257 HTMLFrameOwnerElement* frameOwner = |
| 245 culpritDomWindow->frame()->deprecatedLocalOwner(); | 258 culpritDomWindow->frame()->deprecatedLocalOwner(); |
| 246 addLongTaskTiming(startTime, endTime, attribution.first, | 259 addLongTaskTiming(startTime, endTime, attribution.first, |
| 247 getFrameAttribute(frameOwner, HTMLNames::srcAttr, false), | 260 getFrameAttribute(frameOwner, HTMLNames::srcAttr, false), |
| 248 getFrameAttribute(frameOwner, HTMLNames::idAttr, false), | 261 getFrameAttribute(frameOwner, HTMLNames::idAttr, false), |
| 249 getFrameAttribute(frameOwner, HTMLNames::nameAttr, true)); | 262 getFrameAttribute(frameOwner, HTMLNames::nameAttr, true)); |
| 250 } | 263 } |
| 251 } | 264 } |
| 252 | 265 |
| 253 } // namespace blink | 266 } // namespace blink |
| OLD | NEW |