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

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: remove check in dtor 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 15 matching lines...) Expand all
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/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"
37 #include "core/inspector/InspectorWebPerfAgent.h"
36 #include "core/loader/DocumentLoader.h" 38 #include "core/loader/DocumentLoader.h"
37 #include "core/timing/PerformanceTiming.h" 39 #include "core/timing/PerformanceTiming.h"
38 40
39 namespace blink { 41 namespace blink {
40 42
41 static double toTimeOrigin(LocalFrame* frame) 43 static double toTimeOrigin(LocalFrame* frame)
42 { 44 {
43 if (!frame) 45 if (!frame)
44 return 0.0; 46 return 0.0;
45 47
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 87 }
86 88
87 PerformanceTiming* Performance::timing() const 89 PerformanceTiming* Performance::timing() const
88 { 90 {
89 if (!m_timing) 91 if (!m_timing)
90 m_timing = PerformanceTiming::create(m_frame); 92 m_timing = PerformanceTiming::create(m_frame);
91 93
92 return m_timing.get(); 94 return m_timing.get();
93 } 95 }
94 96
97 void Performance::enableLongTaskInstrumentation()
98 {
99 if (!hasObserverFor(PerformanceEntry::LongTask) || m_longTaskInspectorAgent)
100 return;
101 m_longTaskInspectorAgent = new InspectorWebPerfAgent(
102 InspectedFrames::create(frame()));
103 m_longTaskInspectorAgent->enable();
104 }
105
106 void Performance::disableLongTaskInstrumentation()
107 {
108 if (hasObserverFor(PerformanceEntry::LongTask) || !m_longTaskInspectorAgent)
dgozman 2016/09/19 17:55:59 Since we check for enable conditions in both metho
panicker 2016/09/20 12:00:39 Done.
109 return;
110 m_longTaskInspectorAgent->disable();
111 m_longTaskInspectorAgent = nullptr;
112 }
113
95 DEFINE_TRACE(Performance) 114 DEFINE_TRACE(Performance)
96 { 115 {
97 visitor->trace(m_navigation); 116 visitor->trace(m_navigation);
98 visitor->trace(m_timing); 117 visitor->trace(m_timing);
118 visitor->trace(m_longTaskInspectorAgent);
99 DOMWindowProperty::trace(visitor); 119 DOMWindowProperty::trace(visitor);
100 PerformanceBase::trace(visitor); 120 PerformanceBase::trace(visitor);
101 } 121 }
102 122
103 } // namespace blink 123 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698