 Chromium Code Reviews
 Chromium Code Reviews Issue 2647643004:
  Report nav timing 2 instance as soon as it's requested.  (Closed)
    
  
    Issue 2647643004:
  Report nav timing 2 instance as soon as it's requested.  (Closed) 
  | 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 std::unique_ptr<ResourceTimingInfo> Performance::getNavigationTimingInfo() | |
| 145 const { | |
| 146 DCHECK(frame()); | |
| 147 const DocumentLoader* documentLoader = frame()->loader().documentLoader(); | |
| 148 DCHECK(documentLoader); | |
| 149 return documentLoader->getNavigationTimingInfo(); | |
| 150 } | |
| 151 | |
| 152 PerformanceNavigationTiming* Performance::getNavigationTimingInstance() { | |
| 
panicker
2017/02/03 23:53:52
createNavigationTimingInstance?
 
sunjian
2017/02/10 18:32:46
Done.
 | |
| 153 return new PerformanceNavigationTiming(frame(), getNavigationTimingInfo(), | |
| 154 toTimeOrigin(frame())); | |
| 155 } | |
| 156 | |
| 143 void Performance::updateLongTaskInstrumentation() { | 157 void Performance::updateLongTaskInstrumentation() { | 
| 144 DCHECK(frame()); | 158 DCHECK(frame()); | 
| 145 if (!frame()->document() || | 159 if (!frame()->document() || | 
| 146 !OriginTrials::longTaskObserverEnabled(frame()->document())) | 160 !OriginTrials::longTaskObserverEnabled(frame()->document())) | 
| 147 return; | 161 return; | 
| 148 | 162 | 
| 149 if (hasObserverFor(PerformanceEntry::LongTask)) { | 163 if (hasObserverFor(PerformanceEntry::LongTask)) { | 
| 150 UseCounter::count(frame()->localFrameRoot(), UseCounter::LongTaskObserver); | 164 UseCounter::count(frame()->localFrameRoot(), UseCounter::LongTaskObserver); | 
| 151 frame()->performanceMonitor()->subscribe(PerformanceMonitor::kLongTask, | 165 frame()->performanceMonitor()->subscribe(PerformanceMonitor::kLongTask, | 
| 152 kLongTaskThreshold, this); | 166 kLongTaskThreshold, this); | 
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 HTMLFrameOwnerElement* frameOwner = | 259 HTMLFrameOwnerElement* frameOwner = | 
| 246 culpritDomWindow->frame()->deprecatedLocalOwner(); | 260 culpritDomWindow->frame()->deprecatedLocalOwner(); | 
| 247 addLongTaskTiming(startTime, endTime, attribution.first, | 261 addLongTaskTiming(startTime, endTime, attribution.first, | 
| 248 getFrameAttribute(frameOwner, HTMLNames::srcAttr, false), | 262 getFrameAttribute(frameOwner, HTMLNames::srcAttr, false), | 
| 249 getFrameAttribute(frameOwner, HTMLNames::idAttr, false), | 263 getFrameAttribute(frameOwner, HTMLNames::idAttr, false), | 
| 250 getFrameAttribute(frameOwner, HTMLNames::nameAttr, true)); | 264 getFrameAttribute(frameOwner, HTMLNames::nameAttr, true)); | 
| 251 } | 265 } | 
| 252 } | 266 } | 
| 253 | 267 | 
| 254 } // namespace blink | 268 } // namespace blink | 
| OLD | NEW |