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

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: decouple enable / disable observer from ctor / dtor, to prevent the issue of tasks getting reported… 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()
99 {
100 if (!hasObserverFor(PerformanceEntry::LongTask) || m_longTaskInspectorAgent)
101 return;
102 m_longTaskInspectorAgent = new InspectorWebPerfAgent(
103 InspectedFrames::create(frame()));
104 m_longTaskInspectorAgent->enableObserver();
105 frame()->instrumentingAgents()->addInspectorWebPerfAgent(
dgozman 2016/09/17 01:11:00 I'd move this call into enableObserver.
panicker 2016/09/17 03:04:00 Done.
106 m_longTaskInspectorAgent);
107 }
108
109 void Performance::disableLongTaskInstrumentation()
110 {
111 if (hasObserverFor(PerformanceEntry::LongTask) || !m_longTaskInspectorAgent)
112 return;
113 m_longTaskInspectorAgent->disableObserver();
114 frame()->instrumentingAgents()->removeInspectorWebPerfAgent(
dgozman 2016/09/17 01:11:00 Similar here.
panicker 2016/09/17 03:04:00 Done.
115 m_longTaskInspectorAgent);
116 m_longTaskInspectorAgent = nullptr;
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