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

Side by Side Diff: sky/engine/core/frame/DOMTimer.cpp

Issue 889823002: Remove TRACE_EVENT indirection through blink::Platform (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « sky/engine/core/frame/ConsoleBase.cpp ('k') | sky/engine/core/frame/FrameView.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 10 matching lines...) Expand all
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 * 24 *
25 */ 25 */
26 26
27 #include "sky/engine/config.h" 27 #include "sky/engine/config.h"
28 #include "sky/engine/core/frame/DOMTimer.h" 28 #include "sky/engine/core/frame/DOMTimer.h"
29 29
30 #include "sky/engine/core/dom/ExecutionContext.h" 30 #include "sky/engine/core/dom/ExecutionContext.h"
31 #include "sky/engine/core/inspector/InspectorTraceEvents.h"
32 #include "sky/engine/platform/Logging.h" 31 #include "sky/engine/platform/Logging.h"
33 #include "sky/engine/platform/TraceEvent.h" 32 #include "sky/engine/platform/TraceEvent.h"
34 #include "sky/engine/wtf/CurrentTime.h" 33 #include "sky/engine/wtf/CurrentTime.h"
35 34
36 namespace blink { 35 namespace blink {
37 36
38 static const int maxTimerNestingLevel = 5; 37 static const int maxTimerNestingLevel = 5;
39 static const double oneMillisecond = 0.001; 38 static const double oneMillisecond = 0.001;
40 // Chromium uses a minimum timer interval of 4ms. We'd like to go 39 // Chromium uses a minimum timer interval of 4ms. We'd like to go
41 // lower; however, there are poorly coded websites out there which do 40 // lower; however, there are poorly coded websites out there which do
(...skipping 13 matching lines...) Expand all
55 54
56 double DOMTimer::visiblePageAlignmentInterval() 55 double DOMTimer::visiblePageAlignmentInterval()
57 { 56 {
58 // Alignment does not apply to timers on visible pages. 57 // Alignment does not apply to timers on visible pages.
59 return 0; 58 return 0;
60 } 59 }
61 60
62 int DOMTimer::install(ExecutionContext* context, PassOwnPtr<ScheduledAction> act ion, int timeout, bool singleShot) 61 int DOMTimer::install(ExecutionContext* context, PassOwnPtr<ScheduledAction> act ion, int timeout, bool singleShot)
63 { 62 {
64 int timeoutID = context->installNewTimeout(action, timeout, singleShot); 63 int timeoutID = context->installNewTimeout(action, timeout, singleShot);
65 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "TimerI nstall", TRACE_EVENT_SCOPE_PROCESS, "data", InspectorTimerInstallEvent::data(con text, timeoutID, timeout, singleShot));
66 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), " CallStack", TRACE_EVENT_SCOPE_PROCESS, "stack", InspectorCallStackEvent::current CallStack());
67 WTF_LOG(Timers, "DOMTimer::install: timeoutID = %d, timeout = %d, singleShot = %d", timeoutID, timeout, singleShot ? 1 : 0); 64 WTF_LOG(Timers, "DOMTimer::install: timeoutID = %d, timeout = %d, singleShot = %d", timeoutID, timeout, singleShot ? 1 : 0);
68 return timeoutID; 65 return timeoutID;
69 } 66 }
70 67
71 void DOMTimer::removeByID(ExecutionContext* context, int timeoutID) 68 void DOMTimer::removeByID(ExecutionContext* context, int timeoutID)
72 { 69 {
73 WTF_LOG(Timers, "DOMTimer::removeByID: timeoutID = %d", timeoutID); 70 WTF_LOG(Timers, "DOMTimer::removeByID: timeoutID = %d", timeoutID);
74 context->removeTimeoutByID(timeoutID); 71 context->removeTimeoutByID(timeoutID);
75 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "TimerR emove", TRACE_EVENT_SCOPE_PROCESS, "data", InspectorTimerRemoveEvent::data(conte xt, timeoutID));
76 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), " CallStack", TRACE_EVENT_SCOPE_PROCESS, "stack", InspectorCallStackEvent::current CallStack());
77 } 72 }
78 73
79 DOMTimer::DOMTimer(ExecutionContext* context, PassOwnPtr<ScheduledAction> action , int interval, bool singleShot, int timeoutID) 74 DOMTimer::DOMTimer(ExecutionContext* context, PassOwnPtr<ScheduledAction> action , int interval, bool singleShot, int timeoutID)
80 : SuspendableTimer(context) 75 : SuspendableTimer(context)
81 , m_timeoutID(timeoutID) 76 , m_timeoutID(timeoutID)
82 , m_nestingLevel(timerNestingLevel + 1) 77 , m_nestingLevel(timerNestingLevel + 1)
83 , m_action(action) 78 , m_action(action)
84 { 79 {
85 ASSERT(timeoutID > 0); 80 ASSERT(timeoutID > 0);
86 81
(...skipping 14 matching lines...) Expand all
101 { 96 {
102 return m_timeoutID; 97 return m_timeoutID;
103 } 98 }
104 99
105 void DOMTimer::fired() 100 void DOMTimer::fired()
106 { 101 {
107 ExecutionContext* context = executionContext(); 102 ExecutionContext* context = executionContext();
108 timerNestingLevel = m_nestingLevel; 103 timerNestingLevel = m_nestingLevel;
109 ASSERT(!context->activeDOMObjectsAreSuspended()); 104 ASSERT(!context->activeDOMObjectsAreSuspended());
110 105
111 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "TimerFire", "d ata", InspectorTimerFireEvent::data(context, m_timeoutID));
112
113 // Simple case for non-one-shot timers. 106 // Simple case for non-one-shot timers.
114 if (isActive()) { 107 if (isActive()) {
115 if (repeatInterval() && repeatInterval() < minimumInterval) { 108 if (repeatInterval() && repeatInterval() < minimumInterval) {
116 m_nestingLevel++; 109 m_nestingLevel++;
117 if (m_nestingLevel >= maxTimerNestingLevel) 110 if (m_nestingLevel >= maxTimerNestingLevel)
118 augmentRepeatInterval(minimumInterval - repeatInterval()); 111 augmentRepeatInterval(minimumInterval - repeatInterval());
119 } 112 }
120 113
121 WTF_LOG(Timers, "DOMTimer::fired: m_timeoutID = %d, repeatInterval = %f, m_action = %p", m_timeoutID, repeatInterval(), m_action.get()); 114 WTF_LOG(Timers, "DOMTimer::fired: m_timeoutID = %d, repeatInterval = %f, m_action = %p", m_timeoutID, repeatInterval(), m_action.get());
122 115
123 // No access to member variables after this point, it can delete the tim er. 116 // No access to member variables after this point, it can delete the tim er.
124 m_action->execute(context); 117 m_action->execute(context);
125 return; 118 return;
126 } 119 }
127 120
128 WTF_LOG(Timers, "DOMTimer::fired: m_timeoutID = %d, one-shot, m_action = %p" , m_timeoutID, m_action.get()); 121 WTF_LOG(Timers, "DOMTimer::fired: m_timeoutID = %d, one-shot, m_action = %p" , m_timeoutID, m_action.get());
129 122
130 // Delete timer before executing the action for one-shot timers. 123 // Delete timer before executing the action for one-shot timers.
131 OwnPtr<ScheduledAction> action = m_action.release(); 124 OwnPtr<ScheduledAction> action = m_action.release();
132 125
133 // This timer is being deleted; no access to member variables allowed after this point. 126 // This timer is being deleted; no access to member variables allowed after this point.
134 context->removeTimeoutByID(m_timeoutID); 127 context->removeTimeoutByID(m_timeoutID);
135 128
136 action->execute(context); 129 action->execute(context);
137 130
138 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", TRACE_EVENT_SCOPE_PROCESS, "data", InspectorUpdateCountersEvent::data ());
139
140 timerNestingLevel = 0; 131 timerNestingLevel = 0;
141 } 132 }
142 133
143 void DOMTimer::contextDestroyed() 134 void DOMTimer::contextDestroyed()
144 { 135 {
145 SuspendableTimer::contextDestroyed(); 136 SuspendableTimer::contextDestroyed();
146 } 137 }
147 138
148 void DOMTimer::stop() 139 void DOMTimer::stop()
149 { 140 {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 if (fireTime - alignedTimeRoundedDown < minimumInterval) 175 if (fireTime - alignedTimeRoundedDown < minimumInterval)
185 return alignedTimeRoundedDown; 176 return alignedTimeRoundedDown;
186 177
187 return alignedTimeRoundedUp; 178 return alignedTimeRoundedUp;
188 } 179 }
189 180
190 return fireTime; 181 return fireTime;
191 } 182 }
192 183
193 } // namespace blink 184 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/frame/ConsoleBase.cpp ('k') | sky/engine/core/frame/FrameView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698