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

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

Issue 2343553005: enable / disable Long Task instrumentation based on presence of LongTask observer (Closed)
Patch Set: Created 4 years, 3 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 13 matching lines...) Expand all
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
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 "core/InstrumentingAgents.h"
34 #include "core/dom/Document.h" 35 #include "core/dom/Document.h"
35 #include "core/frame/LocalFrame.h" 36 #include "core/frame/LocalFrame.h"
37 #include "core/inspector/InspectedFrames.h"
38 #include "core/inspector/InspectorWebPerfAgent.h"
36 #include "core/loader/DocumentLoader.h" 39 #include "core/loader/DocumentLoader.h"
37 #include "core/timing/PerformanceTiming.h" 40 #include "core/timing/PerformanceTiming.h"
38 41
39 namespace blink { 42 namespace blink {
40 43
41 static double toTimeOrigin(LocalFrame* frame) 44 static double toTimeOrigin(LocalFrame* frame)
42 { 45 {
43 if (!frame) 46 if (!frame)
44 return 0.0; 47 return 0.0;
45 48
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 88 }
86 89
87 PerformanceTiming* Performance::timing() const 90 PerformanceTiming* Performance::timing() const
88 { 91 {
89 if (!m_timing) 92 if (!m_timing)
90 m_timing = PerformanceTiming::create(m_frame); 93 m_timing = PerformanceTiming::create(m_frame);
91 94
92 return m_timing.get(); 95 return m_timing.get();
93 } 96 }
94 97
98 void Performance::enableLongTaskInstrumentation() const
99 {
100 if (hasObserverFor(PerformanceEntry::LongTask)
caseq 2016/09/15 23:29:40 nit: we tend to prefer early bail-outs, i.e. "if (
panicker 2016/09/16 17:07:58 Ok. Done.
101 && !m_longTaskInspectorAgent) {
102 m_longTaskInspectorAgent = new InspectorWebPerfAgent(
103 InspectedFrames::create(frame()));
104 frame()->instrumentingAgents()->addInspectorWebPerfAgent(
105 m_longTaskInspectorAgent);
106 }
107 }
108
109 void Performance::disableLongTaskInstrumentation() const
110 {
111 if (!hasObserverFor(PerformanceEntry::LongTask)
112 && m_longTaskInspectorAgent) {
113 frame()->instrumentingAgents()->removeInspectorWebPerfAgent(
114 m_longTaskInspectorAgent);
115 m_longTaskInspectorAgent = nullptr;
116 }
117 }
118
95 DEFINE_TRACE(Performance) 119 DEFINE_TRACE(Performance)
96 { 120 {
97 visitor->trace(m_navigation); 121 visitor->trace(m_navigation);
98 visitor->trace(m_timing); 122 visitor->trace(m_timing);
123 visitor->trace(m_longTaskInspectorAgent);
99 DOMWindowProperty::trace(visitor); 124 DOMWindowProperty::trace(visitor);
100 PerformanceBase::trace(visitor); 125 PerformanceBase::trace(visitor);
101 } 126 }
102 127
103 } // namespace blink 128 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698