Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: third_party/WebKit/Source/core/timing/Performance.cpp

Issue 2383413002: Add OriginTrial flag for Long Task Observer (Closed)
Patch Set: sync and rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 18 matching lines...) Expand all
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 "core/dom/Document.h" 34 #include "core/dom/Document.h"
35 #include "core/frame/LocalFrame.h" 35 #include "core/frame/LocalFrame.h"
36 #include "core/inspector/InspectedFrames.h" 36 #include "core/inspector/InspectedFrames.h"
37 #include "core/inspector/InspectorWebPerfAgent.h" 37 #include "core/inspector/InspectorWebPerfAgent.h"
38 #include "core/loader/DocumentLoader.h" 38 #include "core/loader/DocumentLoader.h"
39 #include "core/origin_trials/OriginTrials.h"
39 #include "core/timing/PerformanceTiming.h" 40 #include "core/timing/PerformanceTiming.h"
40 41
41 namespace blink { 42 namespace blink {
42 43
43 static double toTimeOrigin(LocalFrame* frame) { 44 static double toTimeOrigin(LocalFrame* frame) {
44 if (!frame) 45 if (!frame)
45 return 0.0; 46 return 0.0;
46 47
47 Document* document = frame->document(); 48 Document* document = frame->document();
48 if (!document) 49 if (!document)
(...skipping 30 matching lines...) Expand all
79 80
80 PerformanceTiming* Performance::timing() const { 81 PerformanceTiming* Performance::timing() const {
81 if (!m_timing) 82 if (!m_timing)
82 m_timing = PerformanceTiming::create(frame()); 83 m_timing = PerformanceTiming::create(frame());
83 84
84 return m_timing.get(); 85 return m_timing.get();
85 } 86 }
86 87
87 void Performance::updateLongTaskInstrumentation() { 88 void Performance::updateLongTaskInstrumentation() {
88 if (hasObserverFor(PerformanceEntry::LongTask) && !m_longTaskInspectorAgent) { 89 if (hasObserverFor(PerformanceEntry::LongTask) && !m_longTaskInspectorAgent) {
90 if (!frame() || !frame()->document() ||
91 !OriginTrials::longTaskObserverEnabled(frame()->document()))
92 return;
89 m_longTaskInspectorAgent = new InspectorWebPerfAgent(frame()); 93 m_longTaskInspectorAgent = new InspectorWebPerfAgent(frame());
90 m_longTaskInspectorAgent->enable(); 94 m_longTaskInspectorAgent->enable();
91 } else if (!hasObserverFor(PerformanceEntry::LongTask) && 95 } else if (!hasObserverFor(PerformanceEntry::LongTask) &&
92 m_longTaskInspectorAgent) { 96 m_longTaskInspectorAgent) {
93 m_longTaskInspectorAgent->disable(); 97 m_longTaskInspectorAgent->disable();
94 m_longTaskInspectorAgent = nullptr; 98 m_longTaskInspectorAgent = nullptr;
95 } 99 }
96 } 100 }
97 101
98 DEFINE_TRACE(Performance) { 102 DEFINE_TRACE(Performance) {
99 visitor->trace(m_navigation); 103 visitor->trace(m_navigation);
100 visitor->trace(m_timing); 104 visitor->trace(m_timing);
101 visitor->trace(m_longTaskInspectorAgent); 105 visitor->trace(m_longTaskInspectorAgent);
102 DOMWindowProperty::trace(visitor); 106 DOMWindowProperty::trace(visitor);
103 PerformanceBase::trace(visitor); 107 PerformanceBase::trace(visitor);
104 } 108 }
105 109
106 } // namespace blink 110 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698